Merge remote-tracking branch 'origin/master' into fabric-1.16

# Conflicts:
#	build.gradle
#	gradle.properties
#	src/api/java/appeng/api/config/Upgrades.java
#	src/api/java/appeng/api/recipes/ResolverResult.java
#	src/main/java/appeng/block/AEBaseBlockItemChargeable.java
#	src/main/java/appeng/block/crafting/CraftingStorageItem.java
#	src/main/java/appeng/block/misc/ChargerBlock.java
#	src/main/java/appeng/block/networking/CableBusBlock.java
#	src/main/java/appeng/block/storage/ChestBlock.java
#	src/main/java/appeng/block/storage/DriveSlotCellType.java
#	src/main/java/appeng/capabilities/Capabilities.java
#	src/main/java/appeng/client/me/ItemRepo.java
#	src/main/java/appeng/client/render/cablebus/FacadeBuilder.java
#	src/main/java/appeng/client/render/effects/ChargedOreFX.java
#	src/main/java/appeng/client/render/effects/CraftingFx.java
#	src/main/java/appeng/client/render/effects/EnergyFx.java
#	src/main/java/appeng/client/render/effects/LightningArcFX.java
#	src/main/java/appeng/client/render/effects/LightningFX.java
#	src/main/java/appeng/client/render/effects/MatterCannonFX.java
#	src/main/java/appeng/client/render/effects/VibrantFX.java
#	src/main/java/appeng/client/render/spatial/SpatialPylonRendering.java
#	src/main/java/appeng/client/render/tesr/DriveLedTileEntityRenderer.java
#	src/main/java/appeng/container/AEBaseContainer.java
#	src/main/java/appeng/container/implementations/CellWorkbenchContainer.java
#	src/main/java/appeng/container/implementations/MolecularAssemblerContainer.java
#	src/main/java/appeng/container/implementations/PatternTermContainer.java
#	src/main/java/appeng/container/implementations/QuartzKnifeContainer.java
#	src/main/java/appeng/core/AEConfig.java
#	src/main/java/appeng/core/AEItemGroup.java
#	src/main/java/appeng/core/Api.java
#	src/main/java/appeng/core/AppEng.java
#	src/main/java/appeng/core/Registration.java
#	src/main/java/appeng/core/api/definitions/ApiBlocks.java
#	src/main/java/appeng/core/api/definitions/ApiParts.java
#	src/main/java/appeng/core/features/registries/MovableTileRegistry.java
#	src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java
#	src/main/java/appeng/core/features/registries/WirelessRegistry.java
#	src/main/java/appeng/core/features/registries/WorldGenRegistry.java
#	src/main/java/appeng/core/features/registries/cell/BasicItemCellGuiHandler.java
#	src/main/java/appeng/core/sync/BasePacketHandler.java
#	src/main/java/appeng/core/sync/packets/ClickPacket.java
#	src/main/java/appeng/core/sync/packets/PatternSlotPacket.java
#	src/main/java/appeng/crafting/CraftingTreeProcess.java
#	src/main/java/appeng/debug/ReplicatorCardItem.java
#	src/main/java/appeng/entity/ChargedQuartzEntity.java
#	src/main/java/appeng/entity/SingularityEntity.java
#	src/main/java/appeng/entity/TinyTNTPrimedEntity.java
#	src/main/java/appeng/fluids/helper/DualityFluidInterface.java
#	src/main/java/appeng/fluids/helper/FluidCellConfig.java
#	src/main/java/appeng/fluids/parts/FluidFormationPlanePart.java
#	src/main/java/appeng/fluids/parts/FluidHandlerAdapter.java
#	src/main/java/appeng/forge/data/providers/IAE2DataProvider.java
#	src/main/java/appeng/forge/data/providers/recipes/SlabStairRecipes.java
#	src/main/java/appeng/helpers/CraftingPatternDetails.java
#	src/main/java/appeng/helpers/DualityInterface.java
#	src/main/java/appeng/helpers/WirelessTerminalGuiObject.java
#	src/main/java/appeng/hooks/IBlockTool.java
#	src/main/java/appeng/hooks/TickHandler.java
#	src/main/java/appeng/integration/modules/jei/CondenserCategory.java
#	src/main/java/appeng/integration/modules/jei/JEIPlugin.java
#	src/main/java/appeng/items/misc/EncodedPatternItem.java
#	src/main/java/appeng/items/parts/FacadeItem.java
#	src/main/java/appeng/items/parts/PartItem.java
#	src/main/java/appeng/items/storage/AbstractStorageCell.java
#	src/main/java/appeng/items/storage/CreativeStorageCellItem.java
#	src/main/java/appeng/items/tools/powered/ColorApplicatorItem.java
#	src/main/java/appeng/items/tools/powered/EntropyManipulatorItem.java
#	src/main/java/appeng/items/tools/powered/MatterCannonItem.java
#	src/main/java/appeng/items/tools/powered/WirelessTerminalItem.java
#	src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java
#	src/main/java/appeng/me/storage/MEMonitorIFluidHandler.java
#	src/main/java/appeng/parts/PartPlacement.java
#	src/main/java/appeng/parts/automation/FormationPlanePart.java
#	src/main/java/appeng/parts/p2p/FluidP2PTunnelPart.java
#	src/main/java/appeng/parts/reporting/PatternTerminalPart.java
#	src/main/java/appeng/spatial/CachedPlane.java
#	src/main/java/appeng/spatial/StorageChunkGenerator.java
#	src/main/java/appeng/spatial/StorageHelper.java
#	src/main/java/appeng/tile/crafting/CraftingBlockEntity.java
#	src/main/java/appeng/tile/crafting/CraftingStorageBlockEntity.java
#	src/main/java/appeng/tile/crafting/MolecularAssemblerBlockEntity.java
#	src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java
#	src/main/java/appeng/tile/misc/ChargerBlockEntity.java
#	src/main/java/appeng/tile/misc/CondenserBlockEntity.java
#	src/main/java/appeng/tile/misc/InscriberBlockEntity.java
#	src/main/java/appeng/tile/misc/InscriberRecipes.java
#	src/main/java/appeng/tile/qnb/QuantumBridgeBlockEntity.java
#	src/main/java/appeng/tile/storage/ChestBlockEntity.java
#	src/main/java/appeng/tile/storage/DriveBlockEntity.java
#	src/main/java/appeng/util/Platform.java
#	src/main/java/team/chisel/ctm/api/IFacade.java
#	src/main/resources/assets/appliedenergistics2/models/block/chest/base.json
#	src/unported/java/appeng/client/render/FacadeItemModel.java
#	src/unported/java/appeng/client/render/model/DriveBakedModel.java
#	src/unported/java/appeng/client/render/model/DriveModel.java
#	src/unported/java/appeng/core/PluginLoader.java
This commit is contained in:
Sebastian Hartte
2020-07-18 01:45:43 +02:00
233 changed files with 2321 additions and 1937 deletions
+4 -1
View File
@@ -21,10 +21,13 @@ jobs:
with: with:
path: ~/.gradle/caches path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets - name: Generate assets
uses: GabrielBB/xvfb-action@v1.2 uses: GabrielBB/xvfb-action@v1.2
with: with:
run: ./gradlew runData --no-daemon run: ./gradlew runData --no-daemon
- name: Validate assets
run: test -d ./src/generated
- name: Build with Gradle - name: Build with Gradle
run: ./gradlew build --no-daemon run: ./gradlew build --no-daemon
+4
View File
@@ -21,9 +21,13 @@ jobs:
with: with:
path: ~/.gradle/caches path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets - name: Generate assets
uses: GabrielBB/xvfb-action@v1.2 uses: GabrielBB/xvfb-action@v1.2
with: with:
run: ./gradlew runData --no-daemon run: ./gradlew runData --no-daemon
- name: Validate assets
run: test -d ./src/generated
- name: Build with Gradle - name: Build with Gradle
run: ./gradlew build --no-daemon run: ./gradlew build --no-daemon
+4
View File
@@ -21,10 +21,14 @@ jobs:
with: with:
path: ~/.gradle/caches path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets - name: Generate assets
uses: GabrielBB/xvfb-action@v1.2 uses: GabrielBB/xvfb-action@v1.2
with: with:
run: ./gradlew runData --no-daemon run: ./gradlew runData --no-daemon
- name: Validate assets
run: test -d ./src/generated
- name: Build with Gradle - name: Build with Gradle
env: env:
PR_NUMBER: ${{ github.event.pull_request.number }} PR_NUMBER: ${{ github.event.pull_request.number }}
+22 -3
View File
@@ -2,7 +2,7 @@ name: 'Release'
on: on:
release: release:
types: [created] types: [published]
jobs: jobs:
build: build:
@@ -28,17 +28,36 @@ jobs:
java-version: 1.8 java-version: 1.8
- name: Grant execute permission for gradlew - name: Grant execute permission for gradlew
run: chmod +x gradlew run: chmod +x gradlew
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets - name: Generate assets
uses: GabrielBB/xvfb-action@v1.2 uses: GabrielBB/xvfb-action@v1.2
with: with:
run: ./gradlew runData --no-daemon run: ./gradlew runData --no-daemon
- name: Build, sign, and publish with Gradle - name: Validate assets
run: test -d ./src/generated
- name: Build with Gradle
env: env:
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }} KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }} KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }} KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew build publish --no-daemon run: ./gradlew build --no-daemon
- 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
- 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
- name: Prepare artifact metadata - name: Prepare artifact metadata
id: prepare_artifact_metadata id: prepare_artifact_metadata
run: | run: |
+33 -62
View File
@@ -12,10 +12,9 @@
* [Downloads](#downloads) * [Downloads](#downloads)
* [Installation](#installation) * [Installation](#installation)
* [Issues](#issues) * [Issues](#issues)
* [API](#applied-energistics-2-api)
* [Building](#building) * [Building](#building)
* [Contribution](#contribution) * [Contribution](#contribution)
* [API](#applied-energistics-2-api)
* [CraftTweaker](#applied-energistics-2-crafttweaker)
* [Localization](#applied-energistics-2-localization) * [Localization](#applied-energistics-2-localization)
* [Credits](#credits) * [Credits](#credits)
@@ -67,6 +66,38 @@ 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. 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 ## Building
1. Clone this repository via 1. Clone this repository via
@@ -110,66 +141,6 @@ Here are a few things to keep in mind that will help get your PR approved.
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. 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 ## Applied Energistics 2 Localization
### English Text ### English Text
+3 -2
View File
@@ -20,7 +20,7 @@ plugins {
id 'java' id 'java'
id 'fabric-loom' id 'fabric-loom'
id 'maven-publish' id 'maven-publish'
id "org.jetbrains.kotlin.jvm" id "com.matthewprenger.cursegradle" version "1.4.0"
id "org.sonarqube" version "2.8" id "org.sonarqube" version "2.8"
id "jacoco" id "jacoco"
} }
@@ -140,7 +140,8 @@ jar {
from "LICENSE" from "LICENSE"
} }
compileKotlin.kotlinOptions.jvmTarget = "1.8" apply from: 'gradle/scripts/artifacts.gradle'
apply from: 'gradle/scripts/curseforge.gradle'
publishing { publishing {
publications { publications {
+7
View File
@@ -26,3 +26,10 @@ archives_base_name = fabric-example-mod
# Kotlin # Kotlin
kotlin_version=1.3.61 kotlin_version=1.3.61
fabric_kotlin_version=1.3.61+build.1 fabric_kotlin_version=1.3.61+build.1
#########################################################
# Deployment #
#########################################################
website_version=1.15.2
curse_versions=1.15.2
curseforge_project=223794
+39
View File
@@ -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
}
}
}
@@ -26,12 +26,16 @@ import java.lang.annotation.Target;
/** /**
* Use this annotation on a class in your Mod to have it instantiated during the * 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 * initialization phase of Applied Energistics.
* single constructor and can supply certain arguments to your constructor using *
* dependency injection. * 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) @Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.CLASS)
@Documented @Documented
public @interface AEPlugin { public @interface AEAddon {
} }
-67
View File
@@ -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;
}
}
-33
View File
@@ -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 {
}
@@ -1,7 +1,7 @@
/* /*
* The MIT License (MIT) * 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 * 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 * 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. * 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.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.networking.crafting.ICraftingPatternDetails;
/** /**
* 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 * This gets called once the API is successfully constructed and ready to be
* used.
* *
* @param is pattern * For now this happens during {@link FMLCommonSetupEvent}.
* @param w crafting world
* *
* @return details of pattern * 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);
} }
+13 -7
View File
@@ -23,16 +23,22 @@
package appeng.api; package appeng.api;
import appeng.api.client.IClientHelper;
import appeng.api.crafting.ICraftingHelper;
import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IDefinitions;
import appeng.api.features.IRegistryContainer; import appeng.api.features.IRegistryContainer;
import appeng.api.networking.IGridHelper; import appeng.api.networking.IGridHelper;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
import appeng.api.parts.IPartHelper; import appeng.api.parts.IPartHelper;
import appeng.api.storage.IStorageHelper; import appeng.api.storage.IStorageHelper;
import appeng.api.util.IClientHelper;
@AEInjectable
public interface IAppEngApi { public interface IAppEngApi {
/**
* @return An accessible list of all AE definitions
*/
IDefinitions definitions();
/** /**
* @return Registry Container for the numerous registries in AE2. * @return Registry Container for the numerous registries in AE2.
*/ */
@@ -43,6 +49,11 @@ public interface IAppEngApi {
*/ */
IStorageHelper storage(); 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. * @return A helper to create {@link IGridNode} and other grid related objects.
*/ */
@@ -53,11 +64,6 @@ public interface IAppEngApi {
*/ */
IPartHelper partHelper(); IPartHelper partHelper();
/**
* @return An accessible list of all AE definitions
*/
IDefinitions definitions();
/** /**
* @return Utility methods primarily useful for client side stuff * @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();
}
@@ -21,7 +21,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 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; import java.util.List;
@@ -39,4 +39,11 @@ public interface IClientHelper {
*/ */
<T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler, List<Text> lines); <T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler, List<Text> lines);
/**
* A helper to work with clientside related tasks for cells.
*
* @return
*/
ICellModelRegistry cells();
} }
+21 -11
View File
@@ -23,7 +23,11 @@
package appeng.api.config; 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; import javax.annotation.Nullable;
@@ -36,6 +40,7 @@ import net.minecraft.item.BlockItem;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemConvertible;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.text.TranslationTextComponent;
public enum Upgrades { public enum Upgrades {
/** /**
@@ -74,11 +79,11 @@ public enum Upgrades {
* @param item machine in which this upgrade can be installed * @param item machine in which this upgrade can be installed
* @param maxSupported amount how many upgrades 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, * @param tooltipGroup If more than one item of the same group are supported,
* the tooltip will show this group name instead. If the * the tooltip will show this translation key instead. If
* items have different maxSupported values, the highest * the items have different maxSupported values, the highest
* will be shown. * will be shown.
*/ */
public void registerItem(final ItemConvertible item, final int maxSupported, @Nullable Text tooltipGroup) { public void registerItem(final ItemConvertible item, final int maxSupported, @Nullable String tooltipGroup) {
Preconditions.checkNotNull(item); Preconditions.checkNotNull(item);
this.supported.add(new Supported(item.asItem(), maxSupported, tooltipGroup)); this.supported.add(new Supported(item.asItem(), maxSupported, tooltipGroup));
supportedTooltipLines = null; // Reset tooltip supportedTooltipLines = null; // Reset tooltip
@@ -98,17 +103,17 @@ public enum Upgrades {
Text name = supported.item.getName(); Text name = supported.item.getName();
// If the group was already added by a previous item, skip this // 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; continue;
} }
// If any of the following items would be of the same group, use the group name // If any of the following items would be of the same group, use the group name
// instead // instead
if (supported.tooltipGroup != null) { if (supported.getTooltipGroup() != null) {
for (int j = i + 1; j < this.supported.size(); j++) { for (int j = i + 1; j < this.supported.size(); j++) {
Text otherGroup = this.supported.get(j).tooltipGroup; Text otherGroup = this.supported.get(j).getTooltipGroup();
if (supported.tooltipGroup.equals(otherGroup)) { if (supported.getTooltipGroup().equals(otherGroup)) {
name = supported.tooltipGroup; name = supported.getTooltipGroup();
break; break;
} }
} }
@@ -135,10 +140,11 @@ public enum Upgrades {
private final Item item; private final Item item;
private final Block block; private final Block block;
private final int maxCount; private final int maxCount;
// Translation key of the tooltip group
@Nullable @Nullable
private final Text tooltipGroup; private final String tooltipGroup;
public Supported(Item item, int maxCount, @Nullable Text tooltipGroup) { public Supported(Item item, int maxCount, @Nullable String tooltipGroup) {
this.item = item; this.item = item;
if (item instanceof BlockItem) { if (item instanceof BlockItem) {
this.block = ((BlockItem) item).getBlock(); this.block = ((BlockItem) item).getBlock();
@@ -161,6 +167,10 @@ public enum Upgrades {
return item != null && this.item == item; 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; package appeng.api.features;
import appeng.api.AEInjectable;
import appeng.api.movable.IMovableRegistry; import appeng.api.movable.IMovableRegistry;
import appeng.api.networking.IGridCacheRegistry; import appeng.api.networking.IGridCacheRegistry;
import appeng.api.parts.IPartModels; import appeng.api.parts.IPartModels;
@@ -36,7 +35,6 @@ import appeng.api.storage.ICellRegistry;
* @version 7 * @version 7
* @since rv0 * @since rv0
*/ */
@AEInjectable
public interface IRegistryContainer { public interface IRegistryContainer {
/** /**
@@ -28,18 +28,25 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.storage.IStorageChannel; 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.cells.ICellWorkbenchItem;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
/** /**
* Any item which implements this can be treated as an IMEInventory via * Any item which implements this can be treated as an IMEInventory via
* Util.getCell / Util.isCell It automatically handles the internals and NBT * {@link ICellHandler#getCellInventory(ItemStack, appeng.api.storage.cells.ISaveProvider, IStorageChannel)}
* data, which is both nice, and bad for you! * 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 * Good cause it means you don't have to do anything, bad because you have
* little to no control over it. * 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 { public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem {
@@ -91,16 +91,6 @@ public interface IGridBlock {
*/ */
void onGridNotification(@Nonnull GridNotification notification); 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 * Determine which sides of the block can be connected too, only used when
* isWorldAccessible returns true, not used for {@link IPart} implementations. * isWorldAccessible returns true, not used for {@link IPart} implementations.
@@ -27,18 +27,19 @@ import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
/** /**
* do not implement provided by {@link ICraftingPatternItem} * Describes a crafting or processing pattern decoded by
* * {@link appeng.api.crafting.ICraftingHelper}.
* caching this INSTANCE will increase performance of validation and checks. * <p>
* Do not cache instances of this class unless you handle recipe reloads on the
* server and client correctly.
*/ */
public interface ICraftingPatternDetails { public interface ICraftingPatternDetails {
/** /**
* @return source item. * @return encodes this crafting pattern into a new item stack.
*/ */
ItemStack getPattern(); ItemStack getPattern();
@@ -52,7 +53,9 @@ public interface ICraftingPatternDetails {
boolean isValidItemForSlot(int slotIndex, ItemStack itemStack, World world); 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(); boolean isCraftable();
@@ -23,6 +23,7 @@
package appeng.api.networking.crafting; package appeng.api.networking.crafting;
import appeng.api.crafting.ICraftingHelper;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
/** /**
@@ -33,6 +34,9 @@ public interface ICraftingProviderHelper {
/** /**
* Add new Pattern to AE's crafting cache. * 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); void addCraftingOption(ICraftingMedium medium, ICraftingPatternDetails api);
@@ -23,7 +23,6 @@
package appeng.api.networking.security; package appeng.api.networking.security;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
@@ -31,6 +31,6 @@ public interface ICustomCableConnection {
* @return This controls the cable connection to the node. -1 to render * @return This controls the cable connection to the node. -1 to render
* connection yourself. * connection yourself.
*/ */
public float getCableConnectionLength(AECableType cable); float getCableConnectionLength(AECableType cable);
} }
@@ -24,7 +24,6 @@
package appeng.api.parts; package appeng.api.parts;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
+1 -1
View File
@@ -274,7 +274,7 @@ public interface IPart extends ICustomCableConnection {
* the node. -1 to render connection yourself. * the node. -1 to render connection yourself.
*/ */
@Override @Override
public float getCableConnectionLength(AECableType cable); float getCableConnectionLength(AECableType cable);
/** /**
* same as Block.randomDisplayTick, for but parts. * same as Block.randomDisplayTick, for but parts.
@@ -23,13 +23,10 @@ import java.util.Collection;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import appeng.api.AEInjectable;
/** /**
* Allows registration of part models that can then be used in * Allows registration of part models that can then be used in
* {@link IPart#getStaticModels()}. * {@link IPart#getStaticModels()}.
*/ */
@AEInjectable
public interface IPartModels { 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.CompoundTag;
public class ResolverResult {
public final String itemName;
public final int damageValue;
public final CompoundTag 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 CompoundTag 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;
}
}
@@ -106,4 +106,13 @@ public interface IAEItemStack extends IAEStack<IAEItemStack> {
* @return definition stack * @return definition stack
*/ */
ItemStack getDefinition(); ItemStack getDefinition();
/**
* Compare this AE item stack to another item stack, but ignores the amount. It
* checks the item type, NBT and damage values.
*
* @param is An item stack
*/
boolean equals(ItemStack is);
} }
@@ -179,17 +179,7 @@ public interface IAEStack<T extends IAEStack<T>> {
T empty(); T empty();
/** /**
* @return true if the stack is a {@link IAEItemStack} * @return The {@link IStorageChannel} backing this stack.
*/
boolean isItem();
/**
* @return true if the stack is a {@link IAEFluidStack}
*/
boolean isFluid();
/**
* @return ITEM or FLUID
*/ */
IStorageChannel<T> getChannel(); IStorageChannel<T> getChannel();
@@ -18,7 +18,7 @@
package appeng.block; package appeng.block;
import appeng.api.AEApi; import appeng.core.Api;
import appeng.api.config.AccessRestriction; import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits; import appeng.api.config.PowerUnits;
@@ -129,7 +129,7 @@ public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEIte
private double getMaxEnergyCapacity() { private double getMaxEnergyCapacity() {
final Block blockID = Block.getBlockFromItem(this); 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 -> { return energyCell.maybeBlock().map(block -> {
if (blockID == block) { if (blockID == block) {
@@ -22,10 +22,10 @@ import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.features.AEFeature; import appeng.api.features.AEFeature;
import appeng.block.AEBaseBlockItem; import appeng.block.AEBaseBlockItem;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api;
public class CraftingStorageItem extends AEBaseBlockItem { public class CraftingStorageItem extends AEBaseBlockItem {
@@ -36,7 +36,7 @@ public class CraftingStorageItem extends AEBaseBlockItem {
// FIXME FABRIC needs to move to disassembly crafting recipes // FIXME FABRIC needs to move to disassembly crafting recipes
// FIXME FABRIC @Override // FIXME FABRIC @Override
// FIXME FABRIC public Item getRecipeRemainder() { // FIXME FABRIC public Item getRecipeRemainder() {
// FIXME FABRIC return AEApi.instance().definitions().blocks().craftingUnit().item(); // FIXME FABRIC return Api.instance().definitions().blocks().craftingUnit().item();
// FIXME FABRIC } // FIXME FABRIC }
// FIXME FABRIC // FIXME FABRIC
// FIXME FABRIC @Override // FIXME FABRIC @Override
@@ -50,13 +50,13 @@ import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.util.AEAxisAlignedBB; import appeng.api.util.AEAxisAlignedBB;
import appeng.block.AEBaseTileBlock; import appeng.block.AEBaseTileBlock;
import appeng.client.render.effects.ParticleTypes; import appeng.client.render.effects.ParticleTypes;
import appeng.client.render.renderable.ItemRenderable; import appeng.client.render.renderable.ItemRenderable;
import appeng.client.render.tesr.ModularTESR; import appeng.client.render.tesr.ModularTESR;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.tile.misc.ChargerBlockEntity; import appeng.tile.misc.ChargerBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
@@ -102,7 +102,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
final ChargerBlockEntity tile = this.getBlockEntity(w, pos); final ChargerBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) { if (tile != null) {
if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged() if (Api.instance().definitions().materials().certusQuartzCrystalCharged()
.isSameAs(tile.getInternalInventory().getInvStack(0))) { .isSameAs(tile.getInternalInventory().getInvStack(0))) {
final double xOff = 0.0; final double xOff = 0.0;
final double yOff = 0.0; final double yOff = 0.0;
@@ -28,7 +28,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.state.property.EnumProperty; import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.StateManager; import net.minecraft.state.StateManager;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
@@ -43,18 +43,17 @@ import appeng.tile.storage.ChestBlockEntity;
public class ChestBlock extends AEBaseTileBlock<ChestBlockEntity> { public class ChestBlock extends AEBaseTileBlock<ChestBlockEntity> {
private final static EnumProperty<DriveSlotState> SLOT_STATE = EnumProperty.of("slot_state", private final static BooleanProperty LIGHTS_ON = BooleanProperty.of("lights_on");
DriveSlotState.class);
public ChestBlock() { public ChestBlock() {
super(defaultProps(Material.METAL)); super(defaultProps(Material.METAL));
this.setDefaultState(this.getDefaultState().with(SLOT_STATE, DriveSlotState.EMPTY)); this.setDefaultState(this.getDefaultState().with(LIGHTS_ON, false));
} }
@Override @Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) { protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder); super.appendProperties(builder);
builder.add(SLOT_STATE); builder.add(LIGHTS_ON);
} }
@Override @Override
@@ -69,7 +68,7 @@ public class ChestBlock extends AEBaseTileBlock<ChestBlockEntity> {
slotState = DriveSlotState.OFFLINE; slotState = DriveSlotState.OFFLINE;
} }
return currentState.with(SLOT_STATE, slotState); return currentState.with(LIGHTS_ON, slotState != DriveSlotState.EMPTY && slotState != DriveSlotState.OFFLINE);
} }
@Override @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.StringIdentifiable;
/**
* Describes the type of cell present in a slot.
*/
public enum DriveSlotCellType implements StringIdentifiable {
EMPTY("empty"),
ITEM("item"),
FLUID("fluid");
private final String name;
DriveSlotCellType(String name) {
this.name = name;
}
@Override
public String asString() {
return this.name;
}
}
@@ -8,7 +8,6 @@ import net.minecraft.client.render.item.ItemRenderer;
import net.minecraft.screen.ScreenHandlerType; import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts; import appeng.api.definitions.IParts;
import appeng.client.gui.AEBaseScreen; import appeng.client.gui.AEBaseScreen;
@@ -18,6 +17,7 @@ import appeng.container.implementations.CraftingTermContainer;
import appeng.container.implementations.MEMonitorableContainer; import appeng.container.implementations.MEMonitorableContainer;
import appeng.container.implementations.PatternTermContainer; import appeng.container.implementations.PatternTermContainer;
import appeng.container.implementations.WirelessTermContainer; import appeng.container.implementations.WirelessTermContainer;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.SwitchGuisPacket; import appeng.core.sync.packets.SwitchGuisPacket;
import appeng.helpers.IPriorityHost; import appeng.helpers.IPriorityHost;
@@ -45,7 +45,7 @@ final class AESubScreen {
public AESubScreen(AEBaseScreen<?> gui, Object containerTarget) { public AESubScreen(AEBaseScreen<?> gui, Object containerTarget) {
this.gui = gui; this.gui = gui;
final IDefinitions definitions = AEApi.instance().definitions(); final IDefinitions definitions = Api.instance().definitions();
final IParts parts = definitions.parts(); final IParts parts = definitions.parts();
if (containerTarget instanceof ChestBlockEntity) { if (containerTarget instanceof ChestBlockEntity) {
@@ -34,13 +34,13 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.client.gui.AEBaseScreen; import appeng.client.gui.AEBaseScreen;
import appeng.client.gui.widgets.Scrollbar; import appeng.client.gui.widgets.Scrollbar;
import appeng.container.implementations.CraftConfirmContainer; import appeng.container.implementations.CraftConfirmContainer;
import appeng.core.Api;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket; import appeng.core.sync.packets.ConfigValuePacket;
@@ -52,11 +52,11 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
private final int rows = 5; 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(); .getStorageChannel(IItemStorageChannel.class).createList();
private final IItemList<IAEItemStack> pending = AEApi.instance().storage() private final IItemList<IAEItemStack> pending = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList(); .getStorageChannel(IItemStorageChannel.class).createList();
private final IItemList<IAEItemStack> missing = AEApi.instance().storage() private final IItemList<IAEItemStack> missing = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList(); .getStorageChannel(IItemStorageChannel.class).createList();
private final List<IAEItemStack> visual = new ArrayList<>(); private final List<IAEItemStack> visual = new ArrayList<>();
@@ -35,7 +35,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.config.SortDir; import appeng.api.config.SortDir;
import appeng.api.config.SortOrder; import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems; import appeng.api.config.ViewItems;
@@ -48,6 +47,7 @@ import appeng.client.gui.widgets.ISortSource;
import appeng.client.gui.widgets.Scrollbar; import appeng.client.gui.widgets.Scrollbar;
import appeng.container.implementations.CraftingCPUContainer; import appeng.container.implementations.CraftingCPUContainer;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket; import appeng.core.sync.packets.ConfigValuePacket;
@@ -80,11 +80,11 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
private static final int ITEMSTACK_LEFT_OFFSET = 9; private static final int ITEMSTACK_LEFT_OFFSET = 9;
private static final int ITEMSTACK_TOP_OFFSET = 22; 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(); .createList();
private IItemList<IAEItemStack> active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) private IItemList<IAEItemStack> active = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList(); .createList();
private IItemList<IAEItemStack> pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) private IItemList<IAEItemStack> pending = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList(); .createList();
private List<IAEItemStack> visual = new ArrayList<>(); private List<IAEItemStack> visual = new ArrayList<>();
@@ -101,9 +101,9 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
} }
public void clearItems() { public void clearItems() {
this.storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); this.storage = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); this.active = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); this.pending = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.visual = new ArrayList<>(); this.visual = new ArrayList<>();
} }
@@ -22,7 +22,6 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.config.FullnessMode; import appeng.api.config.FullnessMode;
import appeng.api.config.OperationMode; import appeng.api.config.OperationMode;
import appeng.api.config.RedstoneMode; import appeng.api.config.RedstoneMode;
@@ -31,6 +30,7 @@ import appeng.api.definitions.IDefinitions;
import appeng.client.gui.widgets.ServerSettingToggleButton; import appeng.client.gui.widgets.ServerSettingToggleButton;
import appeng.client.gui.widgets.SettingToggleButton; import appeng.client.gui.widgets.SettingToggleButton;
import appeng.container.implementations.IOPortContainer; import appeng.container.implementations.IOPortContainer;
import appeng.core.Api;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
public class IOPortScreen extends UpgradeableScreen<IOPortContainer> { public class IOPortScreen extends UpgradeableScreen<IOPortContainer> {
@@ -79,7 +79,7 @@ public class IOPortScreen extends UpgradeableScreen<IOPortContainer> {
public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) { public void drawBG(MatrixStack matrices, final int offsetX, final int offsetY, final int mouseX, final int mouseY, float partialTicks) {
super.drawBG(matrices, offsetX, offsetY, mouseX, mouseY, partialTicks); super.drawBG(matrices, offsetX, offsetY, mouseX, mouseY, partialTicks);
final IDefinitions definitions = AEApi.instance().definitions(); final IDefinitions definitions = Api.instance().definitions();
definitions.items().cell1k().maybeStack(1) definitions.items().cell1k().maybeStack(1)
.ifPresent(cell1kStack -> this.drawItem(offsetX + 66 - 8, offsetY + 17, cell1kStack)); .ifPresent(cell1kStack -> this.drawItem(offsetX + 66 - 8, offsetY + 17, cell1kStack));
@@ -42,7 +42,6 @@ import net.minecraft.nbt.ListTag;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.client.ActionKey; import appeng.client.ActionKey;
import appeng.client.gui.AEBaseScreen; import appeng.client.gui.AEBaseScreen;
@@ -51,6 +50,7 @@ import appeng.client.gui.widgets.Scrollbar;
import appeng.client.me.ClientDCInternalInv; import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected; import appeng.client.me.SlotDisconnected;
import appeng.container.implementations.InterfaceTerminalContainer; import appeng.container.implementations.InterfaceTerminalContainer;
import appeng.core.Api;
import appeng.core.AppEng; import appeng.core.AppEng;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.util.Platform; import appeng.util.Platform;
@@ -321,7 +321,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
final ItemStack parsedItemStack = ItemStack.fromTag(outTag.getCompound(i)); final ItemStack parsedItemStack = ItemStack.fromTag(outTag.getCompound(i));
if (!parsedItemStack.isEmpty()) { 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() .getStorageChannel(IItemStorageChannel.class).createStack(parsedItemStack)).getString()
.toLowerCase(); .toLowerCase();
if (displayName.contains(searchTerm)) { if (displayName.contains(searchTerm)) {
@@ -29,7 +29,12 @@ import net.minecraft.screen.slot.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.text.Text; import net.minecraft.text.Text;
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.guiobjects.IPortableCell;
import appeng.api.implementations.tiles.IMEChest; import appeng.api.implementations.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage; import appeng.api.implementations.tiles.IViewCellStorage;
@@ -38,7 +43,11 @@ import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject; import appeng.api.util.IConfigurableObject;
import appeng.client.ActionKey; import appeng.client.ActionKey;
import appeng.client.gui.AEBaseMEScreen; 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.InternalSlotME;
import appeng.client.me.ItemRepo; import appeng.client.me.ItemRepo;
import appeng.container.implementations.CraftingStatusContainer; import appeng.container.implementations.CraftingStatusContainer;
@@ -27,8 +27,6 @@ import javax.annotation.Nonnull;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.config.Settings;
import appeng.api.config.SortOrder; import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems; import appeng.api.config.ViewItems;
import appeng.api.config.YesNo; 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.IScrollSource;
import appeng.client.gui.widgets.ISortSource; import appeng.client.gui.widgets.ISortSource;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.fluids.util.FluidSorters; import appeng.fluids.util.FluidSorters;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.prioritylist.IPartitionList; import appeng.util.prioritylist.IPartitionList;
@@ -48,8 +47,8 @@ import appeng.util.prioritylist.IPartitionList;
* @since rv6 22/05/2018 * @since rv6 22/05/2018
*/ */
public class FluidRepo { public class FluidRepo {
private final IItemList<IAEFluidStack> list = AEApi.instance().storage() private final IItemList<IAEFluidStack> list = Api.instance().storage().getStorageChannel(IFluidStorageChannel.class)
.getStorageChannel(IFluidStorageChannel.class).createList(); .createList();
private final ArrayList<IAEFluidStack> view = new ArrayList<>(); private final ArrayList<IAEFluidStack> view = new ArrayList<>();
private final IScrollSource src; private final IScrollSource src;
private final ISortSource sortSrc; private final ISortSource sortSrc;
+2 -2
View File
@@ -28,7 +28,6 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.config.SearchBoxMode; import appeng.api.config.SearchBoxMode;
import appeng.api.config.SortOrder; import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems; 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.IScrollSource;
import appeng.client.gui.widgets.ISortSource; import appeng.client.gui.widgets.ISortSource;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.integration.abstraction.ReiFacade; import appeng.integration.abstraction.ReiFacade;
import appeng.items.storage.ViewCellItem; import appeng.items.storage.ViewCellItem;
import appeng.util.ItemSorters; import appeng.util.ItemSorters;
@@ -47,7 +47,7 @@ import appeng.util.prioritylist.IPartitionList;
public class ItemRepo { 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(); .createList();
private final ArrayList<IAEItemStack> view = new ArrayList<>(); private final ArrayList<IAEItemStack> view = new ArrayList<>();
private final IScrollSource src; private final IScrollSource src;
@@ -50,8 +50,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockRenderView; import net.minecraft.world.BlockRenderView;
import appeng.api.AEApi;
import appeng.api.util.AEAxisAlignedBB; import appeng.api.util.AEAxisAlignedBB;
import appeng.core.Api;
import appeng.parts.misc.CableAnchorPart; import appeng.parts.misc.CableAnchorPart;
/** /**
* The FacadeBuilder builds for facades.. * The FacadeBuilder builds for facades..
@@ -99,7 +99,7 @@ public class FacadeBuilder {
RenderContext context, Function<Identifier, BakedModel> modelLookup) { RenderContext context, Function<Identifier, BakedModel> modelLookup) {
//FIXME BakedPipeline pipeline = this.pipelines.get(); //FIXME BakedPipeline pipeline = this.pipelines.get();
//FIXME Quad collectorQuad = this.collectors.get(); //FIXME 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(); Map<Direction, FacadeRenderState> facadeStates = renderState.getFacades();
List<Box> partBoxes = renderState.getBoundingBoxes(); List<Box> partBoxes = renderState.getBoundingBoxes();
Set<Direction> sidesWithParts = renderState.getAttachments().keySet(); Set<Direction> sidesWithParts = renderState.getAttachments().keySet();
@@ -22,7 +22,11 @@ import net.minecraft.client.render.VertexConsumer;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
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.render.Camera; import net.minecraft.client.render.Camera;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@@ -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,7 +1,5 @@
package appeng.client.render.tesr; package appeng.client.render.tesr;
import java.util.EnumMap;
import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumer;
import net.minecraft.client.render.VertexFormats; import net.minecraft.client.render.VertexFormats;
@@ -14,8 +12,8 @@ import net.minecraft.client.util.math.Vector3f;
import net.fabricmc.api.EnvType; import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment; import net.fabricmc.api.Environment;
import appeng.block.storage.DriveSlotState;
import appeng.client.render.FacingToRotation; import appeng.client.render.FacingToRotation;
import appeng.client.render.model.DriveBakedModel;
import appeng.tile.storage.DriveBlockEntity; import appeng.tile.storage.DriveBlockEntity;
/** /**
@@ -24,46 +22,8 @@ import appeng.tile.storage.DriveBlockEntity;
@Environment(EnvType.CLIENT) @Environment(EnvType.CLIENT)
public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEntity> { public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEntity> {
private static final EnumMap<DriveSlotState, Vector3f> STATE_COLORS; public DriveLedTileEntityRenderer(BlockEntityRendererDispatcher rendererDispatcher) {
super(rendererDispatcher);
// 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 RenderLayer STATE = RenderLayer.of("ae_drive_leds", VertexFormats.POSITION_COLOR, 7,
32565, false, true, RenderLayer.MultiPhaseParameters.builder().build(false));
public DriveLedTileEntityRenderer(BlockEntityRenderDispatcher rendererDispatcherIn) {
super(rendererDispatcherIn);
} }
@Override @Override
@@ -79,32 +39,18 @@ public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEn
FacingToRotation.get(drive.getForward(), drive.getUp()).push(ms); FacingToRotation.get(drive.getForward(), drive.getUp()).push(ms);
ms.translate(-0.5, -0.5, -0.5); ms.translate(-0.5, -0.5, -0.5);
VertexConsumer buffer = buffers.getBuffer(STATE); VertexConsumer buffer = buffers.getBuffer(CellLedRenderer.RENDER_LAYER);
Vector3f slotTranslation = new Vector3f();
for (int row = 0; row < 5; row++) { for (int row = 0; row < 5; row++) {
for (int col = 0; col < 2; col++) { for (int col = 0; col < 2; col++) {
int slot = row * 2 + col;
Vector3f color = getColorForSlot(drive, slot, partialTicks);
if (color == null) {
continue;
}
ms.push(); ms.push();
// Position this drive model copy at the correct slot. The transform is based on DriveBakedModel.getSlotOrigin(row, col, slotTranslation);
// the ms.translate(slotTranslation.getX(), slotTranslation.getY(), slotTranslation.getZ());
// 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);
for (int i = 0; i < LED_QUADS.length; i += 3) { int slot = row * 2 + col;
float x = LED_QUADS[i]; CellLedRenderer.renderLed(drive, slot, buffer, ms, partialTicks);
float y = LED_QUADS[i + 1];
float z = LED_QUADS[i + 2];
buffer.vertex(ms.peek().getModel(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
.next();
}
ms.pop(); ms.pop();
} }
@@ -113,31 +59,4 @@ public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEn
ms.pop(); ms.pop();
} }
private Vector3f getColorForSlot(DriveBlockEntity 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;
}
} }
@@ -38,7 +38,6 @@ import net.minecraft.inventory.Inventory;
import net.minecraft.screen.ScreenHandlerListener; import net.minecraft.screen.ScreenHandlerListener;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.implementations.guiobjects.IGuiItemObject; import appeng.api.implementations.guiobjects.IGuiItemObject;
@@ -65,6 +64,7 @@ import appeng.container.slot.InaccessibleSlot;
import appeng.container.slot.PlayerHotBarSlot; import appeng.container.slot.PlayerHotBarSlot;
import appeng.container.slot.PlayerInvSlot; import appeng.container.slot.PlayerInvSlot;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket; import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.InventoryActionPacket; import appeng.core.sync.packets.InventoryActionPacket;
@@ -664,7 +664,7 @@ public abstract class AEBaseContainer extends ScreenHandler {
final ItemStack isg = player.inventory.getCursorStack(); final ItemStack isg = player.inventory.getCursorStack();
if (!isg.isEmpty() && releaseQty > 0) { if (!isg.isEmpty() && releaseQty > 0) {
IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(isg); .createStack(isg);
ais.setStackSize(1); ais.setStackSize(1);
final IAEItemStack extracted = ais.copy(); final IAEItemStack extracted = ais.copy();
@@ -743,7 +743,7 @@ public abstract class AEBaseContainer extends ScreenHandler {
this.updateHeld(player); this.updateHeld(player);
} }
} else { } else {
IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(player.inventory.getCursorStack()); .createStack(player.inventory.getCursorStack());
ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais, ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais,
this.getActionSource()); this.getActionSource());
@@ -783,7 +783,7 @@ public abstract class AEBaseContainer extends ScreenHandler {
this.updateHeld(player); this.updateHeld(player);
} }
} else { } else {
IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(player.inventory.getCursorStack()); .createStack(player.inventory.getCursorStack());
ais.setStackSize(1); ais.setStackSize(1);
ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais, ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais,
@@ -861,7 +861,7 @@ public abstract class AEBaseContainer extends ScreenHandler {
return input; return input;
} }
final IAEItemStack ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), 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()); this.getActionSource());
if (ais == null) { if (ais == null) {
return ItemStack.EMPTY; return ItemStack.EMPTY;
@@ -31,7 +31,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.impl.EmptyFixedItemInv; import alexiil.mc.lib.attributes.item.impl.EmptyFixedItemInv;
import appeng.api.AEApi;
import appeng.api.config.CopyMode; import appeng.api.config.CopyMode;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings; import appeng.api.config.Settings;
@@ -47,6 +46,7 @@ import appeng.container.guisync.GuiSync;
import appeng.container.slot.FakeTypeOnlySlot; import appeng.container.slot.FakeTypeOnlySlot;
import appeng.container.slot.OptionalRestrictedInputSlot; import appeng.container.slot.OptionalRestrictedInputSlot;
import appeng.container.slot.RestrictedInputSlot; import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.tile.misc.CellWorkbenchBlockEntity; import appeng.tile.misc.CellWorkbenchBlockEntity;
import appeng.util.EnumCycler; import appeng.util.EnumCycler;
import appeng.util.Platform; import appeng.util.Platform;
@@ -208,9 +208,9 @@ public class CellWorkbenchContainer extends UpgradeableContainer {
final ItemStack is = this.getUpgradeable().getInventoryByName("cell").getInvStack(0); final ItemStack is = this.getUpgradeable().getInventoryByName("cell").getInvStack(0);
final IStorageChannel channel = is.getItem() instanceof IStorageCell final IStorageChannel channel = is.getItem() instanceof IStorageCell
? ((IStorageCell) is.getItem()).getChannel() ? ((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<>(); Iterator<IAEStack> i = new NullIterator<>();
if (cellInv != null) { if (cellInv != null) {
@@ -14,7 +14,6 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.features.IWirelessTermHandler; import appeng.api.features.IWirelessTermHandler;
import appeng.api.implementations.guiobjects.IGuiItem; import appeng.api.implementations.guiobjects.IGuiItem;
@@ -24,6 +23,7 @@ import appeng.api.parts.IPartHost;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api;
import appeng.helpers.ICustomNameObject; import appeng.helpers.ICustomNameObject;
import appeng.helpers.WirelessTerminalGuiObject; import appeng.helpers.WirelessTerminalGuiObject;
import appeng.util.Platform; import appeng.util.Platform;
@@ -212,7 +212,7 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
} }
if (interfaceClass.isAssignableFrom(WirelessTerminalGuiObject.class)) { 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) { if (wh != null) {
return interfaceClass.cast(new WirelessTerminalGuiObject(wh, it, player, locator.getItemIndex())); return interfaceClass.cast(new WirelessTerminalGuiObject(wh, it, player, locator.getItemIndex()));
} }
@@ -38,7 +38,6 @@ import net.minecraft.text.LiteralText;
import net.minecraft.util.Util; import net.minecraft.util.Util;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
@@ -59,6 +58,7 @@ import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.MEInventoryUpdatePacket; import appeng.core.sync.packets.MEInventoryUpdatePacket;
import appeng.helpers.WirelessTerminalGuiObject; import appeng.helpers.WirelessTerminalGuiObject;
@@ -198,7 +198,7 @@ public class CraftConfirmContainer extends AEBaseContainer {
final MEInventoryUpdatePacket c = this.result.isSimulation() ? new MEInventoryUpdatePacket((byte) 2) final MEInventoryUpdatePacket c = this.result.isSimulation() ? new MEInventoryUpdatePacket((byte) 2)
: null; : null;
final IItemList<IAEItemStack> plan = AEApi.instance().storage() final IItemList<IAEItemStack> plan = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList(); .getStorageChannel(IItemStorageChannel.class).createList();
this.result.populatePlan(plan); this.result.populatePlan(plan);
@@ -216,7 +216,7 @@ public class CraftConfirmContainer extends AEBaseContainer {
final IStorageGrid sg = this.getGrid().getCache(IStorageGrid.class); final IStorageGrid sg = this.getGrid().getCache(IStorageGrid.class);
final IMEInventory<IAEItemStack> items = sg final IMEInventory<IAEItemStack> items = sg
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); .getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
IAEItemStack m = null; IAEItemStack m = null;
if (c != null && this.result.isSimulation()) { if (c != null && this.result.isSimulation()) {
@@ -28,7 +28,6 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
import appeng.api.networking.crafting.CraftingItemList; import appeng.api.networking.crafting.CraftingItemList;
@@ -43,6 +42,7 @@ import appeng.api.storage.data.IItemList;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket; import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.MEInventoryUpdatePacket; import appeng.core.sync.packets.MEInventoryUpdatePacket;
@@ -60,7 +60,7 @@ public class CraftingCPUContainer extends AEBaseContainer
private static final ContainerHelper<CraftingCPUContainer, CraftingBlockEntity> helper = new ContainerHelper<>( private static final ContainerHelper<CraftingCPUContainer, CraftingBlockEntity> helper = new ContainerHelper<>(
CraftingCPUContainer::new, CraftingBlockEntity.class, SecurityPermissions.CRAFT); CraftingCPUContainer::new, CraftingBlockEntity.class, SecurityPermissions.CRAFT);
private final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) private final IItemList<IAEItemStack> list = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList(); .createList();
private IGrid network; private IGrid network;
private CraftingCPUCluster monitor = null; private CraftingCPUCluster monitor = null;
@@ -26,13 +26,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.FixedItemInv; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.AEApi;
import appeng.api.definitions.IItemDefinition; import appeng.api.definitions.IItemDefinition;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.container.interfaces.IProgressProvider; import appeng.container.interfaces.IProgressProvider;
import appeng.container.slot.OutputSlot; import appeng.container.slot.OutputSlot;
import appeng.container.slot.RestrictedInputSlot; import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.tile.misc.InscriberRecipes; import appeng.tile.misc.InscriberRecipes;
import appeng.tile.misc.InscriberBlockEntity; import appeng.tile.misc.InscriberBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
@@ -131,7 +131,7 @@ public class InscriberContainer extends UpgradeableContainer implements IProgres
final ItemStack bot = this.ti.getInternalInventory().getInvStack(1); final ItemStack bot = this.ti.getInternalInventory().getInvStack(1);
if (s == this.middle) { if (s == this.middle) {
IItemDefinition press = AEApi.instance().definitions().materials().namePress(); IItemDefinition press = Api.instance().definitions().materials().namePress();
if (press.isSameAs(top) || press.isSameAs(bot)) { if (press.isSameAs(top) || press.isSameAs(bot)) {
return !press.isSameAs(is); return !press.isSameAs(is);
} }
@@ -146,7 +146,7 @@ public class InscriberContainer extends UpgradeableContainer implements IProgres
} }
// name presses // name presses
final IItemDefinition namePress = AEApi.instance().definitions().materials().namePress(); final IItemDefinition namePress = Api.instance().definitions().materials().namePress();
if (namePress.isSameAs(otherSlot)) { if (namePress.isSameAs(otherSlot)) {
return namePress.isSameAs(is); return namePress.isSameAs(is);
} }
@@ -32,7 +32,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier; import appeng.api.config.PowerMultiplier;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
@@ -67,6 +66,7 @@ import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.container.slot.RestrictedInputSlot; import appeng.container.slot.RestrictedInputSlot;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket; import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.MEInventoryUpdatePacket; import appeng.core.sync.packets.MEInventoryUpdatePacket;
@@ -93,8 +93,8 @@ public class MEMonitorableContainer extends AEBaseContainer
private final RestrictedInputSlot[] cellView = new RestrictedInputSlot[5]; private final RestrictedInputSlot[] cellView = new RestrictedInputSlot[5];
private final IMEMonitor<IAEItemStack> monitor; private final IMEMonitor<IAEItemStack> monitor;
private final IItemList<IAEItemStack> items = AEApi.instance().storage() private final IItemList<IAEItemStack> items = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.getStorageChannel(IItemStorageChannel.class).createList(); .createList();
private final IConfigManager clientCM; private final IConfigManager clientCM;
private final ITerminalHost host; private final ITerminalHost host;
@GuiSync(99) @GuiSync(99)
@@ -126,7 +126,7 @@ public class MEMonitorableContainer extends AEBaseContainer
this.serverCM = monitorable.getConfigManager(); this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable this.monitor = monitorable
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); .getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
if (this.monitor != null) { if (this.monitor != null) {
this.monitor.addListener(this, null); this.monitor.addListener(this, null);
@@ -185,7 +185,7 @@ public class MEMonitorableContainer extends AEBaseContainer
public void sendContentUpdates() { public void sendContentUpdates() {
if (Platform.isServer()) { if (Platform.isServer()) {
if (this.monitor != this.host if (this.monitor != this.host
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class))) { .getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class))) {
this.setValidContainer(false); this.setValidContainer(false);
} }
@@ -38,6 +38,7 @@ import appeng.container.slot.AppEngSlot;
import appeng.container.slot.MolecularAssemblerPatternSlot; import appeng.container.slot.MolecularAssemblerPatternSlot;
import appeng.container.slot.OutputSlot; import appeng.container.slot.OutputSlot;
import appeng.container.slot.RestrictedInputSlot; import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.items.misc.EncodedPatternItem; import appeng.items.misc.EncodedPatternItem;
import appeng.tile.crafting.MolecularAssemblerBlockEntity; import appeng.tile.crafting.MolecularAssemblerBlockEntity;
import appeng.util.Platform; import appeng.util.Platform;
@@ -79,8 +80,7 @@ public class MolecularAssemblerContainer extends UpgradeableContainer implements
if (is.getItem() instanceof EncodedPatternItem) { if (is.getItem() instanceof EncodedPatternItem) {
final World w = this.getBlockEntity().getWorld(); final World w = this.getBlockEntity().getWorld();
final EncodedPatternItem iep = (EncodedPatternItem) is.getItem(); final ICraftingPatternDetails ph = Api.instance().crafting().decodePattern(is, w);
final ICraftingPatternDetails ph = iep.getPatternForItem(is, w);
if (ph.isCraftable()) { if (ph.isCraftable()) {
return ph.isValidItemForSlot(slotIndex, i, w); return ph.isValidItemForSlot(slotIndex, i, w);
} }
@@ -27,7 +27,6 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.api.implementations.guiobjects.INetworkTool; import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
import appeng.api.networking.IGridBlock; import appeng.api.networking.IGridBlock;
@@ -41,6 +40,7 @@ import appeng.api.util.AEPartLocation;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.MEInventoryUpdatePacket; import appeng.core.sync.packets.MEInventoryUpdatePacket;
import appeng.util.Platform; import appeng.util.Platform;
@@ -115,7 +115,7 @@ public class NetworkStatusContainer extends AEBaseContainer {
final MEInventoryUpdatePacket piu = new MEInventoryUpdatePacket(); final MEInventoryUpdatePacket piu = new MEInventoryUpdatePacket();
for (final Class<? extends IGridHost> machineClass : this.network.getMachinesClasses()) { for (final Class<? extends IGridHost> machineClass : this.network.getMachinesClasses()) {
final IItemList<IAEItemStack> list = AEApi.instance().storage() final IItemList<IAEItemStack> list = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList(); .getStorageChannel(IItemStorageChannel.class).createList();
for (final IGridNode machine : this.network.getMachines(machineClass)) { for (final IGridNode machine : this.network.getMachines(machineClass)) {
final IGridBlock blk = machine.getGridBlock(); final IGridBlock blk = machine.getGridBlock();
@@ -20,7 +20,6 @@ package appeng.container.implementations;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import alexiil.mc.lib.attributes.item.FixedItemInv; import alexiil.mc.lib.attributes.item.FixedItemInv;
import alexiil.mc.lib.attributes.item.compat.FixedInventoryVanillaWrapper; import alexiil.mc.lib.attributes.item.compat.FixedInventoryVanillaWrapper;
@@ -43,9 +42,9 @@ import net.minecraft.nbt.ListTag;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.crafting.ICraftingHelper;
import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IDefinitions;
import appeng.api.storage.IMEMonitor; import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost; import appeng.api.storage.ITerminalHost;
@@ -61,6 +60,7 @@ import appeng.container.slot.OptionalFakeSlot;
import appeng.container.slot.PatternOutputsSlot; import appeng.container.slot.PatternOutputsSlot;
import appeng.container.slot.PatternTermSlot; import appeng.container.slot.PatternTermSlot;
import appeng.container.slot.RestrictedInputSlot; import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.core.sync.packets.PatternSlotPacket; import appeng.core.sync.packets.PatternSlotPacket;
import appeng.helpers.IContainerCraftingPacket; import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ViewCellItem; import appeng.items.storage.ViewCellItem;
@@ -99,6 +99,7 @@ public class PatternTermContainer extends MEMonitorableContainer
private final PatternTermSlot craftSlot; private final PatternTermSlot craftSlot;
private final RestrictedInputSlot patternSlotIN; private final RestrictedInputSlot patternSlotIN;
private final RestrictedInputSlot patternSlotOUT; private final RestrictedInputSlot patternSlotOUT;
private final ICraftingHelper craftingHelper = Api.INSTANCE.crafting();
private Recipe<CraftingInventory> currentRecipe; private Recipe<CraftingInventory> currentRecipe;
@GuiSync(97) @GuiSync(97)
@@ -212,17 +213,17 @@ public class PatternTermContainer extends MEMonitorableContainer
final ItemStack[] out = this.getOutputs(); final ItemStack[] out = this.getOutputs();
// if there is no input, this would be silly. // if there is no input, this would be silly.
if (in == null || out == null) { if (in == null || out == null || isCraftingMode() && currentRecipe == null) {
return; return;
} }
// first check the output slots, should either be null, or a pattern // first check the output slots, should either be null, or a pattern
if (!output.isEmpty() && !this.isPattern(output)) { if (!output.isEmpty() && !craftingHelper.isEncodedPattern(output)) {
return; return;
} // if nothing is there we should snag a new pattern. } // if nothing is there we should snag a new pattern.
else if (output.isEmpty()) { else if (output.isEmpty()) {
output = this.patternSlotIN.getStack(); output = this.patternSlotIN.getStack();
if (output.isEmpty() || !this.isPattern(output)) { if (output.isEmpty() || !isPattern(output)) {
return; // no blanks. return; // no blanks.
} }
@@ -232,34 +233,17 @@ public class PatternTermContainer extends MEMonitorableContainer
this.patternSlotIN.setStack(ItemStack.EMPTY); this.patternSlotIN.setStack(ItemStack.EMPTY);
} }
// add a new encoded pattern. // let the crafting helper create a new encoded pattern
Optional<ItemStack> maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack(1); output = null;
if (maybePattern.isPresent()) {
output = maybePattern.get();
this.patternSlotOUT.setStack(output);
}
} }
// encode the slot. if (this.isCraftingMode()) {
final CompoundTag encodedValue = new CompoundTag(); output = craftingHelper.encodeCraftingPattern(output, this.currentRecipe, in, out[0], isSubstitute());
} else {
final ListTag tagIn = new ListTag(); output = craftingHelper.encodeProcessingPattern(output, in, out);
final ListTag tagOut = new ListTag();
for (final ItemStack i : in) {
tagIn.add(this.createItemTag(i));
} }
this.patternSlotOUT.putStack(output);
for (final ItemStack i : out) {
tagOut.add(this.createItemTag(i));
}
encodedValue.put("in", tagIn);
encodedValue.put("out", tagOut);
encodedValue.putBoolean("crafting", this.isCraftingMode());
encodedValue.putBoolean("substitute", this.isSubstitute());
output.setTag(encodedValue);
} }
private ItemStack[] getInputs() { private ItemStack[] getInputs() {
@@ -313,22 +297,8 @@ public class PatternTermContainer extends MEMonitorableContainer
return false; return false;
} }
final IDefinitions definitions = AEApi.instance().definitions(); final IDefinitions definitions = Api.instance().definitions();
return definitions.materials().blankPattern().isSameAs(output);
boolean isPattern = definitions.items().encodedPattern().isSameAs(output);
isPattern |= definitions.materials().blankPattern().isSameAs(output);
return isPattern;
}
private Tag createItemTag(final ItemStack i) {
final CompoundTag c = new CompoundTag();
if (!i.isEmpty()) {
i.toTag(c);
}
return c;
} }
@Override @Override
@@ -386,7 +356,7 @@ public class PatternTermContainer extends MEMonitorableContainer
} }
final IMEMonitor<IAEItemStack> storage = this.getPatternTerminal() final IMEMonitor<IAEItemStack> storage = this.getPatternTerminal()
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); .getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
final IItemList<IAEItemStack> all = storage.getStorageList(); final IItemList<IAEItemStack> all = storage.getStorageList();
final ItemStack is = r.craft(ic); final ItemStack is = r.craft(ic);
@@ -28,11 +28,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.slot.OutputSlot; import appeng.container.slot.OutputSlot;
import appeng.container.slot.RestrictedInputSlot; import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.items.contents.QuartzKnifeObj; import appeng.items.contents.QuartzKnifeObj;
import appeng.items.materials.MaterialItem; import appeng.items.materials.MaterialItem;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
@@ -113,7 +113,7 @@ public class QuartzKnifeContainer extends AEBaseContainer {
if (RestrictedInputSlot.isMetalIngot(input)) { if (RestrictedInputSlot.isMetalIngot(input)) {
if (QuartzKnifeContainer.this.myName.length() > 0) { if (QuartzKnifeContainer.this.myName.length() > 0) {
return AEApi.instance().definitions().materials().namePress().maybeStack(1).map(namePressStack -> { return Api.instance().definitions().materials().namePress().maybeStack(1).map(namePressStack -> {
final CompoundTag compound = namePressStack.getOrCreateTag(); final CompoundTag compound = namePressStack.getOrCreateTag();
compound.putString(MaterialItem.TAG_INSCRIBE_NAME, QuartzKnifeContainer.this.myName); compound.putString(MaterialItem.TAG_INSCRIBE_NAME, QuartzKnifeContainer.this.myName);
@@ -26,7 +26,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.FixedItemInv; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.features.INetworkEncodable; import appeng.api.features.INetworkEncodable;
import appeng.api.features.IWirelessTermHandler; import appeng.api.features.IWirelessTermHandler;
@@ -36,6 +35,7 @@ import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.container.slot.OutputSlot; import appeng.container.slot.OutputSlot;
import appeng.container.slot.RestrictedInputSlot; import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.misc.SecurityStationBlockEntity; import appeng.tile.misc.SecurityStationBlockEntity;
import appeng.util.inv.IAEAppEngInventory; import appeng.util.inv.IAEAppEngInventory;
@@ -150,7 +150,7 @@ public class SecurityStationContainer extends MEMonitorableContainer implements
networkEncodable = (INetworkEncodable) term.getItem(); networkEncodable = (INetworkEncodable) term.getItem();
} }
final IWirelessTermHandler wTermHandler = AEApi.instance().registries().wireless() final IWirelessTermHandler wTermHandler = Api.instance().registries().wireless()
.getWirelessTerminalHandler(term); .getWirelessTerminalHandler(term);
if (wTermHandler != null) { if (wTermHandler != null) {
networkEncodable = wTermHandler; networkEncodable = wTermHandler;
@@ -27,7 +27,6 @@ import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction; import appeng.api.config.AccessRestriction;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
@@ -43,6 +42,7 @@ import appeng.container.guisync.GuiSync;
import appeng.container.slot.FakeTypeOnlySlot; import appeng.container.slot.FakeTypeOnlySlot;
import appeng.container.slot.OptionalTypeOnlyFakeSlot; import appeng.container.slot.OptionalTypeOnlyFakeSlot;
import appeng.container.slot.RestrictedInputSlot; import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.parts.misc.StorageBusPart; import appeng.parts.misc.StorageBusPart;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil; import appeng.util.helpers.ItemHandlerUtil;
@@ -155,7 +155,7 @@ public class StorageBusContainer extends UpgradeableContainer {
Iterator<IAEItemStack> i = new NullIterator<>(); Iterator<IAEItemStack> i = new NullIterator<>();
if (cellInv != null) { if (cellInv != null) {
final IItemList<IAEItemStack> list = cellInv.getAvailableItems( final IItemList<IAEItemStack> list = cellInv.getAvailableItems(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()); Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
i = list.iterator(); i = list.iterator();
} }
@@ -33,7 +33,6 @@ import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.networking.energy.IEnergySource; import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
@@ -44,6 +43,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull; import appeng.container.ContainerNull;
import appeng.container.implementations.CraftingTermContainer; import appeng.container.implementations.CraftingTermContainer;
import appeng.core.Api;
import appeng.helpers.IContainerCraftingPacket; import appeng.helpers.IContainerCraftingPacket;
import appeng.helpers.InventoryAction; import appeng.helpers.InventoryAction;
import appeng.items.storage.ViewCellItem; import appeng.items.storage.ViewCellItem;
@@ -100,7 +100,7 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
} }
final IMEMonitor<IAEItemStack> inv = this.storage final IMEMonitor<IAEItemStack> inv = this.storage
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); .getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
final int howManyPerCraft = this.getStack().getCount(); final int howManyPerCraft = this.getStack().getCount();
int maxTimesToCraft = 0; int maxTimesToCraft = 0;
@@ -22,11 +22,11 @@ import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.networking.energy.IEnergySource; import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IStorageMonitorable; import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.core.Api;
import appeng.core.sync.BasePacket; import appeng.core.sync.BasePacket;
import appeng.core.sync.packets.PatternSlotPacket; import appeng.core.sync.packets.PatternSlotPacket;
import appeng.helpers.IContainerCraftingPacket; import appeng.helpers.IContainerCraftingPacket;
@@ -48,7 +48,7 @@ public class PatternTermSlot extends CraftingTermSlot {
public BasePacket getRequest(final boolean shift) { public BasePacket getRequest(final boolean shift) {
return new PatternSlotPacket(this.getPattern(), return new PatternSlotPacket(this.getPattern(),
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(this.getStack()), Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(this.getStack()),
shift); shift);
} }
@@ -35,18 +35,18 @@ import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.AEApi; import appeng.api.crafting.ICraftingHelper;
import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IItems; import appeng.api.definitions.IItems;
import appeng.api.definitions.IMaterials; import appeng.api.definitions.IMaterials;
import appeng.api.features.INetworkEncodable; import appeng.api.features.INetworkEncodable;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.implementations.items.IBiometricCard; import appeng.api.implementations.items.IBiometricCard;
import appeng.api.implementations.items.ISpatialStorageCell; import appeng.api.implementations.items.ISpatialStorageCell;
import appeng.api.implementations.items.IStorageComponent; import appeng.api.implementations.items.IStorageComponent;
import appeng.api.implementations.items.IUpgradeModule; import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.cells.ICellWorkbenchItem; import appeng.api.storage.cells.ICellWorkbenchItem;
import appeng.core.Api;
import appeng.items.misc.EncodedPatternItem; import appeng.items.misc.EncodedPatternItem;
import appeng.recipes.handlers.GrinderRecipes; import appeng.recipes.handlers.GrinderRecipes;
import appeng.tile.misc.InscriberRecipes; import appeng.tile.misc.InscriberRecipes;
@@ -90,10 +90,7 @@ public class RestrictedInputSlot extends AppEngSlot {
public boolean isValid(final ItemStack is, final World theWorld) { public boolean isValid(final ItemStack is, final World theWorld) {
if (this.which == PlacableItemType.VALID_ENCODED_PATTERN_W_OUTPUT) { if (this.which == PlacableItemType.VALID_ENCODED_PATTERN_W_OUTPUT) {
final ICraftingPatternDetails ap = is.getItem() instanceof ICraftingPatternItem return Api.instance().crafting().decodePattern(is, theWorld) != null;
? ((ICraftingPatternItem) is.getItem()).getPatternForItem(is, theWorld)
: null;
return ap != null;
} }
return true; return true;
} }
@@ -125,42 +122,27 @@ public class RestrictedInputSlot extends AppEngSlot {
return false; return false;
} }
final IDefinitions definitions = AEApi.instance().definitions(); final IDefinitions definitions = Api.instance().definitions();
final IMaterials materials = definitions.materials(); final IMaterials materials = definitions.materials();
final IItems items = definitions.items(); final IItems items = definitions.items();
final ICraftingHelper crafting = Api.instance().crafting();
switch (this.which) { switch (this.which) {
case ENCODED_CRAFTING_PATTERN: case ENCODED_CRAFTING_PATTERN:
if (i.getItem() instanceof ICraftingPatternItem) { final ICraftingPatternDetails de = crafting.decodePattern(i, this.p.player.world);
final ICraftingPatternItem b = (ICraftingPatternItem) i.getItem(); if (de != null) {
final ICraftingPatternDetails de = b.getPatternForItem(i, this.p.player.world); return de.isCraftable();
if (de != null) {
return de.isCraftable();
}
} }
return false; return false;
case VALID_ENCODED_PATTERN_W_OUTPUT: case VALID_ENCODED_PATTERN_W_OUTPUT:
case ENCODED_PATTERN_W_OUTPUT: case ENCODED_PATTERN_W_OUTPUT:
case ENCODED_PATTERN: { case ENCODED_PATTERN:
if (i.getItem() instanceof ICraftingPatternItem) { return crafting.isEncodedPattern(i);
return true;
}
// ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem
// ?
// ((ICraftingPatternItem)
// i.getItem()).getPatternForItem( i ) : null;
return false;// pattern != null;
}
case BLANK_PATTERN: case BLANK_PATTERN:
return materials.blankPattern().isSameAs(i); return materials.blankPattern().isSameAs(i);
case PATTERN: case PATTERN:
return materials.blankPattern().isSameAs(i) || crafting.isEncodedPattern(i);
if (i.getItem() instanceof ICraftingPatternItem) {
return true;
}
return materials.blankPattern().isSameAs(i);
case INSCRIBER_PLATE: case INSCRIBER_PLATE:
if (materials.namePress().isSameAs(i)) { if (materials.namePress().isSameAs(i)) {
@@ -197,14 +179,14 @@ public class RestrictedInputSlot extends AppEngSlot {
return i.getItem() instanceof ISpatialStorageCell return i.getItem() instanceof ISpatialStorageCell
&& ((ISpatialStorageCell) i.getItem()).isSpatialStorage(i); && ((ISpatialStorageCell) i.getItem()).isSpatialStorage(i);
case STORAGE_CELLS: case STORAGE_CELLS:
return AEApi.instance().registries().cell().isCellHandled(i); return Api.instance().registries().cell().isCellHandled(i);
case WORKBENCH_CELL: case WORKBENCH_CELL:
return i.getItem() instanceof ICellWorkbenchItem && ((ICellWorkbenchItem) i.getItem()).isEditable(i); return i.getItem() instanceof ICellWorkbenchItem && ((ICellWorkbenchItem) i.getItem()).isEditable(i);
case STORAGE_COMPONENT: case STORAGE_COMPONENT:
return i.getItem() instanceof IStorageComponent return i.getItem() instanceof IStorageComponent
&& ((IStorageComponent) i.getItem()).isStorageComponent(i); && ((IStorageComponent) i.getItem()).isStorageComponent(i);
case TRASH: case TRASH:
if (AEApi.instance().registries().cell().isCellHandled(i)) { if (Api.instance().registries().cell().isCellHandled(i)) {
return false; return false;
} }
@@ -212,7 +194,7 @@ public class RestrictedInputSlot extends AppEngSlot {
&& ((IStorageComponent) i.getItem()).isStorageComponent(i)); && ((IStorageComponent) i.getItem()).isStorageComponent(i));
case ENCODABLE_ITEM: case ENCODABLE_ITEM:
return i.getItem() instanceof INetworkEncodable return i.getItem() instanceof INetworkEncodable
|| AEApi.instance().registries().wireless().isWirelessTerminal(i); || Api.instance().registries().wireless().isWirelessTerminal(i);
case BIOMETRIC_CARD: case BIOMETRIC_CARD:
return i.getItem() instanceof IBiometricCard; return i.getItem() instanceof IBiometricCard;
case UPGRADES: case UPGRADES:
+9
View File
@@ -99,6 +99,7 @@ public final class AEConfig {
// Spatial IO/Dimension // Spatial IO/Dimension
private double spatialPowerExponent; private double spatialPowerExponent;
private double spatialPowerMultiplier; private double spatialPowerMultiplier;
private boolean spatialBlockTags;
// Grindstone // Grindstone
private float oreDoublePercentage; private float oreDoublePercentage;
@@ -191,6 +192,7 @@ public final class AEConfig {
this.spatialPowerMultiplier = commonConfig.spatialPowerMultiplier.get(); this.spatialPowerMultiplier = commonConfig.spatialPowerMultiplier.get();
this.spatialPowerExponent = commonConfig.spatialPowerExponent.get(); this.spatialPowerExponent = commonConfig.spatialPowerExponent.get();
this.spatialBlockTags = commonConfig.spatialBlockTags.get();
this.craftingCalculationTimePerTick = commonConfig.craftingCalculationTimePerTick.get(); this.craftingCalculationTimePerTick = commonConfig.craftingCalculationTimePerTick.get();
@@ -311,6 +313,10 @@ public final class AEConfig {
return this.spatialPowerMultiplier; return this.spatialPowerMultiplier;
} }
public boolean getSpatialBlockTags() {
return this.spatialBlockTags;
}
public float getOreDoublePercentage() { public float getOreDoublePercentage() {
return this.oreDoublePercentage; return this.oreDoublePercentage;
} }
@@ -428,6 +434,7 @@ public final class AEConfig {
// Spatial IO/Dimension // Spatial IO/Dimension
public final DoubleOption spatialPowerExponent; public final DoubleOption spatialPowerExponent;
public final DoubleOption spatialPowerMultiplier; public final DoubleOption spatialPowerMultiplier;
public final BooleanOption spatialBlockTags;
// Grindstone // Grindstone
public final DoubleOption oreDoublePercentage; public final DoubleOption oreDoublePercentage;
@@ -504,6 +511,8 @@ public final class AEConfig {
ConfigSection spatialio = root.subsection("spatialio"); ConfigSection spatialio = root.subsection("spatialio");
this.spatialPowerMultiplier = spatialio.addDouble("spatialPowerMultiplier", 1250.0); this.spatialPowerMultiplier = spatialio.addDouble("spatialPowerMultiplier", 1250.0);
this.spatialPowerExponent = spatialio.addDouble("spatialPowerExponent", 1.35); this.spatialPowerExponent = spatialio.addDouble("spatialPowerExponent", 1.35);
this.spatialBlockTags = spatialio
.addBoolean("spatialBlockTags", false, "BE CAREFUL, CAN CORRUPT YOUR WORLD! Will use #spatial/whitelist as whitelist.");
ConfigSection grindStone = root.subsection("GrindStone"); ConfigSection grindStone = root.subsection("GrindStone");
this.oreDoublePercentage = grindStone.addDouble("oreDoublePercentage", 90.0, 0.0, 100.0, "Chance to actually get an output with stacksize > 1."); this.oreDoublePercentage = grindStone.addDouble("oreDoublePercentage", 90.0, 0.0, 100.0, "Chance to actually get an output with stacksize > 1.");
@@ -0,0 +1,61 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2020, 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.core;
import java.util.Collection;
import java.util.Objects;
import java.util.Set;
import org.objectweb.asm.Type;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.forgespi.language.ModFileScanData;
import net.minecraftforge.forgespi.language.ModFileScanData.AnnotationData;
import appeng.api.AEAddon;
import appeng.api.IAEAddon;
import appeng.api.IAppEngApi;
/**
* Loads AE addons on startup and provides them with an {@link IAppEngApi}
* instance.
*/
class AddonLoader {
public static void loadAddons(IAppEngApi api) {
final Type annotationType = Type.getType(AEAddon.class);
final Collection<ModFileScanData> allScanData = ModList.get().getAllScanData();
allScanData.stream().map(ModFileScanData::getAnnotations).flatMap(Set::stream)
.filter(a -> Objects.equals(a.getAnnotationType(), annotationType)).map(AnnotationData::getMemberName)
.forEach(className -> {
try {
final Class<?> clazz = Class.forName(className);
final Class<? extends IAEAddon> instanceClass = clazz.asSubclass(IAEAddon.class);
final IAEAddon instance = instanceClass.newInstance();
instance.onAPIAvailable(api);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| LinkageError e) {
AELog.error("Failed to load: %s", className, e);
throw new RuntimeException(e);
}
});
}
}
+30 -2
View File
@@ -18,12 +18,15 @@
package appeng.core; package appeng.core;
import appeng.api.AEAddon;
import appeng.api.IAppEngApi; import appeng.api.IAppEngApi;
import appeng.api.client.IClientHelper;
import appeng.api.crafting.ICraftingHelper;
import appeng.api.features.IRegistryContainer; import appeng.api.features.IRegistryContainer;
import appeng.api.networking.IGridHelper; import appeng.api.networking.IGridHelper;
import appeng.api.storage.IStorageHelper; import appeng.api.storage.IStorageHelper;
import appeng.api.util.IClientHelper;
import appeng.core.api.ApiClientHelper; import appeng.core.api.ApiClientHelper;
import appeng.core.api.ApiCrafting;
import appeng.core.api.ApiGrid; import appeng.core.api.ApiGrid;
import appeng.core.api.ApiPart; import appeng.core.api.ApiPart;
import appeng.core.api.ApiStorage; import appeng.core.api.ApiStorage;
@@ -31,14 +34,33 @@ import appeng.core.features.registries.PartModels;
import appeng.core.features.registries.RegistryContainer; import appeng.core.features.registries.RegistryContainer;
public final class Api implements IAppEngApi { public final class Api implements IAppEngApi {
/**
* While permitting public access, directly using {@link Api#instance()} is not
* recommended except in very special cases.
*/
public static Api INSTANCE; public static Api INSTANCE;
/**
* Use primarily to access the API.
*
* Using {@link IAppEngApi} intentionally to avoid using functionality not
* exposed by accident.
*
* In some cases we might have to access the API before it is announced via
* {@link AEAddon}, otherwise we could just inject it into AE2 itself.
*/
public static IAppEngApi instance() {
return INSTANCE;
}
private final ApiPart partHelper; private final ApiPart partHelper;
private final IRegistryContainer registryContainer; private final IRegistryContainer registryContainer;
private final IStorageHelper storageHelper; private final IStorageHelper storageHelper;
private final IGridHelper networkHelper; private final IGridHelper networkHelper;
private final ApiDefinitions definitions; private final ApiDefinitions definitions;
private final ICraftingHelper craftingHelper;
private final IClientHelper client; private final IClientHelper client;
public Api() { public Api() {
@@ -47,7 +69,8 @@ public final class Api implements IAppEngApi {
this.registryContainer = new RegistryContainer(); this.registryContainer = new RegistryContainer();
this.partHelper = new ApiPart(); this.partHelper = new ApiPart();
this.definitions = new ApiDefinitions((PartModels) this.registryContainer.partModels()); this.definitions = new ApiDefinitions((PartModels) this.registryContainer.partModels());
this.client = new ApiClientHelper(); this.craftingHelper = new ApiCrafting(this.definitions);
this.client = new ApiClientHelper(this.definitions);
} }
public PartModels getPartModels() { public PartModels getPartModels() {
@@ -64,6 +87,11 @@ public final class Api implements IAppEngApi {
return this.storageHelper; return this.storageHelper;
} }
@Override
public ICraftingHelper crafting() {
return this.craftingHelper;
}
@Override @Override
public IGridHelper grid() { public IGridHelper grid() {
return this.networkHelper; return this.networkHelper;
@@ -1,5 +1,6 @@
/* /*
* This file is part of Applied Energistics 2. * This file is part of Applied Energistics 2.
*
* Copyright (c) 2013 - 2020, AlgorithmX2, All rights reserved. * Copyright (c) 2013 - 2020, AlgorithmX2, All rights reserved.
* *
* Applied Energistics 2 is free software: you can redistribute it and/or modify * Applied Energistics 2 is free software: you can redistribute it and/or modify
@@ -23,14 +24,24 @@ import java.util.List;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import appeng.api.client.ICellModelRegistry;
import appeng.api.client.IClientHelper;
import appeng.api.config.IncludeExclude; import appeng.api.config.IncludeExclude;
import appeng.api.storage.cells.ICellInventory; import appeng.api.storage.cells.ICellInventory;
import appeng.api.storage.cells.ICellInventoryHandler; import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.api.util.IClientHelper; import appeng.core.ApiDefinitions;
import appeng.core.api.client.ApiCellModelRegistry;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
public class ApiClientHelper implements IClientHelper { public class ApiClientHelper implements IClientHelper {
private final ICellModelRegistry cells;
public ApiClientHelper(ApiDefinitions definitions) {
this.cells = new ApiCellModelRegistry(definitions);
}
@Override @Override
public <T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler, public <T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler,
List<Text> lines) { List<Text> lines) {
@@ -65,4 +76,9 @@ public class ApiClientHelper implements IClientHelper {
} }
@Override
public ICellModelRegistry cells() {
return this.cells;
}
} }
@@ -0,0 +1,167 @@
/*
* 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
* 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.core.api;
import java.util.List;
import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.RecipeManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import appeng.api.crafting.ICraftingHelper;
import appeng.api.definitions.IItemDefinition;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.ContainerNull;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.ApiDefinitions;
import appeng.helpers.CraftingPatternDetails;
import appeng.items.misc.EncodedPatternItem;
public class ApiCrafting implements ICraftingHelper {
private final IItemDefinition encodedPattern;
public ApiCrafting(ApiDefinitions definitions) {
this.encodedPattern = definitions.items().encodedPattern();
}
@Override
public boolean isEncodedPattern(@Nullable IAEItemStack item) {
return item != null && item.getItem() instanceof EncodedPatternItem;
}
@Override
public boolean isEncodedPattern(ItemStack item) {
return !item.isEmpty() && item.getItem() instanceof EncodedPatternItem;
}
@Override
public ItemStack encodeCraftingPattern(@Nullable ItemStack stack, ICraftingRecipe recipe, ItemStack[] in,
ItemStack out, boolean allowSubstitutes) {
if (stack == null) {
stack = encodedPattern.stack(1);
} else {
Preconditions.checkArgument(isEncodedPattern(stack));
}
EncodedPatternItem.encodeCraftingPattern(stack, in, new ItemStack[] { out }, recipe.getId(), allowSubstitutes);
return stack;
}
@Override
public ItemStack encodeProcessingPattern(@Nullable ItemStack stack, ItemStack[] in, ItemStack[] out) {
if (stack == null) {
stack = encodedPattern.stack(1);
} else {
Preconditions.checkArgument(isEncodedPattern(stack));
}
EncodedPatternItem.encodeProcessingPattern(stack, in, out);
return stack;
}
@Override
public ICraftingPatternDetails decodePattern(final ItemStack is, final World world, boolean autoRecovery) {
if (is == null || world == null) {
return null;
}
EncodedPatternItem patternItem = getPatternItem(is);
if (patternItem == null || !patternItem.isEncodedPattern(is)) {
return null;
}
// The recipe ids encoded in a pattern can go stale. This code attempts to find
// the new id
// based on the stored inputs/outputs if that happens.
ResourceLocation recipeId = patternItem.getCraftingRecipeId(is);
if (recipeId != null) {
IRecipe<?> recipe = world.getRecipeManager().getRecipes(IRecipeType.CRAFTING).get(recipeId);
if (!(recipe instanceof ICraftingRecipe)) {
if (!autoRecovery || !attemptRecovery(patternItem, is, world)) {
return null;
}
}
}
// We use the shared itemstack for an identity lookup.
IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(is);
return new CraftingPatternDetails(ais, world);
}
private boolean attemptRecovery(EncodedPatternItem patternItem, ItemStack itemStack, World world) {
RecipeManager recipeManager = world.getRecipeManager();
List<IAEItemStack> ingredients = patternItem.getIngredients(itemStack);
List<IAEItemStack> products = patternItem.getProducts(itemStack);
if (ingredients.size() < 9 || products.size() < 1) {
return false;
}
ResourceLocation currentRecipeId = patternItem.getCraftingRecipeId(itemStack);
// Fill a crafting inventory with the ingredients to find a suitable recipe
CraftingInventory testInventory = new CraftingInventory(new ContainerNull(), 3, 3);
for (int x = 0; x < 9; x++) {
final IAEItemStack ais = ingredients.get(x);
final ItemStack gs = ais != null ? ais.createItemStack() : ItemStack.EMPTY;
testInventory.setInventorySlotContents(x, gs);
}
ICraftingRecipe potentialRecipe = recipeManager.getRecipe(IRecipeType.CRAFTING, testInventory, world)
.orElse(null);
if (potentialRecipe != null) {
// Check that it matches the expected output
if (products.get(0).isSameType(potentialRecipe.getCraftingResult(testInventory))) {
// Yay we found a match, reencode the pattern
AELog.debug("Re-Encoding pattern from %s -> %s", currentRecipeId, potentialRecipe.getId());
ItemStack[] in = ingredients.stream().map(ais -> ais != null ? ais.createItemStack() : ItemStack.EMPTY)
.toArray(ItemStack[]::new);
ItemStack out = products.get(0).createItemStack();
encodeCraftingPattern(itemStack, potentialRecipe, in, out, patternItem.allowsSubstitution(itemStack));
}
}
AELog.debug("Failed to recover encoded crafting pattern for recipe %s", currentRecipeId);
return false;
}
private static EncodedPatternItem getPatternItem(ItemStack itemStack) {
if (itemStack.getItem() instanceof EncodedPatternItem) {
return (EncodedPatternItem) itemStack.getItem();
}
return null;
}
}
@@ -0,0 +1,119 @@
/*
* 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
* 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.core.api.client;
import java.util.Arrays;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import appeng.api.client.ICellModelRegistry;
import appeng.core.ApiDefinitions;
public class ApiCellModelRegistry implements ICellModelRegistry {
private static final ResourceLocation MODEL_BASE = new ResourceLocation(
"appliedenergistics2:block/drive/drive_base");
private static final ResourceLocation MODEL_CELL_EMPTY = new ResourceLocation(
"appliedenergistics2:block/drive/drive_cell_empty");
private static final ResourceLocation MODEL_CELL_DEFAULT = new ResourceLocation(
"appliedenergistics2:block/drive/drive_cell");
private static final ResourceLocation MODEL_CELL_ITEMS_1K = new ResourceLocation(
"appliedenergistics2:block/drive/cells/1k_item_cell");
private static final ResourceLocation MODEL_CELL_ITEMS_4K = new ResourceLocation(
"appliedenergistics2:block/drive/cells/4k_item_cell");
private static final ResourceLocation MODEL_CELL_ITEMS_16K = new ResourceLocation(
"appliedenergistics2:block/drive/cells/16k_item_cell");
private static final ResourceLocation MODEL_CELL_ITEMS_64K = new ResourceLocation(
"appliedenergistics2:block/drive/cells/64k_item_cell");
private static final ResourceLocation MODEL_CELL_FLUIDS_1K = new ResourceLocation(
"appliedenergistics2:block/drive/cells/1k_fluid_cell");
private static final ResourceLocation MODEL_CELL_FLUIDS_4K = new ResourceLocation(
"appliedenergistics2:block/drive/cells/4k_fluid_cell");
private static final ResourceLocation MODEL_CELL_FLUIDS_16K = new ResourceLocation(
"appliedenergistics2:block/drive/cells/16k_fluid_cell");
private static final ResourceLocation MODEL_CELL_FLUIDS_64K = new ResourceLocation(
"appliedenergistics2:block/drive/cells/64k_fluid_cell");
private static final ResourceLocation MODEL_CELL_CREATIVE = new ResourceLocation(
"appliedenergistics2:block/drive/cells/creative_cell");
private static final ResourceLocation[] MODELS = { MODEL_BASE, MODEL_CELL_EMPTY, MODEL_CELL_DEFAULT,
MODEL_CELL_ITEMS_1K, MODEL_CELL_ITEMS_4K, MODEL_CELL_ITEMS_16K, MODEL_CELL_ITEMS_64K, MODEL_CELL_FLUIDS_1K,
MODEL_CELL_FLUIDS_4K, MODEL_CELL_FLUIDS_16K, MODEL_CELL_FLUIDS_64K, MODEL_CELL_CREATIVE };
public static void registerModels() {
Arrays.stream(MODELS).forEach(ModelLoader::addSpecialModel);
}
private final Map<Item, ResourceLocation> registry;
public ApiCellModelRegistry(ApiDefinitions definitions) {
this.registry = new IdentityHashMap<>();
this.registry.put(definitions.items().cell1k().item(), MODEL_CELL_ITEMS_1K);
this.registry.put(definitions.items().cell4k().item(), MODEL_CELL_ITEMS_4K);
this.registry.put(definitions.items().cell16k().item(), MODEL_CELL_ITEMS_16K);
this.registry.put(definitions.items().cell64k().item(), MODEL_CELL_ITEMS_64K);
this.registry.put(definitions.items().fluidCell1k().item(), MODEL_CELL_FLUIDS_1K);
this.registry.put(definitions.items().fluidCell4k().item(), MODEL_CELL_FLUIDS_4K);
this.registry.put(definitions.items().fluidCell16k().item(), MODEL_CELL_FLUIDS_16K);
this.registry.put(definitions.items().fluidCell64k().item(), MODEL_CELL_FLUIDS_64K);
this.registry.put(definitions.items().fluidCell64k().item(), MODEL_CELL_FLUIDS_64K);
this.registry.put(definitions.items().cellCreative().item(), MODEL_CELL_CREATIVE);
}
@Override
public void registerModel(Item item, ResourceLocation model) {
Preconditions.checkNotNull(item);
Preconditions.checkNotNull(model);
Preconditions.checkArgument(!this.registry.containsKey(item), "Cannot register an item twice.");
this.registry.put(item, model);
}
@Override
@Nullable
public ResourceLocation model(@Nonnull Item item) {
Preconditions.checkNotNull(item);
return this.registry.get(item);
}
@Override
@Nonnull
public Map<Item, ResourceLocation> models() {
return Collections.unmodifiableMap(this.registry);
}
@Override
@Nonnull
public ResourceLocation getDefaultModel() {
return MODEL_CELL_DEFAULT;
}
}
@@ -45,6 +45,7 @@ import appeng.bootstrap.definitions.TileEntityDefinition;
import appeng.client.render.crafting.CraftingCubeRendering; import appeng.client.render.crafting.CraftingCubeRendering;
import appeng.client.render.model.AutoRotatingBakedModel; import appeng.client.render.model.AutoRotatingBakedModel;
import appeng.client.render.spatial.SpatialPylonRendering; import appeng.client.render.spatial.SpatialPylonRendering;
import appeng.client.render.tesr.ChestTileEntityRenderer;
import appeng.client.render.tesr.CrankTESR; import appeng.client.render.tesr.CrankTESR;
import appeng.client.render.tesr.DriveLedTileEntityRenderer; import appeng.client.render.tesr.DriveLedTileEntityRenderer;
import appeng.client.render.tesr.SkyChestTESR; import appeng.client.render.tesr.SkyChestTESR;
@@ -362,7 +363,14 @@ public final class ApiBlocks implements IBlocks {
}).build()) }).build())
.rendering(new DriveRendering()).build(); .rendering(new DriveRendering()).build();
this.chest = registry.block("chest", ChestBlock::new).features(AEFeature.STORAGE_CELLS, AEFeature.ME_CHEST) this.chest = registry.block("chest", ChestBlock::new).features(AEFeature.STORAGE_CELLS, AEFeature.ME_CHEST)
.tileEntity(registry.tileEntity("chest", ChestBlockEntity.class, ChestBlockEntity::new).build()) .tileEntity(registry.tileEntity("chest", ChestBlockEntity.class, ChestBlockEntity::new)
.rendering(new TileEntityRenderingCustomizer<ChestTileEntity>() {
@Override
@OnlyIn(Dist.CLIENT)
public void customize(TileEntityRendering<ChestTileEntity> rendering) {
rendering.tileEntityRenderer(ChestTileEntityRenderer::new);
}
}).build())
.rendering(new ChestRendering()).build(); .rendering(new ChestRendering()).build();
this.iface = registry.block("interface", InterfaceBlock::new).features(AEFeature.INTERFACE) this.iface = registry.block("interface", InterfaceBlock::new).features(AEFeature.INTERFACE)
.tileEntity( .tileEntity(
@@ -36,13 +36,50 @@ import appeng.core.features.ActivityState;
import appeng.core.features.ColoredItemDefinition; import appeng.core.features.ColoredItemDefinition;
import appeng.core.features.ItemStackSrc; import appeng.core.features.ItemStackSrc;
import appeng.core.features.registries.PartModels; import appeng.core.features.registries.PartModels;
import appeng.fluids.parts.FluidAnnihilationPlanePart;
import appeng.fluids.parts.FluidExportBusPart;
import appeng.fluids.parts.FluidFormationPlanePart;
import appeng.fluids.parts.FluidImportBusPart;
import appeng.fluids.parts.FluidInterfacePart;
import appeng.fluids.parts.FluidLevelEmitterPart;
import appeng.fluids.parts.FluidStorageBusPart;
import appeng.fluids.parts.FluidTerminalPart;
import appeng.items.parts.ColoredPartItem; import appeng.items.parts.ColoredPartItem;
import appeng.items.parts.PartItem; import appeng.items.parts.PartItem;
import appeng.items.parts.PartItemRendering; import appeng.items.parts.PartItemRendering;
import appeng.items.parts.PartModelsHelper; import appeng.items.parts.PartModelsHelper;
import appeng.parts.misc.*; import appeng.parts.automation.AnnihilationPlanePart;
import appeng.parts.networking.*; import appeng.parts.automation.ExportBusPart;
import appeng.parts.reporting.*; import appeng.parts.automation.FormationPlanePart;
import appeng.parts.automation.IdentityAnnihilationPlanePart;
import appeng.parts.automation.ImportBusPart;
import appeng.parts.automation.LevelEmitterPart;
import appeng.parts.misc.CableAnchorPart;
import appeng.parts.misc.InterfacePart;
import appeng.parts.misc.InvertedToggleBusPart;
import appeng.parts.misc.StorageBusPart;
import appeng.parts.misc.ToggleBusPart;
import appeng.parts.networking.CoveredCablePart;
import appeng.parts.networking.CoveredDenseCablePart;
import appeng.parts.networking.GlassCablePart;
import appeng.parts.networking.QuartzFiberPart;
import appeng.parts.networking.SmartCablePart;
import appeng.parts.networking.SmartDenseCablePart;
import appeng.parts.p2p.FEP2PTunnelPart;
import appeng.parts.p2p.FluidP2PTunnelPart;
import appeng.parts.p2p.ItemP2PTunnelPart;
import appeng.parts.p2p.LightP2PTunnelPart;
import appeng.parts.p2p.MEP2PTunnelPart;
import appeng.parts.p2p.RedstoneP2PTunnelPart;
import appeng.parts.reporting.ConversionMonitorPart;
import appeng.parts.reporting.CraftingTerminalPart;
import appeng.parts.reporting.DarkPanelPart;
import appeng.parts.reporting.InterfaceTerminalPart;
import appeng.parts.reporting.PanelPart;
import appeng.parts.reporting.PatternTerminalPart;
import appeng.parts.reporting.SemiDarkPanelPart;
import appeng.parts.reporting.StorageMonitorPart;
import appeng.parts.reporting.TerminalPart;
/** /**
* Internal implementation for the API parts * Internal implementation for the API parts
@@ -29,7 +29,6 @@ import appeng.api.networking.IGrid;
import appeng.api.networking.IGridCache; import appeng.api.networking.IGridCache;
import appeng.api.networking.IGridCacheFactory; import appeng.api.networking.IGridCacheFactory;
import appeng.api.networking.IGridCacheRegistry; import appeng.api.networking.IGridCacheRegistry;
import appeng.core.AELog;
public final class GridCacheRegistry implements IGridCacheRegistry { public final class GridCacheRegistry implements IGridCacheRegistry {
@@ -19,29 +19,45 @@
package appeng.core.features.registries; package appeng.core.features.registries;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.Tag;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.ResourceLocation;
import appeng.api.exceptions.AppEngException; import appeng.api.exceptions.AppEngException;
import appeng.api.movable.IMovableHandler; import appeng.api.movable.IMovableHandler;
import appeng.api.movable.IMovableRegistry; import appeng.api.movable.IMovableRegistry;
import appeng.api.movable.IMovableTile; import appeng.api.movable.IMovableTile;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.spatial.DefaultSpatialHandler; import appeng.spatial.DefaultSpatialHandler;
public class MovableTileRegistry implements IMovableRegistry { public class MovableTileRegistry implements IMovableRegistry {
private final HashSet<Block> blacklisted = new HashSet<>(); private static final ResourceLocation TAG_WHITELIST = new ResourceLocation(AppEng.MOD_ID, "spatial/whitelist");
private static final ResourceLocation TAG_BLACKLIST = new ResourceLocation(AppEng.MOD_ID, "spatial/blacklist");
private final HashMap<Class<? extends BlockEntity>, IMovableHandler> Valid = new HashMap<>(); private final Set<Block> blacklisted = new HashSet<>();
private final Map<Class<? extends BlockEntity>, IMovableHandler> valid = new IdentityHashMap<>();
private final List<Class<? extends BlockEntity>> test = new ArrayList<>(); private final List<Class<? extends BlockEntity>> test = new ArrayList<>();
private final List<IMovableHandler> handlers = new ArrayList<>(); private final List<IMovableHandler> handlers = new ArrayList<>();
private final DefaultSpatialHandler dsh = new DefaultSpatialHandler(); private final DefaultSpatialHandler dsh = new DefaultSpatialHandler();
private final IMovableHandler nullHandler = new DefaultSpatialHandler(); private final IMovableHandler nullHandler = new DefaultSpatialHandler();
private final Tag<Block> blockTagWhiteList;
private final Tag<Block> blockTagBlackList;
public MovableTileRegistry() {
this.blockTagWhiteList = BlockTags.getCollection().getOrCreate(TAG_WHITELIST);
this.blockTagBlackList = BlockTags.getCollection().getOrCreate(TAG_BLACKLIST);
}
@Override @Override
public void blacklistBlock(final Block blk) { public void blacklistBlock(final Block blk) {
@@ -60,8 +76,8 @@ public class MovableTileRegistry implements IMovableRegistry {
@Override @Override
public boolean askToMove(final BlockEntity te) { public boolean askToMove(final BlockEntity te) {
final Class myClass = te.getClass(); final Class<? extends BlockEntity> myClass = te.getClass();
IMovableHandler canMove = this.Valid.get(myClass); IMovableHandler canMove = this.valid.get(myClass);
if (canMove == null) { if (canMove == null) {
canMove = this.testClass(myClass, te); canMove = this.testClass(myClass, te);
@@ -79,7 +95,7 @@ public class MovableTileRegistry implements IMovableRegistry {
return false; return false;
} }
private IMovableHandler testClass(final Class myClass, final BlockEntity te) { private IMovableHandler testClass(final Class<? extends BlockEntity> myClass, final BlockEntity te) {
IMovableHandler handler = null; IMovableHandler handler = null;
// ask handlers... // ask handlers...
@@ -92,25 +108,32 @@ public class MovableTileRegistry implements IMovableRegistry {
// if you have a handler your opted in // if you have a handler your opted in
if (handler != null) { if (handler != null) {
this.Valid.put(myClass, handler); this.valid.put(myClass, handler);
return handler; return handler;
} }
// if your movable our opted in // if your movable our opted in
if (te instanceof IMovableTile) { if (te instanceof IMovableTile) {
this.Valid.put(myClass, this.dsh); this.valid.put(myClass, this.dsh);
return this.dsh;
}
// if the block itself is via block tags
if (AEConfig.instance().getSpatialBlockTags()
&& this.blockTagWhiteList.contains(te.getBlockState().getBlock())) {
this.valid.put(myClass, this.dsh);
return this.dsh; return this.dsh;
} }
// if you are on the white list your opted in. // if you are on the white list your opted in.
for (final Class<? extends BlockEntity> testClass : this.test) { for (final Class<? extends BlockEntity> testClass : this.test) {
if (testClass.isAssignableFrom(myClass)) { if (testClass.isAssignableFrom(myClass)) {
this.Valid.put(myClass, this.dsh); this.valid.put(myClass, this.dsh);
return this.dsh; return this.dsh;
} }
} }
this.Valid.put(myClass, this.nullHandler); this.valid.put(myClass, this.nullHandler);
return this.nullHandler; return this.nullHandler;
} }
@@ -129,8 +152,8 @@ public class MovableTileRegistry implements IMovableRegistry {
@Override @Override
public IMovableHandler getHandler(final BlockEntity te) { public IMovableHandler getHandler(final BlockEntity te) {
final Class myClass = te.getClass(); final Class<? extends BlockEntity> myClass = te.getClass();
final IMovableHandler h = this.Valid.get(myClass); final IMovableHandler h = this.valid.get(myClass);
return h == null ? this.dsh : h; return h == null ? this.dsh : h;
} }
@@ -141,6 +164,6 @@ public class MovableTileRegistry implements IMovableRegistry {
@Override @Override
public boolean isBlacklisted(final Block blk) { public boolean isBlacklisted(final Block blk) {
return this.blacklisted.contains(blk); return this.blacklisted.contains(blk) || this.blockTagBlackList.contains(blk);
} }
} }
@@ -34,7 +34,6 @@ import net.minecraft.item.Items;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import appeng.api.AEApi;
import appeng.api.config.TunnelType; import appeng.api.config.TunnelType;
import appeng.api.definitions.IBlocks; import appeng.api.definitions.IBlocks;
import appeng.api.definitions.IDefinitions; import appeng.api.definitions.IDefinitions;
@@ -43,6 +42,7 @@ import appeng.api.definitions.IParts;
import appeng.api.features.IP2PTunnelRegistry; import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.util.AEColor; import appeng.api.util.AEColor;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import appeng.core.Api;
public final class P2PTunnelRegistry implements IP2PTunnelRegistry { public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
private static final int INITIAL_CAPACITY = 40; private static final int INITIAL_CAPACITY = 40;
@@ -53,7 +53,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
public void configure() { public void configure() {
final IDefinitions definitions = AEApi.instance().definitions(); final IDefinitions definitions = Api.instance().definitions();
final IBlocks blocks = definitions.blocks(); final IBlocks blocks = definitions.blocks();
final IParts parts = definitions.parts(); final IParts parts = definitions.parts();
@@ -27,10 +27,13 @@ import net.minecraft.util.Hand;
import net.minecraft.util.Util; import net.minecraft.util.Util;
import net.minecraft.world.BlockView; import net.minecraft.world.BlockView;
import appeng.api.AEApi;
import appeng.api.features.ILocatable; import appeng.api.features.ILocatable;
import appeng.api.features.IWirelessTermHandler; import appeng.api.features.IWirelessTermHandler;
import appeng.api.features.IWirelessTermRegistry; import appeng.api.features.IWirelessTermRegistry;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.WirelessTermContainer;
import appeng.core.Api;
import appeng.core.localization.PlayerMessages; import appeng.core.localization.PlayerMessages;
import appeng.util.Platform; import appeng.util.Platform;
@@ -87,7 +90,7 @@ public final class WirelessRegistry implements IWirelessTermRegistry {
} }
final long parsedKey = Long.parseLong(unparsedKey); final long parsedKey = Long.parseLong(unparsedKey);
final ILocatable securityStation = AEApi.instance().registries().locatable().getLocatableBy(parsedKey); final ILocatable securityStation = Api.instance().registries().locatable().getLocatableBy(parsedKey);
if (securityStation == null) { if (securityStation == null) {
player.sendSystemMessage(PlayerMessages.StationCanNotBeLocated.get(), Util.NIL_UUID); player.sendSystemMessage(PlayerMessages.StationCanNotBeLocated.get(), Util.NIL_UUID);
return; return;
@@ -18,6 +18,12 @@
package appeng.core.features.registries; package appeng.core.features.registries;
import java.util.HashSet;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IWorld;
import net.minecraft.world.dimension.Dimension;
import appeng.api.features.IWorldGen; import appeng.api.features.IWorldGen;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
@@ -8,7 +8,6 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.implementations.tiles.IChestOrDrive; import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.api.storage.IMEInventoryHandler; import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
@@ -16,11 +15,15 @@ import appeng.api.storage.cells.ICellGuiHandler;
import appeng.api.storage.cells.ICellHandler; import appeng.api.storage.cells.ICellHandler;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEStack; import appeng.api.storage.data.IAEStack;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.MEMonitorableContainer;
import appeng.core.Api;
public class BasicItemCellGuiHandler implements ICellGuiHandler { public class BasicItemCellGuiHandler implements ICellGuiHandler {
@Override @Override
public <T extends IAEStack<T>> boolean isHandlerFor(final IStorageChannel<T> channel) { public <T extends IAEStack<T>> boolean isHandlerFor(final IStorageChannel<T> channel) {
return channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); return channel == Api.instance().storage().getStorageChannel(IItemStorageChannel.class);
} }
@Override @Override
@@ -20,13 +20,13 @@ package appeng.core.features.registries.cell;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.storage.IStorageChannel; import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.CellState; import appeng.api.storage.cells.CellState;
import appeng.api.storage.cells.ICellHandler; import appeng.api.storage.cells.ICellHandler;
import appeng.api.storage.cells.ICellInventoryHandler; import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.cells.ISaveProvider; import appeng.api.storage.cells.ISaveProvider;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.core.Api;
import appeng.items.storage.CreativeStorageCellItem; import appeng.items.storage.CreativeStorageCellItem;
import appeng.me.storage.CreativeCellInventory; import appeng.me.storage.CreativeCellInventory;
@@ -40,7 +40,7 @@ public final class CreativeCellHandler implements ICellHandler {
@Override @Override
public ICellInventoryHandler getCellInventory(final ItemStack is, final ISaveProvider container, public ICellInventoryHandler getCellInventory(final ItemStack is, final ISaveProvider container,
final IStorageChannel channel) { final IStorageChannel channel) {
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) && !is.isEmpty() if (channel == Api.instance().storage().getStorageChannel(IItemStorageChannel.class) && !is.isEmpty()
&& is.getItem() instanceof CreativeStorageCellItem) { && is.getItem() instanceof CreativeStorageCellItem) {
return CreativeCellInventory.getCell(is); return CreativeCellInventory.getCell(is);
} }
@@ -101,6 +101,7 @@ public class BlockTransitionEffectPacket extends BasePacket {
playBreakOrPickupSound(); playBreakOrPickupSound();
} }
@OnlyIn(Dist.CLIENT)
private void spawnParticles() { private void spawnParticles() {
EnergyParticleData data = new EnergyParticleData(false, direction); EnergyParticleData data = new EnergyParticleData(false, direction);
@@ -119,6 +120,7 @@ public class BlockTransitionEffectPacket extends BasePacket {
} }
} }
@OnlyIn(Dist.CLIENT)
private void playBreakOrPickupSound() { private void playBreakOrPickupSound() {
SoundEvent soundEvent; SoundEvent soundEvent;
@@ -31,7 +31,6 @@ import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import appeng.api.AEApi;
import appeng.api.definitions.IComparableDefinition; import appeng.api.definitions.IComparableDefinition;
import appeng.api.definitions.IItems; import appeng.api.definitions.IItems;
import appeng.api.implementations.items.IMemoryCard; import appeng.api.implementations.items.IMemoryCard;
@@ -40,6 +39,7 @@ import appeng.block.networking.CableBusBlock;
import appeng.container.ContainerLocator; import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener; import appeng.container.ContainerOpener;
import appeng.container.implementations.NetworkToolContainer; import appeng.container.implementations.NetworkToolContainer;
import appeng.core.Api;
import appeng.core.sync.BasePacket; import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.items.tools.NetworkToolItem; import appeng.items.tools.NetworkToolItem;
@@ -123,7 +123,7 @@ public class ClickPacket extends BasePacket {
final BlockPos pos = new BlockPos(this.x, this.y, this.z); final BlockPos pos = new BlockPos(this.x, this.y, this.z);
final ItemStack is = player.getStackInHand(hand); final ItemStack is = player.getStackInHand(hand);
final IItems items = AEApi.instance().definitions().items(); final IItems items = Api.instance().definitions().items();
final IComparableDefinition maybeMemoryCard = items.memoryCard(); final IComparableDefinition maybeMemoryCard = items.memoryCard();
final IComparableDefinition maybeColorApplicator = items.colorApplicator(); final IComparableDefinition maybeColorApplicator = items.colorApplicator();
@@ -101,7 +101,7 @@ public class CraftRequestPacket extends BasePacket {
if (futureJob != null) { if (futureJob != null) {
futureJob.cancel(true); futureJob.cancel(true);
} }
AELog.debug(e); AELog.info(e);
} }
} }
} }
@@ -29,7 +29,6 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
@@ -41,6 +40,7 @@ import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEMonitor; import appeng.api.storage.IMEMonitor;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.core.Api;
import appeng.core.sync.BasePacket; import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.helpers.IContainerCraftingPacket; import appeng.helpers.IContainerCraftingPacket;
@@ -113,7 +113,7 @@ public class JEIRecipePacket extends BasePacket {
if (inv != null && this.recipe != null && security != null) { if (inv != null && this.recipe != null && security != null) {
final IMEMonitor<IAEItemStack> storage = inv final IMEMonitor<IAEItemStack> storage = inv
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); .getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
final IPartitionList<IAEItemStack> filter = ViewCellItem.createFilter(cct.getViewCells()); final IPartitionList<IAEItemStack> filter = ViewCellItem.createFilter(cct.getViewCells());
for (int x = 0; x < craftMatrix.getSlotCount(); x++) { for (int x = 0; x < craftMatrix.getSlotCount(); x++) {
@@ -25,10 +25,10 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.container.implementations.PatternTermContainer; import appeng.container.implementations.PatternTermContainer;
import appeng.core.Api;
import appeng.core.sync.BasePacket; import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo; import appeng.core.sync.network.INetworkInfo;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
@@ -76,7 +76,7 @@ public class PatternSlotPacket extends BasePacket {
this.writeItem(slotItem, data); this.writeItem(slotItem, data);
for (int x = 0; x < 9; x++) { for (int x = 0; x < 9; x++) {
this.pattern[x] = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) this.pattern[x] = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(pat.getInvStack(x)); .createStack(pat.getInvStack(x));
this.writeItem(this.pattern[x], data); this.writeItem(this.pattern[x], data);
} }
@@ -27,7 +27,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.networking.IGrid; import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost; import appeng.api.networking.IGridHost;
@@ -44,6 +43,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api;
import appeng.hooks.TickHandler; import appeng.hooks.TickHandler;
public class CraftingJob implements Runnable, ICraftingJob { public class CraftingJob implements Runnable, ICraftingJob {
@@ -52,9 +52,9 @@ public class CraftingJob implements Runnable, ICraftingJob {
private final MECraftingInventory original; private final MECraftingInventory original;
private final World world; private final World world;
private final IItemList<IAEItemStack> crafting = AEApi.instance().storage() private final IItemList<IAEItemStack> crafting = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList(); .getStorageChannel(IItemStorageChannel.class).createList();
private final IItemList<IAEItemStack> missing = AEApi.instance().storage() private final IItemList<IAEItemStack> missing = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList(); .getStorageChannel(IItemStorageChannel.class).createList();
private final HashMap<String, TwoIntegers> opsAndMultiplier = new HashMap<>(); private final HashMap<String, TwoIntegers> opsAndMultiplier = new HashMap<>();
private final Object monitor = new Object(); private final Object monitor = new Object();
@@ -85,7 +85,7 @@ public class CraftingJob implements Runnable, ICraftingJob {
final ICraftingGrid cc = grid.getCache(ICraftingGrid.class); final ICraftingGrid cc = grid.getCache(ICraftingGrid.class);
final IStorageGrid sg = grid.getCache(IStorageGrid.class); final IStorageGrid sg = grid.getCache(IStorageGrid.class);
this.original = new MECraftingInventory( this.original = new MECraftingInventory(
sg.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)), actionSrc, sg.getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class)), actionSrc,
false, false, false); false, false, false);
this.setTree(this.getCraftingTree(cc, what)); this.setTree(this.getCraftingTree(cc, what));
@@ -26,7 +26,6 @@ import com.google.common.collect.Lists;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.networking.crafting.ICraftingGrid; import appeng.api.networking.crafting.ICraftingGrid;
@@ -35,6 +34,7 @@ import appeng.api.networking.security.IActionSource;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.core.Api;
import appeng.me.cluster.implementations.CraftingCPUCluster; import appeng.me.cluster.implementations.CraftingCPUCluster;
public class CraftingTreeNode { public class CraftingTreeNode {
@@ -42,7 +42,7 @@ public class CraftingTreeNode {
// what slot! // what slot!
private final int slot; private final int slot;
private final CraftingJob job; private final CraftingJob job;
private final IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) private final IItemList<IAEItemStack> used = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList(); .createList();
// parent node. // parent node.
private final CraftingTreeProcess parent; private final CraftingTreeProcess parent;
@@ -27,6 +27,7 @@ import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull; import appeng.container.ContainerNull;
import appeng.core.Api;
import appeng.me.cluster.implementations.CraftingCPUCluster; import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.util.Platform; import appeng.util.Platform;
import net.minecraft.inventory.CraftingInventory; import net.minecraft.inventory.CraftingInventory;
@@ -179,7 +180,7 @@ public class CraftingTreeProcess {
ItemStack is = ic.getStack(x); ItemStack is = ic.getStack(x);
is = Platform.getRecipeRemainder(is); is = Platform.getRecipeRemainder(is);
final IAEItemStack o = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) final IAEItemStack o = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(is); .createStack(is);
if (o != null) { if (o != null) {
this.bytes++; this.bytes++;
@@ -194,7 +195,7 @@ public class CraftingTreeProcess {
if (this.containerItems) { if (this.containerItems) {
final ItemStack is = Platform.getRecipeRemainder(stack.createItemStack()); final ItemStack is = Platform.getRecipeRemainder(stack.createItemStack());
final IAEItemStack o = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) final IAEItemStack o = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(is); .createStack(is);
if (o != null) { if (o != null) {
this.bytes++; this.bytes++;
@@ -18,7 +18,6 @@
package appeng.crafting; package appeng.crafting;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource; import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventory; import appeng.api.storage.IMEInventory;
@@ -27,6 +26,7 @@ import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.core.Api;
import appeng.util.inv.ItemListIgnoreCrafting; import appeng.util.inv.ItemListIgnoreCrafting;
public class MECraftingInventory implements IMEInventory<IAEItemStack> { public class MECraftingInventory implements IMEInventory<IAEItemStack> {
@@ -47,7 +47,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack> {
public MECraftingInventory() { public MECraftingInventory() {
this.localCache = new ItemListIgnoreCrafting<>( this.localCache = new ItemListIgnoreCrafting<>(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()); Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
this.extractedCache = null; this.extractedCache = null;
this.injectedCache = null; this.injectedCache = null;
this.missingCache = null; this.missingCache = null;
@@ -65,25 +65,25 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack> {
this.logMissing = parent.logMissing; this.logMissing = parent.logMissing;
if (this.logMissing) { if (this.logMissing) {
this.missingCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); this.missingCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else { } else {
this.missingCache = null; this.missingCache = null;
} }
if (this.logExtracted) { if (this.logExtracted) {
this.extractedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); this.extractedCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else { } else {
this.extractedCache = null; this.extractedCache = null;
} }
if (this.logInjections) { if (this.logInjections) {
this.injectedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); this.injectedCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else { } else {
this.injectedCache = null; this.injectedCache = null;
} }
this.localCache = this.target.getAvailableItems(new ItemListIgnoreCrafting<>( this.localCache = this.target.getAvailableItems(new ItemListIgnoreCrafting<>(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList())); Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()));
this.par = parent; this.par = parent;
} }
@@ -96,25 +96,25 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack> {
this.logMissing = logMissing; this.logMissing = logMissing;
if (logMissing) { if (logMissing) {
this.missingCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); this.missingCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else { } else {
this.missingCache = null; this.missingCache = null;
} }
if (logExtracted) { if (logExtracted) {
this.extractedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); this.extractedCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else { } else {
this.extractedCache = null; this.extractedCache = null;
} }
if (logInjections) { if (logInjections) {
this.injectedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); this.injectedCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else { } else {
this.injectedCache = null; this.injectedCache = null;
} }
this.localCache = new ItemListIgnoreCrafting<>( this.localCache = new ItemListIgnoreCrafting<>(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()); Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
for (final IAEItemStack is : target.getStorageList()) { for (final IAEItemStack is : target.getStorageList()) {
this.localCache.add(target.extractItems(is, Actionable.SIMULATE, src)); this.localCache.add(target.extractItems(is, Actionable.SIMULATE, src));
} }
@@ -130,25 +130,25 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack> {
this.logMissing = logMissing; this.logMissing = logMissing;
if (logMissing) { if (logMissing) {
this.missingCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); this.missingCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else { } else {
this.missingCache = null; this.missingCache = null;
} }
if (logExtracted) { if (logExtracted) {
this.extractedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); this.extractedCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else { } else {
this.extractedCache = null; this.extractedCache = null;
} }
if (logInjections) { if (logInjections) {
this.injectedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList(); this.injectedCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else { } else {
this.injectedCache = null; this.injectedCache = null;
} }
this.localCache = target.getAvailableItems( this.localCache = target
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()); .getAvailableItems(Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
this.par = null; this.par = null;
} }
@@ -214,7 +214,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack> {
@Override @Override
public IStorageChannel getChannel() { public IStorageChannel getChannel() {
return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class); return Api.instance().storage().getStorageChannel(IItemStorageChannel.class);
} }
public IItemList<IAEItemStack> getItemList() { public IItemList<IAEItemStack> getItemList() {
@@ -222,9 +222,9 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack> {
} }
public boolean commit(final IActionSource src) { public boolean commit(final IActionSource src) {
final IItemList<IAEItemStack> added = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) final IItemList<IAEItemStack> added = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList(); .createList();
final IItemList<IAEItemStack> pulled = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class) final IItemList<IAEItemStack> pulled = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList(); .createList();
boolean failed = false; boolean failed = false;
@@ -31,6 +31,7 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.Util; import net.minecraft.util.Util;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
@@ -56,10 +57,31 @@ public class ReplicatorCardItem extends AEBaseItem implements AEToolItem {
super(properties); super(properties);
} }
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
if (!worldIn.isRemote()) {
final CompoundNBT tag = playerIn.getHeldItem(handIn).getOrCreateTag();
final int replications;
if (tag.contains("r")) {
replications = (tag.getInt("r") + 1) % 4;
} else {
replications = 0;
}
tag.putInt("r", replications);
playerIn.sendMessage(new StringTextComponent((replications + 1) + "³ Replications"));
}
return super.onItemRightClick(worldIn, playerIn, handIn);
}
@Override @Override
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) { public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
if (context.getWorld().isClient()) { if (context.getWorld().isClient()) {
return ActionResult.PASS; // Needed, otherwise client will trigger onItemRightClick also on server...
return ActionResult.SUCCESS;
} }
PlayerEntity player = context.getPlayer(); PlayerEntity player = context.getPlayer();
@@ -78,13 +100,15 @@ public class ReplicatorCardItem extends AEBaseItem implements AEToolItem {
if (player.isInSneakingPose()) { if (player.isInSneakingPose()) {
if (world.getBlockEntity(pos) instanceof IGridHost) { if (world.getBlockEntity(pos) instanceof IGridHost) {
final CompoundTag tag = new CompoundTag(); final CompoundTag tag = player.getStackInHand(hand).getOrCreateTag();
tag.putInt("x", x); tag.putInt("x", x);
tag.putInt("y", y); tag.putInt("y", y);
tag.putInt("z", z); tag.putInt("z", z);
tag.putInt("side", side.ordinal()); tag.putInt("side", side.ordinal());
tag.putString("w", world.getRegistryKey().getValue().toString()); tag.putString("w", world.getRegistryKey().getValue().toString());
player.getStackInHand(hand).setTag(tag); tag.putInt("r", 0);
this.outputMsg(player, "Set replicator source");
} else { } else {
this.outputMsg(player, "This is not a Grid Tile."); this.outputMsg(player, "This is not a Grid Tile.");
} }
@@ -97,6 +121,7 @@ public class ReplicatorCardItem extends AEBaseItem implements AEToolItem {
final int src_side = ish.getInt("side"); final int src_side = ish.getInt("side");
final String worldId = ish.getString("w"); final String worldId = ish.getString("w");
final World src_w = world.getServer().getWorld(RegistryKey.of(Registry.DIMENSION, new Identifier(worldId))); final World src_w = world.getServer().getWorld(RegistryKey.of(Registry.DIMENSION, new Identifier(worldId)));
final int replications = ish.getInt("r") + 1;
final BlockEntity te = src_w.getBlockEntity(new BlockPos(src_x, src_y, src_z)); final BlockEntity te = src_w.getBlockEntity(new BlockPos(src_x, src_y, src_z));
if (te instanceof IGridHost) { if (te instanceof IGridHost) {
@@ -104,50 +129,73 @@ public class ReplicatorCardItem extends AEBaseItem implements AEToolItem {
final Direction sideOff = Direction.values()[src_side]; final Direction sideOff = Direction.values()[src_side];
final Direction currentSideOff = side; final Direction currentSideOff = side;
final IGridNode n = gh.getGridNode(AEPartLocation.fromFacing(sideOff)); final IGridNode n = gh.getGridNode(AEPartLocation.fromFacing(sideOff));
if (n != null) { if (n != null) {
final IGrid g = n.getGrid(); final IGrid g = n.getGrid();
if (g != null) { if (g != null) {
final ISpatialCache sc = g.getCache(ISpatialCache.class); final ISpatialCache sc = g.getCache(ISpatialCache.class);
if (sc.isValidRegion()) { if (sc.isValidRegion()) {
final DimensionalCoord min = sc.getMin(); final DimensionalCoord min = sc.getMin();
final DimensionalCoord max = sc.getMax(); final DimensionalCoord max = sc.getMax();
x += currentSideOff.getOffsetX(); // TODO: Why??? Places it one block up each time...
y += currentSideOff.getOffsetY(); // x += currentSideOff.getOffsetX();
z += currentSideOff.getOffsetZ(); // y += currentSideOff.getOffsetY();
// z += currentSideOff.getOffsetZ();
final int sc_size_x = max.x - min.x;
final int sc_size_y = max.y - min.y;
final int sc_size_z = max.z - min.z;
final int min_x = min.x; final int min_x = min.x;
final int min_y = min.y; final int min_y = min.y;
final int min_z = min.z; final int min_z = min.z;
final int rel_x = min.x - src_x + x; // Invert to maintain correct sign for west/east
final int rel_y = min.y - src_y + y; final int x_rot = (int) -Math.signum(MathHelper.wrapDegrees(player.rotationYaw));
final int rel_z = min.z - src_z + z; // Rotate by 90 degree, so north/south are negative/positive
final int z_rot = (int) Math.signum(MathHelper.wrapDegrees(player.rotationYaw + 90));
final int scale_x = max.x - min.x; // Loops for replication in each direction
final int scale_y = max.y - min.y; for (int r_x = 0; r_x < replications; r_x++) {
final int scale_z = max.z - min.z; for (int r_y = 0; r_y < replications; r_y++) {
for (int r_z = 0; r_z < replications; r_z++) {
for (int i = 1; i < scale_x; i++) { // Offset x/z by the rotation index.
for (int j = 1; j < scale_y; j++) { // For sake of simplicity always grow upwards.
for (int k = 1; k < scale_z; k++) { final int rel_x = min.x - src_x + x + (r_x * sc_size_x * x_rot);
final BlockPos p = new BlockPos(min_x + i, min_y + j, min_z + k); final int rel_y = min.y - src_y + y + (r_y * sc_size_y);
final BlockPos d = new BlockPos(i + rel_x, j + rel_y, k + rel_z); final int rel_z = min.z - src_z + z + (r_z * sc_size_z * z_rot);
final BlockState state = src_w.getBlockState(p);
final Block blk = state.getBlock();
final BlockState prev = world.getBlockState(d);
world.setBlockState(d, state); // Copy a single SC instance completely
if (blk instanceof BlockEntityProvider) { for (int i = 1; i < sc_size_x; i++) {
for (int j = 1; j < sc_size_y; j++) {
for (int k = 1; k < sc_size_z; k++) {
final BlockPos p = new BlockPos(min_x + i, min_y + j,
min_z + k);
final BlockPos d = new BlockPos(i + rel_x, j + rel_y,
k + rel_z);
final BlockState state = src_w.getBlockState(p);
final Block blk = state.getBlock();
final BlockState prev = world.getBlockState(d);
world.setBlockState(d, state);
if (blk instanceof BlockEntityProvider) {
BlockEntityProvider blkEntityProvider = (BlockEntityProvider)blk; BlockEntityProvider blkEntityProvider = (BlockEntityProvider)blk;
final BlockEntity ote = src_w.getBlockEntity(p); final BlockEntity ote = src_w.getBlockEntity(p);
final BlockEntity nte = blkEntityProvider.createBlockEntity(world); final BlockEntity nte = blkEntityProvider.createBlockEntity(world);
final CompoundTag data = new CompoundTag(); final CompoundTag data = new CompoundTag();
ote.toTag(data); ote.toTag(data);
nte.fromTag(state, data.copy()); nte.fromTag(state, data.copy());
world.setBlockEntity(d, nte); world.setBlockEntity(d, nte);
}
world.updateListeners(d, prev, state, 3);
}
}
} }
world.updateListeners(d, prev, state, 3);
} }
} }
} }
@@ -34,10 +34,11 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.definitions.IMaterials; import appeng.api.definitions.IMaterials;
import appeng.api.features.AEFeature; import appeng.api.features.AEFeature;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.util.Platform; import appeng.util.Platform;
public final class ChargedQuartzEntity extends AEBaseItemEntity { public final class ChargedQuartzEntity extends AEBaseItemEntity {
@@ -92,7 +93,7 @@ public final class ChargedQuartzEntity extends AEBaseItemEntity {
private boolean transform() { private boolean transform() {
final ItemStack item = this.getStack(); final ItemStack item = this.getStack();
final IMaterials materials = AEApi.instance().definitions().materials(); final IMaterials materials = Api.instance().definitions().materials();
if (materials.certusQuartzCrystalCharged().isSameAs(item)) { if (materials.certusQuartzCrystalCharged().isSameAs(item)) {
final Box region = new Box(this.getX() - 1, this.getY() - 1, this.getZ() - 1, final Box region = new Box(this.getX() - 1, this.getY() - 1, this.getZ() - 1,
@@ -27,17 +27,20 @@ import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.damage.DamageSource;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
import net.minecraft.world.World; import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.definitions.IMaterials; import appeng.api.definitions.IMaterials;
import appeng.api.features.AEFeature; import appeng.api.features.AEFeature;
import appeng.core.AEConfig; import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.util.Platform; import appeng.util.Platform;
public final class SingularityEntity extends AEBaseItemEntity { public final class SingularityEntity extends AEBaseItemEntity {
private static final ResourceLocation TAG_ENDER_PEARL = new ResourceLocation("forge:ender_pearls");
public static EntityType<SingularityEntity> TYPE; public static EntityType<SingularityEntity> TYPE;
private static int randTickSeed = 0; private static int randTickSeed = 0;
@@ -71,7 +74,7 @@ public final class SingularityEntity extends AEBaseItemEntity {
final ItemStack item = this.getStack(); final ItemStack item = this.getStack();
final IMaterials materials = AEApi.instance().definitions().materials(); final IMaterials materials = Api.instance().definitions().materials();
if (materials.singularity().isSameAs(item)) { if (materials.singularity().isSameAs(item)) {
final Box region = new Box(this.getX() - 4, this.getY() - 4, this.getZ() - 4, final Box region = new Box(this.getX() - 4, this.getY() - 4, this.getZ() - 4,
@@ -84,6 +87,17 @@ public final class SingularityEntity extends AEBaseItemEntity {
if (!other.isEmpty()) { if (!other.isEmpty()) {
boolean matches = false; boolean matches = false;
if (materials.enderDust().isSameAs(other)) {
matches = true;
}
// check... other name.
if (!matches) {
if (other.getItem().getTags().contains(TAG_ENDER_PEARL)) {
matches = true;
}
}
if (matches) { if (matches) {
while (item.getCount() > 0 && other.getCount() > 0) { while (item.getCount() > 0 && other.getCount() > 0) {
other.increment(-1); other.increment(-1);
@@ -26,11 +26,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.api.parts.IFacadeContainer; import appeng.api.parts.IFacadeContainer;
import appeng.api.parts.IFacadePart; import appeng.api.parts.IFacadePart;
import appeng.api.parts.IPartHost; import appeng.api.parts.IPartHost;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.core.Api;
import appeng.items.parts.FacadeItem; import appeng.items.parts.FacadeItem;
import appeng.parts.CableBusStorage; import appeng.parts.CableBusStorage;
@@ -110,7 +110,7 @@ public class FacadeContainer implements IFacadeContainer {
if ((facadeSides & ix) == ix) { if ((facadeSides & ix) == ix) {
final int id = Math.abs(out.readInt()); final int id = Math.abs(out.readInt());
Optional<net.minecraft.item.Item> maybeFacadeItem = AEApi.instance().definitions().items().facade() Optional<net.minecraft.item.Item> maybeFacadeItem = Api.instance().definitions().items().facade()
.maybeItem(); .maybeItem();
if (maybeFacadeItem.isPresent()) { if (maybeFacadeItem.isPresent()) {
final FacadeItem ifa = (FacadeItem) maybeFacadeItem.get(); final FacadeItem ifa = (FacadeItem) maybeFacadeItem.get();
@@ -26,7 +26,6 @@ import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.FixedItemInv; import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction; import appeng.api.config.AccessRestriction;
import appeng.api.config.FuzzyMode; import appeng.api.config.FuzzyMode;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
@@ -41,6 +40,7 @@ import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.container.implementations.ContainerHelper; import appeng.container.implementations.ContainerHelper;
import appeng.container.slot.RestrictedInputSlot; import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.fluids.parts.FluidStorageBusPart; import appeng.fluids.parts.FluidStorageBusPart;
import appeng.fluids.util.IAEFluidTank; import appeng.fluids.util.IAEFluidTank;
import appeng.util.Platform; import appeng.util.Platform;
@@ -162,7 +162,7 @@ public class FluidStorageBusContainer extends FluidConfigurableContainer {
Iterator<IAEFluidStack> i = new NullIterator<>(); Iterator<IAEFluidStack> i = new NullIterator<>();
if (cellInv != null) { if (cellInv != null) {
final IItemList<IAEFluidStack> list = cellInv.getAvailableItems( final IItemList<IAEFluidStack> list = cellInv.getAvailableItems(
AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class).createList()); Api.instance().storage().getStorageChannel(IFluidStorageChannel.class).createList());
i = list.iterator(); i = list.iterator();
} }
@@ -40,7 +40,6 @@ import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier; import appeng.api.config.PowerMultiplier;
import appeng.api.config.SecurityPermissions; import appeng.api.config.SecurityPermissions;
@@ -70,6 +69,7 @@ import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync; import appeng.container.guisync.GuiSync;
import appeng.container.implementations.ContainerHelper; import appeng.container.implementations.ContainerHelper;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket; import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.MEFluidInventoryUpdatePacket; import appeng.core.sync.packets.MEFluidInventoryUpdatePacket;
@@ -104,7 +104,7 @@ public class FluidTerminalContainer extends AEBaseContainer
private final IConfigManager clientCM; private final IConfigManager clientCM;
private final IMEMonitor<IAEFluidStack> monitor; private final IMEMonitor<IAEFluidStack> monitor;
private final IItemList<IAEFluidStack> fluids = AEApi.instance().storage() private final IItemList<IAEFluidStack> fluids = Api.instance().storage()
.getStorageChannel(IFluidStorageChannel.class).createList(); .getStorageChannel(IFluidStorageChannel.class).createList();
@GuiSync(99) @GuiSync(99)
public boolean hasPower = false; public boolean hasPower = false;
@@ -126,7 +126,7 @@ public class FluidTerminalContainer extends AEBaseContainer
if (Platform.isServer()) { if (Platform.isServer()) {
this.serverCM = terminal.getConfigManager(); this.serverCM = terminal.getConfigManager();
this.monitor = terminal this.monitor = terminal
.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); .getInventory(Api.instance().storage().getStorageChannel(IFluidStorageChannel.class));
if (this.monitor != null) { if (this.monitor != null) {
this.monitor.addListener(this, null); this.monitor.addListener(this, null);
@@ -252,7 +252,7 @@ public class FluidTerminalContainer extends AEBaseContainer
public void sendContentUpdates() { public void sendContentUpdates() {
if (Platform.isServer()) { if (Platform.isServer()) {
if (this.monitor != this.terminal if (this.monitor != this.terminal
.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class))) { .getInventory(Api.instance().storage().getStorageChannel(IFluidStorageChannel.class))) {
this.setValidContainer(false); this.setValidContainer(false);
} }
@@ -26,7 +26,6 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntity;
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume; import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.config.Settings; import appeng.api.config.Settings;
import appeng.api.config.Upgrades; import appeng.api.config.Upgrades;
@@ -53,6 +52,8 @@ import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation; import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord; import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager; import appeng.api.util.IConfigManager;
import appeng.capabilities.Capabilities;
import appeng.core.Api;
import appeng.core.settings.TickRates; import appeng.core.settings.TickRates;
import appeng.fluids.util.AEFluidInventory; import appeng.fluids.util.AEFluidInventory;
import appeng.fluids.util.IAEFluidInventory; import appeng.fluids.util.IAEFluidInventory;
@@ -86,10 +87,9 @@ public class DualityFluidInterface
private int priority; private int priority;
private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>( private final MEMonitorPassThrough<IAEItemStack> items = new MEMonitorPassThrough<>(
new NullInventory<IAEItemStack>(), AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)); new NullInventory<IAEItemStack>(), Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>( private final MEMonitorPassThrough<IAEFluidStack> fluids = new MEMonitorPassThrough<>(
new NullInventory<IAEFluidStack>(), new NullInventory<IAEFluidStack>(), Api.instance().storage().getStorageChannel(IFluidStorageChannel.class));
AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
public DualityFluidInterface(final AENetworkProxy networkProxy, final IFluidInterfaceHost ih) { public DualityFluidInterface(final AENetworkProxy networkProxy, final IFluidInterfaceHost ih) {
this.gridProxy = networkProxy; this.gridProxy = networkProxy;
@@ -120,13 +120,13 @@ public class DualityFluidInterface
@Override @Override
public <T extends IAEStack<T>> IMEMonitor<T> getInventory(IStorageChannel<T> channel) { public <T extends IAEStack<T>> IMEMonitor<T> getInventory(IStorageChannel<T> channel) {
if (channel == AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)) { if (channel == Api.instance().storage().getStorageChannel(IItemStorageChannel.class)) {
if (this.hasConfig()) { if (this.hasConfig()) {
return null; return null;
} }
return (IMEMonitor<T>) this.items; return (IMEMonitor<T>) this.items;
} else if (channel == AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)) { } else if (channel == Api.instance().storage().getStorageChannel(IFluidStorageChannel.class)) {
if (this.hasConfig()) { if (this.hasConfig()) {
return (IMEMonitor<T>) new InterfaceInventory(this); return (IMEMonitor<T>) new InterfaceInventory(this);
} }
@@ -180,9 +180,9 @@ public class DualityFluidInterface
public void gridChanged() { public void gridChanged() {
try { try {
this.items.setInternal(this.gridProxy.getStorage() this.items.setInternal(this.gridProxy.getStorage()
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class))); .getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class)));
this.fluids.setInternal(this.gridProxy.getStorage() this.fluids.setInternal(this.gridProxy.getStorage()
.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class))); .getInventory(Api.instance().storage().getStorageChannel(IFluidStorageChannel.class)));
} catch (final GridAccessException gae) { } catch (final GridAccessException gae) {
this.items.setInternal(new NullInventory<IAEItemStack>()); this.items.setInternal(new NullInventory<IAEItemStack>());
this.fluids.setInternal(new NullInventory<IAEFluidStack>()); this.fluids.setInternal(new NullInventory<IAEFluidStack>());
@@ -296,7 +296,7 @@ public class DualityFluidInterface
boolean changed = false; boolean changed = false;
try { try {
final IMEInventory<IAEFluidStack> dest = this.gridProxy.getStorage() final IMEInventory<IAEFluidStack> dest = this.gridProxy.getStorage()
.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)); .getInventory(Api.instance().storage().getStorageChannel(IFluidStorageChannel.class));
final IEnergySource src = this.gridProxy.getEnergy(); final IEnergySource src = this.gridProxy.getEnergy();
if (work.getStackSize() > 0) { if (work.getStackSize() > 0) {

Some files were not shown because too many files have changed in this diff Show More