aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorGlease <4586901+Glease@users.noreply.github.com>2021-07-30 17:34:20 +0800
committerGlease <4586901+Glease@users.noreply.github.com>2021-07-30 17:34:20 +0800
commitea5c515f4769fa83f4eb6268f0b8048f76fbb0ac (patch)
treebe8869a6318dcec84cffab392e12d4ff17984d69 /src/main
parent1f862e953334cee47a942df3847dcab13ffcc54c (diff)
downloadGT5-Unofficial-ea5c515f4769fa83f4eb6268f0b8048f76fbb0ac.tar.gz
GT5-Unofficial-ea5c515f4769fa83f4eb6268f0b8048f76fbb0ac.tar.bz2
GT5-Unofficial-ea5c515f4769fa83f4eb6268f0b8048f76fbb0ac.zip
Make GT_MetaTileEntity_CubicMultiBlockBase easier to use
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java55
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java5
2 files changed, 55 insertions, 5 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java
index fa7bb739a9..de36b845b2 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java
@@ -13,19 +13,56 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose
import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
/**
- * A simple 3x3x3 hollow cubic multiblock, that can be arbitrarily rotated, made of a single type of machine casing and accepts hatches everywhere.
+ * A simple 3x3x3 hollow cubic multiblock, that can be arbitrarily rotated, made of a single type of machine casing, accepts hatches everywhere.
+ *
* Controller will be placed in front center of the structure.
* <p>
* Note: You cannot use different casing for the same Class. Make a new subclass for it. You also should not change the casing
* dynamically, i.e. it should be a dumb method returning some sort of constant.
* <p>
* Implementation tips:
- * 1. To restrict hatches, override {@link #addDynamoToMachineList(IGregTechTileEntity, int)} and its cousins instead of overriding the whole
+ * <ul>
+ * <li>To restrict hatches, override {@link #addDynamoToMachineList(IGregTechTileEntity, int)} and its cousins instead of overriding the whole
* {@link #getStructureDefinition()} or change {@link #checkHatches(IGregTechTileEntity, ItemStack)}. The former is a total overkill, while the later cannot
* stop the structure check early.
- * 2. To limit rotation, override {@link #getInitialAlignmentLimits()}
- *
- * @param <T>
+ * Example 1: Require ULV input only:
+ * <pre>
+ * {@code
+ * @Override
+ * public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ * if (aTileEntity == null) return false;
+ * IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
+ * if (aMetaTileEntity == null) return false;
+ * if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
+ * if (((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier != 0) return false; // addition
+ * ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ * ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap();
+ * return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity);
+ * }
+ * if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) {
+ * if (((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier != 0) return false; // addition
+ * ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
+ * ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap();
+ * return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity);
+ * }
+ * return false;
+ * }
+ * }</pre>
+ * Example 2: Allow dynamo, muffler and prevent energy hatch
+ * <pre>
+ * {@code
+ * @Override
+ * public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ * return addInputToMachineList(aTileEntity, aBaseCasingIndex) ||
+ * addOutputToMachineList(aTileEntity, aBaseCasingIndex) ||
+ * addDynamoToMachineList(aTileEntity, aBaseCasingIndex) ||
+ * addMufflerToMachineList(aTileEntity, aBaseCasingIndex) ||
+ * addMaintenanceToMachineList(aTileEntity, aBaseCasingIndex);
+ * }
+ * }</pre></li>
+ * <li>To limit rotation, override {@link #getInitialAlignmentLimits()}</li>
+ *</ul>
+ * @param <T> this
*/
public abstract class GT_MetaTileEntity_CubicMultiBlockBase<T extends GT_MetaTileEntity_CubicMultiBlockBase<T>> extends GT_MetaTileEntity_EnhancedMultiBlockBase<T> {
protected static final String STRUCTURE_PIECE_MAIN = "main";
@@ -58,6 +95,14 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase<T extends GT_MetaTil
super(aName);
}
+ @Override
+ public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ return addInputToMachineList(aTileEntity, aBaseCasingIndex) ||
+ addOutputToMachineList(aTileEntity, aBaseCasingIndex) ||
+ addEnergyInputToMachineList(aTileEntity, aBaseCasingIndex) ||
+ addMaintenanceToMachineList(aTileEntity, aBaseCasingIndex);
+ }
+
/**
* Create a simple 3x3x3 hollow cubic structure made of a single type of machine casing and accepts hatches everywhere.
* <p>
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java
index 86792ac81d..b71d01ec07 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ImplosionCompressor.java
@@ -61,6 +61,11 @@ public class GT_MetaTileEntity_ImplosionCompressor extends GT_MetaTileEntity_Cub
}
@Override
+ public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
+ return super.addToMachineList(aTileEntity, aBaseCasingIndex) || addMufflerToMachineList(aTileEntity, aBaseCasingIndex);
+ }
+
+ @Override
public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
if (aSide == aFacing) {
if (aActive) return new ITexture[]{