diff options
Diffstat (limited to 'src/main/java/com')
7 files changed, 200 insertions, 144 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java new file mode 100644 index 0000000000..e4714d059d --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BorosilicateGlass.java @@ -0,0 +1,152 @@ +package com.github.bartimaeusnek.bartworks.API; + +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.block.Block; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.BiConsumer; +import java.util.function.Function; +import java.util.stream.Collectors; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAdder; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlockAnyMeta; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; + +/** + * API for bartworks borosilicate glass. + * <p> + * You might have noticed this API does not expose any Block instance, but only IStructureElements. This is in case we + * add more glass blocks later, and we run out of meta id for only one block. + * <p> + * IStructureElements returned from this class should not have its methods called before the game start. + */ +public class BorosilicateGlass { + + private static Block block; + private static List<Pair<Block, Integer>> representatives; + + private static Block getGlassBlock() { + if (block == null) + block = GameRegistry.findBlock("bartworks", "BW_GlasBlocks"); + return block; + } + + private static List<Pair<Block, Integer>> getRepresentatives() { + if (representatives == null) { + ArrayList<Pair<Block, Integer>> ret = new ArrayList<>(); + Block block = getGlassBlock(); + ret.add(Pair.of(block, 0)); + ret.add(Pair.of(block, 1)); + ret.add(Pair.of(block, 2)); + ret.add(Pair.of(block, 3)); + ret.add(Pair.of(block, 4)); + ret.add(Pair.of(block, 5)); + ret.add(Pair.of(block, 13)); + ret.add(Pair.of(block, 14)); + representatives = ret; + } + return representatives; + } + + private static byte checkWithinBound(byte val, byte lo, byte hi) { + return val > hi || val < lo ? -1 : val; + } + + /** + * Check if there is at least one type of boroglass in that tier. + */ + public static boolean hasGlassInTier(int tier) { + return tier >= 3 && tier <= 10; + } + + /** + * Get a structure element for a certain tier of <b>borosilicate</b> glass. DOES NOT accept other glass like reinforced glass, magic mirror, vanilla glass, etc. + * <p> + * Use this if you just want boroglass here and doesn't care what tier it is. + */ + public static <T> IStructureElement<T> ofBoroGlass(int tier) { + if (!hasGlassInTier(tier)) throw new IllegalArgumentException(); + return lazy(t -> { + Pair<Block, Integer> pair = getRepresentatives().get(tier - 3); + return ofBlockAdder((t1, block1, meta) -> getTier(block1, meta) == tier, pair.getKey(), pair.getValue()); + }); + } + + /** + * Get a structure element for any kind of <b>borosilicate</b> glass. DOES NOT accept other glass like reinforced glass, magic mirror, vanilla glass, etc. + * <p> + * Use this if you just want boroglass here and doesn't care what tier it is. + */ + public static <T> IStructureElement<T> ofBoroGlassAnyTier() { + return lazy(t -> ofBlockAnyMeta(getGlassBlock())); + } + + /** + * Get a structure element for <b>borosilicate</b> glass. DOES NOT accept other glass like reinforced glass, magic mirror, vanilla glass, etc. + * <p> + * This assumes you want all glass used to be of the same tier. + * <p> + * NOTE: This will accept the basic boron glass (HV tier) as well. You might not want this. Use the other overload to filter this out. + * + * @param initialValue the value set before structure check started + */ + public static <T> IStructureElement<T> ofBoroGlass(byte initialValue, BiConsumer<T, Byte> setter, Function<T, Byte> getter) { + return lazy(t -> ofBlocksTiered(BorosilicateGlass::getTier, getRepresentatives(), initialValue, setter, getter)); + } + + /** + * Get a structure element for <b>borosilicate</b> glass. DOES NOT accept other glass like reinforced glass, magic mirror, vanilla glass, etc. + * + * @param initialValue the value set before structure check started + * @param minTier minimal accepted tier. inclusive. must be greater than 0. + * @param maxTier maximal accepted tier. inclusive. + */ + public static <T> IStructureElement<T> ofBoroGlass(byte initialValue, byte minTier, byte maxTier, BiConsumer<T, Byte> setter, Function<T, Byte> getter) { + if (minTier > maxTier || minTier < 0) throw new IllegalArgumentException(); + return lazy(t -> ofBlocksTiered( + (block1, meta) -> checkWithinBound(getTier(block1, meta), minTier, maxTier), + getRepresentatives().stream().skip(Math.max(minTier - 3, 0)).limit(maxTier - minTier + 1).collect(Collectors.toList()), + initialValue, + setter, + getter + )); + } + + /** + * Get the tier of this <b>borosilicate</b> glass. DOES NOT consider other glass like reinforced glass, magic mirror, vanilla glass, etc. + */ + public static byte getTier(Block block, int meta) { + byte ret; + switch (meta) { + case 1: + ret = 4; + break; + case 2: + case 12: + ret = 5; + break; + case 3: + ret = 6; + break; + case 4: + ret = 7; + break; + case 5: + ret = 8; + break; + case 13: + ret = 9; + break; + case 14: + ret = 10; + break; + default: + ret = 3; + } + return block == getGlassBlock() ? ret : -1; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java index 4ea3582bd1..223a067ce6 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/ASM/BWCoreTransformer.java @@ -296,6 +296,9 @@ public class BWCoreTransformer implements IClassTransformer { toPatch.instructions.add(new VarInsnNode(ALOAD,2)); toPatch.instructions.add(new MethodInsnNode(INVOKESTATIC,"com/github/bartimaeusnek/bartworks/ASM/BWCoreStaticReplacementMethodes","findCachedMatchingRecipe","(Lnet/minecraft/inventory/InventoryCrafting;Lnet/minecraft/world/World;)Lnet/minecraft/item/ItemStack;",false)); toPatch.instructions.add(new InsnNode(ARETURN)); + toPatch.localVariables.clear(); + toPatch.maxStack = 2; + toPatch.maxLocals = 3; break scase; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java index e0c172f1cd..a136cfd34b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java @@ -22,6 +22,7 @@ package com.github.bartimaeusnek.bartworks.common.items; +import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.blocks.BW_GlasBlocks; @@ -69,8 +70,10 @@ public class BW_ItemBlocks extends ItemBlock { @SideOnly(Side.CLIENT) @SuppressWarnings("unchecked") public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - if (this.field_150939_a instanceof BW_GlasBlocks) - aList.add(StatCollector.translateToLocal("tooltip.glas.0.name") + " " + BW_ColorUtil.getColorForTier(BW_Util.getTierFromGlasMeta(aStack.getItemDamage())) + GT_Values.VN[BW_Util.getTierFromGlasMeta(aStack.getItemDamage())]); + byte tier = BorosilicateGlass.getTier(this.field_150939_a, aStack.getItemDamage()); + if (tier >= 0) { + aList.add(StatCollector.translateToLocal("tooltip.glas.0.name") + " " + BW_ColorUtil.getColorForTier(tier) + GT_Values.VN[tier]); + } if (this.field_150939_a instanceof ITileAddsInformation) { aList.addAll(Arrays.asList(((ITileAddsInformation) this.field_150939_a).getInfoData())); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java index f9263f140a..b204f30502 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java @@ -22,6 +22,7 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; +import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; import com.github.bartimaeusnek.bartworks.API.LoaderReference; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; @@ -77,7 +78,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl .addElement('t', ofHatchAdderOptional(GT_TileEntity_MegaBlastFurnace::addOutputHatchToTopList, CASING_INDEX, 1, GregTech_API.sBlockCasings1, CASING_INDEX)) .addElement('m', ofHatchAdder(GT_TileEntity_MegaBlastFurnace::addMufflerToMachineList, CASING_INDEX, 2)) .addElement('C', ofCoil(GT_TileEntity_MegaBlastFurnace::setCoilLevel, GT_MetaTileEntity_ElectricBlastFurnace::getCoilLevel)) - .addElement('g', ofBlockAdder(GT_TileEntity_MegaBlastFurnace::addGlas, ItemRegistry.bw_glasses[0], 1)) + .addElement('g', BorosilicateGlass.ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glasTier = t, te -> te.glasTier)) .addElement('b', ofHatchAdderOptional(GT_TileEntity_MegaBlastFurnace::addBottomHatch, CASING_INDEX, 3, GregTech_API.sBlockCasings1, CASING_INDEX)) .build(); @@ -163,9 +164,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl return tt; } - @SuppressWarnings("rawtypes") public ArrayList<Object> TTTunnels = new ArrayList<>(); - @SuppressWarnings("rawtypes") public ArrayList<Object> TTMultiAmp = new ArrayList<>(); @Override @@ -455,17 +454,6 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl buildPiece("main", stackSize, hintsOnly, 7, 17, 0); } - private boolean addGlas(Block block, int meta) { - if (block != ItemRegistry.bw_glasses[0]) - return false; - byte tier = BW_Util.getTierFromGlasMeta(meta); - if (tier >= 8) tier = 8; - if (glasTier > 0) - return tier == glasTier; - glasTier = tier; - return true; - } - @Override public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { if (LoaderReference.tectech) { @@ -489,11 +477,11 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl if (mMaintenanceHatches.size() != 1) return false; - if (LoaderReference.tectech && this.glasTier != 8) + if (LoaderReference.tectech && this.glasTier < 8) if (!areLazorsLowPowa() || areThingsNotProperlyTiered(this.getTecTechEnergyTunnels()) || areThingsNotProperlyTiered(this.getTecTechEnergyMultis())) return false; - if (this.glasTier != 8 && !this.mEnergyHatches.isEmpty()) + if (this.glasTier < 8 && !this.mEnergyHatches.isEmpty()) for (GT_MetaTileEntity_Hatch_Energy hatchEnergy : this.mEnergyHatches) if (this.glasTier < hatchEnergy.mTier) return false; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java index 3aaeab8c30..e2383c8fa1 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaChemicalReactor.java @@ -22,9 +22,9 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; +import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; import com.github.bartimaeusnek.bartworks.API.LoaderReference; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; -import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; import com.github.bartimaeusnek.bartworks.util.BW_Util; import com.github.bartimaeusnek.bartworks.util.MegaUtils; @@ -33,20 +33,15 @@ import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti; import com.github.bartimaeusnek.crossmod.tectech.helper.TecTechUtils; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; -import com.gtnewhorizon.structurelib.structure.StructureUtility; import cpw.mods.fml.common.Optional; import gregtech.api.GregTech_API; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeChemicalReactor; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -55,13 +50,19 @@ import java.util.List; import static com.github.bartimaeusnek.bartworks.util.RecipeFinderForParallel.getMultiOutput; import static com.github.bartimaeusnek.bartworks.util.RecipeFinderForParallel.handleParallelRecipe; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.util.GT_StructureUtility.*; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; @Optional.Interface(iface = "com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti", modid = "tectech", striprefs = true) public class GT_TileEntity_MegaChemicalReactor extends GT_MetaTileEntity_LargeChemicalReactor implements TecTechEnabledMulti { + private final ArrayList<?> TTTunnels = new ArrayList<>(); + private final ArrayList<?> TTMultiAmp = new ArrayList<>(); + + private byte glasTier; public GT_TileEntity_MegaChemicalReactor(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -99,11 +100,6 @@ public class GT_TileEntity_MegaChemicalReactor extends GT_MetaTileEntity_LargeCh return new GT_TileEntity_MegaChemicalReactor(this.mName); } - @SuppressWarnings("rawtypes") - public ArrayList TTTunnels = new ArrayList<>(); - @SuppressWarnings("rawtypes") - public ArrayList TTMultiAmp = new ArrayList<>(); - @Override public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (LoaderReference.tectech) { @@ -207,7 +203,7 @@ public class GT_TileEntity_MegaChemicalReactor extends GT_MetaTileEntity_LargeCh return false; } - if (this.glasTier != 8 && !this.mEnergyHatches.isEmpty()) { + if (this.glasTier < 8 && !this.mEnergyHatches.isEmpty()) { for (GT_MetaTileEntity_Hatch_Energy hatchEnergy : this.mEnergyHatches) { if (this.glasTier < hatchEnergy.mTier) { return false; @@ -234,51 +230,21 @@ public class GT_TileEntity_MegaChemicalReactor extends GT_MetaTileEntity_LargeCh .addElement('d', ofChain( ofHatchAdder(GT_TileEntity_MegaChemicalReactor::addInputToMachineList, CASING_INDEX, 1), ofHatchAdder(GT_TileEntity_MegaChemicalReactor::addOutputToMachineList, CASING_INDEX, 1), - onElementPass(GT_TileEntity_MegaChemicalReactor::onCasingAdded, ofBlock(GregTech_API.sBlockCasings8, 0)) - )) - .addElement('r', ofChain( - ofHatchAdder(GT_TileEntity_MegaChemicalReactor::addMaintenanceToMachineList, CASING_INDEX, 2) - )) - .addElement('e', ofChain( - ofHatchAdder(GT_TileEntity_MegaChemicalReactor::addEnergyInputToMachineList, CASING_INDEX, 3), - onElementPass(GT_TileEntity_MegaChemicalReactor::onCasingAdded, ofBlock(GregTech_API.sBlockCasings8, 0)) - )) - .addElement('c', ofChain( - ofBlock(GregTech_API.sBlockCasings4, 7) - )) - .addElement('g', ofChain( - ofBlockAdder(GT_TileEntity_MegaChemicalReactor::addGlas, ItemRegistry.bw_glasses[0], 1) + ofBlock(GregTech_API.sBlockCasings8, 0) )) + .addElement('r', ofHatchAdder(GT_TileEntity_MegaChemicalReactor::addMaintenanceToMachineList, CASING_INDEX, 2)) + .addElement('e', ofHatchAdderOptional(GT_TileEntity_MegaChemicalReactor::addEnergyInputToMachineList, CASING_INDEX, 3, GregTech_API.sBlockCasings8, 0)) + .addElement('c', ofBlock(GregTech_API.sBlockCasings4, 7)) + .addElement('g', BorosilicateGlass.ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glasTier = t, te -> te.glasTier)) .build(); - private int mCasingAmount; - - + @SuppressWarnings({"unchecked", "rawtypes"}) @Override public IStructureDefinition<GT_MetaTileEntity_LargeChemicalReactor> getStructureDefinition() { return (IStructureDefinition) STRUCTURE_DEFINITION; } - private void onCasingAdded() { - mCasingAmount++; - } - - private byte glasTier; - - private boolean addGlas(Block block, int meta) { - if (block != ItemRegistry.bw_glasses[0]) { - return false; - } - byte tier = BW_Util.getTierFromGlasMeta(meta); - if (tier >= 8) tier = 8; - if (glasTier > 0) { - return tier == glasTier; - } - glasTier = tier; - return true; - } - @Override public String[] getInfoData() { return LoaderReference.tectech ? this.getInfoDataArray(this) : super.getInfoData(); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java index c8e9c00d58..b936958948 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaOilCracker.java @@ -22,28 +22,19 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; +import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; import com.github.bartimaeusnek.bartworks.API.LoaderReference; -import com.github.bartimaeusnek.bartworks.API.SideReference; -import com.github.bartimaeusnek.bartworks.client.textures.PrefixTextureLinker; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; -import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; -import com.github.bartimaeusnek.bartworks.system.material.*; import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; import com.github.bartimaeusnek.bartworks.util.BW_Util; import com.github.bartimaeusnek.bartworks.util.MegaUtils; import com.github.bartimaeusnek.bartworks.util.Pair; import com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti; import com.github.bartimaeusnek.crossmod.tectech.helper.TecTechUtils; -import com.gtnewhorizon.structurelib.StructureLibAPI; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.IStructureElement; import com.gtnewhorizon.structurelib.structure.StructureDefinition; import cpw.mods.fml.common.Optional; import gregtech.api.GregTech_API; -import gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.TextureSet; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; @@ -53,16 +44,10 @@ import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_OilCracker; -import net.minecraft.block.Block; -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 net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import static com.github.bartimaeusnek.bartworks.util.RecipeFinderForParallel.getMultiOutput; @@ -74,6 +59,11 @@ import static gregtech.api.util.GT_StructureUtility.*; @Optional.Interface(iface = "com.github.bartimaeusnek.crossmod.tectech.TecTechEnabledMulti", modid = "tectech", striprefs = true) public class GT_TileEntity_MegaOilCracker extends GT_MetaTileEntity_OilCracker implements TecTechEnabledMulti { + private final ArrayList<?> TTTunnels = new ArrayList<>(); + private final ArrayList<?> TTMultiAmp = new ArrayList<>(); + + private byte glasTier; + public GT_TileEntity_MegaOilCracker(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -113,11 +103,6 @@ public class GT_TileEntity_MegaOilCracker extends GT_MetaTileEntity_OilCracker i return new GT_TileEntity_MegaOilCracker(this.mName); } - @SuppressWarnings("rawtypes") - public ArrayList TTTunnels = new ArrayList<>(); - @SuppressWarnings("rawtypes") - public ArrayList TTMultiAmp = new ArrayList<>(); - @Override public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (LoaderReference.tectech) { @@ -201,8 +186,8 @@ public class GT_TileEntity_MegaOilCracker extends GT_MetaTileEntity_OilCracker i return false; } - if (this.heatLevel.getTier() < 5) { - this.mEUt *= 1 - (0.1D * (this.heatLevel.getTier() + 1)); + if (this.getCoilLevel().getTier() < 5) { + this.mEUt *= 1 - (0.1D * (this.getCoilLevel().getTier() + 1)); } else { this.mEUt *= 0.5; @@ -243,7 +228,7 @@ public class GT_TileEntity_MegaOilCracker extends GT_MetaTileEntity_OilCracker i } - if (this.glasTier != 8 && !this.mEnergyHatches.isEmpty()) { + if (this.glasTier < 8 && !this.mEnergyHatches.isEmpty()) { for (GT_MetaTileEntity_Hatch_Energy hatchEnergy : this.mEnergyHatches) { if (this.glasTier < hatchEnergy.mTier) { return false; @@ -269,7 +254,6 @@ public class GT_TileEntity_MegaOilCracker extends GT_MetaTileEntity_OilCracker i })) .addElement('c', ofCoil(GT_TileEntity_MegaOilCracker::setCoilLevel, GT_TileEntity_MegaOilCracker::getCoilLevel)) .addElement('p', ofBlock(GregTech_API.sBlockCasings4, 1)) -// .addElement('s', addTileCasing(BW_GT_MaterialReference.StainlessSteel)) .addElement('l', ofChain( ofHatchAdder(GT_TileEntity_MegaOilCracker::addLeftHatchToMachineList, CASING_INDEX, 2) )) @@ -279,20 +263,14 @@ public class GT_TileEntity_MegaOilCracker extends GT_MetaTileEntity_OilCracker i .addElement('m', ofChain( ofHatchAdder(GT_TileEntity_MegaOilCracker::addEnergyInputToMachineList, CASING_INDEX, 1), ofHatchAdder(GT_TileEntity_MegaOilCracker::addMaintenanceToMachineList, CASING_INDEX, 1), - onElementPass(GT_TileEntity_MegaOilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 1)) + ofBlock(GregTech_API.sBlockCasings4, 1) )) .addElement('M', ofChain( ofHatchAdder(GT_TileEntity_MegaOilCracker::addMiddleInputToMachineList, CASING_INDEX, 4) )) - .addElement('g', ofChain( - ofBlockAdder(GT_TileEntity_MegaOilCracker::addGlas, ItemRegistry.bw_glasses[0], 1) - )) + .addElement('g', BorosilicateGlass.ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glasTier = t, te -> te.glasTier)) .build(); - private HeatingCoilLevel heatLevel; - - private int mCoilAmount; - private boolean addLeftHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (aTileEntity == null) { return false; @@ -397,36 +375,12 @@ public class GT_TileEntity_MegaOilCracker extends GT_MetaTileEntity_OilCracker i return rList; } + @SuppressWarnings({"unchecked", "rawtypes"}) @Override public IStructureDefinition<GT_MetaTileEntity_OilCracker> getStructureDefinition() { return (IStructureDefinition) STRUCTURE_DEFINITION; } - private void onCasingAdded() { - mCasingAmount++; - } - - private byte glasTier; - - private boolean addGlas(Block block, int meta) { - if (block != ItemRegistry.bw_glasses[0]) { - return false; - } - byte tier = BW_Util.getTierFromGlasMeta(meta); - if (tier >= 8) tier = 8; - if (glasTier > 0) { - return tier == glasTier; - } - glasTier = tier; - return true; - } - - private void onCoilAdded() { - mCoilAmount++; - } - - - @Override public String[] getInfoData() { return LoaderReference.tectech ? this.getInfoDataArray(this) : super.getInfoData(); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java index f7ef9806c4..dc0b26776f 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java @@ -23,6 +23,7 @@ package com.github.bartimaeusnek.bartworks.util; import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; +import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; import com.github.bartimaeusnek.bartworks.MainMod; import gregtech.api.enums.Materials; import gregtech.api.enums.OreDictNames; @@ -325,6 +326,10 @@ public class BW_Util { return 0; } + /** + * @deprecated Use stuff in {@link com.github.bartimaeusnek.bartworks.API.BorosilicateGlass} instead + */ + @Deprecated public static byte getTierFromGlasMeta(int meta) { byte ret; switch (meta) { @@ -585,24 +590,9 @@ public class BW_Util { public static byte calculateGlassTier(@Nonnull Block block, @Nonnegative byte meta) { - if (bw_realglasRef == null){ - try { - bw_realglasRef = (Block) Class.forName("com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry").getField("bw_realglas").get(null); - } catch (IllegalAccessException | NoSuchFieldException | ClassNotFoundException e) { - e.printStackTrace(); - } - } - - if (block.equals(bw_realglasRef)) { - if (meta > 12) { - return (byte) (meta - 3); - } - if (meta == 12) - return 5; - if (meta > 1 && meta < 6) - return (byte) (meta + 3); - return 4; - } + byte boroTier = BorosilicateGlass.getTier(block, meta); + if (boroTier < 0) + return boroTier; if (block.getUnlocalizedName().equals("blockAlloyGlass")) return 4; |