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:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets
uses: GabrielBB/xvfb-action@v1.2
with:
run: ./gradlew runData --no-daemon
- name: Validate assets
run: test -d ./src/generated
- name: Build with Gradle
run: ./gradlew build --no-daemon
+4
View File
@@ -21,9 +21,13 @@ jobs:
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets
uses: GabrielBB/xvfb-action@v1.2
with:
run: ./gradlew runData --no-daemon
- name: Validate assets
run: test -d ./src/generated
- name: Build with Gradle
run: ./gradlew build --no-daemon
+4
View File
@@ -21,10 +21,14 @@ jobs:
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets
uses: GabrielBB/xvfb-action@v1.2
with:
run: ./gradlew runData --no-daemon
- name: Validate assets
run: test -d ./src/generated
- name: Build with Gradle
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
+22 -3
View File
@@ -2,7 +2,7 @@ name: 'Release'
on:
release:
types: [created]
types: [published]
jobs:
build:
@@ -28,17 +28,36 @@ jobs:
java-version: 1.8
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Validate no assets
run: test ! -d ./src/generated
- name: Generate assets
uses: GabrielBB/xvfb-action@v1.2
with:
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:
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }}
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }}
KEY_STORE_KEY_PASS: ${{ secrets.KEY_STORE_KEY_PASS }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew build publish --no-daemon
run: ./gradlew build --no-daemon
- 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
id: prepare_artifact_metadata
run: |
+33 -62
View File
@@ -12,10 +12,9 @@
* [Downloads](#downloads)
* [Installation](#installation)
* [Issues](#issues)
* [API](#applied-energistics-2-api)
* [Building](#building)
* [Contribution](#contribution)
* [API](#applied-energistics-2-api)
* [CraftTweaker](#applied-energistics-2-crafttweaker)
* [Localization](#applied-energistics-2-localization)
* [Credits](#credits)
@@ -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.
## Applied Energistics 2 API
The API for Applied Energistics 2. It is open source to discuss changes, improve documentation, and provide better add-on support in general.
### Maven
We use Github Packages as maven repository now. You can use the following snippet as example on how to add a repository to your gradle build file.
repositories {
maven {
name "AE2"
url "https://maven.pkg.github.com/AppliedEnergistics/Applied-Energistics-2"
}
}
When compiling against the AE2 API you can use gradle dependencies, just add
dependencies {
compileOnly "appeng:appliedenergistics2:VERSION:api"
}
or add the `compileOnly` line to your existing dependencies task to your build.gradle.
Replace `VERSION` with the desired one. With 1.15+ we switched to using [semver](https://semver.org/).
It is highly recommended following its specification and further considering an upper bound for the dependency version.
A change of the `MAJOR` version will be an API break and can lead to various crashes. Better to inform a player about the addon not supporting the new version until it could be tested or updated.
An example string would be `appeng:appliedenergistics2:7.0.0-alpha.6:api` for the API only or `appeng:appliedenergistics2:7.0.0-alpha.6` for the whole mod.
Builds obtained [here](https://github.com/AppliedEnergistics/Applied-Energistics-2/releases) or via [maven](https://github.com/AppliedEnergistics/Applied-Energistics-2/packages) should work in a development environment.
However the dependency might need to be wrapped in `fg.deobf()` like `runtimeOnly fg.deobf("appeng:appliedenergistics2:VERSION:api")`
## Building
1. Clone this repository via
@@ -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.
## Applied Energistics 2 API
The API for Applied Energistics 2. It is open source to discuss changes, improve documentation, and provide better add-on support in general.
Universal builds obtained [Here](http://ae2.ae-mod.info/Downloads/) should work in a development environment.
### Maven
When compiling against the AE2 API you can use gradle dependencies, just add
dependencies {
compile "appeng:appliedenergistics2:rv_-_____-__:api"
}
or add the compile line to your existing dependencies task to your build.gradle
Where the __ are filled in with the correct version criteria; AE2 is available from the default forge maven so no additional repositories are necessary.
An example string would be `appeng:appliedenergistics2:rv5-stable-1:api` for the API only or `appeng:appliedenergistics2:rv5-stable-1` for the whole mod.
## Applied Energistics 2 CraftTweaker
### Inscriber
The inscriber uses the vanilla recipe system with a custom `type` of `appliedenergistics2:inscriber`.
See the [inscriber recipe folder](src/main/resources/data/appliedenergistics2/recipes/inscriber) for some examples.
### Grindstone
The grindstone uses the vanilla recipe system with a custom `type` of `appliedenergistics2:grinder`.
See the [grinder recipe folder](src/main/resources/data/appliedenergistics2/recipes/grinder) for some examples.
### Spatial
Whitelist a TileEntity class for Spatial IO.
mods.appliedenergistics2.Spatial.whitelistEntity( String fullEntityClassName );
### Attunement
Attune a ItemStack or ModID to a specific P2P-Tunnel type. ModID's are used as fallback when no ItemStack was found.
mods.appliedenergistics2.Attunement.attuneME( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneME( String modID );
mods.appliedenergistics2.Attunement.attuneItem( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneItem( String modID );
mods.appliedenergistics2.Attunement.attuneFluid( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneFluid( String modID );
mods.appliedenergistics2.Attunement.attuneRedstone( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneRedstone( String modID );
mods.appliedenergistics2.Attunement.attuneRF( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneRF( String modID );
mods.appliedenergistics2.Attunement.attuneIC2( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneIC2( String modID );
mods.appliedenergistics2.Attunement.attuneLight( ItemStack itemStack );
mods.appliedenergistics2.Attunement.attuneLight( String modID );
### Cannon
Add ammo types for the matter cannon.
mods.appliedenergistics2.Cannon.registerAmmo( ItemStack itemStack, double weight );
## Applied Energistics 2 Localization
### English Text
+3 -2
View File
@@ -20,7 +20,7 @@ plugins {
id 'java'
id 'fabric-loom'
id 'maven-publish'
id "org.jetbrains.kotlin.jvm"
id "com.matthewprenger.cursegradle" version "1.4.0"
id "org.sonarqube" version "2.8"
id "jacoco"
}
@@ -140,7 +140,8 @@ jar {
from "LICENSE"
}
compileKotlin.kotlinOptions.jvmTarget = "1.8"
apply from: 'gradle/scripts/artifacts.gradle'
apply from: 'gradle/scripts/curseforge.gradle'
publishing {
publications {
+7
View File
@@ -26,3 +26,10 @@ archives_base_name = fabric-example-mod
# Kotlin
kotlin_version=1.3.61
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
* initialization phase of Applied Energistics. AE expects your class to have a
* single constructor and can supply certain arguments to your constructor using
* dependency injection.
* initialization phase of Applied Energistics.
*
* The class also needs to implement {@link IAEAddon}.
*
* AE expects your class to have a single constructor without any parameters.
*
* This is the only way to get access to the public {@link IAppEngApi} instance.
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Retention(RetentionPolicy.CLASS)
@Documented
public @interface AEPlugin {
public @interface AEAddon {
}
-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)
*
* Copyright (c) 2013 AlgorithmX2
* Copyright (c) 2020 TeamAppliedEnergistics
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
@@ -21,26 +21,30 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.implementations;
package appeng.api;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
/**
* Implemented on {@link Item}
* Every AE2 addon requiring access to {@link IAppEngApi}, needs to provide at
* least one class implementing this interface.
*
* Further it requires the class to be annotated with {@link AEAddon}.
*
*/
public interface ICraftingPatternItem {
public interface IAEAddon {
/**
* Access Details about a pattern
*
* @param is pattern
* @param w crafting world
*
* @return details of pattern
* This gets called once the API is successfully constructed and ready to be
* used.
*
* For now this happens during {@link FMLCommonSetupEvent}.
*
* Each addon is responsible to maintain a reference to {@link IAppEngApi} for
* future use. Otherwise there is no alternative to access it later.
*
* @param api The API instance when ready.
*/
ICraftingPatternDetails getPatternForItem(ItemStack is, World w);
void onAPIAvailable(IAppEngApi api);
}
+13 -7
View File
@@ -23,16 +23,22 @@
package appeng.api;
import appeng.api.client.IClientHelper;
import appeng.api.crafting.ICraftingHelper;
import appeng.api.definitions.IDefinitions;
import appeng.api.features.IRegistryContainer;
import appeng.api.networking.IGridHelper;
import appeng.api.networking.IGridNode;
import appeng.api.parts.IPartHelper;
import appeng.api.storage.IStorageHelper;
import appeng.api.util.IClientHelper;
@AEInjectable
public interface IAppEngApi {
/**
* @return An accessible list of all AE definitions
*/
IDefinitions definitions();
/**
* @return Registry Container for the numerous registries in AE2.
*/
@@ -43,6 +49,11 @@ public interface IAppEngApi {
*/
IStorageHelper storage();
/**
* @return A helper for working with crafting related tasks.
*/
ICraftingHelper crafting();
/**
* @return A helper to create {@link IGridNode} and other grid related objects.
*/
@@ -53,11 +64,6 @@ public interface IAppEngApi {
*/
IPartHelper partHelper();
/**
* @return An accessible list of all AE definitions
*/
IDefinitions definitions();
/**
* @return Utility methods primarily useful for client side stuff
*/
@@ -0,0 +1,88 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 TeamAppliedEnergistics
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.client;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.item.Item;
import net.minecraft.util.ResourceLocation;
/**
* A registry for 3D models used to render storage cells in the world, when they
* are inserted into a drive or similar machines.
*/
public interface ICellModelRegistry {
/**
* Register a new model for a storage cell item.
*
* <p>
* You are responsible for ensuring that the given model is actually loaded by
* the game. See
* {@see net.minecraftforge.client.model.ModelLoader#addSpecialModel}.
*
* This method only maps an {@link Item} to a {@link ResourceLocation} which can
* be looked up from the {@link ModelBakery}. No validation about missing models
* will be done.
*
* Will throw an exception in case a model is already registered for an item.
*
* For examples look at our cell part models within the drive model directory.
*
* @param item The cell item
* @param model The {@link ResourceLocation} representing the model.
* @return
*/
void registerModel(@Nonnull Item item, @Nonnull ResourceLocation model);
/**
* The {@link ResourceLocation} of the model used to render the given storage
* cell {@link Item} when inserted into a drive or similar.
*
* @param item
* @return null, if no model is registered.
*/
@Nullable
ResourceLocation model(@Nonnull Item item);
/**
* An unmodifiable map of all registered mappings.
*
* @return
*/
@Nonnull
Map<Item, ResourceLocation> models();
/**
* Returns the default model, which can be used when no explicit model is
* registered.
*/
@Nonnull
ResourceLocation getDefaultModel();
}
@@ -21,7 +21,7 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.util;
package appeng.api.client;
import java.util.List;
@@ -39,4 +39,11 @@ public interface IClientHelper {
*/
<T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler, List<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;
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;
@@ -36,6 +40,7 @@ import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible;
import net.minecraft.text.Text;
import net.minecraft.util.text.TranslationTextComponent;
public enum Upgrades {
/**
@@ -74,11 +79,11 @@ public enum Upgrades {
* @param item machine in which this upgrade can be installed
* @param maxSupported amount how many upgrades can be installed
* @param tooltipGroup If more than one item of the same group are supported,
* the tooltip will show this group name instead. If the
* items have different maxSupported values, the highest
* the tooltip will show this translation key instead. If
* the items have different maxSupported values, the highest
* will be shown.
*/
public void registerItem(final ItemConvertible item, final int maxSupported, @Nullable Text tooltipGroup) {
public void registerItem(final ItemConvertible item, final int maxSupported, @Nullable String tooltipGroup) {
Preconditions.checkNotNull(item);
this.supported.add(new Supported(item.asItem(), maxSupported, tooltipGroup));
supportedTooltipLines = null; // Reset tooltip
@@ -98,17 +103,17 @@ public enum Upgrades {
Text name = supported.item.getName();
// If the group was already added by a previous item, skip this
if (supported.tooltipGroup != null && namesAdded.contains(supported.tooltipGroup)) {
if (supported.getTooltipGroup() != null && namesAdded.contains(supported.getTooltipGroup())) {
continue;
}
// If any of the following items would be of the same group, use the group name
// instead
if (supported.tooltipGroup != null) {
if (supported.getTooltipGroup() != null) {
for (int j = i + 1; j < this.supported.size(); j++) {
Text otherGroup = this.supported.get(j).tooltipGroup;
if (supported.tooltipGroup.equals(otherGroup)) {
name = supported.tooltipGroup;
Text otherGroup = this.supported.get(j).getTooltipGroup();
if (supported.getTooltipGroup().equals(otherGroup)) {
name = supported.getTooltipGroup();
break;
}
}
@@ -135,10 +140,11 @@ public enum Upgrades {
private final Item item;
private final Block block;
private final int maxCount;
// Translation key of the tooltip group
@Nullable
private final 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;
if (item instanceof BlockItem) {
this.block = ((BlockItem) item).getBlock();
@@ -161,6 +167,10 @@ public enum Upgrades {
return item != null && this.item == item;
}
public ITextComponent getTooltipGroup() {
return this.tooltipGroup != null ? new TranslationTextComponent(this.tooltipGroup) : null;
}
}
}
@@ -0,0 +1,108 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2020 TeamAppliedEnergistics
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.crafting;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.ICraftingRecipe;
import net.minecraft.world.World;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.data.IAEItemStack;
public interface ICraftingHelper {
/**
* Checks that the given item stack is an encoded pattern.
*/
boolean isEncodedPattern(@Nullable IAEItemStack item);
/**
* Checks that the given item stack is an encoded pattern.
*/
boolean isEncodedPattern(ItemStack item);
/**
* Encodes a processing pattern which represents the ability to convert the
* given inputs into the given outputs using some process external to the ME
* system.
*
* @param stack If null, a new item will be created to hold the encoded pattern.
* Otherwise the given item must already contains an encoded
* pattern that will be overwritten.
* @return A new encoded pattern, or the given stack with the pattern encoded in
* it.
*/
ItemStack encodeProcessingPattern(@Nullable ItemStack stack, ItemStack[] in, ItemStack[] out);
/**
* Encodes a crafting pattern which represents a Vanilla crafting recipe.
*
* @param stack If null, a new item will be created to hold the
* encoded pattern. Otherwise the given item must
* already contains an encoded pattern that will be
* overwritten.
* @param recipe The Vanilla crafting recipe to be encoded.
* @param in The items in the crafting grid, which are used to
* determine what items are supplied from the ME system
* to craft using this pattern.
* @param out What is to be expected as the result of this crafting
* operation by the ME system.
* @param allowSubstitutes Controls whether the ME system will allow the use of
* equivalent items to craft this recipe.
*/
ItemStack encodeCraftingPattern(@Nullable ItemStack stack, ICraftingRecipe recipe, ItemStack[] in, ItemStack out,
boolean allowSubstitutes);
/**
* Same as {@link #decodePattern(ItemStack, World, boolean)} with no auto
* recovery of changed recipe ids.
*/
@Nullable
default ICraftingPatternDetails decodePattern(@Nonnull ItemStack itemStack, @Nonnull World world) {
return decodePattern(itemStack, world, false);
}
/**
* Decodes an encoded crafting pattern and returns the pattern details.
* <p>
* The item backing the {@link ItemStack} needs to be an item returned by the
* encode methods of this class.
*
* @param itemStack pattern
* @param world world used to access the
* {@link net.minecraft.item.crafting.RecipeManager}.
* @param autoRecovery If true, the method will try to recover from changed
* recipe ids by searching the entire recipe manager for a
* recipe matching the inputs. If this is successful, the
* given item stack will be changed to reflect the new
* recipe id.
* @return The pattern details if the pattern could be decoded. Otherwise null.
*/
@Nullable
ICraftingPatternDetails decodePattern(@Nonnull ItemStack itemStack, @Nonnull World world, boolean autoRecovery);
}
@@ -23,7 +23,6 @@
package appeng.api.features;
import appeng.api.AEInjectable;
import appeng.api.movable.IMovableRegistry;
import appeng.api.networking.IGridCacheRegistry;
import appeng.api.parts.IPartModels;
@@ -36,7 +35,6 @@ import appeng.api.storage.ICellRegistry;
* @version 7
* @since rv0
*/
@AEInjectable
public interface IRegistryContainer {
/**
@@ -28,18 +28,25 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.ICellHandler;
import appeng.api.storage.cells.ICellInventory;
import appeng.api.storage.cells.ICellWorkbenchItem;
import appeng.api.storage.data.IAEStack;
/**
* Any item which implements this can be treated as an IMEInventory via
* Util.getCell / Util.isCell It automatically handles the internals and NBT
* data, which is both nice, and bad for you!
* {@link ICellHandler#getCellInventory(ItemStack, appeng.api.storage.cells.ISaveProvider, IStorageChannel)}
* or {@link ICellHandler#isCell(ItemStack)}. It automatically handles the
* internals and NBT data, which is both nice, and bad for you!
*
* Good cause it means you don't have to do anything, bad because you have
* little to no control over it.
*
* The standard AE implementation only provides 1-63 Types
*
* Limited to {@link Integer} internally for most calculations. E.g. if the used
* or remaining bytes would overflow {@link Integer#MAX_VALUE} the behaviour is
* no longer specified. Even if {@link ICellInventory} is using {@link Long}.
*
* The standard AE implementation also only provides 1-63 Types.
*/
public interface IStorageCell<T extends IAEStack<T>> extends ICellWorkbenchItem {
@@ -91,16 +91,6 @@ public interface IGridBlock {
*/
void onGridNotification(@Nonnull GridNotification notification);
/**
* Update Blocks network/connection/booting status. grid,
*
* @param grid grid
* @param channelsInUse used channels
* @deprecated to be removed in rv7
*/
@Deprecated
void setNetworkStatus(IGrid grid, int channelsInUse);
/**
* Determine which sides of the block can be connected too, only used when
* isWorldAccessible returns true, not used for {@link IPart} implementations.
@@ -27,18 +27,19 @@ import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.storage.data.IAEItemStack;
/**
* do not implement provided by {@link ICraftingPatternItem}
*
* caching this INSTANCE will increase performance of validation and checks.
* Describes a crafting or processing pattern decoded by
* {@link appeng.api.crafting.ICraftingHelper}.
* <p>
* Do not cache instances of this class unless you handle recipe reloads on the
* server and client correctly.
*/
public interface ICraftingPatternDetails {
/**
* @return source item.
* @return encodes this crafting pattern into a new item stack.
*/
ItemStack getPattern();
@@ -52,7 +53,9 @@ public interface ICraftingPatternDetails {
boolean isValidItemForSlot(int slotIndex, ItemStack itemStack, World world);
/**
* @return if this pattern is a crafting pattern ( work bench )
* @return if this pattern is for a Vanilla
* {@link net.minecraft.item.crafting.IRecipeType#CRAFTING crafting
* recipe}.
*/
boolean isCraftable();
@@ -23,6 +23,7 @@
package appeng.api.networking.crafting;
import appeng.api.crafting.ICraftingHelper;
import appeng.api.storage.data.IAEItemStack;
/**
@@ -33,6 +34,9 @@ public interface ICraftingProviderHelper {
/**
* Add new Pattern to AE's crafting cache.
*
* This will only accept instances created by
* {@link ICraftingHelper#decodePattern(net.minecraft.item.ItemStack, net.minecraft.world.World)}
*/
void addCraftingOption(ICraftingMedium medium, ICraftingPatternDetails api);
@@ -23,7 +23,6 @@
package appeng.api.networking.security;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.api.networking.IGridNode;
@@ -31,6 +31,6 @@ public interface ICustomCableConnection {
* @return This controls the cable connection to the node. -1 to render
* connection yourself.
*/
public float getCableConnectionLength(AECableType cable);
float getCableConnectionLength(AECableType cable);
}
@@ -24,7 +24,6 @@
package appeng.api.parts;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
+1 -1
View File
@@ -274,7 +274,7 @@ public interface IPart extends ICustomCableConnection {
* the node. -1 to render connection yourself.
*/
@Override
public float getCableConnectionLength(AECableType cable);
float getCableConnectionLength(AECableType cable);
/**
* same as Block.randomDisplayTick, for but parts.
@@ -23,13 +23,10 @@ import java.util.Collection;
import net.minecraft.util.Identifier;
import appeng.api.AEInjectable;
/**
* Allows registration of part models that can then be used in
* {@link IPart#getStaticModels()}.
*/
@AEInjectable
public interface IPartModels {
/**
@@ -1,54 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.recipes;
import java.util.List;
import appeng.api.exceptions.MissingIngredientException;
import appeng.api.exceptions.RecipeException;
import appeng.api.exceptions.RegistrationException;
@Deprecated
public interface ICraftHandler {
/**
* Called when your recipe handler receives a newly parsed list of
* inputs/outputs.
*
* @param input parsed inputs
* @param output parsed outputs
*
* @throws RecipeException
*/
void setup(List<List<IIngredient>> input, List<List<IIngredient>> output) throws RecipeException;
/**
* called when all recipes are parsed, and your required to register your
* recipe.
*
* @throws RegistrationException
* @throws MissingIngredientException
*/
void register() throws RegistrationException, MissingIngredientException;
}
@@ -1,92 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.recipes;
import net.minecraft.item.ItemStack;
import appeng.api.exceptions.MissingIngredientException;
import appeng.api.exceptions.RegistrationException;
@Deprecated
public interface IIngredient {
/**
* Acquire a single input stack for the current recipe, if more then one
* ItemStack is possible a RegistrationError exception will be thrown, ignore
* these and let the system handle the error.
*
* @return a single ItemStack for the recipe handler.
*
* @throws RegistrationException
* @throws MissingIngredientException
*/
ItemStack getItemStack() throws RegistrationException, MissingIngredientException;
/**
* Acquire a list of all the input stacks for the current recipe, this is for
* handlers that support multiple inputs per slot.
*
* @return an array of ItemStacks for the recipe handler.
*
* @throws RegistrationException
* @throws MissingIngredientException
*/
ItemStack[] getItemStackSet() throws RegistrationException, MissingIngredientException;
/**
* If you wish to support air, you must test before getting the ItemStack, or
* ItemStackSet
*
* @return true if this slot contains no ItemStack, this is passed as "_"
*/
boolean isAir();
/**
* @return The Name Space of the item. Prefer getItemStack or getItemStackSet
*/
String getNameSpace();
/**
* @return The Name of the item. Prefer getItemStack or getItemStackSet
*/
String getItemName();
/**
* @return The Damage Value of the item. Prefer getItemStack or getItemStackSet
*/
int getDamageValue();
/**
* @return The Damage Value of the item. Prefer getItemStack or getItemStackSet
*/
int getQty();
/**
* Bakes the lists in for faster runtime look-ups.
*
* @throws MissingIngredientException
* @throws RegistrationException
*/
void bake() throws RegistrationException, MissingIngredientException;
}
@@ -1,44 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.recipes;
/**
* Represents the AE2 Recipe Loading/Reading Class
*/
@Deprecated
public interface IRecipeHandler {
/**
* Call when you want to read recipes in from a file based on a loader
*
* @param loader recipe loader
* @param path path of file
*/
void parseRecipes(IRecipeLoader loader, String path);
/**
* this loads the read recipes into minecraft, should be called in Init.
*/
void injectRecipes();
}
@@ -1,40 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 - 2015 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.recipes;
import java.io.BufferedReader;
import javax.annotation.Nonnull;
@Deprecated
public interface IRecipeLoader {
/**
* @param filePath the path to the to be loaded file
*
* @return reader handler of the file
*
* @throws Exception if reading goes wrong
*/
BufferedReader getFile(@Nonnull String filePath) throws Exception;
}
@@ -1,45 +0,0 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2013 AlgorithmX2
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package appeng.api.recipes;
import net.minecraft.nbt.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
*/
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();
/**
* @return true if the stack is a {@link IAEItemStack}
*/
boolean isItem();
/**
* @return true if the stack is a {@link IAEFluidStack}
*/
boolean isFluid();
/**
* @return ITEM or FLUID
* @return The {@link IStorageChannel} backing this stack.
*/
IStorageChannel<T> getChannel();
@@ -18,7 +18,7 @@
package appeng.block;
import appeng.api.AEApi;
import appeng.core.Api;
import appeng.api.config.AccessRestriction;
import appeng.api.config.Actionable;
import appeng.api.config.PowerUnits;
@@ -129,7 +129,7 @@ public class AEBaseBlockItemChargeable extends AEBaseBlockItem implements IAEIte
private double getMaxEnergyCapacity() {
final Block blockID = Block.getBlockFromItem(this);
final IBlockDefinition energyCell = AEApi.instance().definitions().blocks().energyCell();
final IBlockDefinition energyCell = Api.instance().definitions().blocks().energyCell();
return energyCell.maybeBlock().map(block -> {
if (blockID == block) {
@@ -22,10 +22,10 @@ import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.features.AEFeature;
import appeng.block.AEBaseBlockItem;
import appeng.core.AEConfig;
import appeng.core.Api;
public class CraftingStorageItem extends AEBaseBlockItem {
@@ -36,7 +36,7 @@ public class CraftingStorageItem extends AEBaseBlockItem {
// FIXME FABRIC needs to move to disassembly crafting recipes
// FIXME FABRIC @Override
// 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 @Override
@@ -50,13 +50,13 @@ import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.util.AEAxisAlignedBB;
import appeng.block.AEBaseTileBlock;
import appeng.client.render.effects.ParticleTypes;
import appeng.client.render.renderable.ItemRenderable;
import appeng.client.render.tesr.ModularTESR;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.tile.misc.ChargerBlockEntity;
import appeng.util.Platform;
@@ -102,7 +102,7 @@ public class ChargerBlock extends AEBaseTileBlock<ChargerBlockEntity> {
final ChargerBlockEntity tile = this.getBlockEntity(w, pos);
if (tile != null) {
if (AEApi.instance().definitions().materials().certusQuartzCrystalCharged()
if (Api.instance().definitions().materials().certusQuartzCrystalCharged()
.isSameAs(tile.getInternalInventory().getInvStack(0))) {
final double xOff = 0.0;
final double yOff = 0.0;
@@ -28,7 +28,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity;
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.util.ActionResult;
import net.minecraft.util.Hand;
@@ -43,18 +43,17 @@ import appeng.tile.storage.ChestBlockEntity;
public class ChestBlock extends AEBaseTileBlock<ChestBlockEntity> {
private final static EnumProperty<DriveSlotState> SLOT_STATE = EnumProperty.of("slot_state",
DriveSlotState.class);
private final static BooleanProperty LIGHTS_ON = BooleanProperty.of("lights_on");
public ChestBlock() {
super(defaultProps(Material.METAL));
this.setDefaultState(this.getDefaultState().with(SLOT_STATE, DriveSlotState.EMPTY));
this.setDefaultState(this.getDefaultState().with(LIGHTS_ON, false));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(SLOT_STATE);
builder.add(LIGHTS_ON);
}
@Override
@@ -69,7 +68,7 @@ public class ChestBlock extends AEBaseTileBlock<ChestBlockEntity> {
slotState = DriveSlotState.OFFLINE;
}
return currentState.with(SLOT_STATE, slotState);
return currentState.with(LIGHTS_ON, slotState != DriveSlotState.EMPTY && slotState != DriveSlotState.OFFLINE);
}
@Override
@@ -1,45 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.block.storage;
import net.minecraft.util.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.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IParts;
import appeng.client.gui.AEBaseScreen;
@@ -18,6 +17,7 @@ import appeng.container.implementations.CraftingTermContainer;
import appeng.container.implementations.MEMonitorableContainer;
import appeng.container.implementations.PatternTermContainer;
import appeng.container.implementations.WirelessTermContainer;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.SwitchGuisPacket;
import appeng.helpers.IPriorityHost;
@@ -45,7 +45,7 @@ final class AESubScreen {
public AESubScreen(AEBaseScreen<?> gui, Object containerTarget) {
this.gui = gui;
final IDefinitions definitions = AEApi.instance().definitions();
final IDefinitions definitions = Api.instance().definitions();
final IParts parts = definitions.parts();
if (containerTarget instanceof ChestBlockEntity) {
@@ -34,13 +34,13 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.client.gui.AEBaseScreen;
import appeng.client.gui.widgets.Scrollbar;
import appeng.container.implementations.CraftConfirmContainer;
import appeng.core.Api;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket;
@@ -52,11 +52,11 @@ public class CraftConfirmScreen extends AEBaseScreen<CraftConfirmContainer> {
private final int rows = 5;
private final IItemList<IAEItemStack> storage = AEApi.instance().storage()
private final IItemList<IAEItemStack> storage = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList();
private final IItemList<IAEItemStack> pending = AEApi.instance().storage()
private final IItemList<IAEItemStack> pending = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList();
private final IItemList<IAEItemStack> missing = AEApi.instance().storage()
private final IItemList<IAEItemStack> missing = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList();
private final List<IAEItemStack> visual = new ArrayList<>();
@@ -35,7 +35,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
@@ -48,6 +47,7 @@ import appeng.client.gui.widgets.ISortSource;
import appeng.client.gui.widgets.Scrollbar;
import appeng.container.implementations.CraftingCPUContainer;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket;
@@ -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_TOP_OFFSET = 22;
private IItemList<IAEItemStack> storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
private IItemList<IAEItemStack> storage = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList();
private IItemList<IAEItemStack> active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
private IItemList<IAEItemStack> active = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList();
private IItemList<IAEItemStack> pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
private IItemList<IAEItemStack> pending = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList();
private List<IAEItemStack> visual = new ArrayList<>();
@@ -101,9 +101,9 @@ public class CraftingCPUScreen<T extends CraftingCPUContainer> extends AEBaseScr
}
public void clearItems() {
this.storage = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.active = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.pending = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.storage = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.active = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.pending = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.visual = new ArrayList<>();
}
@@ -22,7 +22,6 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.config.FullnessMode;
import appeng.api.config.OperationMode;
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.SettingToggleButton;
import appeng.container.implementations.IOPortContainer;
import appeng.core.Api;
import appeng.core.localization.GuiText;
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) {
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)
.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 appeng.api.AEApi;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.client.ActionKey;
import appeng.client.gui.AEBaseScreen;
@@ -51,6 +50,7 @@ import appeng.client.gui.widgets.Scrollbar;
import appeng.client.me.ClientDCInternalInv;
import appeng.client.me.SlotDisconnected;
import appeng.container.implementations.InterfaceTerminalContainer;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
@@ -321,7 +321,7 @@ public class InterfaceTerminalScreen extends AEBaseScreen<InterfaceTerminalConta
final ItemStack parsedItemStack = ItemStack.fromTag(outTag.getCompound(i));
if (!parsedItemStack.isEmpty()) {
final String displayName = Platform.getItemDisplayName(AEApi.instance().storage()
final String displayName = Platform.getItemDisplayName(Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createStack(parsedItemStack)).getString()
.toLowerCase();
if (displayName.contains(searchTerm)) {
@@ -29,7 +29,12 @@ import net.minecraft.screen.slot.Slot;
import net.minecraft.item.ItemStack;
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.tiles.IMEChest;
import appeng.api.implementations.tiles.IViewCellStorage;
@@ -38,7 +43,11 @@ import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.ActionKey;
import appeng.client.gui.AEBaseMEScreen;
import appeng.client.gui.widgets.*;
import appeng.client.gui.widgets.AETextField;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.gui.widgets.Scrollbar;
import appeng.client.gui.widgets.SettingToggleButton;
import appeng.client.gui.widgets.TabButton;
import appeng.client.me.InternalSlotME;
import appeng.client.me.ItemRepo;
import appeng.container.implementations.CraftingStatusContainer;
@@ -27,8 +27,6 @@ import javax.annotation.Nonnull;
import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.config.Settings;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.config.YesNo;
@@ -38,6 +36,7 @@ import appeng.api.storage.data.IItemList;
import appeng.client.gui.widgets.IScrollSource;
import appeng.client.gui.widgets.ISortSource;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.fluids.util.FluidSorters;
import appeng.util.Platform;
import appeng.util.prioritylist.IPartitionList;
@@ -48,8 +47,8 @@ import appeng.util.prioritylist.IPartitionList;
* @since rv6 22/05/2018
*/
public class FluidRepo {
private final IItemList<IAEFluidStack> list = AEApi.instance().storage()
.getStorageChannel(IFluidStorageChannel.class).createList();
private final IItemList<IAEFluidStack> list = Api.instance().storage().getStorageChannel(IFluidStorageChannel.class)
.createList();
private final ArrayList<IAEFluidStack> view = new ArrayList<>();
private final IScrollSource src;
private final ISortSource sortSrc;
+2 -2
View File
@@ -28,7 +28,6 @@ import javax.annotation.Nonnull;
import net.minecraft.item.ItemStack;
import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.config.SearchBoxMode;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
@@ -39,6 +38,7 @@ import appeng.api.storage.data.IItemList;
import appeng.client.gui.widgets.IScrollSource;
import appeng.client.gui.widgets.ISortSource;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.integration.abstraction.ReiFacade;
import appeng.items.storage.ViewCellItem;
import appeng.util.ItemSorters;
@@ -47,7 +47,7 @@ import appeng.util.prioritylist.IPartitionList;
public class ItemRepo {
private final IItemList<IAEItemStack> list = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
private final IItemList<IAEItemStack> list = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList();
private final ArrayList<IAEItemStack> view = new ArrayList<>();
private final IScrollSource src;
@@ -50,8 +50,8 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockRenderView;
import appeng.api.AEApi;
import appeng.api.util.AEAxisAlignedBB;
import appeng.core.Api;
import appeng.parts.misc.CableAnchorPart;
/**
* The FacadeBuilder builds for facades..
@@ -99,7 +99,7 @@ public class FacadeBuilder {
RenderContext context, Function<Identifier, BakedModel> modelLookup) {
//FIXME BakedPipeline pipeline = this.pipelines.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();
List<Box> partBoxes = renderState.getBoundingBoxes();
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.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.world.ClientWorld;
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;
import java.util.EnumMap;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumer;
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.Environment;
import appeng.block.storage.DriveSlotState;
import appeng.client.render.FacingToRotation;
import appeng.client.render.model.DriveBakedModel;
import appeng.tile.storage.DriveBlockEntity;
/**
@@ -24,46 +22,8 @@ import appeng.tile.storage.DriveBlockEntity;
@Environment(EnvType.CLIENT)
public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEntity> {
private static final EnumMap<DriveSlotState, Vector3f> STATE_COLORS;
// Color used for the cell indicator for blinking during recent activity
private static final Vector3f BLINK_COLOR = new Vector3f(1, 0.5f, 0.5f);
static {
STATE_COLORS = new EnumMap<>(DriveSlotState.class);
STATE_COLORS.put(DriveSlotState.OFFLINE, new Vector3f(0, 0, 0));
STATE_COLORS.put(DriveSlotState.ONLINE, new Vector3f(0, 1, 0));
STATE_COLORS.put(DriveSlotState.NOT_EMPTY, new Vector3f(0f, 0.667f, 1));
STATE_COLORS.put(DriveSlotState.TYPES_FULL, new Vector3f(1, 0.667f, 0));
STATE_COLORS.put(DriveSlotState.FULL, new Vector3f(1, 0, 0));
}
private static final float L = 14 / 16.f; // left (x-axis)
private static final float R = 13 / 16.f; // right (x-axis)
private static final float T = 14 / 16.f; // top (x-axis)
private static final float B = 12.999f / 16.f; // bottom (x-axis)
private static final float FR = 0.999f / 16.f; // front (z-axis)
private static final float BA = 1.499f / 16.f; // back (z-axis)
// Vertex data for the LED cuboid (has no back)
// Directions are when looking from the front onto the LED
private static final float[] LED_QUADS = {
// Front Face
R, T, FR, L, T, FR, L, B, FR, R, B, FR,
// Left Face
L, T, FR, L, T, BA, L, B, BA, L, B, FR,
// Right Face
R, T, BA, R, T, FR, R, B, FR, R, B, BA,
// Top Face
R, T, BA, L, T, BA, L, T, FR, R, T, FR,
// Bottom Face
R, B, FR, L, B, FR, L, B, BA, R, B, BA, };
private static final 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);
public DriveLedTileEntityRenderer(BlockEntityRendererDispatcher rendererDispatcher) {
super(rendererDispatcher);
}
@Override
@@ -79,32 +39,18 @@ public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEn
FacingToRotation.get(drive.getForward(), drive.getUp()).push(ms);
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 col = 0; col < 2; col++) {
int slot = row * 2 + col;
Vector3f color = getColorForSlot(drive, slot, partialTicks);
if (color == null) {
continue;
}
ms.push();
// Position this drive model copy at the correct slot. The transform is based on
// the
// cell-model being in slot 0,0 at the top left of the drive.
float xOffset = -col * 8 / 16.0f;
float yOffset = -row * 3 / 16.0f;
ms.translate(xOffset, yOffset, 0);
DriveBakedModel.getSlotOrigin(row, col, slotTranslation);
ms.translate(slotTranslation.getX(), slotTranslation.getY(), slotTranslation.getZ());
for (int i = 0; i < LED_QUADS.length; i += 3) {
float x = LED_QUADS[i];
float y = LED_QUADS[i + 1];
float z = LED_QUADS[i + 2];
buffer.vertex(ms.peek().getModel(), x, y, z).color(color.getX(), color.getY(), color.getZ(), 1.f)
.next();
}
int slot = row * 2 + col;
CellLedRenderer.renderLed(drive, slot, buffer, ms, partialTicks);
ms.pop();
}
@@ -113,31 +59,4 @@ public class DriveLedTileEntityRenderer extends BlockEntityRenderer<DriveBlockEn
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.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
import appeng.api.implementations.guiobjects.IGuiItemObject;
@@ -65,6 +64,7 @@ import appeng.container.slot.InaccessibleSlot;
import appeng.container.slot.PlayerHotBarSlot;
import appeng.container.slot.PlayerInvSlot;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.InventoryActionPacket;
@@ -664,7 +664,7 @@ public abstract class AEBaseContainer extends ScreenHandler {
final ItemStack isg = player.inventory.getCursorStack();
if (!isg.isEmpty() && releaseQty > 0) {
IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(isg);
ais.setStackSize(1);
final IAEItemStack extracted = ais.copy();
@@ -743,7 +743,7 @@ public abstract class AEBaseContainer extends ScreenHandler {
this.updateHeld(player);
}
} else {
IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(player.inventory.getCursorStack());
ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais,
this.getActionSource());
@@ -783,7 +783,7 @@ public abstract class AEBaseContainer extends ScreenHandler {
this.updateHeld(player);
}
} else {
IAEItemStack ais = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
IAEItemStack ais = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(player.inventory.getCursorStack());
ais.setStackSize(1);
ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(), ais,
@@ -861,7 +861,7 @@ public abstract class AEBaseContainer extends ScreenHandler {
return input;
}
final IAEItemStack ais = Platform.poweredInsert(this.getPowerSource(), this.getCellInventory(),
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(input),
Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(input),
this.getActionSource());
if (ais == null) {
return ItemStack.EMPTY;
@@ -31,7 +31,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.impl.EmptyFixedItemInv;
import appeng.api.AEApi;
import appeng.api.config.CopyMode;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
@@ -47,6 +46,7 @@ import appeng.container.guisync.GuiSync;
import appeng.container.slot.FakeTypeOnlySlot;
import appeng.container.slot.OptionalRestrictedInputSlot;
import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.tile.misc.CellWorkbenchBlockEntity;
import appeng.util.EnumCycler;
import appeng.util.Platform;
@@ -208,9 +208,9 @@ public class CellWorkbenchContainer extends UpgradeableContainer {
final ItemStack is = this.getUpgradeable().getInventoryByName("cell").getInvStack(0);
final IStorageChannel channel = is.getItem() instanceof IStorageCell
? ((IStorageCell) is.getItem()).getChannel()
: AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
: Api.instance().storage().getStorageChannel(IItemStorageChannel.class);
final IMEInventory cellInv = AEApi.instance().registries().cell().getCellInventory(is, null, channel);
final IMEInventory cellInv = Api.instance().registries().cell().getCellInventory(is, null, channel);
Iterator<IAEStack> i = new NullIterator<>();
if (cellInv != null) {
@@ -14,7 +14,6 @@ import net.minecraft.text.LiteralText;
import net.minecraft.text.TranslatableText;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions;
import appeng.api.features.IWirelessTermHandler;
import appeng.api.implementations.guiobjects.IGuiItem;
@@ -24,6 +23,7 @@ import appeng.api.parts.IPartHost;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.helpers.ICustomNameObject;
import appeng.helpers.WirelessTerminalGuiObject;
import appeng.util.Platform;
@@ -212,7 +212,7 @@ public final class ContainerHelper<C extends AEBaseContainer, I> {
}
if (interfaceClass.isAssignableFrom(WirelessTerminalGuiObject.class)) {
final IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler(it);
final IWirelessTermHandler wh = Api.instance().registries().wireless().getWirelessTerminalHandler(it);
if (wh != null) {
return interfaceClass.cast(new WirelessTerminalGuiObject(wh, it, player, locator.getItemIndex()));
}
@@ -38,7 +38,6 @@ import net.minecraft.text.LiteralText;
import net.minecraft.util.Util;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
@@ -59,6 +58,7 @@ import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.guisync.GuiSync;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.MEInventoryUpdatePacket;
import appeng.helpers.WirelessTerminalGuiObject;
@@ -198,7 +198,7 @@ public class CraftConfirmContainer extends AEBaseContainer {
final MEInventoryUpdatePacket c = this.result.isSimulation() ? new MEInventoryUpdatePacket((byte) 2)
: null;
final IItemList<IAEItemStack> plan = AEApi.instance().storage()
final IItemList<IAEItemStack> plan = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList();
this.result.populatePlan(plan);
@@ -216,7 +216,7 @@ public class CraftConfirmContainer extends AEBaseContainer {
final IStorageGrid sg = this.getGrid().getCache(IStorageGrid.class);
final IMEInventory<IAEItemStack> items = sg
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
.getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
IAEItemStack m = null;
if (c != null && this.result.isSimulation()) {
@@ -28,7 +28,6 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.text.Text;
import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
import appeng.api.networking.crafting.CraftingItemList;
@@ -43,6 +42,7 @@ import appeng.api.storage.data.IItemList;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.MEInventoryUpdatePacket;
@@ -60,7 +60,7 @@ public class CraftingCPUContainer extends AEBaseContainer
private static final ContainerHelper<CraftingCPUContainer, CraftingBlockEntity> helper = new ContainerHelper<>(
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();
private IGrid network;
private CraftingCPUCluster monitor = null;
@@ -26,13 +26,13 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.AEApi;
import appeng.api.definitions.IItemDefinition;
import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync;
import appeng.container.interfaces.IProgressProvider;
import appeng.container.slot.OutputSlot;
import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.tile.misc.InscriberRecipes;
import appeng.tile.misc.InscriberBlockEntity;
import appeng.util.Platform;
@@ -131,7 +131,7 @@ public class InscriberContainer extends UpgradeableContainer implements IProgres
final ItemStack bot = this.ti.getInternalInventory().getInvStack(1);
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)) {
return !press.isSameAs(is);
}
@@ -146,7 +146,7 @@ public class InscriberContainer extends UpgradeableContainer implements IProgres
}
// name presses
final IItemDefinition namePress = AEApi.instance().definitions().materials().namePress();
final IItemDefinition namePress = Api.instance().definitions().materials().namePress();
if (namePress.isSameAs(otherSlot)) {
return namePress.isSameAs(is);
}
@@ -32,7 +32,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.block.entity.BlockEntity;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.SecurityPermissions;
@@ -67,6 +66,7 @@ import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.RestrictedInputSlot;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.MEInventoryUpdatePacket;
@@ -93,8 +93,8 @@ public class MEMonitorableContainer extends AEBaseContainer
private final RestrictedInputSlot[] cellView = new RestrictedInputSlot[5];
private final IMEMonitor<IAEItemStack> monitor;
private final IItemList<IAEItemStack> items = AEApi.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList();
private final IItemList<IAEItemStack> items = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList();
private final IConfigManager clientCM;
private final ITerminalHost host;
@GuiSync(99)
@@ -126,7 +126,7 @@ public class MEMonitorableContainer extends AEBaseContainer
this.serverCM = monitorable.getConfigManager();
this.monitor = monitorable
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class));
.getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class));
if (this.monitor != null) {
this.monitor.addListener(this, null);
@@ -185,7 +185,7 @@ public class MEMonitorableContainer extends AEBaseContainer
public void sendContentUpdates() {
if (Platform.isServer()) {
if (this.monitor != this.host
.getInventory(AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class))) {
.getInventory(Api.instance().storage().getStorageChannel(IItemStorageChannel.class))) {
this.setValidContainer(false);
}
@@ -38,6 +38,7 @@ import appeng.container.slot.AppEngSlot;
import appeng.container.slot.MolecularAssemblerPatternSlot;
import appeng.container.slot.OutputSlot;
import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.items.misc.EncodedPatternItem;
import appeng.tile.crafting.MolecularAssemblerBlockEntity;
import appeng.util.Platform;
@@ -79,8 +80,7 @@ public class MolecularAssemblerContainer extends UpgradeableContainer implements
if (is.getItem() instanceof EncodedPatternItem) {
final World w = this.getBlockEntity().getWorld();
final EncodedPatternItem iep = (EncodedPatternItem) is.getItem();
final ICraftingPatternDetails ph = iep.getPatternForItem(is, w);
final ICraftingPatternDetails ph = Api.instance().crafting().decodePattern(is, w);
if (ph.isCraftable()) {
return ph.isValidItemForSlot(slotIndex, i, w);
}
@@ -27,7 +27,6 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.api.implementations.guiobjects.INetworkTool;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridBlock;
@@ -41,6 +40,7 @@ import appeng.api.util.AEPartLocation;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.MEInventoryUpdatePacket;
import appeng.util.Platform;
@@ -115,7 +115,7 @@ public class NetworkStatusContainer extends AEBaseContainer {
final MEInventoryUpdatePacket piu = new MEInventoryUpdatePacket();
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();
for (final IGridNode machine : this.network.getMachines(machineClass)) {
final IGridBlock blk = machine.getGridBlock();
@@ -20,7 +20,6 @@ package appeng.container.implementations;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import alexiil.mc.lib.attributes.item.FixedItemInv;
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.world.World;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
import appeng.api.crafting.ICraftingHelper;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost;
@@ -61,6 +60,7 @@ import appeng.container.slot.OptionalFakeSlot;
import appeng.container.slot.PatternOutputsSlot;
import appeng.container.slot.PatternTermSlot;
import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.core.sync.packets.PatternSlotPacket;
import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ViewCellItem;
@@ -99,6 +99,7 @@ public class PatternTermContainer extends MEMonitorableContainer
private final PatternTermSlot craftSlot;
private final RestrictedInputSlot patternSlotIN;
private final RestrictedInputSlot patternSlotOUT;
private final ICraftingHelper craftingHelper = Api.INSTANCE.crafting();
private Recipe<CraftingInventory> currentRecipe;
@GuiSync(97)
@@ -212,17 +213,17 @@ public class PatternTermContainer extends MEMonitorableContainer
final ItemStack[] out = this.getOutputs();
// if there is no input, this would be silly.
if (in == null || out == null) {
if (in == null || out == null || isCraftingMode() && currentRecipe == null) {
return;
}
// 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;
} // if nothing is there we should snag a new pattern.
else if (output.isEmpty()) {
output = this.patternSlotIN.getStack();
if (output.isEmpty() || !this.isPattern(output)) {
if (output.isEmpty() || !isPattern(output)) {
return; // no blanks.
}
@@ -232,34 +233,17 @@ public class PatternTermContainer extends MEMonitorableContainer
this.patternSlotIN.setStack(ItemStack.EMPTY);
}
// add a new encoded pattern.
Optional<ItemStack> maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack(1);
if (maybePattern.isPresent()) {
output = maybePattern.get();
this.patternSlotOUT.setStack(output);
}
// let the crafting helper create a new encoded pattern
output = null;
}
// encode the slot.
final CompoundTag encodedValue = new CompoundTag();
final ListTag tagIn = new ListTag();
final ListTag tagOut = new ListTag();
for (final ItemStack i : in) {
tagIn.add(this.createItemTag(i));
if (this.isCraftingMode()) {
output = craftingHelper.encodeCraftingPattern(output, this.currentRecipe, in, out[0], isSubstitute());
} else {
output = craftingHelper.encodeProcessingPattern(output, in, out);
}
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() {
@@ -313,22 +297,8 @@ public class PatternTermContainer extends MEMonitorableContainer
return false;
}
final IDefinitions definitions = AEApi.instance().definitions();
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;
final IDefinitions definitions = Api.instance().definitions();
return definitions.materials().blankPattern().isSameAs(output);
}
@Override
@@ -386,7 +356,7 @@ public class PatternTermContainer extends MEMonitorableContainer
}
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 ItemStack is = r.craft(ic);
@@ -28,11 +28,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.container.AEBaseContainer;
import appeng.container.ContainerLocator;
import appeng.container.slot.OutputSlot;
import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.items.contents.QuartzKnifeObj;
import appeng.items.materials.MaterialItem;
import appeng.tile.inventory.AppEngInternalInventory;
@@ -113,7 +113,7 @@ public class QuartzKnifeContainer extends AEBaseContainer {
if (RestrictedInputSlot.isMetalIngot(input)) {
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();
compound.putString(MaterialItem.TAG_INSCRIBE_NAME, QuartzKnifeContainer.this.myName);
@@ -26,7 +26,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions;
import appeng.api.features.INetworkEncodable;
import appeng.api.features.IWirelessTermHandler;
@@ -36,6 +35,7 @@ import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.OutputSlot;
import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.misc.SecurityStationBlockEntity;
import appeng.util.inv.IAEAppEngInventory;
@@ -150,7 +150,7 @@ public class SecurityStationContainer extends MEMonitorableContainer implements
networkEncodable = (INetworkEncodable) term.getItem();
}
final IWirelessTermHandler wTermHandler = AEApi.instance().registries().wireless()
final IWirelessTermHandler wTermHandler = Api.instance().registries().wireless()
.getWirelessTerminalHandler(term);
if (wTermHandler != null) {
networkEncodable = wTermHandler;
@@ -27,7 +27,6 @@ import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.FuzzyMode;
import appeng.api.config.SecurityPermissions;
@@ -43,6 +42,7 @@ import appeng.container.guisync.GuiSync;
import appeng.container.slot.FakeTypeOnlySlot;
import appeng.container.slot.OptionalTypeOnlyFakeSlot;
import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.parts.misc.StorageBusPart;
import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil;
@@ -155,7 +155,7 @@ public class StorageBusContainer extends UpgradeableContainer {
Iterator<IAEItemStack> i = new NullIterator<>();
if (cellInv != null) {
final IItemList<IAEItemStack> list = cellInv.getAvailableItems(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
i = list.iterator();
}
@@ -33,7 +33,6 @@ import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.IActionSource;
@@ -44,6 +43,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull;
import appeng.container.implementations.CraftingTermContainer;
import appeng.core.Api;
import appeng.helpers.IContainerCraftingPacket;
import appeng.helpers.InventoryAction;
import appeng.items.storage.ViewCellItem;
@@ -100,7 +100,7 @@ public class CraftingTermSlot extends AppEngCraftingSlot {
}
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();
int maxTimesToCraft = 0;
@@ -22,11 +22,11 @@ import alexiil.mc.lib.attributes.item.FixedItemInv;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.core.Api;
import appeng.core.sync.BasePacket;
import appeng.core.sync.packets.PatternSlotPacket;
import appeng.helpers.IContainerCraftingPacket;
@@ -48,7 +48,7 @@ public class PatternTermSlot extends CraftingTermSlot {
public BasePacket getRequest(final boolean shift) {
return new PatternSlotPacket(this.getPattern(),
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(this.getStack()),
Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(this.getStack()),
shift);
}
@@ -35,18 +35,18 @@ import net.minecraft.tag.Tag;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.crafting.ICraftingHelper;
import appeng.api.definitions.IDefinitions;
import appeng.api.definitions.IItems;
import appeng.api.definitions.IMaterials;
import appeng.api.features.INetworkEncodable;
import appeng.api.implementations.ICraftingPatternItem;
import appeng.api.implementations.items.IBiometricCard;
import appeng.api.implementations.items.ISpatialStorageCell;
import appeng.api.implementations.items.IStorageComponent;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.networking.crafting.ICraftingPatternDetails;
import appeng.api.storage.cells.ICellWorkbenchItem;
import appeng.core.Api;
import appeng.items.misc.EncodedPatternItem;
import appeng.recipes.handlers.GrinderRecipes;
import appeng.tile.misc.InscriberRecipes;
@@ -90,10 +90,7 @@ public class RestrictedInputSlot extends AppEngSlot {
public boolean isValid(final ItemStack is, final World theWorld) {
if (this.which == PlacableItemType.VALID_ENCODED_PATTERN_W_OUTPUT) {
final ICraftingPatternDetails ap = is.getItem() instanceof ICraftingPatternItem
? ((ICraftingPatternItem) is.getItem()).getPatternForItem(is, theWorld)
: null;
return ap != null;
return Api.instance().crafting().decodePattern(is, theWorld) != null;
}
return true;
}
@@ -125,42 +122,27 @@ public class RestrictedInputSlot extends AppEngSlot {
return false;
}
final IDefinitions definitions = AEApi.instance().definitions();
final IDefinitions definitions = Api.instance().definitions();
final IMaterials materials = definitions.materials();
final IItems items = definitions.items();
final ICraftingHelper crafting = Api.instance().crafting();
switch (this.which) {
case ENCODED_CRAFTING_PATTERN:
if (i.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem b = (ICraftingPatternItem) i.getItem();
final ICraftingPatternDetails de = b.getPatternForItem(i, this.p.player.world);
if (de != null) {
return de.isCraftable();
}
final ICraftingPatternDetails de = crafting.decodePattern(i, this.p.player.world);
if (de != null) {
return de.isCraftable();
}
return false;
case VALID_ENCODED_PATTERN_W_OUTPUT:
case ENCODED_PATTERN_W_OUTPUT:
case ENCODED_PATTERN: {
if (i.getItem() instanceof ICraftingPatternItem) {
return true;
}
// ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem
// ?
// ((ICraftingPatternItem)
// i.getItem()).getPatternForItem( i ) : null;
return false;// pattern != null;
}
case ENCODED_PATTERN:
return crafting.isEncodedPattern(i);
case BLANK_PATTERN:
return materials.blankPattern().isSameAs(i);
case PATTERN:
if (i.getItem() instanceof ICraftingPatternItem) {
return true;
}
return materials.blankPattern().isSameAs(i);
return materials.blankPattern().isSameAs(i) || crafting.isEncodedPattern(i);
case INSCRIBER_PLATE:
if (materials.namePress().isSameAs(i)) {
@@ -197,14 +179,14 @@ public class RestrictedInputSlot extends AppEngSlot {
return i.getItem() instanceof ISpatialStorageCell
&& ((ISpatialStorageCell) i.getItem()).isSpatialStorage(i);
case STORAGE_CELLS:
return AEApi.instance().registries().cell().isCellHandled(i);
return Api.instance().registries().cell().isCellHandled(i);
case WORKBENCH_CELL:
return i.getItem() instanceof ICellWorkbenchItem && ((ICellWorkbenchItem) i.getItem()).isEditable(i);
case STORAGE_COMPONENT:
return i.getItem() instanceof IStorageComponent
&& ((IStorageComponent) i.getItem()).isStorageComponent(i);
case TRASH:
if (AEApi.instance().registries().cell().isCellHandled(i)) {
if (Api.instance().registries().cell().isCellHandled(i)) {
return false;
}
@@ -212,7 +194,7 @@ public class RestrictedInputSlot extends AppEngSlot {
&& ((IStorageComponent) i.getItem()).isStorageComponent(i));
case ENCODABLE_ITEM:
return i.getItem() instanceof INetworkEncodable
|| AEApi.instance().registries().wireless().isWirelessTerminal(i);
|| Api.instance().registries().wireless().isWirelessTerminal(i);
case BIOMETRIC_CARD:
return i.getItem() instanceof IBiometricCard;
case UPGRADES:
+9
View File
@@ -99,6 +99,7 @@ public final class AEConfig {
// Spatial IO/Dimension
private double spatialPowerExponent;
private double spatialPowerMultiplier;
private boolean spatialBlockTags;
// Grindstone
private float oreDoublePercentage;
@@ -191,6 +192,7 @@ public final class AEConfig {
this.spatialPowerMultiplier = commonConfig.spatialPowerMultiplier.get();
this.spatialPowerExponent = commonConfig.spatialPowerExponent.get();
this.spatialBlockTags = commonConfig.spatialBlockTags.get();
this.craftingCalculationTimePerTick = commonConfig.craftingCalculationTimePerTick.get();
@@ -311,6 +313,10 @@ public final class AEConfig {
return this.spatialPowerMultiplier;
}
public boolean getSpatialBlockTags() {
return this.spatialBlockTags;
}
public float getOreDoublePercentage() {
return this.oreDoublePercentage;
}
@@ -428,6 +434,7 @@ public final class AEConfig {
// Spatial IO/Dimension
public final DoubleOption spatialPowerExponent;
public final DoubleOption spatialPowerMultiplier;
public final BooleanOption spatialBlockTags;
// Grindstone
public final DoubleOption oreDoublePercentage;
@@ -504,6 +511,8 @@ public final class AEConfig {
ConfigSection spatialio = root.subsection("spatialio");
this.spatialPowerMultiplier = spatialio.addDouble("spatialPowerMultiplier", 1250.0);
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");
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;
import appeng.api.AEAddon;
import appeng.api.IAppEngApi;
import appeng.api.client.IClientHelper;
import appeng.api.crafting.ICraftingHelper;
import appeng.api.features.IRegistryContainer;
import appeng.api.networking.IGridHelper;
import appeng.api.storage.IStorageHelper;
import appeng.api.util.IClientHelper;
import appeng.core.api.ApiClientHelper;
import appeng.core.api.ApiCrafting;
import appeng.core.api.ApiGrid;
import appeng.core.api.ApiPart;
import appeng.core.api.ApiStorage;
@@ -31,14 +34,33 @@ import appeng.core.features.registries.PartModels;
import appeng.core.features.registries.RegistryContainer;
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;
/**
* 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 IRegistryContainer registryContainer;
private final IStorageHelper storageHelper;
private final IGridHelper networkHelper;
private final ApiDefinitions definitions;
private final ICraftingHelper craftingHelper;
private final IClientHelper client;
public Api() {
@@ -47,7 +69,8 @@ public final class Api implements IAppEngApi {
this.registryContainer = new RegistryContainer();
this.partHelper = new ApiPart();
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() {
@@ -64,6 +87,11 @@ public final class Api implements IAppEngApi {
return this.storageHelper;
}
@Override
public ICraftingHelper crafting() {
return this.craftingHelper;
}
@Override
public IGridHelper grid() {
return this.networkHelper;
@@ -1,5 +1,6 @@
/*
* 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
@@ -23,14 +24,24 @@ import java.util.List;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import appeng.api.client.ICellModelRegistry;
import appeng.api.client.IClientHelper;
import appeng.api.config.IncludeExclude;
import appeng.api.storage.cells.ICellInventory;
import appeng.api.storage.cells.ICellInventoryHandler;
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;
public class ApiClientHelper implements IClientHelper {
private final ICellModelRegistry cells;
public ApiClientHelper(ApiDefinitions definitions) {
this.cells = new ApiCellModelRegistry(definitions);
}
@Override
public <T extends IAEStack<T>> void addCellInformation(ICellInventoryHandler<T> handler,
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.model.AutoRotatingBakedModel;
import appeng.client.render.spatial.SpatialPylonRendering;
import appeng.client.render.tesr.ChestTileEntityRenderer;
import appeng.client.render.tesr.CrankTESR;
import appeng.client.render.tesr.DriveLedTileEntityRenderer;
import appeng.client.render.tesr.SkyChestTESR;
@@ -362,7 +363,14 @@ public final class ApiBlocks implements IBlocks {
}).build())
.rendering(new DriveRendering()).build();
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();
this.iface = registry.block("interface", InterfaceBlock::new).features(AEFeature.INTERFACE)
.tileEntity(
@@ -36,13 +36,50 @@ import appeng.core.features.ActivityState;
import appeng.core.features.ColoredItemDefinition;
import appeng.core.features.ItemStackSrc;
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.PartItem;
import appeng.items.parts.PartItemRendering;
import appeng.items.parts.PartModelsHelper;
import appeng.parts.misc.*;
import appeng.parts.networking.*;
import appeng.parts.reporting.*;
import appeng.parts.automation.AnnihilationPlanePart;
import appeng.parts.automation.ExportBusPart;
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
@@ -29,7 +29,6 @@ import appeng.api.networking.IGrid;
import appeng.api.networking.IGridCache;
import appeng.api.networking.IGridCacheFactory;
import appeng.api.networking.IGridCacheRegistry;
import appeng.core.AELog;
public final class GridCacheRegistry implements IGridCacheRegistry {
@@ -19,29 +19,45 @@
package appeng.core.features.registries;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.Tag;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.util.ResourceLocation;
import appeng.api.exceptions.AppEngException;
import appeng.api.movable.IMovableHandler;
import appeng.api.movable.IMovableRegistry;
import appeng.api.movable.IMovableTile;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.spatial.DefaultSpatialHandler;
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<IMovableHandler> handlers = new ArrayList<>();
private final DefaultSpatialHandler dsh = 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
public void blacklistBlock(final Block blk) {
@@ -60,8 +76,8 @@ public class MovableTileRegistry implements IMovableRegistry {
@Override
public boolean askToMove(final BlockEntity te) {
final Class myClass = te.getClass();
IMovableHandler canMove = this.Valid.get(myClass);
final Class<? extends BlockEntity> myClass = te.getClass();
IMovableHandler canMove = this.valid.get(myClass);
if (canMove == null) {
canMove = this.testClass(myClass, te);
@@ -79,7 +95,7 @@ public class MovableTileRegistry implements IMovableRegistry {
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;
// ask handlers...
@@ -92,25 +108,32 @@ public class MovableTileRegistry implements IMovableRegistry {
// if you have a handler your opted in
if (handler != null) {
this.Valid.put(myClass, handler);
this.valid.put(myClass, handler);
return handler;
}
// if your movable our opted in
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;
}
// if you are on the white list your opted in.
for (final Class<? extends BlockEntity> testClass : this.test) {
if (testClass.isAssignableFrom(myClass)) {
this.Valid.put(myClass, this.dsh);
this.valid.put(myClass, this.dsh);
return this.dsh;
}
}
this.Valid.put(myClass, this.nullHandler);
this.valid.put(myClass, this.nullHandler);
return this.nullHandler;
}
@@ -129,8 +152,8 @@ public class MovableTileRegistry implements IMovableRegistry {
@Override
public IMovableHandler getHandler(final BlockEntity te) {
final Class myClass = te.getClass();
final IMovableHandler h = this.Valid.get(myClass);
final Class<? extends BlockEntity> myClass = te.getClass();
final IMovableHandler h = this.valid.get(myClass);
return h == null ? this.dsh : h;
}
@@ -141,6 +164,6 @@ public class MovableTileRegistry implements IMovableRegistry {
@Override
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.Identifier;
import appeng.api.AEApi;
import appeng.api.config.TunnelType;
import appeng.api.definitions.IBlocks;
import appeng.api.definitions.IDefinitions;
@@ -43,6 +42,7 @@ import appeng.api.definitions.IParts;
import appeng.api.features.IP2PTunnelRegistry;
import appeng.api.util.AEColor;
import net.minecraft.util.registry.Registry;
import appeng.core.Api;
public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
private static final int INITIAL_CAPACITY = 40;
@@ -53,7 +53,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry {
public void configure() {
final IDefinitions definitions = AEApi.instance().definitions();
final IDefinitions definitions = Api.instance().definitions();
final IBlocks blocks = definitions.blocks();
final IParts parts = definitions.parts();
@@ -27,10 +27,13 @@ import net.minecraft.util.Hand;
import net.minecraft.util.Util;
import net.minecraft.world.BlockView;
import appeng.api.AEApi;
import appeng.api.features.ILocatable;
import appeng.api.features.IWirelessTermHandler;
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.util.Platform;
@@ -87,7 +90,7 @@ public final class WirelessRegistry implements IWirelessTermRegistry {
}
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) {
player.sendSystemMessage(PlayerMessages.StationCanNotBeLocated.get(), Util.NIL_UUID);
return;
@@ -18,6 +18,12 @@
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 net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
@@ -8,7 +8,6 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.api.storage.IMEInventoryHandler;
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.channels.IItemStorageChannel;
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 {
@Override
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
@@ -20,13 +20,13 @@ package appeng.core.features.registries.cell;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.cells.CellState;
import appeng.api.storage.cells.ICellHandler;
import appeng.api.storage.cells.ICellInventoryHandler;
import appeng.api.storage.cells.ISaveProvider;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.core.Api;
import appeng.items.storage.CreativeStorageCellItem;
import appeng.me.storage.CreativeCellInventory;
@@ -40,7 +40,7 @@ public final class CreativeCellHandler implements ICellHandler {
@Override
public ICellInventoryHandler getCellInventory(final ItemStack is, final ISaveProvider container,
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) {
return CreativeCellInventory.getCell(is);
}
@@ -101,6 +101,7 @@ public class BlockTransitionEffectPacket extends BasePacket {
playBreakOrPickupSound();
}
@OnlyIn(Dist.CLIENT)
private void spawnParticles() {
EnergyParticleData data = new EnergyParticleData(false, direction);
@@ -119,6 +120,7 @@ public class BlockTransitionEffectPacket extends BasePacket {
}
}
@OnlyIn(Dist.CLIENT)
private void playBreakOrPickupSound() {
SoundEvent soundEvent;
@@ -31,7 +31,6 @@ import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import appeng.api.AEApi;
import appeng.api.definitions.IComparableDefinition;
import appeng.api.definitions.IItems;
import appeng.api.implementations.items.IMemoryCard;
@@ -40,6 +39,7 @@ import appeng.block.networking.CableBusBlock;
import appeng.container.ContainerLocator;
import appeng.container.ContainerOpener;
import appeng.container.implementations.NetworkToolContainer;
import appeng.core.Api;
import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo;
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 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 maybeColorApplicator = items.colorApplicator();
@@ -101,7 +101,7 @@ public class CraftRequestPacket extends BasePacket {
if (futureJob != null) {
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.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
@@ -41,6 +40,7 @@ import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.Api;
import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.helpers.IContainerCraftingPacket;
@@ -113,7 +113,7 @@ public class JEIRecipePacket extends BasePacket {
if (inv != null && this.recipe != null && security != null) {
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());
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.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.implementations.PatternTermContainer;
import appeng.core.Api;
import appeng.core.sync.BasePacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.util.item.AEItemStack;
@@ -76,7 +76,7 @@ public class PatternSlotPacket extends BasePacket {
this.writeItem(slotItem, data);
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));
this.writeItem(this.pattern[x], data);
}
@@ -27,7 +27,6 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.networking.IGrid;
import appeng.api.networking.IGridHost;
@@ -44,6 +43,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.DimensionalCoord;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.hooks.TickHandler;
public class CraftingJob implements Runnable, ICraftingJob {
@@ -52,9 +52,9 @@ public class CraftingJob implements Runnable, ICraftingJob {
private final MECraftingInventory original;
private final World world;
private final IItemList<IAEItemStack> crafting = AEApi.instance().storage()
private final IItemList<IAEItemStack> crafting = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList();
private final IItemList<IAEItemStack> missing = AEApi.instance().storage()
private final IItemList<IAEItemStack> missing = Api.instance().storage()
.getStorageChannel(IItemStorageChannel.class).createList();
private final HashMap<String, TwoIntegers> opsAndMultiplier = new HashMap<>();
private final Object monitor = new Object();
@@ -85,7 +85,7 @@ public class CraftingJob implements Runnable, ICraftingJob {
final ICraftingGrid cc = grid.getCache(ICraftingGrid.class);
final IStorageGrid sg = grid.getCache(IStorageGrid.class);
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);
this.setTree(this.getCraftingTree(cc, what));
@@ -26,7 +26,6 @@ import com.google.common.collect.Lists;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.FuzzyMode;
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.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.core.Api;
import appeng.me.cluster.implementations.CraftingCPUCluster;
public class CraftingTreeNode {
@@ -42,7 +42,7 @@ public class CraftingTreeNode {
// what slot!
private final int slot;
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();
// parent node.
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.IItemList;
import appeng.container.ContainerNull;
import appeng.core.Api;
import appeng.me.cluster.implementations.CraftingCPUCluster;
import appeng.util.Platform;
import net.minecraft.inventory.CraftingInventory;
@@ -179,7 +180,7 @@ public class CraftingTreeProcess {
ItemStack is = ic.getStack(x);
is = Platform.getRecipeRemainder(is);
final IAEItemStack o = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
final IAEItemStack o = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createStack(is);
if (o != null) {
this.bytes++;
@@ -194,7 +195,7 @@ public class CraftingTreeProcess {
if (this.containerItems) {
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);
if (o != null) {
this.bytes++;
@@ -18,7 +18,6 @@
package appeng.crafting;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.networking.security.IActionSource;
import appeng.api.storage.IMEInventory;
@@ -27,6 +26,7 @@ import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.core.Api;
import appeng.util.inv.ItemListIgnoreCrafting;
public class MECraftingInventory implements IMEInventory<IAEItemStack> {
@@ -47,7 +47,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack> {
public MECraftingInventory() {
this.localCache = new ItemListIgnoreCrafting<>(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
this.extractedCache = null;
this.injectedCache = null;
this.missingCache = null;
@@ -65,25 +65,25 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack> {
this.logMissing = parent.logMissing;
if (this.logMissing) {
this.missingCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.missingCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else {
this.missingCache = null;
}
if (this.logExtracted) {
this.extractedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.extractedCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else {
this.extractedCache = null;
}
if (this.logInjections) {
this.injectedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.injectedCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else {
this.injectedCache = null;
}
this.localCache = this.target.getAvailableItems(new ItemListIgnoreCrafting<>(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()));
Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList()));
this.par = parent;
}
@@ -96,25 +96,25 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack> {
this.logMissing = logMissing;
if (logMissing) {
this.missingCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.missingCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else {
this.missingCache = null;
}
if (logExtracted) {
this.extractedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.extractedCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else {
this.extractedCache = null;
}
if (logInjections) {
this.injectedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.injectedCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else {
this.injectedCache = null;
}
this.localCache = new ItemListIgnoreCrafting<>(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
for (final IAEItemStack is : target.getStorageList()) {
this.localCache.add(target.extractItems(is, Actionable.SIMULATE, src));
}
@@ -130,25 +130,25 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack> {
this.logMissing = logMissing;
if (logMissing) {
this.missingCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.missingCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else {
this.missingCache = null;
}
if (logExtracted) {
this.extractedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.extractedCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else {
this.extractedCache = null;
}
if (logInjections) {
this.injectedCache = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
this.injectedCache = Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
} else {
this.injectedCache = null;
}
this.localCache = target.getAvailableItems(
AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
this.localCache = target
.getAvailableItems(Api.instance().storage().getStorageChannel(IItemStorageChannel.class).createList());
this.par = null;
}
@@ -214,7 +214,7 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack> {
@Override
public IStorageChannel getChannel() {
return AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
return Api.instance().storage().getStorageChannel(IItemStorageChannel.class);
}
public IItemList<IAEItemStack> getItemList() {
@@ -222,9 +222,9 @@ public class MECraftingInventory implements IMEInventory<IAEItemStack> {
}
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();
final IItemList<IAEItemStack> pulled = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class)
final IItemList<IAEItemStack> pulled = Api.instance().storage().getStorageChannel(IItemStorageChannel.class)
.createList();
boolean failed = false;
@@ -31,6 +31,7 @@ import net.minecraft.block.entity.BlockEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.math.Direction;
@@ -56,10 +57,31 @@ public class ReplicatorCardItem extends AEBaseItem implements AEToolItem {
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
public ActionResult onItemUseFirst(ItemStack stack, ItemUsageContext context) {
if (context.getWorld().isClient()) {
return ActionResult.PASS;
// Needed, otherwise client will trigger onItemRightClick also on server...
return ActionResult.SUCCESS;
}
PlayerEntity player = context.getPlayer();
@@ -78,13 +100,15 @@ public class ReplicatorCardItem extends AEBaseItem implements AEToolItem {
if (player.isInSneakingPose()) {
if (world.getBlockEntity(pos) instanceof IGridHost) {
final CompoundTag tag = new CompoundTag();
final CompoundTag tag = player.getStackInHand(hand).getOrCreateTag();
tag.putInt("x", x);
tag.putInt("y", y);
tag.putInt("z", z);
tag.putInt("side", side.ordinal());
tag.putString("w", world.getRegistryKey().getValue().toString());
player.getStackInHand(hand).setTag(tag);
tag.putInt("r", 0);
this.outputMsg(player, "Set replicator source");
} else {
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 String worldId = ish.getString("w");
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));
if (te instanceof IGridHost) {
@@ -104,50 +129,73 @@ public class ReplicatorCardItem extends AEBaseItem implements AEToolItem {
final Direction sideOff = Direction.values()[src_side];
final Direction currentSideOff = side;
final IGridNode n = gh.getGridNode(AEPartLocation.fromFacing(sideOff));
if (n != null) {
final IGrid g = n.getGrid();
if (g != null) {
final ISpatialCache sc = g.getCache(ISpatialCache.class);
if (sc.isValidRegion()) {
final DimensionalCoord min = sc.getMin();
final DimensionalCoord max = sc.getMax();
x += currentSideOff.getOffsetX();
y += currentSideOff.getOffsetY();
z += currentSideOff.getOffsetZ();
// TODO: Why??? Places it one block up each time...
// x += currentSideOff.getOffsetX();
// 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_y = min.y;
final int min_z = min.z;
final int rel_x = min.x - src_x + x;
final int rel_y = min.y - src_y + y;
final int rel_z = min.z - src_z + z;
// Invert to maintain correct sign for west/east
final int x_rot = (int) -Math.signum(MathHelper.wrapDegrees(player.rotationYaw));
// 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;
final int scale_y = max.y - min.y;
final int scale_z = max.z - min.z;
// Loops for replication in each direction
for (int r_x = 0; r_x < replications; r_x++) {
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++) {
for (int j = 1; j < scale_y; j++) {
for (int k = 1; k < scale_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);
// Offset x/z by the rotation index.
// For sake of simplicity always grow upwards.
final int rel_x = min.x - src_x + x + (r_x * sc_size_x * x_rot);
final int rel_y = min.y - src_y + y + (r_y * sc_size_y);
final int rel_z = min.z - src_z + z + (r_z * sc_size_z * z_rot);
world.setBlockState(d, state);
if (blk instanceof BlockEntityProvider) {
// Copy a single SC instance completely
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;
final BlockEntity ote = src_w.getBlockEntity(p);
final BlockEntity nte = blkEntityProvider.createBlockEntity(world);
final CompoundTag data = new CompoundTag();
ote.toTag(data);
nte.fromTag(state, data.copy());
world.setBlockEntity(d, nte);
final BlockEntity ote = src_w.getBlockEntity(p);
final BlockEntity nte = blkEntityProvider.createBlockEntity(world);
final CompoundTag data = new CompoundTag();
ote.toTag(data);
nte.fromTag(state, data.copy());
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.world.World;
import appeng.api.AEApi;
import appeng.api.definitions.IMaterials;
import appeng.api.features.AEFeature;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.core.AppEng;
import appeng.util.Platform;
public final class ChargedQuartzEntity extends AEBaseItemEntity {
@@ -92,7 +93,7 @@ public final class ChargedQuartzEntity extends AEBaseItemEntity {
private boolean transform() {
final ItemStack item = this.getStack();
final IMaterials materials = AEApi.instance().definitions().materials();
final IMaterials materials = Api.instance().definitions().materials();
if (materials.certusQuartzCrystalCharged().isSameAs(item)) {
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.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.Box;
import net.minecraft.world.World;
import appeng.api.AEApi;
import appeng.api.definitions.IMaterials;
import appeng.api.features.AEFeature;
import appeng.core.AEConfig;
import appeng.core.Api;
import appeng.util.Platform;
public final class SingularityEntity extends AEBaseItemEntity {
private static final ResourceLocation TAG_ENDER_PEARL = new ResourceLocation("forge:ender_pearls");
public static EntityType<SingularityEntity> TYPE;
private static int randTickSeed = 0;
@@ -71,7 +74,7 @@ public final class SingularityEntity extends AEBaseItemEntity {
final ItemStack item = this.getStack();
final IMaterials materials = AEApi.instance().definitions().materials();
final IMaterials materials = Api.instance().definitions().materials();
if (materials.singularity().isSameAs(item)) {
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()) {
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) {
while (item.getCount() > 0 && other.getCount() > 0) {
other.increment(-1);
@@ -26,11 +26,11 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.api.parts.IFacadeContainer;
import appeng.api.parts.IFacadePart;
import appeng.api.parts.IPartHost;
import appeng.api.util.AEPartLocation;
import appeng.core.Api;
import appeng.items.parts.FacadeItem;
import appeng.parts.CableBusStorage;
@@ -110,7 +110,7 @@ public class FacadeContainer implements IFacadeContainer {
if ((facadeSides & ix) == ix) {
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();
if (maybeFacadeItem.isPresent()) {
final FacadeItem ifa = (FacadeItem) maybeFacadeItem.get();
@@ -26,7 +26,6 @@ import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.network.PacketByteBuf;
import alexiil.mc.lib.attributes.item.FixedItemInv;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
import appeng.api.config.FuzzyMode;
import appeng.api.config.SecurityPermissions;
@@ -41,6 +40,7 @@ import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync;
import appeng.container.implementations.ContainerHelper;
import appeng.container.slot.RestrictedInputSlot;
import appeng.core.Api;
import appeng.fluids.parts.FluidStorageBusPart;
import appeng.fluids.util.IAEFluidTank;
import appeng.util.Platform;
@@ -162,7 +162,7 @@ public class FluidStorageBusContainer extends FluidConfigurableContainer {
Iterator<IAEFluidStack> i = new NullIterator<>();
if (cellInv != null) {
final IItemList<IAEFluidStack> list = cellInv.getAvailableItems(
AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class).createList());
Api.instance().storage().getStorageChannel(IFluidStorageChannel.class).createList());
i = list.iterator();
}
@@ -40,7 +40,6 @@ import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketByteBuf;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.SecurityPermissions;
@@ -70,6 +69,7 @@ import appeng.container.ContainerLocator;
import appeng.container.guisync.GuiSync;
import appeng.container.implementations.ContainerHelper;
import appeng.core.AELog;
import appeng.core.Api;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.ConfigValuePacket;
import appeng.core.sync.packets.MEFluidInventoryUpdatePacket;
@@ -104,7 +104,7 @@ public class FluidTerminalContainer extends AEBaseContainer
private final IConfigManager clientCM;
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();
@GuiSync(99)
public boolean hasPower = false;
@@ -126,7 +126,7 @@ public class FluidTerminalContainer extends AEBaseContainer
if (Platform.isServer()) {
this.serverCM = terminal.getConfigManager();
this.monitor = terminal
.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
.getInventory(Api.instance().storage().getStorageChannel(IFluidStorageChannel.class));
if (this.monitor != null) {
this.monitor.addListener(this, null);
@@ -252,7 +252,7 @@ public class FluidTerminalContainer extends AEBaseContainer
public void sendContentUpdates() {
if (Platform.isServer()) {
if (this.monitor != this.terminal
.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class))) {
.getInventory(Api.instance().storage().getStorageChannel(IFluidStorageChannel.class))) {
this.setValidContainer(false);
}
@@ -26,7 +26,6 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.block.entity.BlockEntity;
import alexiil.mc.lib.attributes.fluid.volume.FluidVolume;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
@@ -53,6 +52,8 @@ import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.api.util.DimensionalCoord;
import appeng.api.util.IConfigManager;
import appeng.capabilities.Capabilities;
import appeng.core.Api;
import appeng.core.settings.TickRates;
import appeng.fluids.util.AEFluidInventory;
import appeng.fluids.util.IAEFluidInventory;
@@ -86,10 +87,9 @@ public class DualityFluidInterface
private int priority;
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<>(
new NullInventory<IAEFluidStack>(),
AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class));
new NullInventory<IAEFluidStack>(), Api.instance().storage().getStorageChannel(IFluidStorageChannel.class));
public DualityFluidInterface(final AENetworkProxy networkProxy, final IFluidInterfaceHost ih) {
this.gridProxy = networkProxy;
@@ -120,13 +120,13 @@ public class DualityFluidInterface
@Override
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()) {
return null;
}
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()) {
return (IMEMonitor<T>) new InterfaceInventory(this);
}
@@ -180,9 +180,9 @@ public class DualityFluidInterface
public void gridChanged() {
try {
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()
.getInventory(AEApi.instance().storage().getStorageChannel(IFluidStorageChannel.class)));
.getInventory(Api.instance().storage().getStorageChannel(IFluidStorageChannel.class)));
} catch (final GridAccessException gae) {
this.items.setInternal(new NullInventory<IAEItemStack>());
this.fluids.setInternal(new NullInventory<IAEFluidStack>());
@@ -296,7 +296,7 @@ public class DualityFluidInterface
boolean changed = false;
try {
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();
if (work.getStackSize() > 0) {

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