diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2021-07-22 18:21:24 +0800 |
---|---|---|
committer | Glease <4586901+Glease@users.noreply.github.com> | 2021-07-30 14:41:47 +0800 |
commit | f4495a61bd5d20f5784856227a567d03f275b554 (patch) | |
tree | 5c65b8e3777861ca45a531091e23b3f4ed227ee7 /src | |
parent | 9267016bf3a3e0ae90c89f3bfc61058f1275207d (diff) | |
download | GT5-Unofficial-f4495a61bd5d20f5784856227a567d03f275b554.tar.gz GT5-Unofficial-f4495a61bd5d20f5784856227a567d03f275b554.tar.bz2 GT5-Unofficial-f4495a61bd5d20f5784856227a567d03f275b554.zip |
Fix frame box hint & placement
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/gregtech/api/util/GT_StructureUtility.java | 92 | ||||
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java | 7 |
2 files changed, 73 insertions, 26 deletions
diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index 2d15f568ab..a627da4fd6 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -3,18 +3,24 @@ package gregtech.api.util; import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.structure.IStructureElement; import com.gtnewhorizon.structurelib.structure.IStructureElementNoPlacement; -import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; import gregtech.common.blocks.GT_Block_Casings5; import net.minecraft.block.Block; +import net.minecraft.init.Items; +import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; import net.minecraft.world.World; -import org.apache.commons.lang3.StringUtils; +import java.util.Arrays; import java.util.function.BiConsumer; import java.util.function.BiPredicate; import java.util.function.Function; @@ -24,35 +30,75 @@ public class GT_StructureUtility { throw new AssertionError("Not instantiable"); } - public static <T> IStructureElementNoPlacement<T> ofHatchAdder(IGT_HatchAdder<T> IGT_HatchAdder, int textureIndex, int dots) { - return ofHatchAdder(IGT_HatchAdder, textureIndex, StructureLibAPI.getBlockHint(), dots - 1); + public static <T> IStructureElementNoPlacement<T> ofHatchAdder(IGT_HatchAdder<T> aHatchAdder, int aTextureIndex, int aDots) { + return ofHatchAdder(aHatchAdder, aTextureIndex, StructureLibAPI.getBlockHint(), aDots - 1); } - public static <T> IStructureElementNoPlacement<T> ofHatchAdder(IGT_HatchAdder<T> IGT_HatchAdder, int textureIndex, Block hintBlock, int hintMeta) { - if (IGT_HatchAdder == null || hintBlock == null) { + public static <T> IStructureElement<T> ofFrame(Materials aFrameMaterial) { + if (aFrameMaterial == null) throw new IllegalArgumentException(); + return new IStructureElement<T>() { + + private IIcon[] mIcons; + + @Override + public boolean check(T t, World world, int x, int y, int z) { + TileEntity tBase = world.getTileEntity(x, y, z); + if (tBase instanceof BaseMetaPipeEntity) { + BaseMetaPipeEntity tPipeBase = (BaseMetaPipeEntity) tBase; + if (tPipeBase.isInvalidTileEntity()) return false; + if (tPipeBase.getMetaTileEntity() instanceof GT_MetaPipeEntity_Frame) + return aFrameMaterial == ((GT_MetaPipeEntity_Frame) tPipeBase.getMetaTileEntity()).mMaterial; + } + return false; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { + if (mIcons == null) { + mIcons = new IIcon[6]; + Arrays.fill(mIcons, aFrameMaterial.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex].getIcon()); + } + StructureLibAPI.hintParticleTinted(world, x, y, z, mIcons, aFrameMaterial.mRGBa); + return true; + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { + ItemStack tFrameStack = GT_OreDictUnificator.get(OrePrefixes.frameGt, aFrameMaterial, 1); + if (tFrameStack.getItem() instanceof ItemBlock) { + ItemBlock tFrameStackItem = (ItemBlock) tFrameStack.getItem(); + return tFrameStackItem.placeBlockAt(tFrameStack, null, world, x, y, z, 6, 0, 0, 0, Items.feather.getDamage(tFrameStack)); + } + return false; + } + }; + } + + public static <T> IStructureElementNoPlacement<T> ofHatchAdder(IGT_HatchAdder<T> aHatchAdder, int aTextureIndex, Block aHintBlock, int aHintMeta) { + if (aHatchAdder == null || aHintBlock == null) { throw new IllegalArgumentException(); } return new IStructureElementNoPlacement<T>() { @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); + return tileEntity instanceof IGregTechTileEntity && aHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) aTextureIndex); } @Override public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - StructureLibAPI.hintParticle(world, x, y, z, hintBlock, hintMeta); + StructureLibAPI.hintParticle(world, x, y, z, aHintBlock, aHintMeta); return true; } }; } - public static <T> IStructureElement<T> ofHatchAdderOptional(IGT_HatchAdder<T> IGT_HatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { - return ofHatchAdderOptional(IGT_HatchAdder, textureIndex, StructureLibAPI.getBlockHint(), dots - 1, placeCasing, placeCasingMeta); + public static <T> IStructureElement<T> ofHatchAdderOptional(IGT_HatchAdder<T> aHatchAdder, int textureIndex, int dots, Block placeCasing, int placeCasingMeta) { + return ofHatchAdderOptional(aHatchAdder, textureIndex, StructureLibAPI.getBlockHint(), dots - 1, placeCasing, placeCasingMeta); } - public static <T> IStructureElement<T> ofHatchAdderOptional(IGT_HatchAdder<T> IGT_HatchAdder, int textureIndex, Block hintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) { - if (IGT_HatchAdder == null || hintBlock == null) { + public static <T> IStructureElement<T> ofHatchAdderOptional(IGT_HatchAdder<T> aHatchAdder, int aTextureIndex, Block aHintBlock, int hintMeta, Block placeCasing, int placeCasingMeta) { + if (aHatchAdder == null || aHintBlock == null) { throw new IllegalArgumentException(); } return new IStructureElement<T>() { @@ -61,13 +107,13 @@ public class GT_StructureUtility { 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)) || + aHatchAdder.apply(t, (IGregTechTileEntity) tileEntity, (short) aTextureIndex)) || (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); + StructureLibAPI.hintParticle(world, x, y, z, aHintBlock, hintMeta); return true; } @@ -83,23 +129,23 @@ public class GT_StructureUtility { * Assume all coils accepted. * @see #ofCoil(BiPredicate, Function) */ - public static <T> IStructureElement<T> ofCoil(BiConsumer<T, HeatingCoilLevel> heatingCoilSetter, Function<T, HeatingCoilLevel> heatingCoilGetter) { + public static <T> IStructureElement<T> ofCoil(BiConsumer<T, HeatingCoilLevel> aHeatingCoilSetter, Function<T, HeatingCoilLevel> aHeatingCoilGetter) { return ofCoil((t, l) -> { - heatingCoilSetter.accept(t, l); + aHeatingCoilSetter.accept(t, l); return true; - }, heatingCoilGetter); + }, aHeatingCoilGetter); } /** * Heating coil structure element. - * @param heatingCoilSetter Notify the controller of this new coil. + * @param aHeatingCoilSetter 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 aHeatingCoilGetter Get the current heating level. Null means no coil recorded yet. */ - public static <T> IStructureElement<T> ofCoil(BiPredicate<T, HeatingCoilLevel> heatingCoilSetter, Function<T, HeatingCoilLevel> heatingCoilGetter) { - if (heatingCoilSetter == null || heatingCoilGetter == null) { + public static <T> IStructureElement<T> ofCoil(BiPredicate<T, HeatingCoilLevel> aHeatingCoilSetter, Function<T, HeatingCoilLevel> aHeatingCoilGetter) { + if (aHeatingCoilSetter == null || aHeatingCoilGetter == null) { throw new IllegalArgumentException(); } return new IStructureElement<T>() { @@ -108,10 +154,10 @@ public class GT_StructureUtility { Block block = world.getBlock(x, y, z); if (!(block instanceof IHeatingCoil)) return false; - HeatingCoilLevel existingLevel = heatingCoilGetter.apply(t), + HeatingCoilLevel existingLevel = aHeatingCoilGetter.apply(t), newLevel = ((IHeatingCoil) block).getCoilHeat(world.getBlockMetadata(x, y, z)); if (existingLevel == null || existingLevel == HeatingCoilLevel.None) { - return heatingCoilSetter.test(t, newLevel); + return aHeatingCoilSetter.test(t, newLevel); } else { return newLevel == existingLevel; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index a610a502f9..010d1558be 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -40,6 +40,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACT import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_GLOW; import static gregtech.api.enums.Textures.BlockIcons.getCasingTextureForId; +import static gregtech.api.util.GT_StructureUtility.ofFrame; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_EnhancedMultiBlockBase<GT_MetaTileEntity_DrillerBase> implements IChunkLoader { @@ -61,10 +62,10 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_En {" f ", "fcf", " f "}, {"b~b", "bbb", "bbb"}, })) - .addElement('f', lazy(t -> ofBlock(GregTech_API.sBlockMachines, t.frameMeta))) - .addElement('c', lazy(t -> ofBlock(t.casingBlock, t.casingMeta))) + .addElement('f', lazy(t -> ofFrame(t.getFrameMaterial()))) + .addElement('c', lazy(t -> ofBlock(t.getCasingBlockItem().getBlock(), t.getCasingBlockItem().get(0).getItemDamage()))) .addElement('b', lazy(t -> ofChain( - ofBlock(t.casingBlock, t.casingMeta), + ofBlock(t.getCasingBlockItem().getBlock(), t.getCasingBlockItem().get(0).getItemDamage()), ofHatchAdder(GT_MetaTileEntity_DrillerBase::addMaintenanceToMachineList, t.casingTextureIndex, 1), ofHatchAdder(GT_MetaTileEntity_DrillerBase::addInputToMachineList, t.casingTextureIndex, 1), ofHatchAdder(GT_MetaTileEntity_DrillerBase::addOutputToMachineList, t.casingTextureIndex, 1), |