From de8829ca474fd3a8e7b3d4c64d5c70b00c8070e0 Mon Sep 17 00:00:00 2001
From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com>
Date: Thu, 29 Jul 2021 19:11:41 -0600
Subject: Oredict clay buckets + fix railcraft item IDs
---
src/main/java/gregtech/api/util/GT_ModHandler.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'src/main/java/gregtech/api')
diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java
index 7e66e6cc2a..ac9f7bd3d4 100644
--- a/src/main/java/gregtech/api/util/GT_ModHandler.java
+++ b/src/main/java/gregtech/api/util/GT_ModHandler.java
@@ -383,14 +383,14 @@ public class GT_ModHandler {
}
/**
- * Gets an Item from RailCraft
+ * Gets an Item from the specified mod
*/
public static ItemStack getModItem(String aModID, String aItem, long aAmount) {
return getModItem(aModID, aItem, aAmount, null);
}
/**
- * Gets an Item from RailCraft, and returns a Replacement Item if not possible
+ * Gets an Item from the specified mod, and returns a Replacement Item if not possible
*/
public static ItemStack getModItem(String aModID, String aItem, long aAmount, ItemStack aReplacement) {
if (GT_Utility.isStringInvalid(aItem) || !GregTech_API.sPreloadStarted) return null;
@@ -398,7 +398,7 @@ public class GT_ModHandler {
}
/**
- * Gets an Item from RailCraft, but the Damage Value can be specified
+ * Gets an Item from the specified mod, but the Damage Value can be specified
*/
public static ItemStack getModItem(String aModID, String aItem, long aAmount, int aMeta) {
ItemStack rStack = getModItem(aModID, aItem, aAmount);
@@ -408,7 +408,7 @@ public class GT_ModHandler {
}
/**
- * Gets an Item from RailCraft, but the Damage Value can be specified, and returns a Replacement Item with the same Damage if not possible
+ * Gets an Item from the specified mod, but the Damage Value can be specified, and returns a Replacement Item with the same Damage if not possible
*/
public static ItemStack getModItem(String aModID, String aItem, long aAmount, int aMeta, ItemStack aReplacement) {
ItemStack rStack = getModItem(aModID, aItem, aAmount, aReplacement);
--
cgit
From 60782c9fe2699ea43ed90a8eaa800756317dca77 Mon Sep 17 00:00:00 2001
From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com>
Date: Thu, 29 Jul 2021 22:05:04 -0600
Subject: Add clay bucket ore prefix; fix oredicting
---
src/main/java/gregtech/api/enums/OrePrefixes.java | 6 ++++++
1 file changed, 6 insertions(+)
(limited to 'src/main/java/gregtech/api')
diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java
index ba91886c99..3aaea29f28 100644
--- a/src/main/java/gregtech/api/enums/OrePrefixes.java
+++ b/src/main/java/gregtech/api/enums/OrePrefixes.java
@@ -102,6 +102,7 @@ public enum OrePrefixes {
cellMolten("Cells of Molten stuff", "Molten ", " Cell", true, true, true, true, false, false, false, true, false, false, 0, M * 1, 64, 31), // Hot Cell full of molten stuff, which can be used in the Plasma Generator.
cell("Cells", "", " Cell", true, true, true, true, false, false, true, true, false, false, B[4] | B[8], M * 1, 64, 30), // Regular Gas/Fluid Cell. Introduced by Calclavia
bucket("Buckets", "", " Bucket", true, true, true, true, false, false, true, false, false, false, B[4] | B[8], M * 1, 16, -1), // A vanilla Iron Bucket filled with the Material.
+ bucketClay("Clay Buckets", "", " Clay Bucket", true, true, true, true, false, false, true, false, false, false, B[4] | B[8], M * 1, 16, -1), // An Iguana Tweaks Clay Bucket filled with the Material.
bottle("Bottles", "", " Bottle", true, true, true, true, false, false, false, false, false, false, B[4] | B[8], -1, 16, -1), // Glass Bottle containing a Fluid.
capsule("Capsules", "", " Capsule", false, true, true, true, false, false, false, false, false, false, B[4] | B[8], M * 1, 16, -1),
crystal("Crystals", "", " Crystal", false, true, false, false, false, false, true, false, false, false, B[2], M * 1, 64, -1),
@@ -413,6 +414,10 @@ public enum OrePrefixes {
bucket.mNotGeneratedItems.add(Materials.Lava);
bucket.mNotGeneratedItems.add(Materials.Milk);
bucket.mNotGeneratedItems.add(Materials.Water);
+ bucketClay.mNotGeneratedItems.add(Materials.Empty);
+ bucketClay.mNotGeneratedItems.add(Materials.Lava);
+ bucketClay.mNotGeneratedItems.add(Materials.Milk);
+ bucketClay.mNotGeneratedItems.add(Materials.Water);
bottle.mNotGeneratedItems.add(Materials.Empty);
bottle.mNotGeneratedItems.add(Materials.Water);
bottle.mNotGeneratedItems.add(Materials.Milk);
@@ -522,6 +527,7 @@ public enum OrePrefixes {
cableGt02.mSecondaryMaterial = new MaterialStack(Materials.Rubber, plate.mMaterialAmount);
cableGt01.mSecondaryMaterial = new MaterialStack(Materials.Rubber, plate.mMaterialAmount);
bucket.mSecondaryMaterial = new MaterialStack(Materials.Iron, ingot.mMaterialAmount * 3);
+ bucketClay.mSecondaryMaterial = new MaterialStack(Materials.Clay, dust.mMaterialAmount * 5);
cell.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2);
cellPlasma.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2);
cellMolten.mSecondaryMaterial = new MaterialStack(Materials.Tin, plate.mMaterialAmount * 2);
--
cgit
From 412d64445546216444f0afbcc562e2ea6b1681d0 Mon Sep 17 00:00:00 2001
From: Glease <4586901+Glease@users.noreply.github.com>
Date: Fri, 30 Jul 2021 12:41:54 +0800
Subject: Remove debug print
---
src/main/java/gregtech/api/gui/GT_Container_BasicTank.java | 3 ---
1 file changed, 3 deletions(-)
(limited to 'src/main/java/gregtech/api')
diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java
index 0ce9ab9232..477e52d103 100644
--- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java
+++ b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java
@@ -52,9 +52,6 @@ public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine {
IFluidAccess tDrainableAccess = IFluidAccess.from(tTank, false);
return handleFluidSlotClick(tDrainableAccess, aPlayer, aMouseclick == 0, true, !tTank.isDrainableStackSeparate());
}
- if (mTileEntity.isServerSide()) {
- aPlayer.addChatComponentMessage(new ChatComponentText(String.format("Slot Index: %d, aMouseClick: %d, Shift Hold: %d", aShifthold, aMouseclick, aShifthold)));
- }
return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
}
--
cgit
From 546b42d7440839477455b818133d80221c70c582 Mon Sep 17 00:00:00 2001
From: Glease <4586901+Glease@users.noreply.github.com>
Date: Sat, 29 May 2021 23:52:15 +0800
Subject: Initial StructureLib integration
---
.../api/metatileentity/BaseMetaTileEntity.java | 35 +++++-
.../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 122 +++++++++++++++++++++
.../GT_MetaTileEntity_MultiBlockBase.java | 9 +-
.../gregtech/api/util/GT_StructureUtility.java | 71 ++++++++++++
.../java/gregtech/api/util/IGT_HatchAdder.java | 14 +++
5 files changed, 241 insertions(+), 10 deletions(-)
create mode 100644 src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
create mode 100644 src/main/java/gregtech/api/util/GT_StructureUtility.java
create mode 100644 src/main/java/gregtech/api/util/IGT_HatchAdder.java
(limited to 'src/main/java/gregtech/api')
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index 6c43799638..d108236a39 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -8,6 +8,10 @@ import appeng.me.helpers.AENetworkProxy;
import appeng.me.helpers.IGridProxyable;
import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
+import com.gtnewhorizon.structurelib.alignment.IAlignment;
+import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits;
+import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider;
+import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
import cpw.mods.fml.common.Optional;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
@@ -25,11 +29,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachin
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch;
import gregtech.api.net.GT_Packet_TileEntity;
import gregtech.api.objects.GT_ItemStack;
-import gregtech.api.util.GT_CoverBehavior;
-import gregtech.api.util.GT_Log;
-import gregtech.api.util.GT_ModHandler;
-import gregtech.api.util.GT_OreDictUnificator;
-import gregtech.api.util.GT_Utility;
+import gregtech.api.util.*;
import gregtech.common.GT_Client;
import gregtech.common.GT_Pollution;
import ic2.api.Direction;
@@ -73,7 +73,7 @@ import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
@Optional.InterfaceList(value = {
@Optional.Interface(iface = "appeng.api.networking.security.IActionHost", modid = "appliedenergistics2", striprefs = true),
@Optional.Interface(iface = "appeng.me.helpers.IGridProxyable", modid = "appliedenergistics2", striprefs = true)})
-public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileEntity, IActionHost, IGridProxyable {
+public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileEntity, IActionHost, IGridProxyable, IAlignmentProvider {
private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior};
protected MetaTileEntity mMetaTileEntity;
protected long mStoredEnergy = 0, mStoredSteam = 0;
@@ -2368,4 +2368,27 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
public void setShutdownStatus(boolean newStatus) {
mWasShutdown = newStatus;
}
+
+ @Override
+ public IAlignment getAlignment() {
+ return getMetaTileEntity() instanceof IAlignmentProvider ? ((IAlignmentProvider) getMetaTileEntity()).getAlignment() : new BasicAlignment();
+ }
+
+ private class BasicAlignment implements IAlignment {
+
+ @Override
+ public ExtendedFacing getExtendedFacing() {
+ return ExtendedFacing.of(ForgeDirection.getOrientation(getFrontFacing()));
+ }
+
+ @Override
+ public void setExtendedFacing(ExtendedFacing alignment) {
+ setFrontFacing((byte) Math.max(alignment.getDirection().ordinal(), 5));
+ }
+
+ @Override
+ public IAlignmentLimits getAlignmentLimits() {
+ return (direction, rotation, flip) -> rotation.isNotRotated() && flip.isNotFlipped();
+ }
+ }
}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
new file mode 100644
index 0000000000..7d06378ce1
--- /dev/null
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
@@ -0,0 +1,122 @@
+package gregtech.api.metatileentity.implementations;
+
+import com.gtnewhorizon.structurelib.StructureLibAPI;
+import com.gtnewhorizon.structurelib.alignment.IAlignment;
+import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits;
+import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider;
+import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
+import com.gtnewhorizon.structurelib.alignment.enumerable.Flip;
+import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import cpw.mods.fml.common.network.NetworkRegistry;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraftforge.common.util.ForgeDirection;
+
+/**
+ * Enhanced multiblock base class, featuring following improvement over {@link GT_MetaTileEntity_MultiBlockBase}
+ *
+ * 1. TecTech style declarative structure check utilizing StructureLib.
+ * 2. Arbitrarily rotating the whole structure, if allowed to.
+ *
+ * @param type of this
+ */
+public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase> extends GT_MetaTileEntity_MultiBlockBase implements IAlignment {
+ private ExtendedFacing mExtendedFacing;
+ private final IAlignmentLimits mLimits;
+
+ protected GT_MetaTileEntity_EnhancedMultiBlockBase(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ mLimits = getInitialAlignmentLimits();
+ }
+
+ protected GT_MetaTileEntity_EnhancedMultiBlockBase(String aName) {
+ super(aName);
+ mLimits = getInitialAlignmentLimits();
+ }
+
+ @Override
+ public ExtendedFacing getExtendedFacing() {
+ return mExtendedFacing;
+ }
+
+ @Override
+ public void setExtendedFacing(ExtendedFacing newExtendedFacing) {
+ if (mExtendedFacing != newExtendedFacing) {
+ stopMachine();
+ mExtendedFacing = newExtendedFacing;
+ IGregTechTileEntity base = getBaseMetaTileEntity();
+ mMachine = false;
+ mUpdate = 100;
+ if (getBaseMetaTileEntity().isServerSide()) {
+ StructureLibAPI.sendAlignment((IAlignmentProvider) base,
+ new NetworkRegistry.TargetPoint(base.getWorld().provider.dimensionId,
+ base.getXCoord(), base.getYCoord(), base.getZCoord(), 512));
+ } else {
+ base.issueTextureUpdate();
+ }
+ }
+ }
+
+ @Override
+ public final boolean isFacingValid(byte aFacing) {
+ return canSetToDirectionAny(ForgeDirection.getOrientation(aFacing));
+ }
+
+ @Override
+ public void onFacingChange() {
+ toolSetDirection(ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()));
+ }
+
+ @Override
+ public IAlignmentLimits getAlignmentLimits() {
+ return mLimits;
+ }
+
+ public abstract IStructureDefinition getStructureDefinition();
+
+ protected IAlignmentLimits getInitialAlignmentLimits() {
+ return UNLIMITED;
+ }
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setByte("mRotation", (byte) mExtendedFacing.getRotation().getIndex());
+ aNBT.setByte("mFlip", (byte) mExtendedFacing.getFlip().getIndex());
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ mExtendedFacing = ExtendedFacing.of(ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()),
+ Rotation.byIndex(aNBT.getByte("mRotation")),
+ Flip.byIndex(aNBT.getByte("mFlip")));
+ }
+
+ @Override
+ public abstract GT_MetaTileEntity_EnhancedMultiBlockBase newMetaEntity(IGregTechTileEntity aTileEntity);
+
+ @SuppressWarnings("unchecked")
+ private IStructureDefinition> getCastedStructureDefinition() {
+ return (IStructureDefinition>) getStructureDefinition();
+ }
+
+ protected final boolean checkPiece(String piece, int horizontalOffset, int verticalOffset, int depthOffset) {
+ IGregTechTileEntity tTile = getBaseMetaTileEntity();
+ return getCastedStructureDefinition().check(this, piece, tTile.getWorld(), getExtendedFacing(), tTile.getXCoord(), tTile.getYCoord(), tTile.getZCoord(), horizontalOffset, verticalOffset, depthOffset, !mMachine);
+ }
+
+ protected final boolean buildPiece(String piece, ItemStack trigger, boolean hintOnly, int horizontalOffset, int verticalOffset, int depthOffset) {
+ IGregTechTileEntity tTile = getBaseMetaTileEntity();
+ return getCastedStructureDefinition().buildOrHints(this, trigger, piece, tTile.getWorld(), getExtendedFacing(), tTile.getXCoord(), tTile.getYCoord(), tTile.getZCoord(), horizontalOffset, verticalOffset, depthOffset, hintOnly);
+ }
+
+ @Override
+ public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {
+ super.onFirstTick(aBaseMetaTileEntity);
+ if (aBaseMetaTileEntity.isClientSide())
+ StructureLibAPI.queryAlignment((IAlignmentProvider) aBaseMetaTileEntity);
+ }
+}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
index 0de4dfecbb..3b1a963c9e 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java
@@ -26,6 +26,7 @@ import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.input.Keyboard;
import java.util.ArrayList;
+import java.util.List;
import static gregtech.api.enums.GT_Values.V;
import static gregtech.api.enums.GT_Values.VN;
@@ -676,8 +677,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
return false;
}
- private boolean dumpFluid(FluidStack copiedFluidStack, boolean restrictiveHatchesOnly){
- for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) {
+ protected static boolean dumpFluid(List aOutputHatches, FluidStack copiedFluidStack, boolean restrictiveHatchesOnly){
+ for (GT_MetaTileEntity_Hatch_Output tHatch : aOutputHatches) {
if (!isValidMetaTileEntity(tHatch) || (restrictiveHatchesOnly && tHatch.mMode == 0)) {
continue;
}
@@ -709,8 +710,8 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity {
public boolean addOutput(FluidStack aLiquid) {
if (aLiquid == null) return false;
FluidStack copiedFluidStack = aLiquid.copy();
- if (!dumpFluid(copiedFluidStack, true)){
- dumpFluid(copiedFluidStack, false);
+ if (!dumpFluid(mOutputHatches, copiedFluidStack, true)){
+ dumpFluid(mOutputHatches, copiedFluidStack, false);
}
return false;
}
diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java
new file mode 100644
index 0000000000..c8d845ec19
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java
@@ -0,0 +1,71 @@
+package gregtech.api.util;
+
+import com.gtnewhorizon.structurelib.StructureLibAPI;
+import com.gtnewhorizon.structurelib.structure.IStructureElement;
+import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import net.minecraft.block.Block;
+import net.minecraft.item.ItemStack;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+
+public class GT_StructureUtility {
+ private GT_StructureUtility() {
+ throw new AssertionError("Not instantiable");
+ }
+
+ public static IStructureElementNoPlacement ofHatchAdder(IGT_HatchAdder IGT_HatchAdder, int textureIndex, int dots) {
+ return ofHatchAdder(IGT_HatchAdder, textureIndex, StructureLibAPI.getBlockHint(), dots - 1);
+ }
+
+ public static IStructureElementNoPlacement ofHatchAdder(IGT_HatchAdder IGT_HatchAdder, int textureIndex, Block hintBlock, int hintMeta) {
+ if (IGT_HatchAdder == null || hintBlock == null) {
+ throw new IllegalArgumentException();
+ }
+ return new IStructureElementNoPlacement() {
+ @Override
+ public boolean check(T t, World world, int x, int y, int z) {
+ TileEntity tileEntity = world.getTileEntity(x, y, z);
+ return tileEntity instanceof IGregTechTileEntity && IGT_HatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex);
+ }
+
+ @Override
+ public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
+ StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
+ return true;
+ }
+ };
+ }
+
+ public static IStructureElement ofHatchAdderOptional(IGT_HatchAdder IGT_HatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) {
+ return ofHatchAdderOptional(IGT_HatchAdder, textureIndex, StructureLibAPI.getBlockHint(), dots - 1, placeCasing, placeCasingMeta);
+ }
+
+ public static IStructureElement ofHatchAdderOptional(IGT_HatchAdder IGT_HatchAdder, int textureIndex, Block hintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) {
+ if (IGT_HatchAdder == null || hintBlock == null) {
+ throw new IllegalArgumentException();
+ }
+ return new IStructureElement() {
+ @Override
+ public boolean check(T t, World world, int x, int y, int z) {
+ TileEntity tileEntity = world.getTileEntity(x, y, z);
+ Block worldBlock = world.getBlock(x, y, z);
+ return (tileEntity instanceof IGregTechTileEntity &&
+ IGT_HatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) textureIndex)) ||
+ (worldBlock == placeCasing && worldBlock.getDamageValue(world, x, y, z) == placeCasingMeta);
+ }
+
+ @Override
+ public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
+ StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta);
+ return true;
+ }
+
+ @Override
+ public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
+ world.setBlock(x, y, z, placeCasing, placeCasingMeta, 2);
+ return true;
+ }
+ };
+ }
+}
diff --git a/src/main/java/gregtech/api/util/IGT_HatchAdder.java b/src/main/java/gregtech/api/util/IGT_HatchAdder.java
new file mode 100644
index 0000000000..be0194fc65
--- /dev/null
+++ b/src/main/java/gregtech/api/util/IGT_HatchAdder.java
@@ -0,0 +1,14 @@
+package gregtech.api.util;
+
+
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+
+public interface IGT_HatchAdder {
+ /**
+ * Callback to add hatch, needs to check if hatch is valid (and add it)
+ * @param iGregTechTileEntity hatch
+ * @param aShort requested texture index, or null if not...
+ * @return managed to add hatch (structure still valid)
+ */
+ boolean apply(T t,IGregTechTileEntity iGregTechTileEntity, Short aShort);
+}
--
cgit
From cb876c46e9f185b73556c1c8ed7ca2751cac2cdc Mon Sep 17 00:00:00 2001
From: Glease <4586901+Glease@users.noreply.github.com>
Date: Mon, 31 May 2021 01:09:30 +0800
Subject: Implement IConstructable for demo multis
---
.../api/metatileentity/BaseMetaTileEntity.java | 2 +-
.../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 35 +++++++++++++++++++++-
src/main/java/gregtech/api/util/GT_Utility.java | 15 +++++++++-
3 files changed, 49 insertions(+), 3 deletions(-)
(limited to 'src/main/java/gregtech/api')
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index d108236a39..6eb06d8fae 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -2383,7 +2383,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
@Override
public void setExtendedFacing(ExtendedFacing alignment) {
- setFrontFacing((byte) Math.max(alignment.getDirection().ordinal(), 5));
+ setFrontFacing((byte) Math.min(alignment.getDirection().ordinal(), ForgeDirection.UNKNOWN.ordinal() - 1));
}
@Override
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
index 7d06378ce1..c3d41664b7 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
@@ -4,15 +4,21 @@ import com.gtnewhorizon.structurelib.StructureLibAPI;
import com.gtnewhorizon.structurelib.alignment.IAlignment;
import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits;
import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider;
+import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable;
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
import com.gtnewhorizon.structurelib.alignment.enumerable.Flip;
import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import cpw.mods.fml.common.network.NetworkRegistry;
+import gregtech.api.GregTech_API;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
+import org.lwjgl.input.Keyboard;
+
+import java.util.concurrent.atomic.AtomicReferenceArray;
/**
* Enhanced multiblock base class, featuring following improvement over {@link GT_MetaTileEntity_MultiBlockBase}
@@ -22,7 +28,8 @@ import net.minecraftforge.common.util.ForgeDirection;
*
* @param type of this
*/
-public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase> extends GT_MetaTileEntity_MultiBlockBase implements IAlignment {
+public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase> extends GT_MetaTileEntity_MultiBlockBase implements IAlignment, IConstructable {
+ private static final AtomicReferenceArray tooltips = new AtomicReferenceArray<>(GregTech_API.METATILEENTITIES.length);
private ExtendedFacing mExtendedFacing;
private final IAlignmentLimits mLimits;
@@ -76,6 +83,32 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase getStructureDefinition();
+ protected abstract GT_Multiblock_Tooltip_Builder createTooltip();
+
+ @Override
+ public String[] getDescription() {
+ if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ return getTooltip().getStructureInformation();
+ } else {
+ return getTooltip().getInformation();
+ }
+ }
+
+ protected GT_Multiblock_Tooltip_Builder getTooltip() {
+ int tId = getBaseMetaTileEntity().getMetaTileID();
+ GT_Multiblock_Tooltip_Builder tooltip = tooltips.get(tId);
+ if (tooltip == null) {
+ tooltip = createTooltip();
+ tooltips.set(tId, tooltip);
+ }
+ return tooltip;
+ }
+
+ @Override
+ public String[] getStructureDescription(ItemStack stackSize) {
+ return getTooltip().getStructureInformation();
+ }
+
protected IAlignmentLimits getInitialAlignmentLimits() {
return UNLIMITED;
}
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index 28faeae7e3..c7cee8c9c2 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -3,6 +3,8 @@ package gregtech.api.util;
import cofh.api.transport.IItemDuct;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Maps;
+import com.gtnewhorizon.structurelib.alignment.IAlignment;
+import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.FMLCommonHandler;
import gregtech.api.GregTech_API;
@@ -1939,7 +1941,7 @@ public class GT_Utility {
tList.add("----- X: " +EnumChatFormatting.AQUA+ aX +EnumChatFormatting.RESET+ " Y: " +EnumChatFormatting.AQUA+ aY +EnumChatFormatting.RESET+ " Z: " +EnumChatFormatting.AQUA+ aZ +EnumChatFormatting.RESET+ " D: " +EnumChatFormatting.AQUA+ aWorld.provider.dimensionId +EnumChatFormatting.RESET+ " -----");
try {
- if (tTileEntity != null && tTileEntity instanceof IInventory)
+ if (tTileEntity instanceof IInventory)
tList.add(trans("162","Name: ") +EnumChatFormatting.BLUE+ ((IInventory) tTileEntity).getInventoryName() +EnumChatFormatting.RESET+ trans("163"," MetaData: ") +EnumChatFormatting.AQUA+ aWorld.getBlockMetadata(aX, aY, aZ) +EnumChatFormatting.RESET);
else
tList.add(trans("162","Name: ") +EnumChatFormatting.BLUE+ tBlock.getUnlocalizedName() +EnumChatFormatting.RESET+ trans("163"," MetaData: ") +EnumChatFormatting.AQUA+ aWorld.getBlockMetadata(aX, aY, aZ) +EnumChatFormatting.RESET);
@@ -1978,6 +1980,17 @@ public class GT_Utility {
} catch (Throwable e) {
if (D1) e.printStackTrace(GT_Log.err);
}
+ try {
+ if (tTileEntity instanceof IAlignmentProvider) {
+ IAlignment tAlignment = ((IAlignmentProvider) tTileEntity).getAlignment();
+ if (tAlignment != null) {
+ rEUAmount += 100;
+ tList.add(trans("219", "Extended Facing: ") + EnumChatFormatting.GREEN + tAlignment.getExtendedFacing() + EnumChatFormatting.RESET);
+ }
+ }
+ } catch (Throwable e) {
+ if (D1) e.printStackTrace(GT_Log.err);
+ }
try {
if (tTileEntity instanceof ic2.api.tile.IWrenchable) {
rEUAmount += 100;
--
cgit
From 86f69a4300e0bdb5c9921f37c84bb446e464ec78 Mon Sep 17 00:00:00 2001
From: Léa Gris
Date: Mon, 31 May 2021 10:13:56 +0200
Subject: feat(texture API): integrate ExtendedFacing rotation
Add ExtendedFacing rotation to the texture API.
Rotatable ExtendedFacing textures can be created with:
```java
TextureFactory.builder().addIcon(IICon).extFacing().build();
```
Improve and unify internal implementation of standard oriented and glow textures.
---
src/main/java/gregtech/api/interfaces/ITextureBuilder.java | 8 ++++++++
src/main/java/gregtech/api/util/LightingHelper.java | 1 +
2 files changed, 9 insertions(+)
(limited to 'src/main/java/gregtech/api')
diff --git a/src/main/java/gregtech/api/interfaces/ITextureBuilder.java b/src/main/java/gregtech/api/interfaces/ITextureBuilder.java
index 8a4d715ccb..d72b538243 100644
--- a/src/main/java/gregtech/api/interfaces/ITextureBuilder.java
+++ b/src/main/java/gregtech/api/interfaces/ITextureBuilder.java
@@ -1,5 +1,6 @@
package gregtech.api.interfaces;
+import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
import gregtech.api.render.TextureFactory;
import net.minecraft.block.Block;
import net.minecraftforge.common.util.ForgeDirection;
@@ -63,6 +64,13 @@ public interface ITextureBuilder {
*/
ITextureBuilder stdOrient();
+ /**
+ * Texture will orientate from block's {@link ExtendedFacing}
+ *
+ * @return {@link ITextureBuilder} for chaining
+ */
+ ITextureBuilder extFacing();
+
/**
* Texture always render with full brightness to glow in the dark
*
diff --git a/src/main/java/gregtech/api/util/LightingHelper.java b/src/main/java/gregtech/api/util/LightingHelper.java
index 598253b7d7..f131ef74a0 100644
--- a/src/main/java/gregtech/api/util/LightingHelper.java
+++ b/src/main/java/gregtech/api/util/LightingHelper.java
@@ -255,6 +255,7 @@ public class LightingHelper {
} else {
+ if (hasBrightnessOverride) tessellator.setBrightness(brightnessOverride);
tessellator.setColorOpaque_F(rgb[0] * lightness, rgb[1] * lightness, rgb[2] * lightness);
}
--
cgit
From f812b4a50c922290d6cdee4d1e5e20530814abdc Mon Sep 17 00:00:00 2001
From: Glease <4586901+Glease@users.noreply.github.com>
Date: Mon, 31 May 2021 22:59:51 +0800
Subject: Add GT_MetaTileEntity_CubicMultiBlockBase and a few minor changes
1. add ofCoil() IStructureElement to standardise how to add a homogeneous set of coils to the structure definition
2. Changed newMetaEntity's return type back to IMetaTileEntity to prevent addons crying out
3. Initialize mExtendedFacing to ensure rendering code don't step on null
---
.../GT_MetaTileEntity_CubicMultiBlockBase.java | 111 +++++++++++++++++++++
.../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 9 +-
.../gregtech/api/util/GT_StructureUtility.java | 73 ++++++++++++++
.../java/gregtech/api/util/IGT_HatchAdder.java | 5 +-
4 files changed, 189 insertions(+), 9 deletions(-)
create mode 100644 src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java
(limited to 'src/main/java/gregtech/api')
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
new file mode 100644
index 0000000000..ef53c1bca2
--- /dev/null
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java
@@ -0,0 +1,111 @@
+package gregtech.api.metatileentity.implementations;
+
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.IStructureElement;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import net.minecraft.item.ItemStack;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain;
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass;
+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.
+ * Controller will be placed in front center of the structure.
+ *
+ * Note: You cannot use different casing for the same Class. Make a new subclass for it.
+ *
+ * Implementation tips:
+ * 1. 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
+ */
+public abstract class GT_MetaTileEntity_CubicMultiBlockBase> extends GT_MetaTileEntity_EnhancedMultiBlockBase {
+ protected static final String STRUCTURE_PIECE_MAIN = "main";
+ private static final ConcurrentMap> STRUCTURE_DEFINITIONS = new ConcurrentHashMap<>();
+ private int mCasingAmount = 0;
+
+ protected GT_MetaTileEntity_CubicMultiBlockBase(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ protected GT_MetaTileEntity_CubicMultiBlockBase(String aName) {
+ super(aName);
+ }
+
+
+ private static IStructureDefinition extends GT_MetaTileEntity_CubicMultiBlockBase>> createStructure(GT_MetaTileEntity_CubicMultiBlockBase> aTile) {
+ return StructureDefinition.>builder()
+ .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{
+ {"hhh", "hhh", "hhh"},
+ {"h-h", "hhh", "hhh"},
+ {"hhh", "hhh", "hhh"},
+ }))
+ .addElement('h', ofChain(
+ ofHatchAdder(GT_MetaTileEntity_CubicMultiBlockBase::addToMachineList, aTile.getHatchTextureIndex(), 1),
+ onElementPass(
+ GT_MetaTileEntity_CubicMultiBlockBase::onCorrectCasingAdded,
+ aTile.getCasingElement()
+ )
+ ))
+ .build();
+ }
+
+ /**
+ * Create a simple 3x3x3 hollow cubic structure made of a single type of machine casing and accepts hatches everywhere.
+ *
+ * The created definition contains a single piece named {@link #STRUCTURE_PIECE_MAIN}.
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public IStructureDefinition getStructureDefinition() {
+ return (IStructureDefinition) STRUCTURE_DEFINITIONS.computeIfAbsent(getBaseMetaTileEntity().getMetaTileID(), o -> createStructure(this));
+ }
+
+ @Override
+ public void construct(ItemStack aStack, boolean aHintsOnly) {
+ buildPiece(STRUCTURE_PIECE_MAIN, aStack, aHintsOnly, 1, 1, 0);
+ }
+
+ @Override
+ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ mCasingAmount = 0;
+ return checkPiece(STRUCTURE_PIECE_MAIN, 1, 1, 0) &&
+ mCasingAmount > getRequiredCasingCount() &&
+ checkHatches(aBaseMetaTileEntity, aStack);
+ }
+
+ /**
+ * Called by {@link #checkMachine(IGregTechTileEntity, ItemStack)} to check if all required hatches are present.
+ *
+ * Default implementation requires EXACTLY ONE maintenance hatch to be present, and ignore all other conditions.
+ *
+ * @param aBaseMetaTileEntity the tile entity of self
+ * @param aStack The item stack inside the controller
+ * @return true if the test passes, false otherwise
+ */
+ protected boolean checkHatches(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ return mMaintenanceHatches.size() == 1;
+ }
+
+ protected abstract IStructureElement> getCasingElement();
+
+ /**
+ * The hatch's texture index.
+ */
+ protected abstract int getHatchTextureIndex();
+
+ protected abstract int getRequiredCasingCount();
+
+ protected void onCorrectCasingAdded() {
+ mCasingAmount++;
+ }
+}
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
index c3d41664b7..89d2ce765e 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
@@ -30,17 +30,15 @@ import java.util.concurrent.atomic.AtomicReferenceArray;
*/
public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase> extends GT_MetaTileEntity_MultiBlockBase implements IAlignment, IConstructable {
private static final AtomicReferenceArray tooltips = new AtomicReferenceArray<>(GregTech_API.METATILEENTITIES.length);
- private ExtendedFacing mExtendedFacing;
- private final IAlignmentLimits mLimits;
+ private ExtendedFacing mExtendedFacing = ExtendedFacing.DEFAULT;
+ private final IAlignmentLimits mLimits = getInitialAlignmentLimits();
protected GT_MetaTileEntity_EnhancedMultiBlockBase(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional);
- mLimits = getInitialAlignmentLimits();
}
protected GT_MetaTileEntity_EnhancedMultiBlockBase(String aName) {
super(aName);
- mLimits = getInitialAlignmentLimits();
}
@Override
@@ -128,9 +126,6 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase newMetaEntity(IGregTechTileEntity aTileEntity);
-
@SuppressWarnings("unchecked")
private IStructureDefinition> getCastedStructureDefinition() {
return (IStructureDefinition>) getStructureDefinition();
diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java
index c8d845ec19..1db672245c 100644
--- a/src/main/java/gregtech/api/util/GT_StructureUtility.java
+++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java
@@ -3,13 +3,24 @@ package gregtech.api.util;
import com.gtnewhorizon.structurelib.StructureLibAPI;
import com.gtnewhorizon.structurelib.structure.IStructureElement;
import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.HeatingCoilLevel;
+import gregtech.api.interfaces.IHeatingCoil;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
+import java.util.function.BiConsumer;
+import java.util.function.BiPredicate;
+import java.util.function.Function;
+
+import static com.gtnewhorizon.structurelib.StructureLibAPI.HINT_BLOCK_META_GENERIC_11;
+
public class GT_StructureUtility {
+ public static final int HINT_COIL_DEFAULT_DOTS = HINT_BLOCK_META_GENERIC_11;
+
private GT_StructureUtility() {
throw new AssertionError("Not instantiable");
}
@@ -68,4 +79,66 @@ public class GT_StructureUtility {
}
};
}
+
+ /**
+ * Assume a default of LV coil. Assume all coils accepted. Assumes using {@link #HINT_COIL_DEFAULT_DOTS} as dots.
+ * @see #ofCoil(BiPredicate, Function, int, Block, int)
+ */
+ public static IStructureElement ofCoil(BiConsumer heatingCoilSetter, Function heatingCoilGetter) {
+ return ofCoil((t, l) -> {
+ heatingCoilSetter.accept(t, l);
+ return true;
+ }, heatingCoilGetter, HINT_COIL_DEFAULT_DOTS, GregTech_API.sBlockCasings5, 0);
+ }
+
+ /**
+ * Assumes using {@link #HINT_COIL_DEFAULT_DOTS} as dots
+ * @see #ofCoil(BiPredicate, Function, int, Block, int)
+ */
+ public static IStructureElement ofCoil(BiPredicate heatingCoilSetter, Function heatingCoilGetter, Block defaultCoil, int defaultMeta) {
+ return ofCoil(heatingCoilSetter, heatingCoilGetter, HINT_COIL_DEFAULT_DOTS, defaultCoil, defaultMeta);
+ }
+
+ /**
+ * Heating coil structure element.
+ * @param heatingCoilSetter Notify the controller of this new coil.
+ * Got called exactly once per coil.
+ * Might be called less times if structure test fails.
+ * If the setter returns false then it assumes the coil is rejected.
+ * @param heatingCoilGetter Get the current heating level. Null means no coil recorded yet.
+ * @param dots The hinting dots
+ * @param defaultCoil The block to place when auto constructing
+ * @param defaultMeta The block meta to place when auto constructing
+ */
+ public static IStructureElement ofCoil(BiPredicate heatingCoilSetter, Function heatingCoilGetter, int dots, Block defaultCoil, int defaultMeta) {
+ if (heatingCoilSetter == null || heatingCoilGetter == null) {
+ throw new IllegalArgumentException();
+ }
+ return new IStructureElement() {
+ @Override
+ public boolean check(T t, World world, int x, int y, int z) {
+ Block block = world.getBlock(x, y, z);
+ if (!(block instanceof IHeatingCoil))
+ return false;
+ HeatingCoilLevel existingLevel = heatingCoilGetter.apply(t),
+ newLevel = ((IHeatingCoil) block).getCoilHeat(world.getBlockMetadata(x, y, z));
+ if (existingLevel == null) {
+ return heatingCoilSetter.test(t, newLevel);
+ } else {
+ return newLevel == existingLevel;
+ }
+ }
+
+ @Override
+ public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
+ StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), dots);
+ return true;
+ }
+
+ @Override
+ public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
+ return world.setBlock(x, y, z, defaultCoil, defaultMeta, 3);
+ }
+ };
+ }
}
diff --git a/src/main/java/gregtech/api/util/IGT_HatchAdder.java b/src/main/java/gregtech/api/util/IGT_HatchAdder.java
index be0194fc65..362fddaf1f 100644
--- a/src/main/java/gregtech/api/util/IGT_HatchAdder.java
+++ b/src/main/java/gregtech/api/util/IGT_HatchAdder.java
@@ -6,9 +6,10 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
public interface IGT_HatchAdder {
/**
* Callback to add hatch, needs to check if hatch is valid (and add it)
+ *
* @param iGregTechTileEntity hatch
- * @param aShort requested texture index, or null if not...
+ * @param aShort requested texture index, or null if not...
* @return managed to add hatch (structure still valid)
*/
- boolean apply(T t,IGregTechTileEntity iGregTechTileEntity, Short aShort);
+ boolean apply(T t, IGregTechTileEntity iGregTechTileEntity, Short aShort);
}
--
cgit
From d736caaf43e43c2bd250f1b5d9a91c8dd06a6147 Mon Sep 17 00:00:00 2001
From: Glease <4586901+Glease@users.noreply.github.com>
Date: Tue, 8 Jun 2021 06:31:42 +0800
Subject: allow gt wrench to rotate the front of controller
also cleaned up GT_Client.java a little bit.
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
---
.../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 13 +++++++++++++
1 file changed, 13 insertions(+)
(limited to 'src/main/java/gregtech/api')
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
index 89d2ce765e..d925cc1d84 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
@@ -13,6 +13,7 @@ import cpw.mods.fml.common.network.NetworkRegistry;
import gregtech.api.GregTech_API;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
@@ -69,6 +70,18 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase
Date: Tue, 8 Jun 2021 08:54:20 +0800
Subject: migrate a few more multis over
also removed the stupid ConcurrentHashMap in GT_MetaTileEntity_CubicMultiBlockBase
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
---
.../GT_MetaTileEntity_CubicMultiBlockBase.java | 39 +++++++++-------------
1 file changed, 16 insertions(+), 23 deletions(-)
(limited to 'src/main/java/gregtech/api')
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 ef53c1bca2..c84ca61eec 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
@@ -6,9 +6,7 @@ import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import net.minecraft.item.ItemStack;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
@@ -30,7 +28,20 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
*/
public abstract class GT_MetaTileEntity_CubicMultiBlockBase> extends GT_MetaTileEntity_EnhancedMultiBlockBase {
protected static final String STRUCTURE_PIECE_MAIN = "main";
- private static final ConcurrentMap> STRUCTURE_DEFINITIONS = new ConcurrentHashMap<>();
+ protected static final IStructureDefinition> STRUCTURE_DEFINITION = StructureDefinition.>builder()
+ .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{
+ {"hhh", "hhh", "hhh"},
+ {"h-h", "hhh", "hhh"},
+ {"hhh", "hhh", "hhh"},
+ }))
+ .addElement('h', ofChain(
+ defer(t -> ofHatchAdder(GT_MetaTileEntity_CubicMultiBlockBase::addToMachineList, t.getHatchTextureIndex(), 1)),
+ onElementPass(
+ GT_MetaTileEntity_CubicMultiBlockBase::onCorrectCasingAdded,
+ defer(GT_MetaTileEntity_CubicMultiBlockBase::getCasingElement)
+ )
+ ))
+ .build();
private int mCasingAmount = 0;
protected GT_MetaTileEntity_CubicMultiBlockBase(int aID, String aName, String aNameRegional) {
@@ -41,24 +52,6 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase> createStructure(GT_MetaTileEntity_CubicMultiBlockBase> aTile) {
- return StructureDefinition.>builder()
- .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{
- {"hhh", "hhh", "hhh"},
- {"h-h", "hhh", "hhh"},
- {"hhh", "hhh", "hhh"},
- }))
- .addElement('h', ofChain(
- ofHatchAdder(GT_MetaTileEntity_CubicMultiBlockBase::addToMachineList, aTile.getHatchTextureIndex(), 1),
- onElementPass(
- GT_MetaTileEntity_CubicMultiBlockBase::onCorrectCasingAdded,
- aTile.getCasingElement()
- )
- ))
- .build();
- }
-
/**
* Create a simple 3x3x3 hollow cubic structure made of a single type of machine casing and accepts hatches everywhere.
*
@@ -67,7 +60,7 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase getStructureDefinition() {
- return (IStructureDefinition) STRUCTURE_DEFINITIONS.computeIfAbsent(getBaseMetaTileEntity().getMetaTileID(), o -> createStructure(this));
+ return (IStructureDefinition) STRUCTURE_DEFINITION;
}
@Override
--
cgit
From 03a45da45fdd85f1276416c2586a98eba79a9b50 Mon Sep 17 00:00:00 2001
From: Glease <4586901+Glease@users.noreply.github.com>
Date: Fri, 11 Jun 2021 02:48:50 +0800
Subject: migrate all other multis over
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
---
.../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 11 +++++++++++
1 file changed, 11 insertions(+)
(limited to 'src/main/java/gregtech/api')
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
index d925cc1d84..e4bfef4a48 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
@@ -144,6 +144,17 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase>) getStructureDefinition();
}
+ /**
+ * Explanation of the world coordinate these offset means:
+ *
+ * Imagine you stand in front of the controller, with controller facing towards you not rotated or flipped.
+ *
+ * The horizontalOffset would be the number of blocks on the left side of the controller, not counting controller itself.
+ * The verticalOffset would be the number of blocks on the top side of the controller, not counting controller itself.
+ * The depthOffset would be the number of blocks between you and controller, not counting controller itself.
+ *
+ * All these offsets can be negative.
+ */
protected final boolean checkPiece(String piece, int horizontalOffset, int verticalOffset, int depthOffset) {
IGregTechTileEntity tTile = getBaseMetaTileEntity();
return getCastedStructureDefinition().check(this, piece, tTile.getWorld(), getExtendedFacing(), tTile.getXCoord(), tTile.getYCoord(), tTile.getZCoord(), horizontalOffset, verticalOffset, depthOffset, !mMachine);
--
cgit
From 6ea3101f0b5604f3f9260a41af6ef1848355c95f Mon Sep 17 00:00:00 2001
From: Glease <4586901+Glease@users.noreply.github.com>
Date: Tue, 15 Jun 2021 02:16:40 +0800
Subject: use TT serialization form
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
---
.../implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
(limited to 'src/main/java/gregtech/api')
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
index e4bfef4a48..e871146d4b 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
@@ -127,16 +127,16 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase
Date: Wed, 16 Jun 2021 11:05:12 +0800
Subject: optimize fuel recipe lookup
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
---
.../GT_MetaTileEntity_BasicGenerator.java | 27 ++++++++++------------
src/main/java/gregtech/api/util/GT_Recipe.java | 23 ++++++++++++++++++
2 files changed, 35 insertions(+), 15 deletions(-)
(limited to 'src/main/java/gregtech/api')
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java
index 9bbfbf0a3a..63151bde59 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java
@@ -18,8 +18,6 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraftforge.fluids.IFluidHandler;
-import java.util.Collection;
-
import static gregtech.api.enums.GT_Values.V;
public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity_BasicTank {
@@ -271,19 +269,18 @@ public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity
public int getFuelValue(FluidStack aLiquid) {
//System.out.println("Fluid stack check");
- if (aLiquid == null || getRecipes() == null) return 0;
- FluidStack tLiquid;
- Collection tRecipeList = getRecipes().mRecipeList;
- if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList)
- if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null)
- if (aLiquid.isFluidEqual(tLiquid)){
- long val=(long)tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid) / 100;
- if(val> Integer.MAX_VALUE){
- throw new ArithmeticException("Integer LOOPBACK!");
- }
- return (int) val;
- }
- return 0;
+ GT_Recipe_Map tRecipes = getRecipes();
+ if (aLiquid == null || !(tRecipes instanceof GT_Recipe.GT_Recipe_Map_Fuel)) return 0;
+ GT_Recipe.GT_Recipe_Map_Fuel tFuels = (GT_Recipe.GT_Recipe_Map_Fuel) tRecipes;
+ GT_Recipe tFuel = tFuels.findFuel(aLiquid);
+ if (tFuel == null) {
+ return 0;
+ }
+ long val=(long)tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(aLiquid) / 100;
+ if(val> Integer.MAX_VALUE){
+ throw new ArithmeticException("Integer LOOPBACK!");
+ }
+ return (int) val;
}
public int getFuelValue(ItemStack aStack) {
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index a04df205b7..a5b263a145 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -197,6 +197,11 @@ public class GT_Recipe implements Comparable {
this(aInput1, aOutput1, null, null, null, aFuelValue, aType);
}
+ private static FluidStack[] tryGetFluidInputsFromCells(ItemStack aInput) {
+ FluidStack tFluid = GT_Utility.getFluidForFilledItem(aInput, true);
+ return tFluid == null ? null : new FluidStack[] {tFluid};
+ }
+
// aSpecialValue = EU per Liter! If there is no Liquid for this Object, then it gets multiplied with 1000!
public GT_Recipe(ItemStack aInput1, ItemStack aOutput1, ItemStack aOutput2, ItemStack aOutput3, ItemStack aOutput4, int aSpecialValue, int aType) {
this(true, new ItemStack[]{aInput1}, new ItemStack[]{aOutput1, aOutput2, aOutput3, aOutput4}, null, null, null, null, 0, 0, Math.max(1, aSpecialValue));
@@ -977,6 +982,7 @@ public class GT_Recipe implements Comparable {
* Just a Recipe Map with Utility specifically for Fuels.
*/
public static class GT_Recipe_Map_Fuel extends GT_Recipe_Map {
+ private final Map mRecipesByFluidInput = new HashMap<>();
public GT_Recipe_Map_Fuel(Collection aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) {
super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed);
}
@@ -1000,6 +1006,23 @@ public class GT_Recipe implements Comparable {
public GT_Recipe addFuel(ItemStack aInput, ItemStack aOutput, FluidStack aFluidInput, FluidStack aFluidOutput, int aChance, int aFuelValueInEU) {
return addRecipe(true, new ItemStack[]{aInput}, new ItemStack[]{aOutput}, null, new int[]{aChance}, new FluidStack[]{aFluidInput}, new FluidStack[]{aFluidOutput}, 0, 0, aFuelValueInEU);
}
+
+ @Override
+ public GT_Recipe add(GT_Recipe aRecipe) {
+ aRecipe = super.add(aRecipe);
+ if (aRecipe.mInputs != null && aRecipe.mInputs.length == 1 && (aRecipe.mFluidInputs == null || aRecipe.mFluidInputs.length == 0)) {
+ FluidStack tFluid = GT_Utility.getFluidForFilledItem(aRecipe.mInputs[0], true);
+ if (tFluid != null) {
+ tFluid.amount = 0;
+ mRecipesByFluidInput.put(tFluid.getUnlocalizedName(), aRecipe);
+ }
+ }
+ return aRecipe;
+ }
+
+ public GT_Recipe findFuel(FluidStack aFluidInput) {
+ return mRecipesByFluidInput.get(aFluidInput.getUnlocalizedName());
+ }
}
/**
--
cgit
From 62f04c2893a66c4f80383da1a973fad4708171d4 Mon Sep 17 00:00:00 2001
From: Glease <4586901+Glease@users.noreply.github.com>
Date: Wed, 16 Jun 2021 16:15:18 +0800
Subject: draw flipped textures & flipping markers
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
---
.../implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'src/main/java/gregtech/api')
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
index e871146d4b..76dbca86b1 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java
@@ -75,7 +75,9 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase
Date: Wed, 16 Jun 2021 16:33:53 +0800
Subject: make fuel recipe map index building a bit more robust
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
---
src/main/java/gregtech/api/util/GT_Recipe.java | 3 ++-
src/main/java/gregtech/api/util/GT_Utility.java | 4 ++++
2 files changed, 6 insertions(+), 1 deletion(-)
(limited to 'src/main/java/gregtech/api')
diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java
index a5b263a145..19f46dfd15 100644
--- a/src/main/java/gregtech/api/util/GT_Recipe.java
+++ b/src/main/java/gregtech/api/util/GT_Recipe.java
@@ -1010,7 +1010,8 @@ public class GT_Recipe implements Comparable {
@Override
public GT_Recipe add(GT_Recipe aRecipe) {
aRecipe = super.add(aRecipe);
- if (aRecipe.mInputs != null && aRecipe.mInputs.length == 1 && (aRecipe.mFluidInputs == null || aRecipe.mFluidInputs.length == 0)) {
+ if (aRecipe.mInputs != null && GT_Utility.getNonnullElementCount(aRecipe.mInputs) == 1 &&
+ (aRecipe.mFluidInputs == null || GT_Utility.getNonnullElementCount(aRecipe.mFluidInputs) == 0)) {
FluidStack tFluid = GT_Utility.getFluidForFilledItem(aRecipe.mInputs[0], true);
if (tFluid != null) {
tFluid.amount = 0;
diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java
index c7cee8c9c2..bb2c644f95 100644
--- a/src/main/java/gregtech/api/util/GT_Utility.java
+++ b/src/main/java/gregtech/api/util/GT_Utility.java
@@ -2884,4 +2884,8 @@ public