Compare commits
80 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 27b8c5f3ac | |||
| 3043887915 | |||
| e0abe9b9a9 | |||
| e19991f1f9 | |||
| 3d97b1e3ec | |||
| 6b1bccffb9 | |||
| 6fab7b91b7 | |||
| 7b6bab4967 | |||
| 04766e5325 | |||
| 662dbca3e1 | |||
| 6cb6c21495 | |||
| 79e9a3913a | |||
| 7e89317dd5 | |||
| 59e40ccbd9 | |||
| 774f88ee90 | |||
| 0528879833 | |||
| b6110e4f4a | |||
| 5b82e59264 | |||
| 3a4b171443 | |||
| 2ac27fd9ce | |||
| d01aa28cdc | |||
| 21aa5ce33b | |||
| f7ef6eb772 | |||
| 10037a9ac5 | |||
| 888de430ba | |||
| 83d661ab2a | |||
| a537bcf0ee | |||
| 590e435ad6 | |||
| 8d92a51e4f | |||
| 4322910614 | |||
| ebe589a714 | |||
| 6187e6a7bb | |||
| d5f113eb35 | |||
| 9ad5bb21c0 | |||
| 1c88ea7b78 | |||
| 5a976ebfae | |||
| b45669bb82 | |||
| e52cc40dbf | |||
| 8a20d3c1d7 | |||
| 749ebeb91d | |||
| 82586732e3 | |||
| e023d83e62 | |||
| de7cbc4949 | |||
| 71a91e51fb | |||
| 223163aa0a | |||
| bdd22093c3 | |||
| 0367b35ce0 | |||
| 755ac12b8a | |||
| e1f9e01404 | |||
| 7121426fc9 | |||
| a94e8504f8 | |||
| 9275bfe001 | |||
| 5b3c4aef79 | |||
| 4a289470e2 | |||
| d79c0f642c | |||
| 9ecad8749f | |||
| e8b57c6dc5 | |||
| 8142eb90a6 | |||
| 08abd4a770 | |||
| b8722dbbc0 | |||
| 1ac6d5d967 | |||
| 5c290789e0 | |||
| 38f6bf16f2 | |||
| 4953509255 | |||
| 188f105730 | |||
| 9bb23bcac8 | |||
| 06735f5c39 | |||
| e8143d3618 | |||
| 0d43ca15be | |||
| d18eabe1fc | |||
| d9d491d51c | |||
| 9a5bd114a4 | |||
| 30cc8c8abc | |||
| 815094e5bf | |||
| 1eaddef694 | |||
| 450299cb67 | |||
| 235fc2e81f | |||
| 92fb39d53a | |||
| eb0e4289b3 | |||
| ebbb5b1059 |
@@ -21,13 +21,15 @@ jobs:
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
|
||||
- name: Clean gradle
|
||||
run: ./gradlew clean --no-daemon --max-workers 1
|
||||
- name: Validate no assets
|
||||
run: test ! -d ./src/generated
|
||||
- name: Generate assets
|
||||
uses: GabrielBB/xvfb-action@v1.2
|
||||
with:
|
||||
run: ./gradlew runData --no-daemon
|
||||
run: ./gradlew runData --no-daemon --max-workers 1
|
||||
- name: Validate assets
|
||||
run: test -d ./src/generated
|
||||
run: test -d ./src/generated -a -f ./src/generated/resources/.cache/cache
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build --no-daemon
|
||||
run: ./gradlew build --no-daemon --max-workers 1
|
||||
|
||||
@@ -21,13 +21,15 @@ jobs:
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
|
||||
- name: Clean gradle
|
||||
run: ./gradlew clean --no-daemon --max-workers 1
|
||||
- name: Validate no assets
|
||||
run: test ! -d ./src/generated
|
||||
- name: Generate assets
|
||||
uses: GabrielBB/xvfb-action@v1.2
|
||||
with:
|
||||
run: ./gradlew runData --no-daemon
|
||||
run: ./gradlew runData --no-daemon --max-workers 1
|
||||
- name: Validate assets
|
||||
run: test -d ./src/generated
|
||||
run: test -d ./src/generated -a -f ./src/generated/resources/.cache/cache
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build --no-daemon
|
||||
run: ./gradlew build --no-daemon --max-workers 1
|
||||
|
||||
@@ -21,18 +21,20 @@ jobs:
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
|
||||
- name: Clean gradle
|
||||
run: ./gradlew clean --no-daemon --max-workers 1
|
||||
- name: Validate no assets
|
||||
run: test ! -d ./src/generated
|
||||
- name: Generate assets
|
||||
uses: GabrielBB/xvfb-action@v1.2
|
||||
with:
|
||||
run: ./gradlew runData --no-daemon
|
||||
run: ./gradlew runData --no-daemon --max-workers 1
|
||||
- name: Validate assets
|
||||
run: test -d ./src/generated
|
||||
run: test -d ./src/generated -a -f ./src/generated/resources/.cache/cache
|
||||
- name: Build with Gradle
|
||||
env:
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
run: ./gradlew build --no-daemon
|
||||
run: ./gradlew build --no-daemon --max-workers 1
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: dist
|
||||
|
||||
@@ -2,7 +2,7 @@ name: 'Release'
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [created]
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -33,16 +33,31 @@ jobs:
|
||||
- name: Generate assets
|
||||
uses: GabrielBB/xvfb-action@v1.2
|
||||
with:
|
||||
run: ./gradlew runData --no-daemon
|
||||
run: ./gradlew runData --no-daemon --max-workers 1
|
||||
- name: Validate assets
|
||||
run: test -d ./src/generated
|
||||
- name: Build, sign, and publish with Gradle
|
||||
run: test -d ./src/generated -a -f ./src/generated/resources/.cache/cache
|
||||
- name: Build with Gradle
|
||||
env:
|
||||
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
|
||||
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
|
||||
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew build publish --no-daemon
|
||||
run: ./gradlew build --no-daemon --max-workers 1
|
||||
- name: Upload to curseforge
|
||||
env:
|
||||
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
|
||||
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
|
||||
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
|
||||
CHANGELOG: ${{ github.event.release.body }}
|
||||
CURSEFORGE: ${{ secrets.CURSEFORGE }}
|
||||
run: ./gradlew curseforge --no-daemon --max-workers 1
|
||||
- name: Publish to github packages
|
||||
env:
|
||||
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
|
||||
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
|
||||
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: ./gradlew publish --no-daemon --max-workers 1
|
||||
- name: Prepare artifact metadata
|
||||
id: prepare_artifact_metadata
|
||||
run: |
|
||||
|
||||
@@ -12,10 +12,9 @@
|
||||
* [Downloads](#downloads)
|
||||
* [Installation](#installation)
|
||||
* [Issues](#issues)
|
||||
* [API](#applied-energistics-2-api)
|
||||
* [Building](#building)
|
||||
* [Contribution](#contribution)
|
||||
* [API](#applied-energistics-2-api)
|
||||
* [CraftTweaker](#applied-energistics-2-crafttweaker)
|
||||
* [Localization](#applied-energistics-2-localization)
|
||||
* [Credits](#credits)
|
||||
|
||||
@@ -46,7 +45,7 @@ A Mod about Matter, Energy and using them to conquer the world..
|
||||
|
||||
## Downloads
|
||||
|
||||
Downloads can be found on [CurseForge](http://www.curse.com/mc-mods/minecraft/223794-applied-energistics-2) or on the [official website](http://ae-mod.info/Downloads/).
|
||||
Downloads can be found on [CurseForge](https://www.curseforge.com/minecraft/mc-mods/applied-energistics-2) or on the [official website](http://ae-mod.info/Downloads/).
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -67,12 +66,44 @@ Providing as many details as possible does help us to find and resolve the issue
|
||||
|
||||
Please note that we might close any issue not matching these requirements.
|
||||
|
||||
## Applied Energistics 2 API
|
||||
|
||||
The API for Applied Energistics 2. It is open source to discuss changes, improve documentation, and provide better add-on support in general.
|
||||
|
||||
### Maven
|
||||
|
||||
We use Github Packages as maven repository now. You can use the following snippet as example on how to add a repository to your gradle build file.
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name "AE2"
|
||||
url "https://maven.pkg.github.com/AppliedEnergistics/Applied-Energistics-2"
|
||||
}
|
||||
}
|
||||
|
||||
When compiling against the AE2 API you can use gradle dependencies, just add
|
||||
|
||||
dependencies {
|
||||
compileOnly "appeng:appliedenergistics2:VERSION:api"
|
||||
}
|
||||
|
||||
or add the `compileOnly` line to your existing dependencies task to your build.gradle.
|
||||
|
||||
Replace `VERSION` with the desired one. With 1.15+ we switched to using [semver](https://semver.org/).
|
||||
It is highly recommended following its specification and further considering an upper bound for the dependency version.
|
||||
A change of the `MAJOR` version will be an API break and can lead to various crashes. Better to inform a player about the addon not supporting the new version until it could be tested or updated.
|
||||
|
||||
An example string would be `appeng:appliedenergistics2:7.0.0-alpha.6:api` for the API only or `appeng:appliedenergistics2:7.0.0-alpha.6` for the whole mod.
|
||||
|
||||
Builds obtained [here](https://github.com/AppliedEnergistics/Applied-Energistics-2/releases) or via [maven](https://github.com/AppliedEnergistics/Applied-Energistics-2/packages) should work in a development environment.
|
||||
However the dependency might need to be wrapped in `fg.deobf()` like `runtimeOnly fg.deobf("appeng:appliedenergistics2:VERSION:api")`
|
||||
|
||||
## Building
|
||||
|
||||
1. Clone this repository via
|
||||
- SSH `git clone git@github.com:AppliedEnergistics/Applied-Energistics-2.git` or
|
||||
- HTTPS `git clone https://github.com/AppliedEnergistics/Applied-Energistics-2.git`
|
||||
2. Build using the gradle `build` task. Jar will be in `build/libs`
|
||||
2. Build using the `gradlew runData build` command. Jar will be in `build/libs`
|
||||
3. For core developer: Setup IDE
|
||||
- IntelliJ: Import as gradle project
|
||||
- Eclipse: Import as gradle project or execute gradle task `eclipse` and potentially `genEclipseRuns`
|
||||
@@ -101,75 +132,16 @@ Here are a few things to keep in mind that will help get your PR approved.
|
||||
* SSH `git clone git@github.com:<your username>/Applied-Energistics-2.git` or
|
||||
* HTTPS `git clone https://github.com/<your username>/Applied-Energistics-2.git`
|
||||
3. Change code base
|
||||
4. Add changes to git `git add -A`
|
||||
5. Commit changes to your clone `git commit -m "<summary of made changes>"`
|
||||
6. Push to your fork `git push`
|
||||
7. Create a Pull-Request on GitHub
|
||||
8. Wait for review
|
||||
9. Squash commits for cleaner history
|
||||
4. Run `gradlew spotlessApply` to apply automatic code formatting
|
||||
5. Add changes to git `git add -A`
|
||||
6. Commit changes to your clone `git commit -m "<summary of made changes>"`
|
||||
7. Push to your fork `git push`
|
||||
8. Create a Pull-Request on GitHub
|
||||
9. Wait for review
|
||||
10. Squash commits for cleaner history
|
||||
|
||||
If you are only doing single file pull requests, GitHub supports using a quick way without the need of cloning your fork. Also read up about [synching](https://help.github.com/articles/syncing-a-fork) if you plan to contribute on regular basis.
|
||||
|
||||
## Applied Energistics 2 API
|
||||
|
||||
The API for Applied Energistics 2. It is open source to discuss changes, improve documentation, and provide better add-on support in general.
|
||||
|
||||
Universal builds obtained [Here](http://ae2.ae-mod.info/Downloads/) should work in a development environment.
|
||||
|
||||
### Maven
|
||||
|
||||
When compiling against the AE2 API you can use gradle dependencies, just add
|
||||
|
||||
dependencies {
|
||||
compile "appeng:appliedenergistics2:rv_-_____-__:api"
|
||||
}
|
||||
|
||||
or add the compile line to your existing dependencies task to your build.gradle
|
||||
|
||||
Where the __ are filled in with the correct version criteria; AE2 is available from the default forge maven so no additional repositories are necessary.
|
||||
|
||||
An example string would be `appeng:appliedenergistics2:rv5-stable-1:api` for the API only or `appeng:appliedenergistics2:rv5-stable-1` for the whole mod.
|
||||
|
||||
## Applied Energistics 2 CraftTweaker
|
||||
|
||||
### Inscriber
|
||||
|
||||
The inscriber uses the vanilla recipe system with a custom `type` of `appliedenergistics2:inscriber`.
|
||||
See the [inscriber recipe folder](src/main/resources/data/appliedenergistics2/recipes/inscriber) for some examples.
|
||||
|
||||
### Grindstone
|
||||
|
||||
The grindstone uses the vanilla recipe system with a custom `type` of `appliedenergistics2:grinder`.
|
||||
See the [grinder recipe folder](src/main/resources/data/appliedenergistics2/recipes/grinder) for some examples.
|
||||
|
||||
### Spatial
|
||||
Whitelist a TileEntity class for Spatial IO.
|
||||
|
||||
mods.appliedenergistics2.Spatial.whitelistEntity( String fullEntityClassName );
|
||||
|
||||
### Attunement
|
||||
Attune a ItemStack or ModID to a specific P2P-Tunnel type. ModID's are used as fallback when no ItemStack was found.
|
||||
|
||||
mods.appliedenergistics2.Attunement.attuneME( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneME( String modID );
|
||||
mods.appliedenergistics2.Attunement.attuneItem( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneItem( String modID );
|
||||
mods.appliedenergistics2.Attunement.attuneFluid( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneFluid( String modID );
|
||||
mods.appliedenergistics2.Attunement.attuneRedstone( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneRedstone( String modID );
|
||||
mods.appliedenergistics2.Attunement.attuneRF( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneRF( String modID );
|
||||
mods.appliedenergistics2.Attunement.attuneIC2( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneIC2( String modID );
|
||||
mods.appliedenergistics2.Attunement.attuneLight( ItemStack itemStack );
|
||||
mods.appliedenergistics2.Attunement.attuneLight( String modID );
|
||||
|
||||
### Cannon
|
||||
Add ammo types for the matter cannon.
|
||||
|
||||
mods.appliedenergistics2.Cannon.registerAmmo( ItemStack itemStack, double weight );
|
||||
|
||||
## Applied Energistics 2 Localization
|
||||
|
||||
### English Text
|
||||
|
||||
@@ -30,6 +30,7 @@ buildscript {
|
||||
plugins {
|
||||
id "maven-publish"
|
||||
id "com.diffplug.gradle.spotless" version "4.3.0"
|
||||
id "com.matthewprenger.cursegradle" version "1.4.0"
|
||||
id "org.sonarqube" version "2.8"
|
||||
id "jacoco"
|
||||
}
|
||||
@@ -165,6 +166,7 @@ task signJar(type: net.minecraftforge.gradle.common.task.SignJar, dependsOn: 're
|
||||
}
|
||||
|
||||
apply from: 'gradle/scripts/artifacts.gradle'
|
||||
apply from: 'gradle/scripts/curseforge.gradle'
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
|
||||
+4
-3
@@ -10,13 +10,13 @@ artifact_basename=appliedenergistics2
|
||||
#########################################################
|
||||
minecraft_release=1.15
|
||||
minecraft_version=1.15.2
|
||||
mcp_mappings=20200701-1.15.1
|
||||
forge_version=31.2.20
|
||||
mcp_mappings=20200715-1.15.1
|
||||
forge_version=31.2.31
|
||||
|
||||
#########################################################
|
||||
# Provided APIs #
|
||||
#########################################################
|
||||
jei_version=6.0.0.4
|
||||
jei_version=6.0.2.12
|
||||
top_version=2.0.4-5
|
||||
hwyla_version=1.10.8-B72_1.15.2
|
||||
ctm_version=MC1.15.2-1.1.0.9
|
||||
@@ -26,6 +26,7 @@ ctm_version=MC1.15.2-1.1.0.9
|
||||
#########################################################
|
||||
website_version=1.15.2
|
||||
curse_versions=1.15.2
|
||||
curseforge_project=223794
|
||||
|
||||
#########################################################
|
||||
# Gradle #
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2020, TeamAppliedEnergistics, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
*g GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
def isAlpha = project.version.contains("alpha")
|
||||
def isBeta = project.version.contains("beta")
|
||||
|
||||
def cfReleaseType = "release"
|
||||
if (isAlpha) {
|
||||
cfReleaseType = "alpha"
|
||||
} else if (isBeta) {
|
||||
cfReleaseType = "beta"
|
||||
}
|
||||
|
||||
if (System.getenv("CURSEFORGE")) {
|
||||
curseforge {
|
||||
apiKey = System.getenv("CURSEFORGE")
|
||||
project {
|
||||
id = project.curseforge_project
|
||||
changelogType = "markdown"
|
||||
changelog = System.getenv("CHANGELOG") ?: "Please visit our [releases](https://github.com/AppliedEnergistics/Applied-Energistics-2/releases) for a changelog"
|
||||
releaseType = cfReleaseType
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,51 +23,6 @@ repositories {
|
||||
name 'modmaven'
|
||||
url "https://modmaven.k-4u.nl/"
|
||||
}
|
||||
|
||||
maven {
|
||||
name "Mobius"
|
||||
url "http://mobiusstrip.eu/maven"
|
||||
}
|
||||
|
||||
maven {
|
||||
name = "JEI repo"
|
||||
url "http://dvs1.progwml6.com/files/maven"
|
||||
}
|
||||
|
||||
maven {
|
||||
name = "Tesla repo"
|
||||
url "http://maven.mcmoddev.com"
|
||||
}
|
||||
|
||||
maven {
|
||||
name = "IC2 repo"
|
||||
url = "http://maven.ic2.player.to"
|
||||
}
|
||||
|
||||
maven {
|
||||
name = "CoFH Maven"
|
||||
url = "http://maven.covers1624.net"
|
||||
}
|
||||
|
||||
maven { // TheOneProbe
|
||||
name 'tterrag maven'
|
||||
url "http://maven.tterrag.com/"
|
||||
}
|
||||
|
||||
maven {
|
||||
name 'mcjty'
|
||||
url "http://maven.k-4u.nl/"
|
||||
}
|
||||
|
||||
maven { // CraftTweaker
|
||||
name 'jared maven'
|
||||
url "http://maven.blamejared.com/"
|
||||
}
|
||||
|
||||
maven {
|
||||
name = "CurseForge"
|
||||
url = "https://minecraft.curseforge.com/api/maven/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -26,12 +26,16 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Use this annotation on a class in your Mod to have it instantiated during the
|
||||
* initialization phase of Applied Energistics. AE expects your class to have a
|
||||
* single constructor and can supply certain arguments to your constructor using
|
||||
* dependency injection.
|
||||
* initialization phase of Applied Energistics.
|
||||
*
|
||||
* The class also needs to implement {@link IAEAddon}.
|
||||
*
|
||||
* AE expects your class to have a single constructor without any parameters.
|
||||
*
|
||||
* This is the only way to get access to the public {@link IAppEngApi} instance.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
@Documented
|
||||
public @interface AEPlugin {
|
||||
public @interface AEAddon {
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import appeng.api.exceptions.CoreInaccessibleException;
|
||||
|
||||
/**
|
||||
* Entry point for api.
|
||||
*/
|
||||
public enum AEApi {
|
||||
;
|
||||
|
||||
private static final String CORE_API_FQN = "appeng.core.Api";
|
||||
private static final String CORE_API_FIELD = "INSTANCE";
|
||||
private static final IAppEngApi HELD_API;
|
||||
|
||||
static {
|
||||
try {
|
||||
final Class<?> apiClass = Class.forName(CORE_API_FQN);
|
||||
final Field apiField = apiClass.getField(CORE_API_FIELD);
|
||||
|
||||
HELD_API = (IAppEngApi) apiField.get(apiClass);
|
||||
} catch (final ClassNotFoundException e) {
|
||||
throw new CoreInaccessibleException(
|
||||
"AE2 API tried to access the " + CORE_API_FQN + " class, without it being declared.");
|
||||
} catch (final NoSuchFieldException e) {
|
||||
throw new CoreInaccessibleException("AE2 API tried to access the " + CORE_API_FIELD + " field in "
|
||||
+ CORE_API_FQN + " without it being declared.");
|
||||
} catch (final IllegalAccessException e) {
|
||||
throw new CoreInaccessibleException("AE2 API tried to access the " + CORE_API_FIELD + " field in "
|
||||
+ CORE_API_FQN + " without enough access permissions.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API Entry Point.
|
||||
*
|
||||
* @return the {@link IAppEngApi}
|
||||
*/
|
||||
public static IAppEngApi instance() {
|
||||
return HELD_API;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.api;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Marks interfaces that can be used as injectable constructor arguments for an
|
||||
* {@link AEPlugin}.
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface AEInjectable {
|
||||
}
|
||||
+20
-16
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
* Copyright (c) 2020 TeamAppliedEnergistics
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
@@ -21,26 +21,30 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.implementations;
|
||||
package appeng.api;
|
||||
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
|
||||
/**
|
||||
* Implemented on {@link Item}
|
||||
* Every AE2 addon requiring access to {@link IAppEngApi}, needs to provide at
|
||||
* least one class implementing this interface.
|
||||
*
|
||||
* Further it requires the class to be annotated with {@link AEAddon}.
|
||||
*
|
||||
*/
|
||||
public interface ICraftingPatternItem {
|
||||
public interface IAEAddon {
|
||||
|
||||
/**
|
||||
* Access Details about a pattern
|
||||
*
|
||||
* @param is pattern
|
||||
* @param w crafting world
|
||||
*
|
||||
* @return details of pattern
|
||||
* This gets called once the API is successfully constructed and ready to be
|
||||
* used.
|
||||
*
|
||||
* For now this happens during {@link FMLCommonSetupEvent}.
|
||||
*
|
||||
* Each addon is responsible to maintain a reference to {@link IAppEngApi} for
|
||||
* future use. Otherwise there is no alternative to access it later.
|
||||
*
|
||||
* @param api The API instance when ready.
|
||||
*/
|
||||
ICraftingPatternDetails getPatternForItem(ItemStack is, World w);
|
||||
void onAPIAvailable(IAppEngApi api);
|
||||
|
||||
}
|
||||
@@ -23,16 +23,22 @@
|
||||
|
||||
package appeng.api;
|
||||
|
||||
import appeng.api.client.IClientHelper;
|
||||
import appeng.api.crafting.ICraftingHelper;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.features.IRegistryContainer;
|
||||
import appeng.api.networking.IGridHelper;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.parts.IPartHelper;
|
||||
import appeng.api.storage.IStorageHelper;
|
||||
import appeng.api.util.IClientHelper;
|
||||
|
||||
@AEInjectable
|
||||
public interface IAppEngApi {
|
||||
|
||||
/**
|
||||
* @return An accessible list of all AE definitions
|
||||
*/
|
||||
IDefinitions definitions();
|
||||
|
||||
/**
|
||||
* @return Registry Container for the numerous registries in AE2.
|
||||
*/
|
||||
@@ -43,6 +49,11 @@ public interface IAppEngApi {
|
||||
*/
|
||||
IStorageHelper storage();
|
||||
|
||||
/**
|
||||
* @return A helper for working with crafting related tasks.
|
||||
*/
|
||||
ICraftingHelper crafting();
|
||||
|
||||
/**
|
||||
* @return A helper to create {@link IGridNode} and other grid related objects.
|
||||
*/
|
||||
@@ -53,11 +64,6 @@ public interface IAppEngApi {
|
||||
*/
|
||||
IPartHelper partHelper();
|
||||
|
||||
/**
|
||||
* @return An accessible list of all AE definitions
|
||||
*/
|
||||
IDefinitions definitions();
|
||||
|
||||
/**
|
||||
* @return Utility methods primarily useful for client side stuff
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 TeamAppliedEnergistics
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.client;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**
|
||||
* A registry for 3D models used to render storage cells in the world, when they
|
||||
* are inserted into a drive or similar machines.
|
||||
*/
|
||||
public interface ICellModelRegistry {
|
||||
|
||||
/**
|
||||
* Register a new model for a storage cell item.
|
||||
*
|
||||
* <p>
|
||||
* You are responsible for ensuring that the given model is actually loaded by
|
||||
* the game. See
|
||||
* {@see net.minecraftforge.client.model.ModelLoader#addSpecialModel}.
|
||||
*
|
||||
* This method only maps an {@link Item} to a {@link ResourceLocation} which can
|
||||
* be looked up from the {@link ModelBakery}. No validation about missing models
|
||||
* will be done.
|
||||
*
|
||||
* Will throw an exception in case a model is already registered for an item.
|
||||
*
|
||||
* For examples look at our cell part models within the drive model directory.
|
||||
*
|
||||
* @param item The cell item
|
||||
* @param model The {@link ResourceLocation} representing the model.
|
||||
* @return
|
||||
*/
|
||||
void registerModel(@Nonnull Item item, @Nonnull ResourceLocation model);
|
||||
|
||||
/**
|
||||
* The {@link ResourceLocation} of the model used to render the given storage
|
||||
* cell {@link Item} when inserted into a drive or similar.
|
||||
*
|
||||
* @param item
|
||||
* @return null, if no model is registered.
|
||||
*/
|
||||
@Nullable
|
||||
ResourceLocation model(@Nonnull Item item);
|
||||
|
||||
/**
|
||||
* An unmodifiable map of all registered mappings.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Nonnull
|
||||
Map<Item, ResourceLocation> models();
|
||||
|
||||
/**
|
||||
* Returns the default model, which can be used when no explicit model is
|
||||
* registered.
|
||||
*/
|
||||
@Nonnull
|
||||
ResourceLocation getDefaultModel();
|
||||
|
||||
}
|
||||
+8
-1
@@ -21,7 +21,7 @@
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.util;
|
||||
package appeng.api.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -39,4 +39,11 @@ public interface IClientHelper {
|
||||
*/
|
||||
<T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler, List<ITextComponent> lines);
|
||||
|
||||
/**
|
||||
* A helper to work with clientside related tasks for cells.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ICellModelRegistry cells();
|
||||
|
||||
}
|
||||
@@ -23,7 +23,11 @@
|
||||
|
||||
package appeng.api.config;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@@ -34,6 +38,7 @@ import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.IItemProvider;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
|
||||
public enum Upgrades {
|
||||
/**
|
||||
@@ -72,11 +77,11 @@ public enum Upgrades {
|
||||
* @param item machine in which this upgrade can be installed
|
||||
* @param maxSupported amount how many upgrades can be installed
|
||||
* @param tooltipGroup If more than one item of the same group are supported,
|
||||
* the tooltip will show this group name instead. If the
|
||||
* items have different maxSupported values, the highest
|
||||
* the tooltip will show this translation key instead. If
|
||||
* the items have different maxSupported values, the highest
|
||||
* will be shown.
|
||||
*/
|
||||
public void registerItem(final IItemProvider item, final int maxSupported, @Nullable ITextComponent tooltipGroup) {
|
||||
public void registerItem(final IItemProvider item, final int maxSupported, @Nullable String tooltipGroup) {
|
||||
Preconditions.checkNotNull(item);
|
||||
this.supported.add(new Supported(item.asItem(), maxSupported, tooltipGroup));
|
||||
supportedTooltipLines = null; // Reset tooltip
|
||||
@@ -95,17 +100,17 @@ public enum Upgrades {
|
||||
ITextComponent name = supported.item.getName();
|
||||
|
||||
// If the group was already added by a previous item, skip this
|
||||
if (supported.tooltipGroup != null && namesAdded.contains(supported.tooltipGroup)) {
|
||||
if (supported.getTooltipGroup() != null && namesAdded.contains(supported.getTooltipGroup())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If any of the following items would be of the same group, use the group name
|
||||
// instead
|
||||
if (supported.tooltipGroup != null) {
|
||||
if (supported.getTooltipGroup() != null) {
|
||||
for (int j = i + 1; j < this.supported.size(); j++) {
|
||||
ITextComponent otherGroup = this.supported.get(j).tooltipGroup;
|
||||
if (supported.tooltipGroup.equals(otherGroup)) {
|
||||
name = supported.tooltipGroup;
|
||||
ITextComponent otherGroup = this.supported.get(j).getTooltipGroup();
|
||||
if (supported.getTooltipGroup().equals(otherGroup)) {
|
||||
name = supported.getTooltipGroup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -132,10 +137,11 @@ public enum Upgrades {
|
||||
private final Item item;
|
||||
private final Block block;
|
||||
private final int maxCount;
|
||||
// Translation key of the tooltip group
|
||||
@Nullable
|
||||
private final ITextComponent tooltipGroup;
|
||||
private final String tooltipGroup;
|
||||
|
||||
public Supported(Item item, int maxCount, @Nullable ITextComponent tooltipGroup) {
|
||||
public Supported(Item item, int maxCount, @Nullable String tooltipGroup) {
|
||||
this.item = item;
|
||||
if (item.getItem() instanceof BlockItem) {
|
||||
this.block = ((BlockItem) item.getItem()).getBlock();
|
||||
@@ -158,6 +164,10 @@ public enum Upgrades {
|
||||
return item != null && this.item == item;
|
||||
}
|
||||
|
||||
public ITextComponent getTooltipGroup() {
|
||||
return this.tooltipGroup != null ? new TranslationTextComponent(this.tooltipGroup) : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2020 TeamAppliedEnergistics
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.crafting;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.ICraftingRecipe;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
public interface ICraftingHelper {
|
||||
|
||||
/**
|
||||
* Checks that the given item stack is an encoded pattern.
|
||||
*/
|
||||
boolean isEncodedPattern(@Nullable IAEItemStack item);
|
||||
|
||||
/**
|
||||
* Checks that the given item stack is an encoded pattern.
|
||||
*/
|
||||
boolean isEncodedPattern(ItemStack item);
|
||||
|
||||
/**
|
||||
* Encodes a processing pattern which represents the ability to convert the
|
||||
* given inputs into the given outputs using some process external to the ME
|
||||
* system.
|
||||
*
|
||||
* @param stack If null, a new item will be created to hold the encoded pattern.
|
||||
* Otherwise the given item must already contains an encoded
|
||||
* pattern that will be overwritten.
|
||||
* @return A new encoded pattern, or the given stack with the pattern encoded in
|
||||
* it.
|
||||
*/
|
||||
ItemStack encodeProcessingPattern(@Nullable ItemStack stack, ItemStack[] in, ItemStack[] out);
|
||||
|
||||
/**
|
||||
* Encodes a crafting pattern which represents a Vanilla crafting recipe.
|
||||
*
|
||||
* @param stack If null, a new item will be created to hold the
|
||||
* encoded pattern. Otherwise the given item must
|
||||
* already contains an encoded pattern that will be
|
||||
* overwritten.
|
||||
* @param recipe The Vanilla crafting recipe to be encoded.
|
||||
* @param in The items in the crafting grid, which are used to
|
||||
* determine what items are supplied from the ME system
|
||||
* to craft using this pattern.
|
||||
* @param out What is to be expected as the result of this crafting
|
||||
* operation by the ME system.
|
||||
* @param allowSubstitutes Controls whether the ME system will allow the use of
|
||||
* equivalent items to craft this recipe.
|
||||
*/
|
||||
ItemStack encodeCraftingPattern(@Nullable ItemStack stack, ICraftingRecipe recipe, ItemStack[] in, ItemStack out,
|
||||
boolean allowSubstitutes);
|
||||
|
||||
/**
|
||||
* Same as {@link #decodePattern(ItemStack, World, boolean)} with no auto
|
||||
* recovery of changed recipe ids.
|
||||
*/
|
||||
@Nullable
|
||||
default ICraftingPatternDetails decodePattern(@Nonnull ItemStack itemStack, @Nonnull World world) {
|
||||
return decodePattern(itemStack, world, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes an encoded crafting pattern and returns the pattern details.
|
||||
* <p>
|
||||
* The item backing the {@link ItemStack} needs to be an item returned by the
|
||||
* encode methods of this class.
|
||||
*
|
||||
* @param itemStack pattern
|
||||
* @param world world used to access the
|
||||
* {@link net.minecraft.item.crafting.RecipeManager}.
|
||||
* @param autoRecovery If true, the method will try to recover from changed
|
||||
* recipe ids by searching the entire recipe manager for a
|
||||
* recipe matching the inputs. If this is successful, the
|
||||
* given item stack will be changed to reflect the new
|
||||
* recipe id.
|
||||
* @return The pattern details if the pattern could be decoded. Otherwise null.
|
||||
*/
|
||||
@Nullable
|
||||
ICraftingPatternDetails decodePattern(@Nonnull ItemStack itemStack, @Nonnull World world, boolean autoRecovery);
|
||||
|
||||
}
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
package appeng.api.features;
|
||||
|
||||
import appeng.api.AEInjectable;
|
||||
import appeng.api.movable.IMovableRegistry;
|
||||
import appeng.api.networking.IGridCacheRegistry;
|
||||
import appeng.api.parts.IPartModels;
|
||||
@@ -36,7 +35,6 @@ import appeng.api.storage.ICellRegistry;
|
||||
* @version 7
|
||||
* @since rv0
|
||||
*/
|
||||
@AEInjectable
|
||||
public interface IRegistryContainer {
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,18 +28,25 @@ import javax.annotation.Nonnull;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.cells.ICellHandler;
|
||||
import appeng.api.storage.cells.ICellInventory;
|
||||
import appeng.api.storage.cells.ICellWorkbenchItem;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
/**
|
||||
* Any item which implements this can be treated as an IMEInventory via
|
||||
* Util.getCell / Util.isCell It automatically handles the internals and NBT
|
||||
* data, which is both nice, and bad for you!
|
||||
* {@link ICellHandler#getCellInventory(ItemStack, appeng.api.storage.cells.ISaveProvider, IStorageChannel)}
|
||||
* or {@link ICellHandler#isCell(ItemStack)}. It automatically handles the
|
||||
* internals and NBT data, which is both nice, and bad for you!
|
||||
*
|
||||
* Good cause it means you don't have to do anything, bad because you have
|
||||
* little to no control over it.
|
||||
*
|
||||
* The standard AE implementation only provides 1-63 Types
|
||||
*
|
||||
* Limited to {@link Integer} internally for most calculations. E.g. if the used
|
||||
* or remaining bytes would overflow {@link Integer#MAX_VALUE} the behaviour is
|
||||
* no longer specified. Even if {@link ICellInventory} is using {@link Long}.
|
||||
*
|
||||
* The standard AE implementation also only provides 1-63 Types.
|
||||
*/
|
||||
public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem {
|
||||
|
||||
|
||||
@@ -91,16 +91,6 @@ public interface IGridBlock {
|
||||
*/
|
||||
void onGridNotification(@Nonnull GridNotification notification);
|
||||
|
||||
/**
|
||||
* Update Blocks network/connection/booting status. grid,
|
||||
*
|
||||
* @param grid grid
|
||||
* @param channelsInUse used channels
|
||||
* @deprecated to be removed in rv7
|
||||
*/
|
||||
@Deprecated
|
||||
void setNetworkStatus(IGrid grid, int channelsInUse);
|
||||
|
||||
/**
|
||||
* Determine which sides of the block can be connected too, only used when
|
||||
* isWorldAccessible returns true, not used for {@link IPart} implementations.
|
||||
|
||||
@@ -23,22 +23,25 @@
|
||||
|
||||
package appeng.api.networking.crafting;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
/**
|
||||
* do not implement provided by {@link ICraftingPatternItem}
|
||||
*
|
||||
* caching this INSTANCE will increase performance of validation and checks.
|
||||
* Describes a crafting or processing pattern decoded by
|
||||
* {@link appeng.api.crafting.ICraftingHelper}.
|
||||
* <p>
|
||||
* Do not cache instances of this class unless you handle recipe reloads on the
|
||||
* server and client correctly.
|
||||
*/
|
||||
public interface ICraftingPatternDetails {
|
||||
|
||||
/**
|
||||
* @return source item.
|
||||
* @return encodes this crafting pattern into a new item stack.
|
||||
*/
|
||||
ItemStack getPattern();
|
||||
|
||||
@@ -52,29 +55,72 @@ public interface ICraftingPatternDetails {
|
||||
boolean isValidItemForSlot(int slotIndex, ItemStack itemStack, World world);
|
||||
|
||||
/**
|
||||
* @return if this pattern is a crafting pattern ( work bench )
|
||||
* @return if this pattern is for a Vanilla
|
||||
* {@link net.minecraft.item.crafting.IRecipeType#CRAFTING crafting
|
||||
* recipe}.
|
||||
*/
|
||||
boolean isCraftable();
|
||||
|
||||
/**
|
||||
* Equal itemstacks will be aggregated into one, respectively 3*64 will be
|
||||
* returned as one stack of 192, up to 576 of a single type.
|
||||
* <p>
|
||||
* This should be the preferred way to deal with the list of inputs.
|
||||
* <p>
|
||||
* The list will be sorted in descending order by stack size. However there is
|
||||
* no guarantee about maintaining the placement order of the inputs in case of
|
||||
* equal values.
|
||||
*
|
||||
* @return an immutable list of inputs without nulls
|
||||
*/
|
||||
List<IAEItemStack> getInputs();
|
||||
|
||||
/**
|
||||
* Equal itemstacks will be aggregated into one, respectively 2*32 will be
|
||||
* returned as one stack of 64, up to 192 of a single type.
|
||||
* <p>
|
||||
* This should be the preferred way to deal with the list of outputs.
|
||||
* <p>
|
||||
*
|
||||
* The list will be sorted in descending order by stack size. However there is
|
||||
* no guarantee about maintaining the placement order of the outputs in case of
|
||||
* equal values.
|
||||
*
|
||||
* @return an immutable list of outputs without nulls
|
||||
*/
|
||||
List<IAEItemStack> getOutputs();
|
||||
|
||||
/**
|
||||
* A sparse list representing the placement order of a crafting grid, left to
|
||||
* right, then top to bottom.
|
||||
* <p>
|
||||
* Only use when absolutely necessary, always prefer
|
||||
* {@link ICraftingPatternDetails#getInputs()}
|
||||
* <p>
|
||||
* This will contain exactly 9 entries.
|
||||
* <p>
|
||||
* This can return a copy from the internal structure, so there are no
|
||||
* guarantees about modifications.
|
||||
*
|
||||
* @return a list of the inputs, will include nulls.
|
||||
*/
|
||||
IAEItemStack[] getInputs();
|
||||
|
||||
/**
|
||||
* @return a list of the inputs, will be clean
|
||||
*/
|
||||
IAEItemStack[] getCondensedInputs();
|
||||
|
||||
/**
|
||||
* @return a list of the outputs, will be clean
|
||||
*/
|
||||
IAEItemStack[] getCondensedOutputs();
|
||||
IAEItemStack[] getSparseInputs();
|
||||
|
||||
/**
|
||||
* A sparse list representing the placement order of the respective output
|
||||
* slots.
|
||||
* <p>
|
||||
* Only use when absolutely necessary, always prefer
|
||||
* {@link ICraftingPatternDetails#getOutputs()}
|
||||
* <p>
|
||||
* This will either contain 1 entry for crafting patterns or 3 for processing.
|
||||
* <p>
|
||||
* This can return a copy from the internal structure, so there are no
|
||||
* guarantees about modifications.
|
||||
*
|
||||
* @return a list of the outputs, will include nulls.
|
||||
*/
|
||||
IAEItemStack[] getOutputs();
|
||||
IAEItemStack[] getSparseOutputs();
|
||||
|
||||
/**
|
||||
* @return if this pattern is enabled to support substitutions.
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
package appeng.api.networking.crafting;
|
||||
|
||||
import appeng.api.crafting.ICraftingHelper;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
|
||||
/**
|
||||
@@ -33,6 +34,9 @@ public interface ICraftingProviderHelper {
|
||||
|
||||
/**
|
||||
* Add new Pattern to AE's crafting cache.
|
||||
*
|
||||
* This will only accept instances created by
|
||||
* {@link ICraftingHelper#decodePattern(net.minecraft.item.ItemStack, net.minecraft.world.World)}
|
||||
*/
|
||||
void addCraftingOption(ICraftingMedium medium, ICraftingPatternDetails api);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.IGrid;
|
||||
|
||||
/**
|
||||
* Used to access information about AE's various power accepting blocks for
|
||||
@@ -71,4 +72,22 @@ public interface IAEPowerStorage extends IEnergySource {
|
||||
*/
|
||||
@Nonnull
|
||||
AccessRestriction getPowerFlow();
|
||||
}
|
||||
|
||||
/**
|
||||
* The priority to use this energy storage.
|
||||
*
|
||||
* A higher value means it is more likely to be extracted from first, and less
|
||||
* likely to be inserted into first.
|
||||
*
|
||||
* The value needs to be constant once added to a {@link IGrid}. Should it ever
|
||||
* need to be changed, it has to be removed from the grid, then update the
|
||||
* value, and finally added back to the grid.
|
||||
*
|
||||
* This should never use {@link Integer#MIN_VALUE} or {@link Integer#MAX_VALUE}.
|
||||
*
|
||||
* @return the priority for this storage
|
||||
*/
|
||||
default int getPriority() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
package appeng.api.networking.security;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
|
||||
@@ -31,6 +31,6 @@ public interface ICustomCableConnection {
|
||||
* @return This controls the cable connection to the node. -1 to render
|
||||
* connection yourself.
|
||||
*/
|
||||
public float getCableConnectionLength(AECableType cable);
|
||||
float getCableConnectionLength(AECableType cable);
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
package appeng.api.parts;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.capabilities.CapabilityProvider;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
@@ -279,7 +280,7 @@ public interface IPart extends ICustomCableConnection {
|
||||
* the node. -1 to render connection yourself.
|
||||
*/
|
||||
@Override
|
||||
public float getCableConnectionLength(AECableType cable);
|
||||
float getCableConnectionLength(AECableType cable);
|
||||
|
||||
/**
|
||||
* same as Block.animateTick, for but parts.
|
||||
@@ -346,10 +347,12 @@ public interface IPart extends ICustomCableConnection {
|
||||
* capabilities on the cable bus will be forwarded to parts on the appropriate
|
||||
* side.
|
||||
*
|
||||
* @see TileEntity#getCapability(Capability, net.minecraft.util.Direction)
|
||||
* @see CapabilityProvider#getCapability(Capability,
|
||||
* net.minecraft.util.Direction)
|
||||
*
|
||||
* @return The capability or null.
|
||||
* @return The capability
|
||||
*/
|
||||
@Nonnull
|
||||
default <T> LazyOptional<T> getCapability(Capability<T> capabilityClass) {
|
||||
return LazyOptional.empty();
|
||||
}
|
||||
@@ -376,7 +379,7 @@ public interface IPart extends ICustomCableConnection {
|
||||
* This will be used by the core to add information about this part to a crash
|
||||
* report if it is attached to a host that caused a crash during tick
|
||||
* processing.
|
||||
*
|
||||
*
|
||||
* @param section The crash report section the information will be added to.
|
||||
*/
|
||||
default void addEntityCrashInfo(final CrashReportCategory section) {
|
||||
|
||||
@@ -23,13 +23,10 @@ import java.util.Collection;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import appeng.api.AEInjectable;
|
||||
|
||||
/**
|
||||
* Allows registration of part models that can then be used in
|
||||
* {@link IPart#getStaticModels()}.
|
||||
*/
|
||||
@AEInjectable
|
||||
public interface IPartModels {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.recipes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.exceptions.MissingIngredientException;
|
||||
import appeng.api.exceptions.RecipeException;
|
||||
import appeng.api.exceptions.RegistrationException;
|
||||
|
||||
@Deprecated
|
||||
public interface ICraftHandler {
|
||||
|
||||
/**
|
||||
* Called when your recipe handler receives a newly parsed list of
|
||||
* inputs/outputs.
|
||||
*
|
||||
* @param input parsed inputs
|
||||
* @param output parsed outputs
|
||||
*
|
||||
* @throws RecipeException
|
||||
*/
|
||||
void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeException;
|
||||
|
||||
/**
|
||||
* called when all recipes are parsed, and your required to register your
|
||||
* recipe.
|
||||
*
|
||||
* @throws RegistrationException
|
||||
* @throws MissingIngredientException
|
||||
*/
|
||||
void register() throws RegistrationException, MissingIngredientException;
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.recipes;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.exceptions.MissingIngredientException;
|
||||
import appeng.api.exceptions.RegistrationException;
|
||||
|
||||
@Deprecated
|
||||
public interface IIngredient {
|
||||
|
||||
/**
|
||||
* Acquire a single input stack for the current recipe, if more then one
|
||||
* ItemStack is possible a RegistrationError exception will be thrown, ignore
|
||||
* these and let the system handle the error.
|
||||
*
|
||||
* @return a single ItemStack for the recipe handler.
|
||||
*
|
||||
* @throws RegistrationException
|
||||
* @throws MissingIngredientException
|
||||
*/
|
||||
ItemStack getItemStack() throws RegistrationException, MissingIngredientException;
|
||||
|
||||
/**
|
||||
* Acquire a list of all the input stacks for the current recipe, this is for
|
||||
* handlers that support multiple inputs per slot.
|
||||
*
|
||||
* @return an array of ItemStacks for the recipe handler.
|
||||
*
|
||||
* @throws RegistrationException
|
||||
* @throws MissingIngredientException
|
||||
*/
|
||||
ItemStack[] getItemStackSet() throws RegistrationException, MissingIngredientException;
|
||||
|
||||
/**
|
||||
* If you wish to support air, you must test before getting the ItemStack, or
|
||||
* ItemStackSet
|
||||
*
|
||||
* @return true if this slot contains no ItemStack, this is passed as "_"
|
||||
*/
|
||||
boolean isAir();
|
||||
|
||||
/**
|
||||
* @return The Name Space of the item. Prefer getItemStack or getItemStackSet
|
||||
*/
|
||||
String getNameSpace();
|
||||
|
||||
/**
|
||||
* @return The Name of the item. Prefer getItemStack or getItemStackSet
|
||||
*/
|
||||
String getItemName();
|
||||
|
||||
/**
|
||||
* @return The Damage Value of the item. Prefer getItemStack or getItemStackSet
|
||||
*/
|
||||
int getDamageValue();
|
||||
|
||||
/**
|
||||
* @return The Damage Value of the item. Prefer getItemStack or getItemStackSet
|
||||
*/
|
||||
int getQty();
|
||||
|
||||
/**
|
||||
* Bakes the lists in for faster runtime look-ups.
|
||||
*
|
||||
* @throws MissingIngredientException
|
||||
* @throws RegistrationException
|
||||
*/
|
||||
void bake() throws RegistrationException, MissingIngredientException;
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.recipes;
|
||||
|
||||
/**
|
||||
* Represents the AE2 Recipe Loading/Reading Class
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IRecipeHandler {
|
||||
|
||||
/**
|
||||
* Call when you want to read recipes in from a file based on a loader
|
||||
*
|
||||
* @param loader recipe loader
|
||||
* @param path path of file
|
||||
*/
|
||||
void parseRecipes(IRecipeLoader loader, String path);
|
||||
|
||||
/**
|
||||
* this loads the read recipes into minecraft, should be called in Init.
|
||||
*/
|
||||
void injectRecipes();
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 - 2015 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.recipes;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@Deprecated
|
||||
public interface IRecipeLoader {
|
||||
/**
|
||||
* @param filePath the path to the to be loaded file
|
||||
*
|
||||
* @return reader handler of the file
|
||||
*
|
||||
* @throws Exception if reading goes wrong
|
||||
*/
|
||||
BufferedReader getFile(@Nonnull String filePath) throws Exception;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.recipes;
|
||||
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
|
||||
public class ResolverResult {
|
||||
|
||||
public final String itemName;
|
||||
public final int damageValue;
|
||||
public final CompoundNBT compound;
|
||||
|
||||
public ResolverResult(final String name, final int damage) {
|
||||
this.itemName = name;
|
||||
this.damageValue = damage;
|
||||
this.compound = null;
|
||||
}
|
||||
|
||||
public ResolverResult(final String name, final int damage, final CompoundNBT data) {
|
||||
this.itemName = name;
|
||||
this.damageValue = damage;
|
||||
this.compound = data;
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013 AlgorithmX2
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package appeng.api.recipes;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ResolverResultSet {
|
||||
|
||||
public final String name;
|
||||
public final List<ItemStack> results;
|
||||
|
||||
public ResolverResultSet(final String myName, final ItemStack... set) {
|
||||
this.results = Arrays.asList(set);
|
||||
this.name = myName;
|
||||
}
|
||||
}
|
||||
@@ -179,17 +179,7 @@ public interface IAEStack<T extends IAEStack<T>> {
|
||||
T empty();
|
||||
|
||||
/**
|
||||
* @return true if the stack is a {@link IAEItemStack}
|
||||
*/
|
||||
boolean isItem();
|
||||
|
||||
/**
|
||||
* @return true if the stack is a {@link IAEFluidStack}
|
||||
*/
|
||||
boolean isFluid();
|
||||
|
||||
/**
|
||||
* @return ITEM or FLUID
|
||||
* @return The {@link IStorageChannel} backing this stack.
|
||||
*/
|
||||
IStorageChannel<T> getChannel();
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEItemPowerStorage {
|
||||
@@ -123,7 +123,7 @@ public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEIte
|
||||
|
||||
private double getMaxEnergyCapacity() {
|
||||
final Block blockID = Block.getBlockFromItem(this);
|
||||
final IBlockDefinition energyCell = AEApi.instance().definitions().blocks().energyCell();
|
||||
final IBlockDefinition energyCell = Api.instance().definitions().blocks().energyCell();
|
||||
|
||||
return energyCell.maybeBlock().map(block -> {
|
||||
if (blockID == block) {
|
||||
|
||||
@@ -23,10 +23,13 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
@@ -54,12 +57,22 @@ public abstract class AbstractCraftingUnitBlock<T extends CraftingTileEntity> ex
|
||||
builder.add(FORMED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn,
|
||||
BlockPos currentPos, BlockPos facingPos) {
|
||||
TileEntity te = worldIn.getTileEntity(currentPos);
|
||||
if (te != null) {
|
||||
te.requestModelDataUpdate();
|
||||
}
|
||||
return super.updatePostPlacement(stateIn, facing, facingState, worldIn, currentPos, facingPos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void neighborChanged(final BlockState state, final World worldIn, final BlockPos pos, final Block blockIn,
|
||||
final BlockPos fromPos, boolean isMoving) {
|
||||
final CraftingTileEntity cp = this.getTileEntity(worldIn, pos);
|
||||
if (cp != null) {
|
||||
cp.updateMultiBlock();
|
||||
cp.updateMultiBlock(fromPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ package appeng.block.crafting;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.features.AEFeature;
|
||||
import appeng.block.AEBaseBlockItem;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
|
||||
public class CraftingStorageItem extends AEBaseBlockItem {
|
||||
|
||||
@@ -34,7 +34,7 @@ public class CraftingStorageItem extends AEBaseBlockItem {
|
||||
|
||||
@Override
|
||||
public ItemStack getContainerItem(final ItemStack itemStack) {
|
||||
return AEApi.instance().definitions().blocks().craftingUnit().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
return Api.instance().definitions().blocks().craftingUnit().maybeStack(1).orElse(ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -49,13 +49,13 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEAxisAlignedBB;
|
||||
import appeng.block.AEBaseTileBlock;
|
||||
import appeng.client.render.effects.ParticleTypes;
|
||||
import appeng.client.render.renderable.ItemRenderable;
|
||||
import appeng.client.render.tesr.ModularTESR;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.misc.ChargerTileEntity;
|
||||
import appeng.util.Platform;
|
||||
@@ -101,7 +101,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerTileEntity> {
|
||||
|
||||
final ChargerTileEntity tile = this.getTileEntity(w, pos);
|
||||
if (tile != null) {
|
||||
if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged()
|
||||
if (Api.instance().definitions().materials().certusQuartzCrystalCharged()
|
||||
.isSameAs(tile.getInternalInventory().getStackInSlot(0))) {
|
||||
final double xOff = 0.0;
|
||||
final double yOff = 0.0;
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package appeng.block.networking;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
@@ -44,8 +43,11 @@ import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult.Type;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.shapes.ISelectionContext;
|
||||
import net.minecraft.util.math.shapes.VoxelShape;
|
||||
import net.minecraft.util.math.shapes.VoxelShapes;
|
||||
|
||||
@@ -25,8 +25,8 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.client.render.cablebus.CubeBuilder;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.tile.qnb.QuantumBridgeTileEntity;
|
||||
|
||||
@@ -41,9 +41,9 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
|
||||
private static final Material TEXTURE_RING_LIGHT_CORNER = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "block/quantum_ring_light_corner"));
|
||||
private static final Material TEXTURE_CABLE_GLASS = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/glass/transparent"));
|
||||
new ResourceLocation(AppEng.MOD_ID, "part/cable/glass/transparent"));
|
||||
private static final Material TEXTURE_COVERED_CABLE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/covered/transparent"));
|
||||
new ResourceLocation(AppEng.MOD_ID, "part/cable/covered/transparent"));
|
||||
|
||||
private static final float DEFAULT_RENDER_MIN = 2.0f;
|
||||
private static final float DEFAULT_RENDER_MAX = 14.0f;
|
||||
@@ -73,7 +73,7 @@ class QnbFormedBakedModel implements IDynamicBakedModel {
|
||||
this.coveredCableTexture = bakedTextureGetter.apply(TEXTURE_COVERED_CABLE);
|
||||
this.lightTexture = bakedTextureGetter.apply(TEXTURE_RING_LIGHT);
|
||||
this.lightCornerTexture = bakedTextureGetter.apply(TEXTURE_RING_LIGHT_CORNER);
|
||||
this.linkBlock = AEApi.instance().definitions().blocks().quantumLink().maybeBlock().orElse(null);
|
||||
this.linkBlock = Api.instance().definitions().blocks().quantumLink().maybeBlock().orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -70,7 +70,7 @@ public abstract class QuantumBaseBlock extends AEBaseTileBlock<QuantumBridgeTile
|
||||
boolean isMoving) {
|
||||
final QuantumBridgeTileEntity bridge = this.getTileEntity(world, pos);
|
||||
if (bridge != null) {
|
||||
bridge.neighborUpdate();
|
||||
bridge.neighborUpdate(fromPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public class SpatialPylonBlock extends AEBaseTileBlock<SpatialPylonTileEntity> {
|
||||
boolean isMoving) {
|
||||
final SpatialPylonTileEntity tsp = this.getTileEntity(world, pos);
|
||||
if (tsp != null) {
|
||||
tsp.neighborChanged();
|
||||
tsp.neighborChanged(fromPos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.EnumProperty;
|
||||
import net.minecraft.state.BooleanProperty;
|
||||
import net.minecraft.state.StateContainer;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Hand;
|
||||
@@ -42,18 +42,17 @@ import appeng.tile.storage.ChestTileEntity;
|
||||
|
||||
public class ChestBlock extends AEBaseTileBlock<ChestTileEntity> {
|
||||
|
||||
private final static EnumProperty<DriveSlotState> SLOT_STATE = EnumProperty.create("slot_state",
|
||||
DriveSlotState.class);
|
||||
private final static BooleanProperty LIGHTS_ON = BooleanProperty.create("lights_on");
|
||||
|
||||
public ChestBlock() {
|
||||
super(defaultProps(Material.IRON));
|
||||
this.setDefaultState(this.getDefaultState().with(SLOT_STATE, DriveSlotState.EMPTY));
|
||||
this.setDefaultState(this.getDefaultState().with(LIGHTS_ON, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
|
||||
super.fillStateContainer(builder);
|
||||
builder.add(SLOT_STATE);
|
||||
builder.add(LIGHTS_ON);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,7 +67,7 @@ public class ChestBlock extends AEBaseTileBlock<ChestTileEntity> {
|
||||
slotState = DriveSlotState.OFFLINE;
|
||||
}
|
||||
|
||||
return currentState.with(SLOT_STATE, slotState);
|
||||
return currentState.with(LIGHTS_ON, slotState != DriveSlotState.EMPTY && slotState != DriveSlotState.OFFLINE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.block.storage;
|
||||
|
||||
import net.minecraft.util.IStringSerializable;
|
||||
|
||||
/**
|
||||
* Describes the type of cell present in a slot.
|
||||
*/
|
||||
public enum DriveSlotCellType implements IStringSerializable {
|
||||
|
||||
EMPTY("empty"),
|
||||
|
||||
ITEM("item"),
|
||||
|
||||
FLUID("fluid");
|
||||
|
||||
private final String name;
|
||||
|
||||
DriveSlotCellType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,7 +25,6 @@ import net.minecraftforge.common.capabilities.CapabilityInject;
|
||||
import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
import appeng.api.storage.IStorageMonitorableAccessor;
|
||||
|
||||
/**
|
||||
@@ -38,8 +37,6 @@ public final class Capabilities {
|
||||
|
||||
public static Capability<IStorageMonitorableAccessor> STORAGE_MONITORABLE_ACCESSOR;
|
||||
|
||||
public static Capability<ISpatialDimension> SPATIAL_DIMENSION;
|
||||
|
||||
public static Capability<IEnergyStorage> FORGE_ENERGY;
|
||||
|
||||
/**
|
||||
@@ -48,7 +45,6 @@ public final class Capabilities {
|
||||
public static void register() {
|
||||
CapabilityManager.INSTANCE.register(IStorageMonitorableAccessor.class, createNullStorage(),
|
||||
NullMENetworkAccessor::new);
|
||||
CapabilityManager.INSTANCE.register(ISpatialDimension.class, createNullStorage(), NullSpatialDimension::new);
|
||||
}
|
||||
|
||||
@CapabilityInject(IStorageMonitorableAccessor.class)
|
||||
@@ -56,11 +52,6 @@ public final class Capabilities {
|
||||
STORAGE_MONITORABLE_ACCESSOR = cap;
|
||||
}
|
||||
|
||||
@CapabilityInject(ISpatialDimension.class)
|
||||
private static void capISpatialDimensionRegistered(Capability<ISpatialDimension> cap) {
|
||||
SPATIAL_DIMENSION = cap;
|
||||
}
|
||||
|
||||
@CapabilityInject(IEnergyStorage.class)
|
||||
private static void capIEnergyStorageRegistered(Capability<IEnergyStorage> cap) {
|
||||
FORGE_ENERGY = cap;
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.capabilities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
import appeng.api.storage.ISpatialDimension;
|
||||
|
||||
class NullSpatialDimension implements ISpatialDimension {
|
||||
@Override
|
||||
public DimensionType createNewCellDimension(BlockPos size) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteCellDimension(DimensionType cellStorageId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCellDimensionOrigin(DimensionType cellStorageId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getCellDimensionSize(DimensionType cellDim) {
|
||||
return BlockPos.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCellDimensionTooltip(DimensionType cellDim, List<ITextComponent> tooltip) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerWorld getWorld(DimensionType cellStorageId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCellDimension(DimensionType cellDimID) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,10 @@ import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
|
||||
import appeng.api.parts.CableRenderMode;
|
||||
import appeng.block.AEBaseBlock;
|
||||
import appeng.client.render.effects.*;
|
||||
import appeng.client.render.effects.EnergyParticleData;
|
||||
import appeng.client.render.effects.LightningArcFX;
|
||||
import appeng.client.render.effects.LightningFX;
|
||||
import appeng.client.render.effects.ParticleTypes;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.player.ClientPlayerEntity;
|
||||
import net.minecraft.client.gui.IGuiEventListener;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
@@ -60,6 +61,7 @@ import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.widgets.CustomSlotWidget;
|
||||
import appeng.client.gui.widgets.ITickingWidget;
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import appeng.client.gui.widgets.Scrollbar;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
@@ -88,6 +90,9 @@ import appeng.fluids.container.slots.IMEFluidSlot;
|
||||
import appeng.helpers.InventoryAction;
|
||||
|
||||
public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerScreen<T> {
|
||||
|
||||
public static final int COLOR_DARK_GRAY = 4210752;
|
||||
|
||||
private final List<InternalSlotME> meSlots = new ArrayList<>();
|
||||
// drag y
|
||||
private final Set<Slot> drag_click = new HashSet<>();
|
||||
@@ -149,14 +154,14 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
||||
|
||||
protected void drawGuiSlot(CustomSlotWidget slot, int mouseX, int mouseY, float partialTicks) {
|
||||
if (slot.isSlotEnabled()) {
|
||||
final int left = slot.xPos();
|
||||
final int top = slot.yPos();
|
||||
final int right = left + slot.getWidth();
|
||||
final int bottom = top + slot.getHeight();
|
||||
final int left = slot.getTooltipAreaX();
|
||||
final int top = slot.getTooltipAreaY();
|
||||
final int right = left + slot.getTooltipAreaWidth();
|
||||
final int bottom = top + slot.getTooltipAreaHeight();
|
||||
|
||||
slot.drawContent(getMinecraft(), mouseX, mouseY, partialTicks);
|
||||
|
||||
if (this.isPointInRegion(left, top, slot.getWidth(), slot.getHeight(), mouseX, mouseY)
|
||||
if (this.isPointInRegion(left, top, slot.getTooltipAreaWidth(), slot.getTooltipAreaHeight(), mouseX, mouseY)
|
||||
&& slot.canClick(getPlayer())) {
|
||||
RenderSystem.colorMask(true, true, true, false);
|
||||
this.fillGradient(left, top, right, bottom, -2130706433, -2130706433);
|
||||
@@ -166,17 +171,17 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
||||
}
|
||||
|
||||
private void drawTooltip(ITooltip tooltip, int mouseX, int mouseY) {
|
||||
final int x = tooltip.xPos(); // ((GuiImgButton) c).x;
|
||||
int y = tooltip.yPos(); // ((GuiImgButton) c).y;
|
||||
final int x = tooltip.getTooltipAreaX();
|
||||
int y = tooltip.getTooltipAreaY();
|
||||
|
||||
if (x < mouseX && x + tooltip.getWidth() > mouseX && tooltip.isVisible()) {
|
||||
if (y < mouseY && y + tooltip.getHeight() > mouseY) {
|
||||
if (x < mouseX && x + tooltip.getTooltipAreaWidth() > mouseX && tooltip.isTooltipAreaVisible()) {
|
||||
if (y < mouseY && y + tooltip.getTooltipAreaHeight() > mouseY) {
|
||||
if (y < 15) {
|
||||
y = 15;
|
||||
}
|
||||
|
||||
final String msg = tooltip.getMessage();
|
||||
if (msg != null) {
|
||||
final String msg = tooltip.getTooltipMessage();
|
||||
if (msg != null && !msg.isEmpty()) {
|
||||
this.drawTooltip(x + 11, y + 4, msg);
|
||||
}
|
||||
}
|
||||
@@ -270,8 +275,8 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
||||
}
|
||||
|
||||
for (CustomSlotWidget slot : this.guiSlots) {
|
||||
if (this.isPointInRegion(slot.xPos(), slot.yPos(), slot.getWidth(), slot.getHeight(), xCoord, yCoord)
|
||||
&& slot.canClick(getPlayer())) {
|
||||
if (this.isPointInRegion(slot.getTooltipAreaX(), slot.getTooltipAreaY(), slot.getTooltipAreaWidth(),
|
||||
slot.getTooltipAreaHeight(), xCoord, yCoord) && slot.canClick(getPlayer())) {
|
||||
slot.slotClicked(getPlayer().inventory.getItemStack(), btn);
|
||||
}
|
||||
}
|
||||
@@ -781,4 +786,14 @@ public abstract class AEBaseScreen<T extends AEBaseContainer> extends ContainerS
|
||||
protected List<InternalSlotME> getMeSlots() {
|
||||
return this.meSlots;
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
super.tick();
|
||||
for (IGuiEventListener child : children) {
|
||||
if (child instanceof ITickingWidget) {
|
||||
((ITickingWidget) child).tick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package appeng.client.gui;
|
||||
|
||||
public enum NumberEntryType {
|
||||
CRAFT_ITEM_COUNT(Long.class), PRIORITY(Long.class), LEVEL_ITEM_COUNT(Long.class), LEVEL_FLUID_VOLUME(Long.class);
|
||||
|
||||
private final Class<? extends Number> inputType;
|
||||
|
||||
NumberEntryType(Class<? extends Number> inputType) {
|
||||
this.inputType = inputType;
|
||||
}
|
||||
|
||||
public Class<? extends Number> getInputType() {
|
||||
return inputType;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.inventory.container.ContainerType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IDefinitions;
|
||||
import appeng.api.definitions.IParts;
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
@@ -18,6 +17,7 @@ import appeng.container.implementations.CraftingTermContainer;
|
||||
import appeng.container.implementations.MEMonitorableContainer;
|
||||
import appeng.container.implementations.PatternTermContainer;
|
||||
import appeng.container.implementations.WirelessTermContainer;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.SwitchGuisPacket;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
@@ -44,7 +44,7 @@ final class AESubScreen {
|
||||
public AESubScreen(AEBaseScreen<?> gui, Object containerTarget) {
|
||||
this.gui = gui;
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IDefinitions definitions = Api.instance().definitions();
|
||||
final IParts parts = definitions.parts();
|
||||
|
||||
if (containerTarget instanceof ChestTileEntity) {
|
||||
|
||||
@@ -19,15 +19,13 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.NumberBox;
|
||||
import appeng.client.gui.NumberEntryType;
|
||||
import appeng.container.implementations.CraftAmountContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.CraftRequestPacket;
|
||||
@@ -35,7 +33,7 @@ import appeng.core.sync.packets.CraftRequestPacket;
|
||||
public class CraftAmountScreen extends AEBaseScreen<CraftAmountContainer> {
|
||||
private final AESubScreen subGui;
|
||||
|
||||
private NumberBox amountToCraft;
|
||||
private NumberEntryWidget amountToCraft;
|
||||
|
||||
private Button next;
|
||||
|
||||
@@ -48,39 +46,22 @@ public class CraftAmountScreen extends AEBaseScreen<CraftAmountContainer> {
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
final int a = AEConfig.instance().craftItemsByStackAmounts(0);
|
||||
final int b = AEConfig.instance().craftItemsByStackAmounts(1);
|
||||
final int c = AEConfig.instance().craftItemsByStackAmounts(2);
|
||||
final int d = AEConfig.instance().craftItemsByStackAmounts(3);
|
||||
|
||||
this.addButton(new Button(this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a, btn -> addQty(a)));
|
||||
this.addButton(new Button(this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b, btn -> addQty(b)));
|
||||
this.addButton(new Button(this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c, btn -> addQty(c)));
|
||||
this.addButton(new Button(this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d, btn -> addQty(d)));
|
||||
|
||||
this.addButton(new Button(this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a, btn -> addQty(-a)));
|
||||
this.addButton(new Button(this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b, btn -> addQty(-b)));
|
||||
this.addButton(new Button(this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c, btn -> addQty(-c)));
|
||||
this.addButton(new Button(this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d, btn -> addQty(-d)));
|
||||
this.amountToCraft = new NumberEntryWidget(this, 20, 30, 138, 62, NumberEntryType.CRAFT_ITEM_COUNT, value -> {
|
||||
});
|
||||
this.amountToCraft.setValue(1);
|
||||
this.amountToCraft.setTextFieldBounds(62, 57, 50);
|
||||
this.amountToCraft.setMinValue(1);
|
||||
this.amountToCraft.addButtons(children::add, this::addButton);
|
||||
|
||||
this.next = this.addButton(
|
||||
new Button(this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal(), this::confirm));
|
||||
|
||||
subGui.addBackButton(this::addButton, 154, 0);
|
||||
|
||||
this.amountToCraft = new NumberBox(this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT,
|
||||
Integer.class);
|
||||
this.amountToCraft.setEnableBackgroundDrawing(false);
|
||||
this.amountToCraft.setMaxStringLength(16);
|
||||
this.amountToCraft.setTextColor(0xFFFFFF);
|
||||
this.amountToCraft.setVisible(true);
|
||||
this.amountToCraft.setFocused2(true);
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
|
||||
private void confirm(Button button) {
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new CraftRequestPacket(Integer.parseInt(this.amountToCraft.getText()), hasShiftDown()));
|
||||
.sendToServer(new CraftRequestPacket((int) this.amountToCraft.getValue(), hasShiftDown()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -95,99 +76,23 @@ public class CraftAmountScreen extends AEBaseScreen<CraftAmountContainer> {
|
||||
this.bindTexture("guis/craft_amt.png");
|
||||
GuiUtils.drawTexturedModalRect(offsetX, offsetY, 0, 0, this.xSize, this.ySize, getBlitOffset());
|
||||
|
||||
try {
|
||||
Long.parseLong(this.amountToCraft.getText());
|
||||
this.next.active = !this.amountToCraft.getText().isEmpty();
|
||||
} catch (final NumberFormatException e) {
|
||||
this.next.active = false;
|
||||
}
|
||||
this.next.active = this.amountToCraft.getValue() > 0;
|
||||
|
||||
this.amountToCraft.render(offsetX, offsetY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char ch, int p_charTyped_2_) {
|
||||
// Forward entered text to the craft amount text-field
|
||||
return this.amountToCraft.charTyped(ch, p_charTyped_2_);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) {
|
||||
if (keyCode == 28) {
|
||||
this.next.onPress();
|
||||
}
|
||||
if ((keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14)
|
||||
&& this.amountToCraft.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
try {
|
||||
String out = this.amountToCraft.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if (fixed) {
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
final long result = Long.parseLong(out);
|
||||
if (result < 0) {
|
||||
this.amountToCraft.setText("1");
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
// :P
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
private void addQty(final int i) {
|
||||
try {
|
||||
String out = this.amountToCraft.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if (fixed) {
|
||||
this.amountToCraft.setText(out);
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
long result = Integer.parseInt(out);
|
||||
|
||||
if (result == 1 && i > 1) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
result += i;
|
||||
if (result < 1) {
|
||||
result = 1;
|
||||
}
|
||||
|
||||
out = Long.toString(result);
|
||||
Integer.parseInt(out);
|
||||
this.amountToCraft.setText(out);
|
||||
} catch (final NumberFormatException e) {
|
||||
// :P
|
||||
if (keyCode == 28) {
|
||||
this.next.onPress();
|
||||
return true;
|
||||
} else {
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.Scrollbar;
|
||||
import appeng.container.implementations.CraftConfirmContainer;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
@@ -51,11 +51,11 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
|
||||
|
||||
private final int rows = 5;
|
||||
|
||||
private final IItemList<IAEItemStack> storage = AEApi.instance().storage()
|
||||
private final IItemList<IAEItemStack> storage = Api.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
private final IItemList<IAEItemStack> pending = AEApi.instance().storage()
|
||||
private final IItemList<IAEItemStack> pending = Api.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
private final IItemList<IAEItemStack> missing = AEApi.instance().storage()
|
||||
private final IItemList<IAEItemStack> missing = Api.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
|
||||
private final List<IAEItemStack> visual = new ArrayList<>();
|
||||
|
||||
@@ -34,7 +34,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
@@ -47,6 +46,7 @@ import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.Scrollbar;
|
||||
import appeng.container.implementations.CraftingCPUContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
@@ -79,11 +79,11 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
|
||||
private static final int ITEMSTACK_LEFT_OFFSET = 9;
|
||||
private static final int ITEMSTACK_TOP_OFFSET = 22;
|
||||
|
||||
private IItemList<IAEItemStack> storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
private IItemList<IAEItemStack> storage = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createList();
|
||||
private IItemList<IAEItemStack> active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
private IItemList<IAEItemStack> active = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createList();
|
||||
private IItemList<IAEItemStack> pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
private IItemList<IAEItemStack> pending = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createList();
|
||||
|
||||
private List<IAEItemStack> visual = new ArrayList<>();
|
||||
@@ -100,9 +100,9 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
|
||||
}
|
||||
|
||||
public void clearItems() {
|
||||
this.storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.storage = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.active = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.pending = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.visual = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ package appeng.client.gui.implementations;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FullnessMode;
|
||||
import appeng.api.config.OperationMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
@@ -30,6 +29,7 @@ import appeng.api.definitions.IDefinitions;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.container.implementations.IOPortContainer;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class IOPortScreen extends UpgradeableScreen<IOPortContainer> {
|
||||
@@ -78,7 +78,7 @@ public class IOPortScreen extends UpgradeableScreen<IOPortContainer> {
|
||||
public void drawBG(final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
|
||||
super.drawBG(offsetX, offsetY, mouseX, mouseY, partialTicks);
|
||||
|
||||
final IDefinitions definitions = AEApi.instance().definitions();
|
||||
final IDefinitions definitions = Api.instance().definitions();
|
||||
|
||||
definitions.items().cell1k().maybeStack(1)
|
||||
.ifPresent(cell1kStack -> this.drawItem(offsetX + 66 - 8, offsetY + 17, cell1kStack));
|
||||
|
||||
@@ -40,7 +40,6 @@ import net.minecraft.nbt.ListNBT;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fml.client.gui.GuiUtils;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
@@ -49,6 +48,7 @@ import appeng.client.gui.widgets.Scrollbar;
|
||||
import appeng.client.me.ClientDCInternalInv;
|
||||
import appeng.client.me.SlotDisconnected;
|
||||
import appeng.container.implementations.InterfaceTerminalContainer;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.util.Platform;
|
||||
@@ -321,7 +321,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
|
||||
|
||||
final ItemStack parsedItemStack = ItemStack.read(outTag.getCompound(i));
|
||||
if (!parsedItemStack.isEmpty()) {
|
||||
final String displayName = Platform.getItemDisplayName(AEApi.instance().storage()
|
||||
final String displayName = Platform.getItemDisplayName(Api.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createStack(parsedItemStack)).getString()
|
||||
.toLowerCase();
|
||||
if (displayName.contains(searchTerm)) {
|
||||
|
||||
@@ -18,39 +18,27 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.LevelType;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.gui.widgets.NumberBox;
|
||||
import appeng.client.gui.NumberEntryType;
|
||||
import appeng.client.gui.widgets.ServerSettingToggleButton;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.container.implementations.LevelEmitterContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
|
||||
public class LevelEmitterScreen extends UpgradeableScreen<LevelEmitterContainer> {
|
||||
|
||||
private NumberBox level;
|
||||
|
||||
private Button plus1;
|
||||
private Button plus10;
|
||||
private Button plus100;
|
||||
private Button plus1000;
|
||||
private Button minus1;
|
||||
private Button minus10;
|
||||
private Button minus100;
|
||||
private Button minus1000;
|
||||
|
||||
private NumberEntryWidget level;
|
||||
private SettingToggleButton<LevelType> levelMode;
|
||||
private SettingToggleButton<YesNo> craftingMode;
|
||||
|
||||
@@ -62,16 +50,17 @@ public class LevelEmitterScreen extends UpgradeableScreen<LevelEmitterContainer>
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
this.level = new NumberBox(this.font, this.guiLeft + 24, this.guiTop + 43, 79, this.font.FONT_HEIGHT,
|
||||
Long.class);
|
||||
this.level.setEnableBackgroundDrawing(false);
|
||||
this.level.setMaxStringLength(16);
|
||||
this.level.setTextColor(0xFFFFFF);
|
||||
this.level.setVisible(true);
|
||||
this.level.setFocused2(true);
|
||||
this.level = new NumberEntryWidget(this, 20, 17, 138, 62, NumberEntryType.LEVEL_ITEM_COUNT,
|
||||
this::onLevelChange);
|
||||
this.level.setTextFieldBounds(25, 44, 75);
|
||||
this.level.addButtons(children::add, this::addButton);
|
||||
container.setTextField(this.level);
|
||||
}
|
||||
|
||||
private void onLevelChange(long level) {
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("LevelEmitter.Value", String.valueOf(level)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons() {
|
||||
this.levelMode = new ServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.LEVEL_TYPE,
|
||||
@@ -82,29 +71,6 @@ public class LevelEmitterScreen extends UpgradeableScreen<LevelEmitterContainer>
|
||||
FuzzyMode.IGNORE_ALL);
|
||||
this.craftingMode = new ServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48,
|
||||
Settings.CRAFT_VIA_REDSTONE, YesNo.NO);
|
||||
|
||||
final int a = AEConfig.instance().levelByStackAmounts(0);
|
||||
final int b = AEConfig.instance().levelByStackAmounts(1);
|
||||
final int c = AEConfig.instance().levelByStackAmounts(2);
|
||||
final int d = AEConfig.instance().levelByStackAmounts(3);
|
||||
|
||||
this.addButton(this.plus1 = new Button(this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a, btn -> addQty(a)));
|
||||
this.addButton(
|
||||
this.plus10 = new Button(this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b, btn -> addQty(b)));
|
||||
this.addButton(
|
||||
this.plus100 = new Button(this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c, btn -> addQty(c)));
|
||||
this.addButton(
|
||||
this.plus1000 = new Button(this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d, btn -> addQty(d)));
|
||||
|
||||
this.addButton(
|
||||
this.minus1 = new Button(this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a, btn -> addQty(-a)));
|
||||
this.addButton(
|
||||
this.minus10 = new Button(this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b, btn -> addQty(-b)));
|
||||
this.addButton(
|
||||
this.minus100 = new Button(this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c, btn -> addQty(-c)));
|
||||
this.addButton(
|
||||
this.minus1000 = new Button(this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d, btn -> addQty(-d)));
|
||||
|
||||
this.addButton(this.levelMode);
|
||||
this.addButton(this.redstoneMode);
|
||||
this.addButton(this.craftingMode);
|
||||
@@ -115,15 +81,7 @@ public class LevelEmitterScreen extends UpgradeableScreen<LevelEmitterContainer>
|
||||
final boolean notCraftingMode = this.bc.getInstalledUpgrades(Upgrades.CRAFTING) == 0;
|
||||
|
||||
// configure enabled status...
|
||||
this.level.setEnabled(notCraftingMode);
|
||||
this.plus1.active = notCraftingMode;
|
||||
this.plus10.active = notCraftingMode;
|
||||
this.plus100.active = notCraftingMode;
|
||||
this.plus1000.active = notCraftingMode;
|
||||
this.minus1.active = notCraftingMode;
|
||||
this.minus10.active = notCraftingMode;
|
||||
this.minus100.active = notCraftingMode;
|
||||
this.minus1000.active = notCraftingMode;
|
||||
this.level.setActive(notCraftingMode);
|
||||
this.levelMode.active = notCraftingMode;
|
||||
this.redstoneMode.active = notCraftingMode;
|
||||
|
||||
@@ -134,7 +92,14 @@ public class LevelEmitterScreen extends UpgradeableScreen<LevelEmitterContainer>
|
||||
}
|
||||
|
||||
if (this.levelMode != null) {
|
||||
this.levelMode.set(((LevelEmitterContainer) this.cvb).getLevelMode());
|
||||
LevelType currentLevelMode = ((LevelEmitterContainer) this.cvb).getLevelMode();
|
||||
this.levelMode.set(currentLevelMode);
|
||||
|
||||
if (notCraftingMode) {
|
||||
if (currentLevelMode == LevelType.ENERGY_LEVEL) {
|
||||
this.font.drawString(PowerUnits.AE.textComponent().getString(), 110, 44, COLOR_DARK_GRAY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,70 +125,4 @@ public class LevelEmitterScreen extends UpgradeableScreen<LevelEmitterContainer>
|
||||
return GuiText.LevelEmitter;
|
||||
}
|
||||
|
||||
private void addQty(final long i) {
|
||||
try {
|
||||
String Out = this.level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith("0") && Out.length() > 1) {
|
||||
Out = Out.substring(1);
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if (Fixed) {
|
||||
this.level.setText(Out);
|
||||
}
|
||||
|
||||
if (Out.isEmpty()) {
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
long result = Long.parseLong(Out);
|
||||
result += i;
|
||||
if (result < 0) {
|
||||
result = 0;
|
||||
}
|
||||
|
||||
this.level.setText(Out = Long.toString(result));
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("LevelEmitter.Value", Out));
|
||||
} catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
this.level.setText("0");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
// Forward entered characters to the number-text-field
|
||||
return level.charTyped(character, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) {
|
||||
if (keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14) {
|
||||
String Out = this.level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith("0") && Out.length() > 1) {
|
||||
Out = Out.substring(1);
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if (Fixed) {
|
||||
this.level.setText(Out);
|
||||
}
|
||||
|
||||
if (Out.isEmpty()) {
|
||||
Out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("LevelEmitter.Value", Out));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,12 @@ import net.minecraft.inventory.container.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.config.*;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
@@ -37,7 +42,11 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.ActionKey;
|
||||
import appeng.client.gui.AEBaseMEScreen;
|
||||
import appeng.client.gui.widgets.*;
|
||||
import appeng.client.gui.widgets.AETextField;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.Scrollbar;
|
||||
import appeng.client.gui.widgets.SettingToggleButton;
|
||||
import appeng.client.gui.widgets.TabButton;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.container.implementations.CraftingStatusContainer;
|
||||
@@ -286,12 +295,15 @@ public class MEMonitorableScreen<T extends MEMonitorableContainer> extends AEBas
|
||||
@Override
|
||||
public boolean mouseClicked(final double xCoord, final double yCoord, final int btn) {
|
||||
if (this.searchField.mouseClicked(xCoord, yCoord, btn)) {
|
||||
if (btn == 1 && this.searchField.isMouseOver(xCoord, yCoord)) {
|
||||
this.searchField.setText("");
|
||||
this.repo.setSearchString("");
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Right-clicking on the search field should clear it
|
||||
if (this.searchField.isMouseOver(xCoord, yCoord) && btn == 1) {
|
||||
this.searchField.setText("");
|
||||
this.repo.setSearchString("");
|
||||
this.repo.updateView();
|
||||
this.setScrollBar();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.LongConsumer;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.IGuiEventListener;
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.NumberEntryType;
|
||||
import appeng.client.gui.widgets.ITickingWidget;
|
||||
import appeng.client.gui.widgets.NumberBox;
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
/**
|
||||
* A utility widget that consists of a text-field to enter a number with
|
||||
* attached buttons to increment/decrement the number in fixed intervals.
|
||||
*/
|
||||
public class NumberEntryWidget implements ITickingWidget {
|
||||
|
||||
private final AEBaseScreen<?> parent;
|
||||
|
||||
private final int x;
|
||||
private final int y;
|
||||
|
||||
private final NumberBox level;
|
||||
private final NumberEntryType type;
|
||||
private Button plus1;
|
||||
private Button plus10;
|
||||
private Button plus100;
|
||||
private Button plus1000;
|
||||
private Button minus1;
|
||||
private Button minus10;
|
||||
private Button minus100;
|
||||
private Button minus1000;
|
||||
|
||||
public NumberEntryWidget(AEBaseScreen<?> parent, int x, int y, int width, int height, NumberEntryType type,
|
||||
LongConsumer changeListener) {
|
||||
this.parent = parent;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.type = type;
|
||||
|
||||
FontRenderer font = parent.getMinecraft().fontRenderer;
|
||||
int inputX = parent.getGuiLeft() + x;
|
||||
int inputY = parent.getGuiTop() + y;
|
||||
this.level = new NumberBox(font, inputX, inputY, width, font.FONT_HEIGHT, type.getInputType(), changeListener);
|
||||
this.level.setEnableBackgroundDrawing(false);
|
||||
this.level.setMaxStringLength(16);
|
||||
this.level.setTextColor(0xFFFFFF);
|
||||
this.level.setVisible(true);
|
||||
this.level.setFocused2(true);
|
||||
parent.setFocusedDefault(this.level);
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.level.setEnabled(active);
|
||||
this.plus1.active = active;
|
||||
this.plus10.active = active;
|
||||
this.plus100.active = active;
|
||||
this.plus1000.active = active;
|
||||
this.minus1.active = active;
|
||||
this.minus10.active = active;
|
||||
this.minus100.active = active;
|
||||
this.minus1000.active = active;
|
||||
}
|
||||
|
||||
public void setTextFieldBounds(int x, int y, int width) {
|
||||
this.level.x = parent.getGuiLeft() + x;
|
||||
this.level.y = parent.getGuiTop() + y;
|
||||
this.level.setWidth(width);
|
||||
}
|
||||
|
||||
public void setMinValue(long minValue) {
|
||||
this.level.setMinValue(minValue);
|
||||
}
|
||||
|
||||
public void addButtons(Consumer<IGuiEventListener> addChildren, Consumer<Button> addButton) {
|
||||
final int[] steps = AEConfig.instance().getNumberEntrySteps(type);
|
||||
int a = steps[0];
|
||||
int b = steps[1];
|
||||
int c = steps[2];
|
||||
int d = steps[3];
|
||||
|
||||
int left = parent.getGuiLeft() + x;
|
||||
int top = parent.getGuiTop() + y;
|
||||
|
||||
addButton.accept(this.plus1 = new Button(left, top, 22, 20, "+" + a, btn -> addQty(a)));
|
||||
addButton.accept(this.plus10 = new Button(left + 28, top, 28, 20, "+" + b, btn -> addQty(b)));
|
||||
addButton.accept(this.plus100 = new Button(left + 62, top, 32, 20, "+" + c, btn -> addQty(c)));
|
||||
addButton.accept(this.plus1000 = new Button(left + 100, top, 38, 20, "+" + d, btn -> addQty(d)));
|
||||
|
||||
// Placing this here will give a sensible tab order
|
||||
addChildren.accept(this.level);
|
||||
|
||||
addButton.accept(this.minus1 = new Button(left, top + 42, 22, 20, "-" + a, btn -> addQty(-a)));
|
||||
addButton.accept(this.minus10 = new Button(left + 28, top + 42, 28, 20, "-" + b, btn -> addQty(-b)));
|
||||
addButton.accept(this.minus100 = new Button(left + 62, top + 42, 32, 20, "-" + c, btn -> addQty(-c)));
|
||||
addButton.accept(this.minus1000 = new Button(left + 100, top + 42, 38, 20, "-" + d, btn -> addQty(-d)));
|
||||
}
|
||||
|
||||
private void addQty(final long i) {
|
||||
long currentValue = this.level.getValue();
|
||||
long minValue = this.level.getMinValue();
|
||||
this.level.setText(String.valueOf(Math.max(minValue, currentValue + i)));
|
||||
}
|
||||
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
this.level.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
public void setValue(long value, boolean skipNotify) {
|
||||
this.level.setValue(value, skipNotify);
|
||||
}
|
||||
|
||||
public void setValue(long value) {
|
||||
setValue(value, false);
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
return level.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
this.level.tick();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,15 +18,12 @@
|
||||
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.gui.widget.button.Button;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.client.gui.AEBaseScreen;
|
||||
import appeng.client.gui.widgets.NumberBox;
|
||||
import appeng.client.gui.NumberEntryType;
|
||||
import appeng.container.implementations.PriorityContainer;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
@@ -35,7 +32,7 @@ public class PriorityScreen extends AEBaseScreen<PriorityContainer> {
|
||||
|
||||
private final AESubScreen subGui;
|
||||
|
||||
private NumberBox priority;
|
||||
private NumberEntryWidget priority;
|
||||
|
||||
public PriorityScreen(PriorityContainer container, PlayerInventory playerInventory, ITextComponent title) {
|
||||
super(container, playerInventory, title);
|
||||
@@ -46,31 +43,18 @@ public class PriorityScreen extends AEBaseScreen<PriorityContainer> {
|
||||
public void init() {
|
||||
super.init();
|
||||
|
||||
final int a = AEConfig.instance().priorityByStacksAmounts(0);
|
||||
final int b = AEConfig.instance().priorityByStacksAmounts(1);
|
||||
final int c = AEConfig.instance().priorityByStacksAmounts(2);
|
||||
final int d = AEConfig.instance().priorityByStacksAmounts(3);
|
||||
|
||||
this.addButton(new Button(this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a, btn -> addQty(a)));
|
||||
this.addButton(new Button(this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b, btn -> addQty(b)));
|
||||
this.addButton(new Button(this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c, btn -> addQty(c)));
|
||||
this.addButton(new Button(this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d, btn -> addQty(d)));
|
||||
|
||||
this.addButton(new Button(this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a, btn -> addQty(-a)));
|
||||
this.addButton(new Button(this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b, btn -> addQty(-b)));
|
||||
this.addButton(new Button(this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c, btn -> addQty(-c)));
|
||||
this.addButton(new Button(this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d, btn -> addQty(-d)));
|
||||
this.priority = new NumberEntryWidget(this, 20, 30, 138, 62, NumberEntryType.PRIORITY, this::onPriorityChange);
|
||||
this.priority.setTextFieldBounds(62, 57, 50);
|
||||
this.priority.setMinValue(Integer.MIN_VALUE);
|
||||
container.setTextField(this.priority);
|
||||
this.priority.addButtons(children::add, this::addButton);
|
||||
|
||||
this.subGui.addBackButton(this::addButton, 154, 0);
|
||||
}
|
||||
|
||||
this.priority = new NumberBox(this.font, this.guiLeft + 62, this.guiTop + 57, 59, this.font.FONT_HEIGHT,
|
||||
Long.class);
|
||||
this.priority.setEnableBackgroundDrawing(false);
|
||||
this.priority.setMaxStringLength(16);
|
||||
this.priority.setTextColor(0xFFFFFF);
|
||||
this.priority.setVisible(true);
|
||||
this.priority.setFocused2(true);
|
||||
container.setTextField(this.priority);
|
||||
private void onPriorityChange(long priority) {
|
||||
NetworkHandler.instance()
|
||||
.sendToServer(new ConfigValuePacket("PriorityHost.Priority", String.valueOf(priority)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,90 +70,6 @@ public class PriorityScreen extends AEBaseScreen<PriorityContainer> {
|
||||
this.priority.render(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
private void addQty(final int i) {
|
||||
try {
|
||||
String out = this.priority.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if (fixed) {
|
||||
this.priority.setText(out);
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
long result = Long.parseLong(out);
|
||||
result += i;
|
||||
|
||||
this.priority.setText(out = Long.toString(result));
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("PriorityHost.Priority", out));
|
||||
} catch (final NumberFormatException e) {
|
||||
// nope..
|
||||
this.priority.setText("0");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean charTyped(char character, int key) {
|
||||
if (priority.charTyped(character, key)) {
|
||||
String out = this.priority.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if (fixed) {
|
||||
this.priority.setText(out);
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("PriorityHost.Priority", out));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int p_keyPressed_3_) {
|
||||
if (!this.checkHotbarKeys(InputMappings.getInputByCode(keyCode, scanCode))) {
|
||||
if ((keyCode == 211 || keyCode == 205 || keyCode == 203 || keyCode == 14)
|
||||
&& this.priority.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
|
||||
String out = this.priority.getText();
|
||||
|
||||
boolean fixed = false;
|
||||
while (out.startsWith("0") && out.length() > 1) {
|
||||
out = out.substring(1);
|
||||
fixed = true;
|
||||
}
|
||||
|
||||
if (fixed) {
|
||||
this.priority.setText(out);
|
||||
}
|
||||
|
||||
if (out.isEmpty()) {
|
||||
out = "0";
|
||||
}
|
||||
|
||||
NetworkHandler.instance().sendToServer(new ConfigValuePacket("PriorityHost.Priority", out));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
|
||||
}
|
||||
|
||||
protected String getBackground() {
|
||||
return "guis/priority.png";
|
||||
}
|
||||
|
||||
@@ -58,20 +58,6 @@ public class AETextField extends TextFieldWidget {
|
||||
this._fontPad = (int) fontRenderer.getCharWidth('_');
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(final double xPos, final double yPos, final int button) {
|
||||
if (!super.mouseClicked(xPos, yPos, button)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final boolean requiresFocus = this.isMouseOver(xPos, yPos);
|
||||
if (!this.isFocused()) {
|
||||
this.setFocused2(requiresFocus);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void selectAll() {
|
||||
this.setCursorPosition(0);
|
||||
this.setSelectionPos(this.getMaxStringLength());
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.regex.Pattern;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
|
||||
public class ActionButton extends IconButton implements ITooltip {
|
||||
public class ActionButton extends IconButton {
|
||||
private static final Pattern PATTERN_NEW_LINE = Pattern.compile("\\n", Pattern.LITERAL);
|
||||
private final int iconIndex;
|
||||
|
||||
|
||||
@@ -34,32 +34,32 @@ public abstract class CustomSlotWidget extends AbstractGui implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public String getTooltipMessage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
public int getTooltipAreaX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
public int getTooltipAreaY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int getTooltipAreaWidth() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int getTooltipAreaHeight() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
public boolean isTooltipAreaVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
|
||||
/**
|
||||
* Indicates that a widget (anything that is in the {@link Screen#children()}
|
||||
* list) should receive callbacks every tick.
|
||||
*/
|
||||
public interface ITickingWidget {
|
||||
|
||||
void tick();
|
||||
|
||||
}
|
||||
@@ -28,38 +28,38 @@ public interface ITooltip {
|
||||
*
|
||||
* @return tooltip message
|
||||
*/
|
||||
String getMessage();
|
||||
String getTooltipMessage();
|
||||
|
||||
/**
|
||||
* x Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return xPosition
|
||||
*/
|
||||
int xPos();
|
||||
int getTooltipAreaX();
|
||||
|
||||
/**
|
||||
* y Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return yPosition
|
||||
*/
|
||||
int yPos();
|
||||
int getTooltipAreaY();
|
||||
|
||||
/**
|
||||
* Width of the object that triggers the tooltip.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
int getWidth();
|
||||
int getTooltipAreaWidth();
|
||||
|
||||
/**
|
||||
* Height for the object that triggers the tooltip.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
int getHeight();
|
||||
int getTooltipAreaHeight();
|
||||
|
||||
/**
|
||||
* @return true if button being drawn
|
||||
*/
|
||||
boolean isVisible();
|
||||
boolean isTooltipAreaVisible();
|
||||
}
|
||||
|
||||
@@ -95,27 +95,32 @@ public abstract class IconButton extends Button implements ITooltip {
|
||||
protected abstract int getIconIndex();
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
public String getTooltipMessage() {
|
||||
return getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTooltipAreaX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
public int getTooltipAreaY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int getTooltipAreaWidth() {
|
||||
return this.halfSize ? 8 : 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int getTooltipAreaHeight() {
|
||||
return this.halfSize ? 8 : 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
public boolean isTooltipAreaVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,35 +18,135 @@
|
||||
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import java.util.function.LongConsumer;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
|
||||
// FIXME: Fix this piece of crap (i.e. onChange listener)
|
||||
public class NumberBox extends TextFieldWidget {
|
||||
|
||||
private final Class type;
|
||||
private final LongConsumer changeListener;
|
||||
|
||||
private long lastValue;
|
||||
|
||||
private long minValue = 0;
|
||||
|
||||
private long maxValue;
|
||||
|
||||
public NumberBox(final FontRenderer fontRenderer, final int x, final int y, final int width, final int height,
|
||||
final Class type) {
|
||||
final Class<?> type, LongConsumer changeListener) {
|
||||
super(fontRenderer, x, y, width, height, "0");
|
||||
this.type = type;
|
||||
this.setText("0");
|
||||
setResponder(this::handleTextChanged);
|
||||
this.lastValue = 0;
|
||||
this.changeListener = changeListener;
|
||||
if (type == int.class || type == Integer.class) {
|
||||
maxValue = Integer.MAX_VALUE;
|
||||
} else {
|
||||
maxValue = Long.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: This method MUST NOT BE NAMED like a method in the superclass because
|
||||
// of a ForgeGradle remapping bug
|
||||
// since it'll not remap this method's name, but it will remap the name of the
|
||||
// method reference above.
|
||||
private void handleTextChanged(String text) {
|
||||
if (text.isEmpty()) {
|
||||
setText("0"); // Will call onTextChanged recursively
|
||||
return;
|
||||
}
|
||||
|
||||
boolean canBeNegative = canBeNegative();
|
||||
if (canBeNegative && text.equals("-")) {
|
||||
// Allow this as a special case to make typing in a negative number easier
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder sanitized = new StringBuilder(text);
|
||||
boolean encounteredNonZero = false;
|
||||
for (int i = 0; i < sanitized.length(); i++) {
|
||||
char ch = sanitized.charAt(i);
|
||||
if (canBeNegative && i == 0 && ch == '-') {
|
||||
continue; // Allow leading minus sign
|
||||
}
|
||||
if (ch >= '1' && ch <= '9') {
|
||||
encounteredNonZero = true;
|
||||
continue;
|
||||
}
|
||||
if (ch != '0' || !encounteredNonZero) {
|
||||
sanitized.deleteCharAt(i--);
|
||||
}
|
||||
}
|
||||
if (sanitized.length() == 0) {
|
||||
sanitized.append('0');
|
||||
}
|
||||
String sanitizedStr = sanitized.toString();
|
||||
if (!sanitizedStr.equals(text)) {
|
||||
setText(sanitizedStr); // Will call onTextChanged recursively
|
||||
return;
|
||||
}
|
||||
if (getValue() < minValue) {
|
||||
setText(String.valueOf(minValue)); // Will call onTextChanged recursively
|
||||
return;
|
||||
}
|
||||
if (getValue() > maxValue) {
|
||||
setText(String.valueOf(maxValue)); // Will call onTextChanged recursively
|
||||
return;
|
||||
}
|
||||
|
||||
reportChange();
|
||||
}
|
||||
|
||||
private void reportChange() {
|
||||
long value = getValue();
|
||||
if (value != lastValue) {
|
||||
lastValue = value;
|
||||
changeListener.accept(value);
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(long value, boolean skipNotify) {
|
||||
// This check avoid changing the cursor position needlessly
|
||||
if (value == this.getValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (skipNotify) {
|
||||
lastValue = value;
|
||||
}
|
||||
setText(String.valueOf(value));
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
if (getText().equals("-") && canBeNegative()) {
|
||||
return lastValue; // Allow this as a special case to type in a negative number more easily
|
||||
}
|
||||
|
||||
return Long.parseLong(getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeText(final String selectedText) {
|
||||
final String original = this.getText();
|
||||
super.writeText(selectedText);
|
||||
|
||||
try {
|
||||
if (this.type == int.class || this.type == Integer.class) {
|
||||
Integer.parseInt(this.getText());
|
||||
} else if (this.type == long.class || this.type == Long.class) {
|
||||
Long.parseLong(this.getText());
|
||||
} else if (this.type == double.class || this.type == Double.class) {
|
||||
Double.parseDouble(this.getText());
|
||||
}
|
||||
} catch (final NumberFormatException e) {
|
||||
this.setText(original);
|
||||
public boolean keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_) {
|
||||
if (super.keyPressed(p_keyPressed_1_, p_keyPressed_2_, p_keyPressed_3_)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Swallow key presses for numbers because they would otherwise trigger the
|
||||
// hotbar swapping unintentionally
|
||||
return isFocused() && p_keyPressed_1_ >= '0' && p_keyPressed_1_ <= '9';
|
||||
}
|
||||
|
||||
public void setMinValue(long minValue) {
|
||||
this.minValue = minValue;
|
||||
}
|
||||
|
||||
public long getMinValue() {
|
||||
return minValue;
|
||||
}
|
||||
|
||||
private boolean canBeNegative() {
|
||||
return minValue < 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ProgressBar extends Widget implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public String getTooltipMessage() {
|
||||
if (this.fullMsg != null) {
|
||||
return this.fullMsg;
|
||||
}
|
||||
@@ -86,27 +86,27 @@ public class ProgressBar extends Widget implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
public int getTooltipAreaX() {
|
||||
return this.x - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
public int getTooltipAreaY() {
|
||||
return this.y - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int getTooltipAreaWidth() {
|
||||
return this.width + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int getTooltipAreaHeight() {
|
||||
return this.height + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
public boolean isTooltipAreaVisible() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ public class SettingToggleButton<T extends Enum<T>> extends IconButton {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public String getTooltipMessage() {
|
||||
ITextComponent displayName = null;
|
||||
ITextComponent displayValue = null;
|
||||
|
||||
@@ -314,7 +314,7 @@ public class SettingToggleButton<T extends Enum<T>> extends IconButton {
|
||||
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
return null;
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getFillVar() {
|
||||
|
||||
@@ -97,27 +97,32 @@ public class TabButton extends Button implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
public String getTooltipMessage() {
|
||||
return getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTooltipAreaX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
public int getTooltipAreaY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int getTooltipAreaWidth() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int getTooltipAreaHeight() {
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
public boolean isTooltipAreaVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ToggleButton extends Button implements ITooltip {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
public String getTooltipMessage() {
|
||||
if (this.displayName != null) {
|
||||
String name = I18n.format(this.displayName);
|
||||
String value = I18n.format(this.displayHint);
|
||||
@@ -99,31 +99,31 @@ public class ToggleButton extends Button implements ITooltip {
|
||||
|
||||
return name + '\n' + sb;
|
||||
}
|
||||
return null;
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos() {
|
||||
public int getTooltipAreaX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos() {
|
||||
public int getTooltipAreaY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
public int getTooltipAreaWidth() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
public int getTooltipAreaHeight() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
public boolean isTooltipAreaVisible() {
|
||||
return this.visible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.config.YesNo;
|
||||
@@ -38,6 +36,7 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.widgets.IScrollSource;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.fluids.util.FluidSorters;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.prioritylist.IPartitionList;
|
||||
@@ -48,8 +47,8 @@ import appeng.util.prioritylist.IPartitionList;
|
||||
* @since rv6 22/05/2018
|
||||
*/
|
||||
public class FluidRepo {
|
||||
private final IItemList<IAEFluidStack> list = AEApi.instance().storage()
|
||||
.getStorageChannel(IFluidStorageChannel.class).createList();
|
||||
private final IItemList<IAEFluidStack> list = Api.instance().storage().getStorageChannel(IFluidStorageChannel.class)
|
||||
.createList();
|
||||
private final ArrayList<IAEFluidStack> view = new ArrayList<>();
|
||||
private final IScrollSource src;
|
||||
private final ISortSource sortSrc;
|
||||
|
||||
@@ -28,7 +28,6 @@ import javax.annotation.Nonnull;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
@@ -39,6 +38,7 @@ import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.widgets.IScrollSource;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.Api;
|
||||
import appeng.integration.abstraction.JEIFacade;
|
||||
import appeng.items.storage.ViewCellItem;
|
||||
import appeng.util.ItemSorters;
|
||||
@@ -47,7 +47,7 @@ import appeng.util.prioritylist.IPartitionList;
|
||||
|
||||
public class ItemRepo {
|
||||
|
||||
private final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
private final IItemList<IAEItemStack> list = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createList();
|
||||
private final ArrayList<IAEItemStack> view = new ArrayList<>();
|
||||
private final IScrollSource src;
|
||||
|
||||
@@ -24,7 +24,12 @@ import java.util.function.Function;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.IModelTransform;
|
||||
import net.minecraft.client.renderer.model.IUnbakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
|
||||
@@ -81,19 +81,19 @@ class CableBuilder {
|
||||
String textureFolder;
|
||||
switch (cableType) {
|
||||
case GLASS:
|
||||
textureFolder = "parts/cable/glass/";
|
||||
textureFolder = "part/cable/glass/";
|
||||
break;
|
||||
case COVERED:
|
||||
textureFolder = "parts/cable/covered/";
|
||||
textureFolder = "part/cable/covered/";
|
||||
break;
|
||||
case SMART:
|
||||
textureFolder = "parts/cable/smart/";
|
||||
textureFolder = "part/cable/smart/";
|
||||
break;
|
||||
case DENSE_COVERED:
|
||||
textureFolder = "parts/cable/dense_covered/";
|
||||
textureFolder = "part/cable/dense_covered/";
|
||||
break;
|
||||
case DENSE_SMART:
|
||||
textureFolder = "parts/cable/dense_smart/";
|
||||
textureFolder = "part/cable/dense_smart/";
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Cable type " + cableType + " does not support connections.");
|
||||
|
||||
@@ -37,7 +37,7 @@ import appeng.core.AppEng;
|
||||
* Covered (also used by the Smart Cable) - Dense
|
||||
*/
|
||||
public enum CableCoreType {
|
||||
GLASS("parts/cable/core/glass"), COVERED("parts/cable/core/covered"), DENSE("parts/cable/core/dense_smart");
|
||||
GLASS("part/cable/core/glass"), COVERED("part/cable/core/covered"), DENSE("part/cable/core/dense_smart");
|
||||
|
||||
private static final Map<AECableType, CableCoreType> cableMapping = generateCableMapping();
|
||||
|
||||
|
||||
@@ -49,8 +49,8 @@ import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.util.AEAxisAlignedBB;
|
||||
import appeng.core.Api;
|
||||
import appeng.parts.misc.CableAnchorPart;
|
||||
import appeng.thirdparty.codechicken.lib.model.CachedFormat;
|
||||
import appeng.thirdparty.codechicken.lib.model.Quad;
|
||||
@@ -108,7 +108,7 @@ public class FacadeBuilder {
|
||||
Function<ResourceLocation, IBakedModel> modelLookup) {
|
||||
BakedPipeline pipeline = this.pipelines.get();
|
||||
Quad collectorQuad = this.collectors.get();
|
||||
boolean transparent = AEApi.instance().partHelper().getCableRenderMode().transparentFacades;
|
||||
boolean transparent = Api.instance().partHelper().getCableRenderMode().transparentFacades;
|
||||
Map<Direction, FacadeRenderState> facadeStates = renderState.getFacades();
|
||||
List<AxisAlignedBB> partBoxes = renderState.getBoundingBoxes();
|
||||
Set<Direction> sidesWithParts = renderState.getAttachments().keySet();
|
||||
|
||||
@@ -23,7 +23,7 @@ import appeng.core.AppEng;
|
||||
|
||||
public class P2PTunnelFrequencyModel implements IModelGeometry<P2PTunnelFrequencyModel> {
|
||||
private static final Material TEXTURE = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/p2p_tunnel_frequency"));
|
||||
new ResourceLocation(AppEng.MOD_ID, "part/p2p_tunnel_frequency"));
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
|
||||
|
||||
@@ -34,16 +34,16 @@ import appeng.core.AppEng;
|
||||
public class SmartCableTextures {
|
||||
|
||||
public static final Material[] SMART_CHANNELS_TEXTURES = Arrays
|
||||
.stream(new ResourceLocation[] { new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_00"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_01"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_02"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_03"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_04"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_10"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_11"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_12"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_13"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "parts/cable/smart/channels_14")//
|
||||
.stream(new ResourceLocation[] { new ResourceLocation(AppEng.MOD_ID, "part/cable/smart/channels_00"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "part/cable/smart/channels_01"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "part/cable/smart/channels_02"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "part/cable/smart/channels_03"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "part/cable/smart/channels_04"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "part/cable/smart/channels_10"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "part/cable/smart/channels_11"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "part/cable/smart/channels_12"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "part/cable/smart/channels_13"), //
|
||||
new ResourceLocation(AppEng.MOD_ID, "part/cable/smart/channels_14")//
|
||||
}).map(e -> new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, e)).toArray(Material[]::new);
|
||||
|
||||
// Textures used to display channels on smart cables. There's two sets of 5
|
||||
|
||||
@@ -28,8 +28,6 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class ChargedOreFX extends RedstoneParticle {
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class CraftingFx extends SpriteTexturedParticle {
|
||||
|
||||
|
||||
@@ -20,15 +20,17 @@ package appeng.client.render.effects;
|
||||
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.SpriteTexturedParticle;
|
||||
import net.minecraft.client.renderer.ActiveRenderInfo;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class EnergyFx extends SpriteTexturedParticle {
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class LightningArcFX extends LightningFX {
|
||||
|
||||
|
||||
@@ -37,8 +37,6 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class LightningFX extends SpriteTexturedParticle {
|
||||
|
||||
|
||||
@@ -18,14 +18,17 @@
|
||||
|
||||
package appeng.client.render.effects;
|
||||
|
||||
import net.minecraft.client.particle.*;
|
||||
import net.minecraft.client.particle.IAnimatedSprite;
|
||||
import net.minecraft.client.particle.IParticleFactory;
|
||||
import net.minecraft.client.particle.IParticleRenderType;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.SpriteTexturedParticle;
|
||||
import net.minecraft.particles.BasicParticleType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class MatterCannonFX extends SpriteTexturedParticle {
|
||||
|
||||
|
||||
@@ -28,8 +28,6 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class VibrantFX extends SpriteTexturedParticle {
|
||||
|
||||
|
||||
@@ -28,25 +28,39 @@ import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.Matrix4f;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
|
||||
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.block.storage.DriveSlotCellType;
|
||||
import appeng.block.storage.DriveSlotsState;
|
||||
import appeng.client.render.DelegateBakedModel;
|
||||
import appeng.core.Api;
|
||||
|
||||
public class DriveBakedModel extends DelegateBakedModel {
|
||||
private final Map<DriveSlotCellType, IBakedModel> bakedCells;
|
||||
private final Map<Item, IBakedModel> bakedCells;
|
||||
private final IBakedModel defaultCell;
|
||||
|
||||
public DriveBakedModel(IBakedModel bakedBase, Map<DriveSlotCellType, IBakedModel> bakedCells) {
|
||||
public DriveBakedModel(IBakedModel bakedBase, Map<Item, IBakedModel> cellModels, IBakedModel defaultCell) {
|
||||
super(bakedBase);
|
||||
this.bakedCells = bakedCells;
|
||||
this.bakedCells = cellModels;
|
||||
this.defaultCell = defaultCell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the origin of a drive slot for positioning a cell model into it.
|
||||
*/
|
||||
public static void getSlotOrigin(int row, int col, Vector3f translation) {
|
||||
// Position this drive model copy at the correct slot. The transform is based on
|
||||
// the cell-model being in slot 0,0,0 while the upper left slot's origin is at
|
||||
// 9,13,1
|
||||
float xOffset = (9 - col * 8) / 16.0f;
|
||||
float yOffset = (13 - row * 3) / 16.0f;
|
||||
float zOffset = 1 / 16.0f;
|
||||
translation.set(xOffset, yOffset, zOffset);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -63,17 +77,14 @@ public class DriveBakedModel extends DelegateBakedModel {
|
||||
|
||||
DriveSlotsState slotsState = driveModelData.getSlotsState();
|
||||
|
||||
Vector3f slotTranslation = new Vector3f();
|
||||
if (slotsState != null) {
|
||||
for (int row = 0; row < 5; row++) {
|
||||
for (int col = 0; col < 2; col++) {
|
||||
Matrix4f transform = new Matrix4f();
|
||||
|
||||
// Position this drive model copy at the correct slot. The transform is based on
|
||||
// the
|
||||
// cell-model being in slot 0,0 at the top left of the drive.
|
||||
float xOffset = -col * 8 / 16.0f;
|
||||
float yOffset = -row * 3 / 16.0f;
|
||||
transform.setTranslation(xOffset, yOffset, 0);
|
||||
getSlotOrigin(row, col, slotTranslation);
|
||||
transform.setTranslation(slotTranslation.getX(), slotTranslation.getY(), slotTranslation.getZ());
|
||||
|
||||
int slot = row * 2 + col;
|
||||
|
||||
@@ -92,23 +103,18 @@ public class DriveBakedModel extends DelegateBakedModel {
|
||||
public boolean isAmbientOcclusion() {
|
||||
// We have faces inside the chassis that are facing east, but should not receive
|
||||
// ambient occlusion from the east-side, but sadly this cannot be fine-tuned on
|
||||
// a
|
||||
// face-by-face basis.
|
||||
// a face-by-face basis.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine which drive chassis to show based on the used cell
|
||||
private IBakedModel getCellChassisModel(Item cell) {
|
||||
IItems items = Api.INSTANCE.definitions().items();
|
||||
if (cell == null) {
|
||||
return bakedCells.get(DriveSlotCellType.EMPTY);
|
||||
} else if (items.fluidCell1k().item() == cell || items.fluidCell4k().item() == cell
|
||||
|| items.fluidCell16k().item() == cell || items.fluidCell64k().item() == cell) {
|
||||
return bakedCells.get(DriveSlotCellType.FLUID);
|
||||
} else {
|
||||
// Fall back to an item model
|
||||
return bakedCells.get(DriveSlotCellType.ITEM);
|
||||
return bakedCells.get(Items.AIR);
|
||||
}
|
||||
final IBakedModel model = bakedCells.get(cell);
|
||||
|
||||
return model != null ? model : defaultCell;
|
||||
}
|
||||
|
||||
private static void addModel(@Nullable BlockState state, @Nonnull Random rand, @Nonnull IModelData extraData,
|
||||
|
||||
@@ -20,13 +20,12 @@ package appeng.client.render.model;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
@@ -36,39 +35,41 @@ import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.Material;
|
||||
import net.minecraft.client.renderer.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelConfiguration;
|
||||
import net.minecraftforge.client.model.geometry.IModelGeometry;
|
||||
|
||||
import appeng.block.storage.DriveSlotCellType;
|
||||
import appeng.api.client.ICellModelRegistry;
|
||||
import appeng.core.Api;
|
||||
|
||||
public class DriveModel implements IModelGeometry<DriveModel> {
|
||||
|
||||
private static final ResourceLocation MODEL_BASE = new ResourceLocation(
|
||||
"appliedenergistics2:block/drive/drive_base");
|
||||
|
||||
private static final Map<DriveSlotCellType, ResourceLocation> MODELS_CELLS = ImmutableMap.of(
|
||||
DriveSlotCellType.EMPTY, new ResourceLocation("appliedenergistics2:block/drive/drive_cell_empty"),
|
||||
DriveSlotCellType.ITEM, new ResourceLocation("appliedenergistics2:block/drive/drive_cell_items"),
|
||||
DriveSlotCellType.FLUID, new ResourceLocation("appliedenergistics2:block/drive/drive_cell_fluids"));
|
||||
|
||||
public static final Set<ResourceLocation> DEPENDENCIES = ImmutableSet.<ResourceLocation>builder()
|
||||
.addAll(MODELS_CELLS.values()).add(MODEL_BASE).build();
|
||||
private static final ResourceLocation MODEL_CELL_EMPTY = new ResourceLocation(
|
||||
"appliedenergistics2:block/drive/drive_cell_empty");
|
||||
|
||||
@Override
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
|
||||
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
|
||||
ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
EnumMap<DriveSlotCellType, IBakedModel> cellModels = new EnumMap<>(DriveSlotCellType.class);
|
||||
final ICellModelRegistry cellRegistry = Api.instance().client().cells();
|
||||
final Map<Item, IBakedModel> cellModels = new IdentityHashMap<>();
|
||||
|
||||
// Load the base model and the model for each cell state.
|
||||
for (DriveSlotCellType cellType : MODELS_CELLS.keySet()) {
|
||||
IBakedModel cellModel = bakery.getBakedModel(MODELS_CELLS.get(cellType), modelTransform, spriteGetter);
|
||||
cellModels.put(cellType, cellModel);
|
||||
// Load the base model and the model for each cell model.
|
||||
for (Entry<Item, ResourceLocation> entry : cellRegistry.models().entrySet()) {
|
||||
IBakedModel cellModel = bakery.getBakedModel(entry.getValue(), modelTransform, spriteGetter);
|
||||
cellModels.put(entry.getKey(), cellModel);
|
||||
}
|
||||
|
||||
IBakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
|
||||
return new DriveBakedModel(baseModel, cellModels);
|
||||
final IBakedModel baseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
|
||||
final IBakedModel defaultCell = bakery.getBakedModel(cellRegistry.getDefaultModel(), modelTransform,
|
||||
spriteGetter);
|
||||
cellModels.put(Items.AIR, bakery.getBakedModel(MODEL_CELL_EMPTY, modelTransform, spriteGetter));
|
||||
|
||||
return new DriveBakedModel(baseModel, cellModels, defaultCell);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -184,7 +184,7 @@ class SpatialPylonBakedModel implements IDynamicBakedModel {
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,14 +19,12 @@
|
||||
package appeng.client.render.spatial;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.bootstrap.BlockRenderingCustomizer;
|
||||
import appeng.bootstrap.IBlockRendering;
|
||||
import appeng.bootstrap.IItemRendering;
|
||||
import appeng.core.AppEng;
|
||||
|
||||
public class SpatialPylonRendering extends BlockRenderingCustomizer {
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.block.storage.DriveSlotState;
|
||||
|
||||
/**
|
||||
* Utility class to render LEDs for storage cells from a Tile Entity Renderer.
|
||||
*/
|
||||
class CellLedRenderer {
|
||||
|
||||
private static final EnumMap<DriveSlotState, Vector3f> STATE_COLORS;
|
||||
|
||||
// Color used for the cell indicator for blinking during recent activity
|
||||
private static final Vector3f BLINK_COLOR = new Vector3f(1, 0.5f, 0.5f);
|
||||
|
||||
static {
|
||||
STATE_COLORS = new EnumMap<>(DriveSlotState.class);
|
||||
STATE_COLORS.put(DriveSlotState.OFFLINE, new Vector3f(0, 0, 0));
|
||||
STATE_COLORS.put(DriveSlotState.ONLINE, new Vector3f(0, 1, 0));
|
||||
STATE_COLORS.put(DriveSlotState.NOT_EMPTY, new Vector3f(0f, 0.667f, 1));
|
||||
STATE_COLORS.put(DriveSlotState.TYPES_FULL, new Vector3f(1, 0.667f, 0));
|
||||
STATE_COLORS.put(DriveSlotState.FULL, new Vector3f(1, 0, 0));
|
||||
}
|
||||
|
||||
// The positions are based on the upper left slot in a drive
|
||||
private static final float L = 5 / 16.f; // left (x-axis)
|
||||
private static final float R = 4 / 16.f; // right (x-axis)
|
||||
private static final float T = 1 / 16.f; // top (y-axis)
|
||||
private static final float B = -0.001f / 16.f; // bottom (y-axis)
|
||||
private static final float FR = -0.001f / 16.f; // front (z-axis)
|
||||
private static final float BA = 0.499f / 16.f; // back (z-axis)
|
||||
|
||||
// Vertex data for the LED cuboid (has no back)
|
||||
// Directions are when looking from the front onto the LED
|
||||
private static final float[] LED_QUADS = {
|
||||
// Front Face
|
||||
R, T, FR, L, T, FR, L, B, FR, R, B, FR,
|
||||
// Left Face
|
||||
L, T, FR, L, T, BA, L, B, BA, L, B, FR,
|
||||
// Right Face
|
||||
R, T, BA, R, T, FR, R, B, FR, R, B, BA,
|
||||
// Top Face
|
||||
R, T, BA, L, T, BA, L, T, FR, R, T, FR,
|
||||
// Bottom Face
|
||||
R, B, FR, L, B, FR, L, B, BA, R, B, BA, };
|
||||
|
||||
public static final RenderType RENDER_LAYER = RenderType.makeType("ae_drive_leds",
|
||||
DefaultVertexFormats.POSITION_COLOR, 7, 32565, false, true, RenderType.State.getBuilder().build(false));
|
||||
|
||||
public static void renderLed(IChestOrDrive drive, int slot, IVertexBuilder buffer, MatrixStack ms,
|
||||
float partialTicks) {
|
||||
|
||||
Vector3f color = getColorForSlot(drive, slot, partialTicks);
|
||||
if (color == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < LED_QUADS.length; i += 3) {
|
||||
float x = LED_QUADS[i];
|
||||
float y = LED_QUADS[i + 1];
|
||||
float z = LED_QUADS[i + 2];
|
||||
buffer.pos(ms.getLast().getMatrix(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
|
||||
.endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector3f getColorForSlot(IChestOrDrive drive, int slot, float partialTicks) {
|
||||
DriveSlotState state = DriveSlotState.fromCellStatus(drive.getCellStatus(slot));
|
||||
if (state == DriveSlotState.EMPTY) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!drive.isPowered()) {
|
||||
return STATE_COLORS.get(DriveSlotState.OFFLINE);
|
||||
}
|
||||
|
||||
Vector3f col = STATE_COLORS.get(state);
|
||||
if (drive.isCellBlinking(slot)) {
|
||||
// 200 ms interval (100ms to get to red, then 100ms back)
|
||||
long t = System.currentTimeMillis() % 200;
|
||||
float f = (t - 100) / 200.0f + 0.5f;
|
||||
f = easeInOutCubic(f);
|
||||
col = col.copy();
|
||||
col.lerp(BLINK_COLOR, f);
|
||||
}
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
private static float easeInOutCubic(float x) {
|
||||
return x < 0.5f ? 4 * x * x * x : 1 - (float) Math.pow(-2 * x + 2, 3) / 2;
|
||||
}
|
||||
|
||||
private CellLedRenderer() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||
*/
|
||||
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.BlockModelRenderer;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ModelManager;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import appeng.api.client.ICellModelRegistry;
|
||||
import appeng.block.storage.DriveSlotsState;
|
||||
import appeng.client.render.DelegateBakedModel;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.core.Api;
|
||||
import appeng.tile.storage.ChestTileEntity;
|
||||
|
||||
/**
|
||||
* The tile entity renderer for ME chests takes care of rendering the right
|
||||
* model for the inserted cell, as well as the LED.
|
||||
*/
|
||||
public class ChestTileEntityRenderer extends TileEntityRenderer<ChestTileEntity> {
|
||||
|
||||
private final ICellModelRegistry cellModelRegistry = Api.instance().client().cells();
|
||||
|
||||
private final ModelManager modelManager;
|
||||
|
||||
private final BlockModelRenderer blockRenderer;
|
||||
|
||||
public ChestTileEntityRenderer(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
Minecraft client = Minecraft.getInstance();
|
||||
modelManager = client.getModelManager();
|
||||
blockRenderer = client.getBlockRendererDispatcher().getBlockModelRenderer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(ChestTileEntity chest, float partialTicks, MatrixStack matrices, IRenderTypeBuffer buffers,
|
||||
int combinedLight, int combinedOverlay) {
|
||||
|
||||
World world = chest.getWorld();
|
||||
if (world == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DriveSlotsState driveSlotState = DriveSlotsState.fromChestOrDrive(chest);
|
||||
|
||||
Item cellItem = driveSlotState.getCell(0);
|
||||
if (cellItem == null || cellItem == Items.AIR) {
|
||||
return; // No cell inserted into chest
|
||||
}
|
||||
|
||||
ResourceLocation cellModelLocation = cellModelRegistry.model(cellItem);
|
||||
if (cellModelLocation == null) {
|
||||
cellModelLocation = cellModelRegistry.getDefaultModel();
|
||||
}
|
||||
|
||||
IBakedModel model = modelManager.getModel(cellModelLocation);
|
||||
|
||||
matrices.push();
|
||||
matrices.translate(0.5, 0.5, 0.5);
|
||||
FacingToRotation rotation = FacingToRotation.get(chest.getForward(), chest.getUp());
|
||||
rotation.push(matrices);
|
||||
matrices.translate(-0.5, -0.5, -0.5);
|
||||
|
||||
// The models are created for the top-left slot of the drive model,
|
||||
// we need to move them into place for the slot on the ME chest
|
||||
matrices.translate(5 / 16.0, 4 / 16.0, 0);
|
||||
|
||||
// Render the cell model as-if it was a block model
|
||||
IVertexBuilder buffer = buffers.getBuffer(RenderType.getCutout());
|
||||
// We "fake" the position here to make it use the light-value in front of the
|
||||
// drive
|
||||
FaceRotatingModel rotatedModel = new FaceRotatingModel(model, rotation);
|
||||
blockRenderer.renderModel(world, rotatedModel, chest.getBlockState(), chest.getPos(), matrices, buffer, false,
|
||||
new Random(), 0L, combinedOverlay, EmptyModelData.INSTANCE);
|
||||
|
||||
IVertexBuilder ledBuffer = buffers.getBuffer(CellLedRenderer.RENDER_LAYER);
|
||||
CellLedRenderer.renderLed(chest, 0, ledBuffer, matrices, partialTicks);
|
||||
|
||||
matrices.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual vertex data will be transformed using the matrix stack, but the
|
||||
* faces will not be correctly rotated so the incorrect lighting data would be
|
||||
* used to apply diffuse lighting and the lightmap texture.
|
||||
*/
|
||||
private static class FaceRotatingModel extends DelegateBakedModel {
|
||||
private final FacingToRotation r;
|
||||
|
||||
protected FaceRotatingModel(IBakedModel base, FacingToRotation r) {
|
||||
super(base);
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand,
|
||||
@Nonnull IModelData extraData) {
|
||||
if (side != null) {
|
||||
side = r.rotate(side); // This fixes the incorrect lightmap position
|
||||
}
|
||||
List<BakedQuad> quads = new ArrayList<>(super.getQuads(state, side, rand, extraData));
|
||||
|
||||
for (int i = 0; i < quads.size(); i++) {
|
||||
BakedQuad quad = quads.get(i);
|
||||
quads.set(i, new BakedQuad(quad.getVertexData(), quad.getTintIndex(), r.rotate(quad.getFace()),
|
||||
quad.func_187508_a(), quad.shouldApplyDiffuseLighting()));
|
||||
}
|
||||
|
||||
return quads;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +1,17 @@
|
||||
package appeng.client.render.tesr;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.vertex.IVertexBuilder;
|
||||
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
import appeng.block.storage.DriveSlotState;
|
||||
import appeng.client.render.FacingToRotation;
|
||||
import appeng.client.render.model.DriveBakedModel;
|
||||
import appeng.tile.storage.DriveTileEntity;
|
||||
|
||||
/**
|
||||
@@ -24,44 +20,6 @@ import appeng.tile.storage.DriveTileEntity;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class DriveLedTileEntityRenderer extends TileEntityRenderer<DriveTileEntity> {
|
||||
|
||||
private static final EnumMap<DriveSlotState, Vector3f> STATE_COLORS;
|
||||
|
||||
// Color used for the cell indicator for blinking during recent activity
|
||||
private static final Vector3f BLINK_COLOR = new Vector3f(1, 0.5f, 0.5f);
|
||||
|
||||
static {
|
||||
STATE_COLORS = new EnumMap<>(DriveSlotState.class);
|
||||
STATE_COLORS.put(DriveSlotState.OFFLINE, new Vector3f(0, 0, 0));
|
||||
STATE_COLORS.put(DriveSlotState.ONLINE, new Vector3f(0, 1, 0));
|
||||
STATE_COLORS.put(DriveSlotState.NOT_EMPTY, new Vector3f(0f, 0.667f, 1));
|
||||
STATE_COLORS.put(DriveSlotState.TYPES_FULL, new Vector3f(1, 0.667f, 0));
|
||||
STATE_COLORS.put(DriveSlotState.FULL, new Vector3f(1, 0, 0));
|
||||
}
|
||||
|
||||
private static final float L = 14 / 16.f; // left (x-axis)
|
||||
private static final float R = 13 / 16.f; // right (x-axis)
|
||||
private static final float T = 14 / 16.f; // top (x-axis)
|
||||
private static final float B = 12.999f / 16.f; // bottom (x-axis)
|
||||
private static final float FR = 0.999f / 16.f; // front (z-axis)
|
||||
private static final float BA = 1.499f / 16.f; // back (z-axis)
|
||||
|
||||
// Vertex data for the LED cuboid (has no back)
|
||||
// Directions are when looking from the front onto the LED
|
||||
private static final float[] LED_QUADS = {
|
||||
// Front Face
|
||||
R, T, FR, L, T, FR, L, B, FR, R, B, FR,
|
||||
// Left Face
|
||||
L, T, FR, L, T, BA, L, B, BA, L, B, FR,
|
||||
// Right Face
|
||||
R, T, BA, R, T, FR, R, B, FR, R, B, BA,
|
||||
// Top Face
|
||||
R, T, BA, L, T, BA, L, T, FR, R, T, FR,
|
||||
// Bottom Face
|
||||
R, B, FR, L, B, FR, L, B, BA, R, B, BA, };
|
||||
|
||||
private static final RenderType STATE = RenderType.makeType("ae_drive_leds", DefaultVertexFormats.POSITION_COLOR, 7,
|
||||
32565, false, true, RenderType.State.getBuilder().build(false));
|
||||
|
||||
public DriveLedTileEntityRenderer(TileEntityRendererDispatcher rendererDispatcherIn) {
|
||||
super(rendererDispatcherIn);
|
||||
}
|
||||
@@ -79,32 +37,18 @@ public class DriveLedTileEntityRenderer extends TileEntityRenderer<DriveTileEnti
|
||||
FacingToRotation.get(drive.getForward(), drive.getUp()).push(ms);
|
||||
ms.translate(-0.5, -0.5, -0.5);
|
||||
|
||||
IVertexBuilder buffer = buffers.getBuffer(STATE);
|
||||
IVertexBuilder buffer = buffers.getBuffer(CellLedRenderer.RENDER_LAYER);
|
||||
|
||||
Vector3f slotTranslation = new Vector3f();
|
||||
for (int row = 0; row < 5; row++) {
|
||||
for (int col = 0; col < 2; col++) {
|
||||
int slot = row * 2 + col;
|
||||
Vector3f color = getColorForSlot(drive, slot, partialTicks);
|
||||
if (color == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ms.push();
|
||||
|
||||
// Position this drive model copy at the correct slot. The transform is based on
|
||||
// the
|
||||
// cell-model being in slot 0,0 at the top left of the drive.
|
||||
float xOffset = -col * 8 / 16.0f;
|
||||
float yOffset = -row * 3 / 16.0f;
|
||||
ms.translate(xOffset, yOffset, 0);
|
||||
DriveBakedModel.getSlotOrigin(row, col, slotTranslation);
|
||||
ms.translate(slotTranslation.getX(), slotTranslation.getY(), slotTranslation.getZ());
|
||||
|
||||
for (int i = 0; i < LED_QUADS.length; i += 3) {
|
||||
float x = LED_QUADS[i];
|
||||
float y = LED_QUADS[i + 1];
|
||||
float z = LED_QUADS[i + 2];
|
||||
buffer.pos(ms.getLast().getMatrix(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
|
||||
.endVertex();
|
||||
}
|
||||
int slot = row * 2 + col;
|
||||
CellLedRenderer.renderLed(drive, slot, buffer, ms, partialTicks);
|
||||
|
||||
ms.pop();
|
||||
}
|
||||
@@ -113,31 +57,4 @@ public class DriveLedTileEntityRenderer extends TileEntityRenderer<DriveTileEnti
|
||||
ms.pop();
|
||||
}
|
||||
|
||||
private Vector3f getColorForSlot(DriveTileEntity drive, int slot, float partialTicks) {
|
||||
DriveSlotState state = DriveSlotState.fromCellStatus(drive.getCellStatus(slot));
|
||||
if (state == DriveSlotState.EMPTY) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!drive.isPowered()) {
|
||||
return STATE_COLORS.get(DriveSlotState.OFFLINE);
|
||||
}
|
||||
|
||||
Vector3f col = STATE_COLORS.get(state);
|
||||
if (drive.isCellBlinking(slot)) {
|
||||
// 200 ms interval (100ms to get to red, then 100ms back)
|
||||
long t = System.currentTimeMillis() % 200;
|
||||
float f = (t - 100) / 200.0f + 0.5f;
|
||||
f = easeInOutCubic(f);
|
||||
col = col.copy();
|
||||
col.lerp(BLINK_COLOR, f);
|
||||
}
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
private static float easeInOutCubic(float x) {
|
||||
return x < 0.5f ? 4 * x * x * x : 1 - (float) Math.pow(-2 * x + 2, 3) / 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.implementations.guiobjects.IGuiItemObject;
|
||||
@@ -64,6 +63,7 @@ import appeng.container.slot.InaccessibleSlot;
|
||||
import appeng.container.slot.PlayerHotBarSlot;
|
||||
import appeng.container.slot.PlayerInvSlot;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.ConfigValuePacket;
|
||||
import appeng.core.sync.packets.InventoryActionPacket;
|
||||
@@ -658,7 +658,7 @@ public abstract class AEBaseContainer extends Container {
|
||||
final ItemStack isg = player.inventory.getItemStack();
|
||||
|
||||
if (!isg.isEmpty() && releaseQty > 0) {
|
||||
IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createStack(isg);
|
||||
ais.setStackSize(1);
|
||||
final IAEItemStack extracted = ais.copy();
|
||||
@@ -737,7 +737,7 @@ public abstract class AEBaseContainer extends Container {
|
||||
this.updateHeld(player);
|
||||
}
|
||||
} else {
|
||||
IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createStack(player.inventory.getItemStack());
|
||||
ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais,
|
||||
this.getActionSource());
|
||||
@@ -777,7 +777,7 @@ public abstract class AEBaseContainer extends Container {
|
||||
this.updateHeld(player);
|
||||
}
|
||||
} else {
|
||||
IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
|
||||
.createStack(player.inventory.getItemStack());
|
||||
ais.setStackSize(1);
|
||||
ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais,
|
||||
@@ -855,7 +855,7 @@ public abstract class AEBaseContainer extends Container {
|
||||
return input;
|
||||
}
|
||||
final IAEItemStack ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(),
|
||||
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(input),
|
||||
Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(input),
|
||||
this.getActionSource());
|
||||
if (ais == null) {
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
@@ -31,7 +31,6 @@ import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.CopyMode;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
@@ -47,6 +46,7 @@ import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.slot.FakeTypeOnlySlot;
|
||||
import appeng.container.slot.OptionalRestrictedInputSlot;
|
||||
import appeng.container.slot.RestrictedInputSlot;
|
||||
import appeng.core.Api;
|
||||
import appeng.tile.misc.CellWorkbenchTileEntity;
|
||||
import appeng.util.EnumCycler;
|
||||
import appeng.util.Platform;
|
||||
@@ -208,9 +208,9 @@ public class CellWorkbenchContainer extends UpgradeableContainer {
|
||||
final ItemStack is = this.getUpgradeable().getInventoryByName("cell").getStackInSlot(0);
|
||||
final IStorageChannel channel = is.getItem() instanceof IStorageCell
|
||||
? ((IStorageCell) is.getItem()).getChannel()
|
||||
: AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
|
||||
: Api.instance().storage().getStorageChannel(IItemStorageChannel.class);
|
||||
|
||||
final IMEInventory cellInv = AEApi.instance().registries().cell().getCellInventory(is, null, channel);
|
||||
final IMEInventory cellInv = Api.instance().registries().cell().getCellInventory(is, null, channel);
|
||||
|
||||
Iterator<IAEStack> i = new NullIterator<>();
|
||||
if (cellInv != null) {
|
||||
|
||||
@@ -15,7 +15,6 @@ import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.guiobjects.IGuiItem;
|
||||
@@ -25,6 +24,7 @@ import appeng.api.parts.IPartHost;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerLocator;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
import appeng.helpers.ICustomNameObject;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.util.Platform;
|
||||
@@ -182,7 +182,7 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
|
||||
}
|
||||
|
||||
if (interfaceClass.isAssignableFrom(WirelessTerminalGuiObject.class)) {
|
||||
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler(it);
|
||||
final IWirelessTermHandler wh = Api.instance().registries().wireless().getWirelessTerminalHandler(it);
|
||||
if (wh != null) {
|
||||
return interfaceClass.cast(new WirelessTerminalGuiObject(wh, it, player, locator.getItemIndex()));
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.networking.IGrid;
|
||||
@@ -58,6 +57,7 @@ import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.Api;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.MEInventoryUpdatePacket;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
@@ -197,7 +197,7 @@ public class CraftConfirmContainer extends AEBaseContainer {
|
||||
final MEInventoryUpdatePacket c = this.result.isSimulation() ? new MEInventoryUpdatePacket((byte) 2)
|
||||
: null;
|
||||
|
||||
final IItemList<IAEItemStack> plan = AEApi.instance().storage()
|
||||
final IItemList<IAEItemStack> plan = Api.instance().storage()
|
||||
.getStorageChannel(IItemStorageChannel.class).createList();
|
||||
this.result.populatePlan(plan);
|
||||
|
||||
@@ -215,7 +215,7 @@ public class CraftConfirmContainer extends AEBaseContainer {
|
||||
|
||||
final IStorageGrid sg = this.getGrid().getCache(IStorageGrid.class);
|
||||
final IMEInventory<IAEItemStack> items = sg
|
||||
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
.getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
|
||||
|
||||
IAEItemStack m = null;
|
||||
if (c != null && this.result.isSimulation()) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user