From ef3d87425d4872432276331bab08b898aad0307f Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Mon, 11 Apr 2022 19:15:00 +0200 Subject: Add Extreme Industrial Greenhouse (GTNewHorizons/bartworks#111) * Add Extreme Industrial Greenhouse * Add info about crops inside the machine * Add a way to remove crops from machine * Add crafting recipe * Dont use full amp * Add glass tier requirements * Bug fix * Account for IC2 crops with two diffrent outputs * Add water requirement --- .../java/kubatech/client/effect/CropRenderer.java | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/main/java/kubatech/client/effect/CropRenderer.java (limited to 'src/main/java/kubatech/client/effect/CropRenderer.java') diff --git a/src/main/java/kubatech/client/effect/CropRenderer.java b/src/main/java/kubatech/client/effect/CropRenderer.java new file mode 100644 index 0000000000..c49b2010e3 --- /dev/null +++ b/src/main/java/kubatech/client/effect/CropRenderer.java @@ -0,0 +1,55 @@ +package kubatech.client.effect; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.particle.EntityFX; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class CropRenderer extends EntityFX { + int meta; + + public CropRenderer(World world, int x, int y, int z, int meta, int age) { + super(world, (double) x, ((double) y - 0.0625d), (double) z); + this.prevPosX = this.posX; + this.prevPosY = this.posY; + this.prevPosZ = this.posZ; + this.particleMaxAge = age; + this.meta = meta; + } + + @Override + public void onUpdate() { + if (this.particleAge++ >= this.particleMaxAge) + this.setDead(); + } + + @Override + public void renderParticle(Tessellator p_70539_1_, float p_70539_2_, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_) { + Tessellator tessellator = Tessellator.instance; + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDepthMask(false); + tessellator.setColorRGBA(255, 255, 255, 255); + float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) p_70539_2_ - interpPosX); + float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) p_70539_2_ - interpPosY); + float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) p_70539_2_ - interpPosZ); + RenderBlocks.getInstance().renderBlockCropsImpl(Blocks.wheat, meta, f11, f12, f13); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDepthMask(true); + } + + @Override + public int getFXLayer() { + return 1; + } + + @Override + public boolean shouldRenderInPass(int pass) { + return pass == 2; + } + +} -- cgit From 6969892cfb1efb03cb83fadc2638e47df04269bc Mon Sep 17 00:00:00 2001 From: Raven Szewczyk Date: Sat, 27 Aug 2022 10:56:37 +0100 Subject: Update buildscript & apply spotless (GTNewHorizons/bartworks#192) * Update dependencies * updateBuildscript & spotlessApply --- .../java/kubatech/client/effect/CropRenderer.java | 13 +- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 732 ++++++++++----------- 2 files changed, 370 insertions(+), 375 deletions(-) (limited to 'src/main/java/kubatech/client/effect/CropRenderer.java') diff --git a/src/main/java/kubatech/client/effect/CropRenderer.java b/src/main/java/kubatech/client/effect/CropRenderer.java index c49b2010e3..1fca559204 100644 --- a/src/main/java/kubatech/client/effect/CropRenderer.java +++ b/src/main/java/kubatech/client/effect/CropRenderer.java @@ -24,12 +24,18 @@ public class CropRenderer extends EntityFX { @Override public void onUpdate() { - if (this.particleAge++ >= this.particleMaxAge) - this.setDead(); + if (this.particleAge++ >= this.particleMaxAge) this.setDead(); } @Override - public void renderParticle(Tessellator p_70539_1_, float p_70539_2_, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_) { + public void renderParticle( + Tessellator p_70539_1_, + float p_70539_2_, + float p_70539_3_, + float p_70539_4_, + float p_70539_5_, + float p_70539_6_, + float p_70539_7_) { Tessellator tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); @@ -51,5 +57,4 @@ public class CropRenderer extends EntityFX { public boolean shouldRenderInPass(int pass) { return pass == 2; } - } diff --git a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java index dcbdbd3e0d..c0fe877df1 100644 --- a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java +++ b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java @@ -17,6 +17,11 @@ package kubatech.tileentity.gregtech.multiblock; +import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_VIA_BARTWORKS; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; import com.github.bartimaeusnek.bartworks.API.LoaderReference; import kubatech.client.effect.CropRenderer; @@ -45,6 +50,7 @@ import ic2.api.crops.CropCard; import ic2.api.crops.Crops; import ic2.core.Ic2Items; import ic2.core.crop.TileEntityCrop; +import java.util.*; import net.minecraft.block.Block; import net.minecraft.block.BlockStem; import net.minecraft.client.Minecraft; @@ -66,14 +72,8 @@ import net.minecraftforge.common.IPlantable; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import java.util.*; - -import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_VIA_BARTWORKS; -import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; -import static gregtech.api.enums.Textures.BlockIcons.*; -import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; - -public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEntity_EnhancedMultiBlockBase { +public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse + extends GT_MetaTileEntity_EnhancedMultiBlockBase { private static final boolean debug = false; @@ -86,29 +86,63 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn private static final int CASING_INDEX = 49; private static final String STRUCTURE_PIECE_MAIN = "main"; private static final Item forestryfertilizer = GameRegistry.findItem("Forestry", "fertilizerCompound"); - private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][] { - {"ccccc", "ccccc", "ccccc", "ccccc", "ccccc"}, - {"ccccc", "clllc", "clllc", "clllc", "ccccc"}, - {"ggggg", "g---g", "g---g", "g---g", "ggggg"}, - {"ggggg", "g---g", "g---g", "g---g", "ggggg"}, - {"ccccc", "cdddc", "cdwdc", "cdddc", "ccccc"}, - {"cc~cc", "cCCCc", "cCCCc", "cCCCc", "ccccc"}, - })) - .addElement('c', ofChain( - onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings4, 1)), - ofHatchAdder(GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addEnergyInputToMachineList, CASING_INDEX, 1), - ofHatchAdder(GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addMaintenanceToMachineList, CASING_INDEX, 1), - ofHatchAdder(GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addInputToMachineList, CASING_INDEX, 1), - ofHatchAdder(GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addOutputToMachineList, CASING_INDEX, 1) - )) - .addElement('C', onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings4, 1))) - .addElement('l', LoaderReference.ProjRedIllumination ? ofBlock(Block.getBlockFromName("ProjRed|Illumination:projectred.illumination.lamp"), 10) : ofBlock(Blocks.redstone_lamp, 0)) - .addElement('g', debug ? ofBlock(Blocks.glass, 0) : BorosilicateGlass.ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glasTier = t, te -> te.glasTier)) - .addElement('d', ofBlock(LoaderReference.RandomThings ? Block.getBlockFromName("RandomThings:fertilizedDirt_tilled") : Blocks.farmland, 0)) - .addElement('w', ofBlock(Blocks.water, 0)) - .build(); - + private static final IStructureDefinition STRUCTURE_DEFINITION = + StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][] { + {"ccccc", "ccccc", "ccccc", "ccccc", "ccccc"}, + {"ccccc", "clllc", "clllc", "clllc", "ccccc"}, + {"ggggg", "g---g", "g---g", "g---g", "ggggg"}, + {"ggggg", "g---g", "g---g", "g---g", "ggggg"}, + {"ccccc", "cdddc", "cdwdc", "cdddc", "ccccc"}, + {"cc~cc", "cCCCc", "cCCCc", "cCCCc", "ccccc"}, + })) + .addElement( + 'c', + ofChain( + onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings4, 1)), + ofHatchAdder( + GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addEnergyInputToMachineList, + CASING_INDEX, + 1), + ofHatchAdder( + GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addMaintenanceToMachineList, + CASING_INDEX, + 1), + ofHatchAdder( + GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addInputToMachineList, + CASING_INDEX, + 1), + ofHatchAdder( + GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addOutputToMachineList, + CASING_INDEX, + 1))) + .addElement('C', onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings4, 1))) + .addElement( + 'l', + LoaderReference.ProjRedIllumination + ? ofBlock( + Block.getBlockFromName("ProjRed|Illumination:projectred.illumination.lamp"), + 10) + : ofBlock(Blocks.redstone_lamp, 0)) + .addElement( + 'g', + debug + ? ofBlock(Blocks.glass, 0) + : BorosilicateGlass.ofBoroGlass( + (byte) 0, + (byte) 1, + Byte.MAX_VALUE, + (te, t) -> te.glasTier = t, + te -> te.glasTier)) + .addElement( + 'd', + ofBlock( + LoaderReference.RandomThings + ? Block.getBlockFromName("RandomThings:fertilizedDirt_tilled") + : Blocks.farmland, + 0)) + .addElement('w', ofBlock(Blocks.water, 0)) + .build(); public GT_MetaTileEntity_ExtremeIndustrialGreenhouse(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -120,31 +154,30 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn @Override public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if(aPlayer.isSneaking()) - { - if(this.mMaxProgresstime > 0) - { + if (aPlayer.isSneaking()) { + if (this.mMaxProgresstime > 0) { GT_Utility.sendChatToPlayer(aPlayer, "You cant change IC2 mode if the machine is working!"); return; } - if(!mStorage.isEmpty()) - { + if (!mStorage.isEmpty()) { GT_Utility.sendChatToPlayer(aPlayer, "You cant change IC2 mode if there are seeds inside!"); return; } this.isIC2Mode = !this.isIC2Mode; GT_Utility.sendChatToPlayer(aPlayer, "IC2 mode is now " + (this.isIC2Mode ? "enabled" : "disabled.")); - } - else { - if(this.mMaxProgresstime > 0) - { + } else { + if (this.mMaxProgresstime > 0) { GT_Utility.sendChatToPlayer(aPlayer, "You cant enable/disable setup if the machine is working!"); return; } this.setupphase++; - if(this.setupphase == 3) - this.setupphase = 0; - GT_Utility.sendChatToPlayer(aPlayer, "EIG is now running in " + (this.setupphase == 1 ? "setup mode (input)." : ( this.setupphase == 2 ? "setup mode (output)." : "normal operation."))); + if (this.setupphase == 3) this.setupphase = 0; + GT_Utility.sendChatToPlayer( + aPlayer, + "EIG is now running in " + + (this.setupphase == 1 + ? "setup mode (input)." + : (this.setupphase == 2 ? "setup mode (output)." : "normal operation."))); } } @@ -163,61 +196,60 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); } - private static String tierString(int tier){ + private static String tierString(int tier) { return GT_Values.TIER_COLORS[tier] + GT_Values.VN[tier] + ChatColorHelper.RESET + ChatColorHelper.GRAY; } @Override protected GT_Multiblock_Tooltip_Builder createTooltip() { GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt. - addMachineType("Crop Farm"). - addInfo("Controller block for the Extreme Industrial Greenhouse"). - addInfo("Grow your crops like a chad !"). - addInfo("Use screwdriver to enable/change/disable setup mode"). - addInfo("Use screwdriver while sneaking to enable/disable IC2 mode"). - addInfo("Uses 1000L of water per crop per operation"). - addInfo("You can insert fertilizer each operation to get more drops (max +400%)"). - addInfo("-------------------- SETUP MODE --------------------"). - addInfo("Does not take power"). - addInfo("There are two modes: input / output"). - addInfo("Input mode: machine will take seeds from input bus and plant them"). - addInfo("[IC2] You need to also input block that is required under the crop"). - addInfo("Output mode: machine will take planted seeds and output them"). - addInfo("-------------------- NORMAL CROPS --------------------"). - addInfo("Minimal tier: " + tierString(4)). - addInfo("Starting with 1 slot"). - addInfo("Every slot gives 64 crops"). - addInfo("Every tier past " + tierString(4) + ", slots are multiplied by 2"). - addInfo("Base process time: 5 sec"). - addInfo("Process time is divided by number of tiers past " + tierString(3) + " (Minimum 1 sec)"). - addInfo("All crops are grown at the end of the operation"). - addInfo("Will automatically craft seeds if they are not dropped"). - addInfo("1 Fertilizer per 1 crop +200%"). - addInfo("-------------------- IC2 CROPS --------------------"). - addInfo("Minimal tier: " + tierString(6)). - addInfo("Need " + tierString(6) + " glass tier"). - addInfo("Starting with 4 slots"). - addInfo("Every slot gives 1 crop"). - addInfo("Every tier past " + tierString(6) + ", slots are multiplied by 4"). - addInfo("Process time: 5 sec"). - addInfo("All crops are accelerated by x32 times"). - addInfo("1 Fertilizer per 1 crop +10%"). - addInfo(BW_Tooltip_Reference.TT_BLUEPRINT). - addSeparator(). - beginStructureBlock(5, 4, 5, false). - addController("Front bottom center"). - addCasingInfo("Clean Stainless Steel Casings", 70). - addOtherStructurePart("Borosilicate Glass", "Hollow two middle layers", 2). - addStructureInfo("The glass tier limits the Energy Input tier"). - addStructureInfo("The dirt is from RandomThings, must be tilled"). - addStructureInfo("Purple lamps are from ProjectRedIllumination. They can be lit"). - addMaintenanceHatch("Any casing (Except inner bottom ones)", 1). - addInputBus("Any casing (Except inner bottom ones)", 1). - addOutputBus("Any casing (Except inner bottom ones)", 1). - addInputHatch("Any casing (Except inner bottom ones)", 1). - addEnergyHatch("Any casing (Except inner bottom ones)", 1). - toolTipFinisher(MULTIBLOCK_ADDED_VIA_BARTWORKS.apply(ChatColorHelper.GOLD + "kuba6000")); + tt.addMachineType("Crop Farm") + .addInfo("Controller block for the Extreme Industrial Greenhouse") + .addInfo("Grow your crops like a chad !") + .addInfo("Use screwdriver to enable/change/disable setup mode") + .addInfo("Use screwdriver while sneaking to enable/disable IC2 mode") + .addInfo("Uses 1000L of water per crop per operation") + .addInfo("You can insert fertilizer each operation to get more drops (max +400%)") + .addInfo("-------------------- SETUP MODE --------------------") + .addInfo("Does not take power") + .addInfo("There are two modes: input / output") + .addInfo("Input mode: machine will take seeds from input bus and plant them") + .addInfo("[IC2] You need to also input block that is required under the crop") + .addInfo("Output mode: machine will take planted seeds and output them") + .addInfo("-------------------- NORMAL CROPS --------------------") + .addInfo("Minimal tier: " + tierString(4)) + .addInfo("Starting with 1 slot") + .addInfo("Every slot gives 64 crops") + .addInfo("Every tier past " + tierString(4) + ", slots are multiplied by 2") + .addInfo("Base process time: 5 sec") + .addInfo("Process time is divided by number of tiers past " + tierString(3) + " (Minimum 1 sec)") + .addInfo("All crops are grown at the end of the operation") + .addInfo("Will automatically craft seeds if they are not dropped") + .addInfo("1 Fertilizer per 1 crop +200%") + .addInfo("-------------------- IC2 CROPS --------------------") + .addInfo("Minimal tier: " + tierString(6)) + .addInfo("Need " + tierString(6) + " glass tier") + .addInfo("Starting with 4 slots") + .addInfo("Every slot gives 1 crop") + .addInfo("Every tier past " + tierString(6) + ", slots are multiplied by 4") + .addInfo("Process time: 5 sec") + .addInfo("All crops are accelerated by x32 times") + .addInfo("1 Fertilizer per 1 crop +10%") + .addInfo(BW_Tooltip_Reference.TT_BLUEPRINT) + .addSeparator() + .beginStructureBlock(5, 4, 5, false) + .addController("Front bottom center") + .addCasingInfo("Clean Stainless Steel Casings", 70) + .addOtherStructurePart("Borosilicate Glass", "Hollow two middle layers", 2) + .addStructureInfo("The glass tier limits the Energy Input tier") + .addStructureInfo("The dirt is from RandomThings, must be tilled") + .addStructureInfo("Purple lamps are from ProjectRedIllumination. They can be lit") + .addMaintenanceHatch("Any casing (Except inner bottom ones)", 1) + .addInputBus("Any casing (Except inner bottom ones)", 1) + .addOutputBus("Any casing (Except inner bottom ones)", 1) + .addInputHatch("Any casing (Except inner bottom ones)", 1) + .addEnergyHatch("Any casing (Except inner bottom ones)", 1) + .toolTipFinisher(MULTIBLOCK_ADDED_VIA_BARTWORKS.apply(ChatColorHelper.GOLD + "kuba6000")); return tt; } @@ -226,7 +258,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn List info = new ArrayList<>(Arrays.asList(super.getStructureDescription(stackSize))); info.add("The dirt is from RandomThings, must be tilled"); info.add("Purple lamps are from ProjectRedIllumination. They can be lit"); - return info.toArray(new String[]{}); + return info.toArray(new String[] {}); } @Override @@ -236,7 +268,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn aNBT.setInteger("setupphase", setupphase); aNBT.setBoolean("isIC2Mode", isIC2Mode); aNBT.setInteger("mStorageSize", mStorage.size()); - for(int i = 0; i < mStorage.size(); i++) + for (int i = 0; i < mStorage.size(); i++) aNBT.setTag("mStorage." + i, mStorage.get(i).toNBTTagCompound()); } @@ -246,12 +278,12 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn glasTier = aNBT.getByte("glasTier"); setupphase = aNBT.getInteger("setupphase"); isIC2Mode = aNBT.getBoolean("isIC2Mode"); - for(int i = 0; i < aNBT.getInteger("mStorageSize"); i++) + for (int i = 0; i < aNBT.getInteger("mStorageSize"); i++) mStorage.add(new GreenHouseSlot(aNBT.getCompoundTag("mStorage." + i))); } @SideOnly(Side.CLIENT) - public void spawnVisualCrop(World world, int x, int y, int z, int meta, int age){ + public void spawnVisualCrop(World world, int x, int y, int z, int meta, int age) { CropRenderer crop = new CropRenderer(world, x, y, z, meta, age); Minecraft.getMinecraft().effectRenderer.addEffect(crop); } @@ -259,36 +291,35 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); - if(aBaseMetaTileEntity.isClientSide()) - { - if(aBaseMetaTileEntity.isActive() && aTick % 40 == 0) { - for(int x = -1; x <= 1; x++) - for(int z = -1; z <= 1; z++) { - if(x == 0 && z == 0) - continue; - int[] abc = new int[]{x, -2, z+2}; - int[] xyz = new int[]{0, 0, 0}; + if (aBaseMetaTileEntity.isClientSide()) { + if (aBaseMetaTileEntity.isActive() && aTick % 40 == 0) { + for (int x = -1; x <= 1; x++) + for (int z = -1; z <= 1; z++) { + if (x == 0 && z == 0) continue; + int[] abc = new int[] {x, -2, z + 2}; + int[] xyz = new int[] {0, 0, 0}; this.getExtendedFacing().getWorldOffset(abc, xyz); xyz[0] += aBaseMetaTileEntity.getXCoord(); xyz[1] += aBaseMetaTileEntity.getYCoord(); xyz[2] += aBaseMetaTileEntity.getZCoord(); - spawnVisualCrop(aBaseMetaTileEntity.getWorld(), xyz[0], xyz[1], xyz[2], aBaseMetaTileEntity.getRandomNumber(8), 40); + spawnVisualCrop( + aBaseMetaTileEntity.getWorld(), + xyz[0], + xyz[1], + xyz[2], + aBaseMetaTileEntity.getRandomNumber(8), + 40); } } } - if(aBaseMetaTileEntity.isServerSide() && this.mMaxProgresstime > 0 && setupphase > 0 && aTick % 5 == 0) - { - if(setupphase == 1 && mStorage.size() < mMaxSlots) { + if (aBaseMetaTileEntity.isServerSide() && this.mMaxProgresstime > 0 && setupphase > 0 && aTick % 5 == 0) { + if (setupphase == 1 && mStorage.size() < mMaxSlots) { List inputs = getStoredInputs(); - for (ItemStack input : inputs) - if (addCrop(input)) - break; + for (ItemStack input : inputs) if (addCrop(input)) break; this.updateSlots(); - } - else if(setupphase == 2 && mStorage.size() > 0) - { + } else if (setupphase == 2 && mStorage.size() > 0) { this.addOutput(this.mStorage.get(0).input.copy()); - if(this.mStorage.get(0).undercrop != null) + if (this.mStorage.get(0).undercrop != null) this.addOutput(this.mStorage.get(0).undercrop.copy()); this.mStorage.remove(0); this.updateSlots(); @@ -306,16 +337,12 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn return true; } - private void updateMaxSlots() - { + private void updateMaxSlots() { long v = this.getMaxInputVoltage(); int tier = GT_Utility.getTier(v); - if(tier < (isIC2Mode ? 6 : 4)) - mMaxSlots = 0; - else if(isIC2Mode) - mMaxSlots = 4 << (2 * (tier - 6)); - else - mMaxSlots = 1 << (tier - 4); + if (tier < (isIC2Mode ? 6 : 4)) mMaxSlots = 0; + else if (isIC2Mode) mMaxSlots = 4 << (2 * (tier - 6)); + else mMaxSlots = 1 << (tier - 4); } @Override @@ -323,8 +350,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn long v = this.getMaxInputVoltage(); int tier = GT_Utility.getTier(v); updateMaxSlots(); - if(setupphase > 0) { - if((mStorage.size() >= mMaxSlots && setupphase == 1) || (mStorage.size() == 0 && setupphase == 2)) + if (setupphase > 0) { + if ((mStorage.size() >= mMaxSlots && setupphase == 1) || (mStorage.size() == 0 && setupphase == 2)) return false; this.mMaxProgresstime = 20; this.mEUt = 0; @@ -332,65 +359,56 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn this.mEfficiencyIncrease = 10000; return true; } - if(mStorage.size() > mMaxSlots) - return false; - if(mStorage.isEmpty()) - return false; + if (mStorage.size() > mMaxSlots) return false; + if (mStorage.isEmpty()) return false; waterusage = 0; - for(GreenHouseSlot s : mStorage) - waterusage += s.input.stackSize; + for (GreenHouseSlot s : mStorage) waterusage += s.input.stackSize; - if(!depleteInput(new FluidStack(FluidRegistry.WATER, waterusage * 1000)) && !debug) - return false; + if (!depleteInput(new FluidStack(FluidRegistry.WATER, waterusage * 1000)) && !debug) return false; // OVERCLOCK - // FERTILIZER IDEA - IC2 +10% per fertilizer per crop per operation, NORMAL +200% per fertilizer per crop per operation + // FERTILIZER IDEA - IC2 +10% per fertilizer per crop per operation, NORMAL +200% per fertilizer per crop per + // operation int boost = 0; int maxboost = 0; - for(GreenHouseSlot s : mStorage) - maxboost += s.input.stackSize * (isIC2Mode ? 40 : 2); + for (GreenHouseSlot s : mStorage) maxboost += s.input.stackSize * (isIC2Mode ? 40 : 2); ArrayList inputs = getStoredInputs(); - for(ItemStack i : inputs){ - if(( i.getItem() == Items.dye && i.getItemDamage() == 15) || - (forestryfertilizer != null && (i.getItem() == forestryfertilizer)) || - (GT_Utility.areStacksEqual(i, Ic2Items.fertilizer))) - { + for (ItemStack i : inputs) { + if ((i.getItem() == Items.dye && i.getItemDamage() == 15) + || (forestryfertilizer != null && (i.getItem() == forestryfertilizer)) + || (GT_Utility.areStacksEqual(i, Ic2Items.fertilizer))) { int used = Math.min(i.stackSize, maxboost - boost); i.stackSize -= used; boost += used; } - if(boost == maxboost) - break; + if (boost == maxboost) break; } - double multiplier = 1.d + (((double)boost/(double)maxboost) * 4d); + double multiplier = 1.d + (((double) boost / (double) maxboost) * 4d); - if(isIC2Mode) - { - if(glasTier < 6) - return false; + if (isIC2Mode) { + if (glasTier < 6) return false; this.mMaxProgresstime = 100; List outputs = new ArrayList<>(); for (int i = 0; i < Math.min(mMaxSlots, mStorage.size()); i++) - outputs.addAll(mStorage.get(i).getIC2Drops(((double)this.mMaxProgresstime / 8d) * multiplier)); + outputs.addAll(mStorage.get(i).getIC2Drops(((double) this.mMaxProgresstime / 8d) * multiplier)); this.mOutputItems = outputs.toArray(new ItemStack[0]); - } - else { + } else { this.mMaxProgresstime = Math.max(20, 100 / (tier - 3)); // Min 1 s List outputs = new ArrayList<>(); for (int i = 0; i < Math.min(mMaxSlots, mStorage.size()); i++) { for (ItemStack drop : mStorage.get(i).getDrops()) { ItemStack s = drop.copy(); - s.stackSize = (int)((double)s.stackSize * multiplier); + s.stackSize = (int) ((double) s.stackSize * multiplier); outputs.add(s); } } this.mOutputItems = outputs.toArray(new ItemStack[0]); } - this.mEUt = -(int)((double) GT_Values.V[tier] * 0.99d); + this.mEUt = -(int) ((double) GT_Values.V[tier] * 0.99d); this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; this.updateSlots(); @@ -401,23 +419,17 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { mCasing = 0; glasTier = 0; - if(debug) - glasTier = 8; + if (debug) glasTier = 8; - if(!checkPiece(STRUCTURE_PIECE_MAIN, 2, 5, 0)) - return false; + if (!checkPiece(STRUCTURE_PIECE_MAIN, 2, 5, 0)) return false; if (this.glasTier < 8 && !this.mEnergyHatches.isEmpty()) for (GT_MetaTileEntity_Hatch_Energy hatchEnergy : this.mEnergyHatches) - if (this.glasTier < hatchEnergy.mTier) - return false; + if (this.glasTier < hatchEnergy.mTier) return false; - boolean valid = this.mMaintenanceHatches.size() == 1 && - this.mEnergyHatches.size() >= 1 && - this.mCasing >= 70; + boolean valid = this.mMaintenanceHatches.size() == 1 && this.mEnergyHatches.size() >= 1 && this.mCasing >= 70; - if(valid) - updateMaxSlots(); + if (valid) updateMaxSlots(); return valid; } @@ -440,62 +452,87 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn @Override public String[] getInfoData() { List info = new ArrayList<>(Arrays.asList( - "Running in mode: " + EnumChatFormatting.GREEN + (setupphase == 0 ? (isIC2Mode ? "IC2 crops" : "Normal crops") : ("Setup mode " + (setupphase == 1 ? "(input)" : "(output)"))) + EnumChatFormatting.RESET, - "Uses " + waterusage * 1000 + "L/operation of water", - "Max slots: " + EnumChatFormatting.GREEN + this.mMaxSlots + EnumChatFormatting.RESET, - "Used slots: " + ((mStorage.size() > mMaxSlots) ? EnumChatFormatting.RED : EnumChatFormatting.GREEN) + this.mStorage.size() + EnumChatFormatting.RESET - )); - for(int i = 0; i < mStorage.size(); i++) { - if(!mStorage.get(i).isValid) - continue; - StringBuilder a = new StringBuilder("Slot " + i + ": " + EnumChatFormatting.GREEN + "x" + this.mStorage.get(i).input.stackSize + " " + this.mStorage.get(i).input.getDisplayName()); - if(this.isIC2Mode) { + "Running in mode: " + EnumChatFormatting.GREEN + + (setupphase == 0 + ? (isIC2Mode ? "IC2 crops" : "Normal crops") + : ("Setup mode " + (setupphase == 1 ? "(input)" : "(output)"))) + + EnumChatFormatting.RESET, + "Uses " + waterusage * 1000 + "L/operation of water", + "Max slots: " + EnumChatFormatting.GREEN + this.mMaxSlots + EnumChatFormatting.RESET, + "Used slots: " + ((mStorage.size() > mMaxSlots) ? EnumChatFormatting.RED : EnumChatFormatting.GREEN) + + this.mStorage.size() + EnumChatFormatting.RESET)); + for (int i = 0; i < mStorage.size(); i++) { + if (!mStorage.get(i).isValid) continue; + StringBuilder a = new StringBuilder( + "Slot " + i + ": " + EnumChatFormatting.GREEN + "x" + this.mStorage.get(i).input.stackSize + " " + + this.mStorage.get(i).input.getDisplayName()); + if (this.isIC2Mode) { a.append(" : "); - for (Map.Entry entry : mStorage.get(i).dropprogress.entrySet()) + for (Map.Entry entry : + mStorage.get(i).dropprogress.entrySet()) a.append((int) (entry.getValue() * 100d)).append("% "); } a.append(EnumChatFormatting.RESET); info.add(a.toString()); } - if(mStorage.size() > mMaxSlots) - info.add(EnumChatFormatting.DARK_RED + "There are too many crops inside to run !" + EnumChatFormatting.RESET); + if (mStorage.size() > mMaxSlots) + info.add(EnumChatFormatting.DARK_RED + "There are too many crops inside to run !" + + EnumChatFormatting.RESET); info.addAll(Arrays.asList(super.getInfoData())); return info.toArray(new String[0]); } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + public ITexture[] getTexture( + IGregTechTileEntity aBaseMetaTileEntity, + byte aSide, + byte aFacing, + byte aColorIndex, + boolean aActive, + boolean aRedstone) { if (aSide == aFacing) { if (aActive) - return new ITexture[]{ + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), - TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE).extFacing().build(), - TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW).extFacing().glow().build()}; - return new ITexture[]{ + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW) + .extFacing() + .glow() + .build() + }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), - TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER).extFacing().build(), - TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW).extFacing().glow().build()}; + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW) + .extFacing() + .glow() + .build() + }; } - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_INDEX)}; + return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(CASING_INDEX)}; } public List mStorage = new ArrayList<>(); - public boolean addCrop(ItemStack input){ - if(!isIC2Mode) - for(GreenHouseSlot g : mStorage) - if(GT_Utility.areStacksEqual(g.input, input)) - { + public boolean addCrop(ItemStack input) { + if (!isIC2Mode) + for (GreenHouseSlot g : mStorage) + if (GT_Utility.areStacksEqual(g.input, input)) { g.addAll(this.getBaseMetaTileEntity().getWorld(), input); - if(input.stackSize == 0) - return true; + if (input.stackSize == 0) return true; } GreenHouseSlot h = new GreenHouseSlot(this, input.copy(), true, isIC2Mode); - if(h.isValid) { - if(isIC2Mode) - input.stackSize--; - else - input.stackSize = 0; + if (h.isValid) { + if (isIC2Mode) input.stackSize--; + else input.stackSize = 0; mStorage.add(h); return true; } @@ -523,69 +560,66 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn static GreenHouseWorld fakeworld = new GreenHouseWorld(5, 5, 5); - public NBTTagCompound toNBTTagCompound(){ + public NBTTagCompound toNBTTagCompound() { NBTTagCompound aNBT = new NBTTagCompound(); aNBT.setTag("input", input.writeToNBT(new NBTTagCompound())); aNBT.setBoolean("isValid", isValid); aNBT.setBoolean("isIC2Crop", isIC2Crop); - if(!isIC2Crop) { + if (!isIC2Crop) { aNBT.setInteger("crop", Block.getIdFromBlock(crop)); aNBT.setInteger("dropscount", drops.size()); for (int i = 0; i < drops.size(); i++) aNBT.setTag("drop." + i, drops.get(i).writeToNBT(new NBTTagCompound())); aNBT.setInteger("optimalgrowth", optimalgrowth); aNBT.setBoolean("needsreplanting", needsreplanting); - } - else { - if(undercrop != null) - aNBT.setTag("undercrop", undercrop.writeToNBT(new NBTTagCompound())); + } else { + if (undercrop != null) aNBT.setTag("undercrop", undercrop.writeToNBT(new NBTTagCompound())); aNBT.setInteger("generationscount", generations.size()); - for(int i = 0; i < generations.size(); i++) - { - aNBT.setInteger("generation." + i + ".count", generations.get(i).size()); - for(int j = 0; j < generations.get(i).size(); j++) - aNBT.setTag("generation." + i + "." + j, generations.get(i).get(j).writeToNBT(new NBTTagCompound())); + for (int i = 0; i < generations.size(); i++) { + aNBT.setInteger( + "generation." + i + ".count", generations.get(i).size()); + for (int j = 0; j < generations.get(i).size(); j++) + aNBT.setTag( + "generation." + i + "." + j, + generations.get(i).get(j).writeToNBT(new NBTTagCompound())); } aNBT.setInteger("growthticks", growthticks); } return aNBT; } - public GreenHouseSlot(NBTTagCompound aNBT){ + public GreenHouseSlot(NBTTagCompound aNBT) { super(null, 3, 3); isIC2Crop = aNBT.getBoolean("isIC2Crop"); isValid = aNBT.getBoolean("isValid"); input = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("input")); - if(!isIC2Crop) { + if (!isIC2Crop) { crop = Block.getBlockById(aNBT.getInteger("crop")); drops = new ArrayList<>(); for (int i = 0; i < aNBT.getInteger("dropscount"); i++) drops.add(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("drop." + i))); optimalgrowth = aNBT.getInteger("optimalgrowth"); - if(optimalgrowth == 0) optimalgrowth = 7; - if(aNBT.hasKey("needsreplanting")) needsreplanting = aNBT.getBoolean("needsreplanting"); - } - else - { - if(aNBT.hasKey("undercrop")) + if (optimalgrowth == 0) optimalgrowth = 7; + if (aNBT.hasKey("needsreplanting")) needsreplanting = aNBT.getBoolean("needsreplanting"); + } else { + if (aNBT.hasKey("undercrop")) undercrop = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("undercrop")); generations = new ArrayList<>(); - for(int i = 0; i < aNBT.getInteger("generationscount"); i++) - { + for (int i = 0; i < aNBT.getInteger("generationscount"); i++) { generations.add(new ArrayList<>()); - for(int j = 0; j < aNBT.getInteger("generation." + i + ".count"); j++) - generations.get(i).add(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("generation." + i + "." + j))); + for (int j = 0; j < aNBT.getInteger("generation." + i + ".count"); j++) + generations + .get(i) + .add(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("generation." + i + "." + j))); } growthticks = aNBT.getInteger("growthticks"); rn = new Random(); } } - public boolean addAll(World world, ItemStack input){ - if(!GT_Utility.areStacksEqual(this.input, input)) - return false; - if(this.input.stackSize == 64) - return false; + public boolean addAll(World world, ItemStack input) { + if (!GT_Utility.areStacksEqual(this.input, input)) return false; + if (this.input.stackSize == 64) return false; int toconsume = Math.min(64 - this.input.stackSize, input.stackSize); int left = addDrops(world, toconsume, true); input.stackSize -= toconsume - left; @@ -593,17 +627,20 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn return left == 0; } - public boolean findCropRecipe(World world){ - if(recipe != null) - return true; - out : for (ItemStack drop : drops) { + public boolean findCropRecipe(World world) { + if (recipe != null) return true; + out: + for (ItemStack drop : drops) { recipeInput = drop; - for (int j = 0; j < CraftingManager.getInstance().getRecipeList().size(); j++) { - recipe = (IRecipe) CraftingManager.getInstance().getRecipeList().get(j); - if (recipe.matches(this, world) && GT_Utility.areStacksEqual(recipe.getCraftingResult(this), input)) { + for (int j = 0; + j < CraftingManager.getInstance().getRecipeList().size(); + j++) { + recipe = (IRecipe) + CraftingManager.getInstance().getRecipeList().get(j); + if (recipe.matches(this, world) + && GT_Utility.areStacksEqual(recipe.getCraftingResult(this), input)) { break out; - } else - recipe = null; + } else recipe = null; } } return recipe != null; @@ -611,8 +648,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn @Override public ItemStack getStackInSlot(int p_70301_1_) { - if(p_70301_1_ == 0) - return recipeInput.copy(); + if (p_70301_1_ == 0) return recipeInput.copy(); return null; } @@ -622,8 +658,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn } @Override - public ItemStack decrStackSize(int par1, int par2) - { + public ItemStack decrStackSize(int par1, int par2) { return null; } @@ -632,65 +667,55 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn return; } - public GreenHouseSlot(GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, ItemStack input, boolean autocraft, boolean IC2){ + public GreenHouseSlot( + GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, ItemStack input, boolean autocraft, boolean IC2) { super(null, 3, 3); World world = tileEntity.getBaseMetaTileEntity().getWorld(); this.input = input.copy(); this.isValid = false; - if(IC2) - { + if (IC2) { GreenHouseSlotIC2(tileEntity, world, input); return; } Item i = input.getItem(); Block b = null; - if(i instanceof IPlantable) { - if (i instanceof ItemSeeds) - b = ((ItemSeeds) i).getPlant(world, 0, 0, 0); - else if (i instanceof ItemSeedFood) - b = ((ItemSeedFood) i).getPlant(world, 0, 0, 0); - } - else { - if(i == Items.reeds) - b = Blocks.reeds; + if (i instanceof IPlantable) { + if (i instanceof ItemSeeds) b = ((ItemSeeds) i).getPlant(world, 0, 0, 0); + else if (i instanceof ItemSeedFood) b = ((ItemSeedFood) i).getPlant(world, 0, 0, 0); + } else { + if (i == Items.reeds) b = Blocks.reeds; else { b = Block.getBlockFromItem(i); - if(!(b == Blocks.cactus)) - return; + if (!(b == Blocks.cactus)) return; } needsreplanting = false; } - if (!(b instanceof IPlantable)) - return; + if (!(b instanceof IPlantable)) return; GameRegistry.UniqueIdentifier u = GameRegistry.findUniqueIdentifierFor(i); - if(u != null && Objects.equals(u.modId, "Natura")) - optimalgrowth = 8; + if (u != null && Objects.equals(u.modId, "Natura")) optimalgrowth = 8; - if(b instanceof BlockStem){ + if (b instanceof BlockStem) { fakeworld.block = null; try { b.updateTick(fakeworld, 5, 5, 5, fakeworld.rand); - } - catch(Exception e) - { + } catch (Exception e) { e.printStackTrace(System.err); } - if(fakeworld.block == null) - return; + if (fakeworld.block == null) return; b = fakeworld.block; needsreplanting = false; } crop = b; isIC2Crop = false; - if(addDrops(world, input.stackSize, autocraft) == 0 && !drops.isEmpty()){ + if (addDrops(world, input.stackSize, autocraft) == 0 && !drops.isEmpty()) { this.isValid = true; } } - public void GreenHouseSlotIC2(GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, World world, ItemStack input){ - if(!ItemList.IC2_Crop_Seeds.isStackEqual(input, true, true)) - return; + public void GreenHouseSlotIC2( + GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, World world, ItemStack input) { + if (!ItemList.IC2_Crop_Seeds.isStackEqual(input, true, true)) return; CropCard cc = Crops.instance.getCropCard(input); this.input.stackSize = 1; NBTTagCompound nbt = input.getTagCompound(); @@ -698,16 +723,16 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn byte ga = nbt.getByte("gain"); byte re = nbt.getByte("resistance"); this.isIC2Crop = true; - int[] abc = new int[]{0, -2, 3}; - int[] xyz = new int[]{0, 0, 0}; + int[] abc = new int[] {0, -2, 3}; + int[] xyz = new int[] {0, 0, 0}; tileEntity.getExtendedFacing().getWorldOffset(abc, xyz); xyz[0] += tileEntity.getBaseMetaTileEntity().getXCoord(); xyz[1] += tileEntity.getBaseMetaTileEntity().getYCoord(); xyz[2] += tileEntity.getBaseMetaTileEntity().getZCoord(); boolean cheating = false; - try{ - if(world.getBlock(xyz[0], xyz[1] - 2, xyz[2]) != GregTech_API.sBlockCasings4 || world.getBlockMetadata(xyz[0], xyz[1] - 2, xyz[2]) != 1) - { + try { + if (world.getBlock(xyz[0], xyz[1] - 2, xyz[2]) != GregTech_API.sBlockCasings4 + || world.getBlockMetadata(xyz[0], xyz[1] - 2, xyz[2]) != 1) { // no cheating = true; return; @@ -715,12 +740,11 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn world.setBlock(xyz[0], xyz[1], xyz[2], Block.getBlockFromItem(Ic2Items.crop.getItem()), 0, 0); TileEntity wte = world.getTileEntity(xyz[0], xyz[1], xyz[2]); - if(!(wte instanceof TileEntityCrop)) - { + if (!(wte instanceof TileEntityCrop)) { // should not be even possible return; } - TileEntityCrop te = (TileEntityCrop)wte; + TileEntityCrop te = (TileEntityCrop) wte; te.ticker = 1; // dont even think about ticking once te.setCrop(cc); @@ -731,20 +755,16 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn ItemStack tobeused = null; te.setSize((byte) (cc.maxSize() - 1)); - if(!cc.canGrow(te)) - { + if (!cc.canGrow(te)) { // needs special block boolean cangrow = false; ArrayList inputs = tileEntity.getStoredInputs(); - for(ItemStack a : inputs) - { + for (ItemStack a : inputs) { Block b = Block.getBlockFromItem(a.getItem()); - if(b == Blocks.air) - continue; + if (b == Blocks.air) continue; world.setBlock(xyz[0], xyz[1] - 2, xyz[2], b, a.getItemDamage(), 0); - if(!cc.canGrow(te)) - continue; + if (!cc.canGrow(te)) continue; cangrow = true; undercrop = a.copy(); undercrop.stackSize = 1; @@ -752,142 +772,116 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn break; } - if(!cangrow) - return; + if (!cangrow) return; } te.setSize((byte) cc.maxSize()); - if(!cc.canBeHarvested(te)) - return; + if (!cc.canBeHarvested(te)) return; // GENERATE DROPS generations = new ArrayList<>(); - out: for(int i = 0; i < 10; i++) // get 10 generations + out: + for (int i = 0; i < 10; i++) // get 10 generations { ItemStack[] st = te.harvest_automated(false); te.setSize((byte) cc.maxSize()); - if (st == null) - continue; - if (st.length == 0) - continue; - for(ItemStack s : st) - if(s == null) - continue out; + if (st == null) continue; + if (st.length == 0) continue; + for (ItemStack s : st) if (s == null) continue out; generations.add(new ArrayList<>(Arrays.asList(st))); } - if(generations.isEmpty()) - return; + if (generations.isEmpty()) return; rn = new Random(); - // CHECK GROWTH SPEED - te.humidity = 12; // humidity with full water storage - te.airQuality = 6; // air quality when sky is seen - te.nutrients = 8; // netrients with full nutrient storage + te.humidity = 12; // humidity with full water storage + te.airQuality = 6; // air quality when sky is seen + te.nutrients = 8; // netrients with full nutrient storage int dur = cc.growthDuration(te); int rate = te.calcGrowthRate(); - if(rate == 0) // should not be possible with those stats - return; + if (rate == 0) // should not be possible with those stats + return; growthticks = dur / rate; - if(growthticks < 1) - growthticks = 1; + if (growthticks < 1) growthticks = 1; - input.stackSize --; - if(tobeused != null) - tobeused.stackSize --; + input.stackSize--; + if (tobeused != null) tobeused.stackSize--; this.isValid = true; - } - catch (Exception e){ + } catch (Exception e) { e.printStackTrace(System.err); - } - finally { - if(!cheating) - world.setBlock(xyz[0], xyz[1] - 2, xyz[2], GregTech_API.sBlockCasings4, 1, 0); + } finally { + if (!cheating) world.setBlock(xyz[0], xyz[1] - 2, xyz[2], GregTech_API.sBlockCasings4, 1, 0); world.setBlockToAir(xyz[0], xyz[1], xyz[2]); } } - public List getDrops(){ + public List getDrops() { return drops; } Map dropprogress = new HashMap<>(); static Map dropstacks = new HashMap<>(); - public List getIC2Drops(double timeelapsed){ + public List getIC2Drops(double timeelapsed) { int r = rn.nextInt(10); - if(generations.size() <= r) - return new ArrayList<>(); - double growthPercent = (timeelapsed / (double)growthticks); + if (generations.size() <= r) return new ArrayList<>(); + double growthPercent = (timeelapsed / (double) growthticks); List generation = generations.get(r); List copied = new ArrayList<>(); - for(ItemStack g : generation) - copied.add(g.copy()); - for(ItemStack s : copied) - { - double pro = ((double)s.stackSize * growthPercent); + for (ItemStack g : generation) copied.add(g.copy()); + for (ItemStack s : copied) { + double pro = ((double) s.stackSize * growthPercent); s.stackSize = 1; - if(dropprogress.containsKey(s.toString())) + if (dropprogress.containsKey(s.toString())) dropprogress.put(s.toString(), dropprogress.get(s.toString()) + pro); - else - dropprogress.put(s.toString(), pro); - if(!dropstacks.containsKey(s.toString())) - dropstacks.put(s.toString(), s.copy()); + else dropprogress.put(s.toString(), pro); + if (!dropstacks.containsKey(s.toString())) dropstacks.put(s.toString(), s.copy()); } copied.clear(); - for(Map.Entry entry : dropprogress.entrySet()) - if(entry.getValue() >= 1d) - { + for (Map.Entry entry : dropprogress.entrySet()) + if (entry.getValue() >= 1d) { copied.add(dropstacks.get(entry.getKey()).copy()); - copied.get(copied.size()-1).stackSize = entry.getValue().intValue(); - entry.setValue(entry.getValue() - (double)entry.getValue().intValue()); + copied.get(copied.size() - 1).stackSize = entry.getValue().intValue(); + entry.setValue(entry.getValue() - (double) entry.getValue().intValue()); } return copied; } - public int addDrops(World world, int count, boolean autocraft){ + public int addDrops(World world, int count, boolean autocraft) { drops = new ArrayList<>(); - for(int i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { List d = crop.getDrops(world, 0, 0, 0, optimalgrowth, 0); - for(ItemStack x : drops) - for(ItemStack y : d) - if(GT_Utility.areStacksEqual(x, y)) - { + for (ItemStack x : drops) + for (ItemStack y : d) + if (GT_Utility.areStacksEqual(x, y)) { x.stackSize += y.stackSize; y.stackSize = 0; } - for(ItemStack x : d) - if(x.stackSize > 0) - drops.add(x.copy()); + for (ItemStack x : d) if (x.stackSize > 0) drops.add(x.copy()); } - if(!needsreplanting) - return 0; - for(int i = 0; i < drops.size(); i++) - { - if(GT_Utility.areStacksEqual(drops.get(i), input)) - { + if (!needsreplanting) return 0; + for (int i = 0; i < drops.size(); i++) { + if (GT_Utility.areStacksEqual(drops.get(i), input)) { int took = Math.min(drops.get(i).stackSize, count); drops.get(i).stackSize -= took; count -= took; - if(drops.get(i).stackSize == 0) { + if (drops.get(i).stackSize == 0) { drops.remove(i); i--; } - if(count == 0) { + if (count == 0) { return 0; } } } - if(autocraft) - { - if(!findCropRecipe(world)) - return count; + if (autocraft) { + if (!findCropRecipe(world)) return count; int totake = count / recipe.getCraftingResult(this).stackSize + 1; - for(int i = 0; i < drops.size(); i++) { - if(GT_Utility.areStacksEqual(drops.get(i), recipeInput)) { + for (int i = 0; i < drops.size(); i++) { + if (GT_Utility.areStacksEqual(drops.get(i), recipeInput)) { int took = Math.min(drops.get(i).stackSize, totake); drops.get(i).stackSize -= took; totake -= took; @@ -895,7 +889,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn drops.remove(i); i--; } - if(totake == 0) { + if (totake == 0) { return 0; } } @@ -907,9 +901,10 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn private static class GreenHouseWorld extends GT_DummyWorld { - public int x = 0,y = 0,z = 0,meta = 0; + public int x = 0, y = 0, z = 0, meta = 0; public Block block; - GreenHouseWorld(int x, int y, int z){ + + GreenHouseWorld(int x, int y, int z) { super(); this.x = x; this.y = y; @@ -919,15 +914,13 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn @Override public int getBlockMetadata(int aX, int aY, int aZ) { - if(aX == x && aY == y && aZ == z) - return 7; + if (aX == x && aY == y && aZ == z) return 7; return 0; } @Override public Block getBlock(int aX, int aY, int aZ) { - if(aY == y - 1) - return Blocks.farmland; + if (aY == y - 1) return Blocks.farmland; return Blocks.air; } @@ -938,21 +931,18 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn @Override public boolean setBlock(int aX, int aY, int aZ, Block aBlock, int aMeta, int aFlags) { - if(aBlock == Blocks.air) - return false; - if(aX == x && aY == y && aZ == z) - return false; + if (aBlock == Blocks.air) return false; + if (aX == x && aY == y && aZ == z) return false; block = aBlock; meta = aMeta; return true; } } - private static class GreenHouseRandom extends Random{ + private static class GreenHouseRandom extends Random { @Override public int nextInt(int bound) { return 0; } } - } -- cgit From eff30d832832f7963932e155b86655928f90a7e5 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Mon, 31 Oct 2022 17:09:23 +0100 Subject: EIG: Fix stocking input bus exploit (GTNewHorizons/bartworks#230) * Disgusting * Fix exploit * Maybe fix black wheat blocks inside * Ok we will fight then * Cosmetics * Proper fix --- src/main/java/kubatech/client/effect/CropRenderer.java | 17 ++++++++++++++--- .../GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 17 +++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) (limited to 'src/main/java/kubatech/client/effect/CropRenderer.java') diff --git a/src/main/java/kubatech/client/effect/CropRenderer.java b/src/main/java/kubatech/client/effect/CropRenderer.java index 1fca559204..88978688a7 100644 --- a/src/main/java/kubatech/client/effect/CropRenderer.java +++ b/src/main/java/kubatech/client/effect/CropRenderer.java @@ -2,6 +2,7 @@ package kubatech.client.effect; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.lang.reflect.Field; import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; @@ -12,6 +13,7 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class CropRenderer extends EntityFX { int meta; + Field tessellatorHasBrightnessField = null; public CropRenderer(World world, int x, int y, int z, int meta, int age) { super(world, (double) x, ((double) y - 0.0625d), (double) z); @@ -39,10 +41,19 @@ public class CropRenderer extends EntityFX { Tessellator tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); + double f11 = this.prevPosX + (this.posX - this.prevPosX) * (double) p_70539_2_ - interpPosX; + double f12 = this.prevPosY + (this.posY - this.prevPosY) * (double) p_70539_2_ - interpPosY; + double f13 = this.prevPosZ + (this.posZ - this.prevPosZ) * (double) p_70539_2_ - interpPosZ; + try { + if (tessellatorHasBrightnessField == null) { + tessellatorHasBrightnessField = Tessellator.class.getDeclaredField("hasBrightness"); + tessellatorHasBrightnessField.setAccessible(true); + } + tessellatorHasBrightnessField.set(tessellator, false); + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new RuntimeException(e); + } tessellator.setColorRGBA(255, 255, 255, 255); - float f11 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) p_70539_2_ - interpPosX); - float f12 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) p_70539_2_ - interpPosY); - float f13 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) p_70539_2_ - interpPosZ); RenderBlocks.getInstance().renderBlockCropsImpl(Blocks.wheat, meta, f11, f12, f13); GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthMask(true); diff --git a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java index 513188dd22..a3dcde7c7f 100644 --- a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java +++ b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java @@ -19,6 +19,7 @@ package kubatech.tileentity.gregtech.multiblock; import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.MULTIBLOCK_ADDED_VIA_BARTWORKS; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.GT_Values.AuthorKuba; import static gregtech.api.enums.Textures.BlockIcons.*; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; @@ -205,6 +206,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Crop Farm") .addInfo("Controller block for the Extreme Industrial Greenhouse") + .addInfo(AuthorKuba) .addInfo("Grow your crops like a chad !") .addInfo("Use screwdriver to enable/change/disable setup mode") .addInfo("Use screwdriver while sneaking to enable/disable IC2 mode") @@ -563,14 +565,12 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse public boolean addCrop(ItemStack input) { if (!isIC2Mode) for (GreenHouseSlot g : mStorage) - if (GT_Utility.areStacksEqual(g.input, input)) { + if (g.input.stackSize < 64 && GT_Utility.areStacksEqual(g.input, input)) { g.addAll(this.getBaseMetaTileEntity().getWorld(), input); if (input.stackSize == 0) return true; } - GreenHouseSlot h = new GreenHouseSlot(this, input.copy(), true, isIC2Mode); + GreenHouseSlot h = new GreenHouseSlot(this, input, true, isIC2Mode); if (h.isValid) { - if (isIC2Mode) input.stackSize--; - else input.stackSize = 0; mStorage.add(h); return true; } @@ -724,7 +724,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse if (i == Items.reeds) b = Blocks.reeds; else { b = Block.getBlockFromItem(i); - if (!(b == Blocks.cactus)) return; + if (b != Blocks.cactus) return; } needsreplanting = false; } @@ -746,7 +746,9 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse crop = b; isIC2Crop = false; - if (addDrops(world, input.stackSize, autocraft) == 0 && !drops.isEmpty()) { + int toUse = Math.min(64, input.stackSize); + if (addDrops(world, toUse, autocraft) == 0 && !drops.isEmpty()) { + input.stackSize -= toUse; this.isValid = true; } } @@ -840,8 +842,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse int dur = cc.growthDuration(te); int rate = te.calcGrowthRate(); - if (rate == 0) // should not be possible with those stats - return; + if (rate == 0) return; // should not be possible with those stats growthticks = dur / rate; if (growthticks < 1) growthticks = 1; -- cgit From ff7c62810df057c38cc85dc43b071972b14e715b Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:49:48 +0100 Subject: EIG: Bug fixes (including small IC2 mode nerf) (GTNewHorizons/bartworks#232) * Yes yes yes, obfuscation * Fix GT Ores not working as a roots in IC2 mode * ' * BEANS * Get rid of some warnings in code inspection * Fix wrong IC2 crop calculation (EIG NERF) * Use constants * Autocraft is always enabled * Recalculate all crops on math updates * Fix dupe * Remove Mana Bean support --- .../java/kubatech/client/effect/CropRenderer.java | 8 +- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 396 +++++++++++++-------- 2 files changed, 244 insertions(+), 160 deletions(-) (limited to 'src/main/java/kubatech/client/effect/CropRenderer.java') diff --git a/src/main/java/kubatech/client/effect/CropRenderer.java b/src/main/java/kubatech/client/effect/CropRenderer.java index 88978688a7..d225ee74db 100644 --- a/src/main/java/kubatech/client/effect/CropRenderer.java +++ b/src/main/java/kubatech/client/effect/CropRenderer.java @@ -7,13 +7,14 @@ import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.init.Blocks; +import net.minecraft.launchwrapper.Launch; import net.minecraft.world.World; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class CropRenderer extends EntityFX { int meta; - Field tessellatorHasBrightnessField = null; + static Field tessellatorHasBrightnessField = null; public CropRenderer(World world, int x, int y, int z, int meta, int age) { super(world, (double) x, ((double) y - 0.0625d), (double) z); @@ -46,7 +47,10 @@ public class CropRenderer extends EntityFX { double f13 = this.prevPosZ + (this.posZ - this.prevPosZ) * (double) p_70539_2_ - interpPosZ; try { if (tessellatorHasBrightnessField == null) { - tessellatorHasBrightnessField = Tessellator.class.getDeclaredField("hasBrightness"); + tessellatorHasBrightnessField = Tessellator.class.getDeclaredField( + (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment") + ? "hasBrightness" + : "field_78414_p"); tessellatorHasBrightnessField.setAccessible(true); } tessellatorHasBrightnessField.set(tessellator, false); diff --git a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java index 94e1ebbc43..da7a634c0d 100644 --- a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java +++ b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java @@ -46,6 +46,9 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Utility; import gregtech.common.GT_DummyWorld; +import gregtech.common.blocks.GT_Block_Ores_Abstract; +import gregtech.common.blocks.GT_Item_Ores; +import gregtech.common.blocks.GT_TileEntity_Ores; import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_OutputBus_ME; import ic2.api.crops.CropCard; import ic2.api.crops.Crops; @@ -59,10 +62,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.Item; -import net.minecraft.item.ItemSeedFood; -import net.minecraft.item.ItemSeeds; -import net.minecraft.item.ItemStack; +import net.minecraft.item.*; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; import net.minecraft.nbt.NBTTagCompound; @@ -77,7 +77,9 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEntity_EnhancedMultiBlockBase { private static final boolean debug = false; + private static final int EIG_MATH_VERSION = 0; + private int oldVersion = 0; private int mCasing = 0; private int mMaxSlots = 0; private int setupphase = 1; @@ -255,7 +257,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse .addOtherStructurePart("Borosilicate Glass", "Hollow two middle layers") .addStructureInfo("The glass tier limits the Energy Input tier") .addStructureInfo("The dirt is from RandomThings, must be tilled") - .addStructureInfo("Purple lamps are from ProjectRedIllumination. They can be lit") + .addStructureInfo("Purple lamps are from ProjectRedIllumination. They can be powered and/or inverted") .addMaintenanceHatch("Any casing (Except inner bottom ones)", 1) .addInputBus("Any casing (Except inner bottom ones)", 1) .addOutputBus("Any casing (Except inner bottom ones)", 1) @@ -269,13 +271,14 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse public String[] getStructureDescription(ItemStack stackSize) { List info = new ArrayList<>(Arrays.asList(super.getStructureDescription(stackSize))); info.add("The dirt is from RandomThings, must be tilled"); - info.add("Purple lamps are from ProjectRedIllumination. They can be lit"); + info.add("Purple lamps are from ProjectRedIllumination. They can be powered and/or inverted"); return info.toArray(new String[] {}); } @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); + aNBT.setInteger("EIG_MATH_VERSION", EIG_MATH_VERSION); aNBT.setByte("glasTier", glasTier); aNBT.setInteger("setupphase", setupphase); aNBT.setBoolean("isIC2Mode", isIC2Mode); @@ -288,6 +291,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); + oldVersion = aNBT.hasKey("EIG_MATH_VERSION") ? aNBT.getInteger("EIG_MATH_VERSION") : -1; glasTier = aNBT.getByte("glasTier"); setupphase = aNBT.getInteger("setupphase"); isIC2Mode = aNBT.getBoolean("isIC2Mode"); @@ -351,6 +355,13 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse long v = this.getMaxInputVoltage(); int tier = GT_Utility.getTier(v); updateMaxSlots(); + + if (oldVersion != EIG_MATH_VERSION) { + for (GreenHouseSlot slot : mStorage) + slot.recalculate(this, getBaseMetaTileEntity().getWorld()); + oldVersion = EIG_MATH_VERSION; + } + if (setupphase > 0) { if ((mStorage.size() >= mMaxSlots && setupphase == 1) || (mStorage.size() == 0 && setupphase == 2)) return false; @@ -420,8 +431,9 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } // OVERCLOCK - // FERTILIZER IDEA - IC2 +10% per fertilizer per crop per operation, NORMAL +200% per fertilizer per crop per - // operation + // FERTILIZER IDEA: + // IC2 +10% per fertilizer per crop per operation + // NORMAL +200% per fertilizer per crop per operation int boost = 0; int maxboost = 0; @@ -446,7 +458,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse this.mMaxProgresstime = 100; List outputs = new ArrayList<>(); for (int i = 0; i < Math.min(mMaxSlots, mStorage.size()); i++) - outputs.addAll(mStorage.get(i).getIC2Drops(((double) this.mMaxProgresstime / 8d) * multiplier)); + outputs.addAll(mStorage.get(i).getIC2Drops(((double) this.mMaxProgresstime * 32d) * multiplier)); this.mOutputItems = outputs.toArray(new ItemStack[0]); } else { this.mMaxProgresstime = Math.max(20, 100 / (tier - 3)); // Min 1 s @@ -572,7 +584,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(CASING_INDEX)}; } - public List mStorage = new ArrayList<>(); + public final List mStorage = new ArrayList<>(); public boolean addCrop(ItemStack input) { if (!isIC2Mode) @@ -581,7 +593,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse g.addAll(this.getBaseMetaTileEntity().getWorld(), input); if (input.stackSize == 0) return true; } - GreenHouseSlot h = new GreenHouseSlot(this, input, true, isIC2Mode, isNoHumidity); + GreenHouseSlot h = new GreenHouseSlot(this, input, isIC2Mode, isNoHumidity); if (h.isValid) { mStorage.add(h); return true; @@ -591,8 +603,9 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse private static class GreenHouseSlot extends InventoryCrafting { - ItemStack input; + final ItemStack input; Block crop; + ArrayList customDrops = null; ItemStack undercrop = null; List drops; boolean isValid; @@ -609,7 +622,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse boolean needsreplanting = true; - static GreenHouseWorld fakeworld = new GreenHouseWorld(5, 5, 5); + static final GreenHouseWorld fakeworld = new GreenHouseWorld(5, 5, 5); public NBTTagCompound toNBTTagCompound() { NBTTagCompound aNBT = new NBTTagCompound(); @@ -618,6 +631,11 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse aNBT.setBoolean("isIC2Crop", isIC2Crop); if (!isIC2Crop) { aNBT.setInteger("crop", Block.getIdFromBlock(crop)); + if (customDrops != null && customDrops.size() > 0) { + aNBT.setInteger("customDropsCount", customDrops.size()); + for (int i = 0; i < customDrops.size(); i++) + aNBT.setTag("customDrop." + i, customDrops.get(i).writeToNBT(new NBTTagCompound())); + } aNBT.setInteger("dropscount", drops.size()); for (int i = 0; i < drops.size(); i++) aNBT.setTag("drop." + i, drops.get(i).writeToNBT(new NBTTagCompound())); @@ -647,6 +665,12 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse input = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("input")); if (!isIC2Crop) { crop = Block.getBlockById(aNBT.getInteger("crop")); + if (aNBT.hasKey("customDropsCount")) { + int imax = aNBT.getInteger("customDropsCount"); + customDrops = new ArrayList<>(imax); + for (int i = 0; i < imax; i++) + customDrops.add(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("customDrop." + i))); + } drops = new ArrayList<>(); for (int i = 0; i < aNBT.getInteger("dropscount"); i++) drops.add(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("drop." + i))); @@ -674,7 +698,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse if (!GT_Utility.areStacksEqual(this.input, input)) return false; if (this.input.stackSize == 64) return false; int toconsume = Math.min(64 - this.input.stackSize, input.stackSize); - int left = addDrops(world, toconsume, true); + int left = addDrops(world, toconsume); input.stackSize -= toconsume - left; this.input.stackSize += toconsume - left; return left == 0; @@ -715,15 +739,13 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse return null; } + @SuppressWarnings("EmptyMethod") @Override - public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { - return; - } + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {} public GreenHouseSlot( GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, ItemStack input, - boolean autocraft, boolean IC2, boolean noHumidity) { super(null, 3, 3); @@ -737,38 +759,42 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } Item i = input.getItem(); Block b = null; - if (i instanceof IPlantable) { - if (i instanceof ItemSeeds) b = ((ItemSeeds) i).getPlant(world, 0, 0, 0); - else if (i instanceof ItemSeedFood) b = ((ItemSeedFood) i).getPlant(world, 0, 0, 0); - } else { - if (i == Items.reeds) b = Blocks.reeds; - else { - b = Block.getBlockFromItem(i); - if (b != Blocks.cactus) return; + boolean detectedCustomHandler = false; + // There will be custom handlers here some day + if (!detectedCustomHandler) { + if (i instanceof IPlantable) { + if (i instanceof ItemSeeds) b = ((ItemSeeds) i).getPlant(world, 0, 0, 0); + else if (i instanceof ItemSeedFood) b = ((ItemSeedFood) i).getPlant(world, 0, 0, 0); + } else { + if (i == Items.reeds) b = Blocks.reeds; + else { + b = Block.getBlockFromItem(i); + if (b != Blocks.cactus) return; + } + needsreplanting = false; } - needsreplanting = false; - } - if (!(b instanceof IPlantable)) return; - GameRegistry.UniqueIdentifier u = GameRegistry.findUniqueIdentifierFor(i); - if (u != null && Objects.equals(u.modId, "Natura")) optimalgrowth = 8; - - if (b instanceof BlockStem) { - fakeworld.block = null; - try { - b.updateTick(fakeworld, 5, 5, 5, fakeworld.rand); - } catch (Exception e) { - e.printStackTrace(System.err); + if (!(b instanceof IPlantable)) return; + GameRegistry.UniqueIdentifier u = GameRegistry.findUniqueIdentifierFor(i); + if (u != null && Objects.equals(u.modId, "Natura")) optimalgrowth = 8; + + if (b instanceof BlockStem) { + fakeworld.block = null; + try { + b.updateTick(fakeworld, 5, 5, 5, fakeworld.rand); + } catch (Exception e) { + e.printStackTrace(System.err); + } + if (fakeworld.block == null) return; + b = fakeworld.block; + needsreplanting = false; } - if (fakeworld.block == null) return; - b = fakeworld.block; - needsreplanting = false; } - crop = b; isIC2Crop = false; int toUse = Math.min(64, input.stackSize); - if (addDrops(world, toUse, autocraft) == 0 && !drops.isEmpty()) { + if (addDrops(world, toUse) == 0 && !drops.isEmpty()) { input.stackSize -= toUse; + this.input.stackSize = toUse; this.isValid = true; } } @@ -779,105 +805,139 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse ItemStack input, boolean noHumidity) { if (!ItemList.IC2_Crop_Seeds.isStackEqual(input, true, true)) return; - CropCard cc = Crops.instance.getCropCard(input); - this.input.stackSize = 1; - NBTTagCompound nbt = input.getTagCompound(); - byte gr = nbt.getByte("growth"); - byte ga = nbt.getByte("gain"); - byte re = nbt.getByte("resistance"); this.isIC2Crop = true; - int[] abc = new int[] {0, -2, 3}; - int[] xyz = new int[] {0, 0, 0}; - tileEntity.getExtendedFacing().getWorldOffset(abc, xyz); - xyz[0] += tileEntity.getBaseMetaTileEntity().getXCoord(); - xyz[1] += tileEntity.getBaseMetaTileEntity().getYCoord(); - xyz[2] += tileEntity.getBaseMetaTileEntity().getZCoord(); - boolean cheating = false; - try { - if (world.getBlock(xyz[0], xyz[1] - 2, xyz[2]) != GregTech_API.sBlockCasings4 - || world.getBlockMetadata(xyz[0], xyz[1] - 2, xyz[2]) != 1) { - // no - cheating = true; - return; - } - - world.setBlock(xyz[0], xyz[1], xyz[2], Block.getBlockFromItem(Ic2Items.crop.getItem()), 0, 0); - TileEntity wte = world.getTileEntity(xyz[0], xyz[1], xyz[2]); - if (!(wte instanceof TileEntityCrop)) { - // should not be even possible - return; - } - TileEntityCrop te = (TileEntityCrop) wte; - te.ticker = 1; // dont even think about ticking once - te.setCrop(cc); - - te.setGrowth(gr); - te.setGain(ga); - te.setResistance(re); - - ItemStack tobeused = null; - - te.setSize((byte) (cc.maxSize() - 1)); - if (!cc.canGrow(te)) { - // needs special block - - boolean cangrow = false; - ArrayList inputs = tileEntity.getStoredInputs(); - for (ItemStack a : inputs) { - if (a.stackSize <= 0) continue; - Block b = Block.getBlockFromItem(a.getItem()); - if (b == Blocks.air) continue; - world.setBlock(xyz[0], xyz[1] - 2, xyz[2], b, a.getItemDamage(), 0); - if (!cc.canGrow(te)) continue; - cangrow = true; - undercrop = a.copy(); - undercrop.stackSize = 1; - tobeused = a; - break; - } + recalculate(tileEntity, world); + if (this.isValid) input.stackSize--; + } - if (!cangrow) return; + private boolean setBlock(ItemStack a, int x, int y, int z, World world) { + Item item = a.getItem(); + Block b = Block.getBlockFromItem(item); + if (b == Blocks.air || !(item instanceof ItemBlock)) return false; + short tDamage = (short) item.getDamage(a); + if (item instanceof GT_Item_Ores && tDamage > 0) { + if (!world.setBlock( + x, + y, + z, + b, + GT_TileEntity_Ores.getHarvestData( + tDamage, ((GT_Block_Ores_Abstract) b).getBaseBlockHarvestLevel(tDamage % 16000 / 1000)), + 0)) { + return false; } + GT_TileEntity_Ores tTileEntity = (GT_TileEntity_Ores) world.getTileEntity(x, y, z); + tTileEntity.mMetaData = tDamage; + tTileEntity.mNatural = false; + } else world.setBlock(x, y, z, b, tDamage, 0); + return true; + } - te.setSize((byte) cc.maxSize()); + public void recalculate(GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, World world) { + if (isIC2Crop) { + CropCard cc = Crops.instance.getCropCard(input); + this.input.stackSize = 1; + NBTTagCompound nbt = input.getTagCompound(); + byte gr = nbt.getByte("growth"); + byte ga = nbt.getByte("gain"); + byte re = nbt.getByte("resistance"); + int[] abc = new int[] {0, -2, 3}; + int[] xyz = new int[] {0, 0, 0}; + tileEntity.getExtendedFacing().getWorldOffset(abc, xyz); + xyz[0] += tileEntity.getBaseMetaTileEntity().getXCoord(); + xyz[1] += tileEntity.getBaseMetaTileEntity().getYCoord(); + xyz[2] += tileEntity.getBaseMetaTileEntity().getZCoord(); + boolean cheating = false; + try { + if (world.getBlock(xyz[0], xyz[1] - 2, xyz[2]) != GregTech_API.sBlockCasings4 + || world.getBlockMetadata(xyz[0], xyz[1] - 2, xyz[2]) != 1) { + // no + cheating = true; + return; + } - if (!cc.canBeHarvested(te)) return; + world.setBlock(xyz[0], xyz[1], xyz[2], Block.getBlockFromItem(Ic2Items.crop.getItem()), 0, 0); + TileEntity wte = world.getTileEntity(xyz[0], xyz[1], xyz[2]); + if (!(wte instanceof TileEntityCrop)) { + // should not be even possible + return; + } + TileEntityCrop te = (TileEntityCrop) wte; + te.ticker = 1; // don't even think about ticking once + te.setCrop(cc); + + te.setGrowth(gr); + te.setGain(ga); + te.setResistance(re); + + ItemStack tobeused = null; + + if (undercrop != null) setBlock(undercrop, xyz[0], xyz[1] - 2, xyz[2], world); + else { + te.setSize((byte) (cc.maxSize() - 1)); + if (!cc.canGrow(te)) { + // needs special block + + boolean cangrow = false; + ArrayList inputs = tileEntity.getStoredInputs(); + for (ItemStack a : inputs) { + if (a.stackSize <= 0) continue; + if (!setBlock(a, xyz[0], xyz[1] - 2, xyz[2], world)) continue; + if (!cc.canGrow(te)) continue; + cangrow = true; + undercrop = a.copy(); + undercrop.stackSize = 1; + tobeused = a; + break; + } + + if (!cangrow) return; + } + } - // GENERATE DROPS - generations = new ArrayList<>(); - out: - for (int i = 0; i < 10; i++) // get 10 generations - { - ItemStack[] st = te.harvest_automated(false); te.setSize((byte) cc.maxSize()); - if (st == null) continue; - if (st.length == 0) continue; - for (ItemStack s : st) if (s == null) continue out; - generations.add(new ArrayList<>(Arrays.asList(st))); - } - if (generations.isEmpty()) return; - rn = new Random(); - // CHECK GROWTH SPEED - te.humidity = (byte) (noHumidity ? 0 : 12); // humidity with full water storage or 0 humidity - te.airQuality = 6; // air quality when sky is seen - te.nutrients = 8; // netrients with full nutrient storage + if (!cc.canBeHarvested(te)) return; + + // GENERATE DROPS + generations = new ArrayList<>(); + out: + for (int i = 0; i < 10; i++) // get 10 generations + { + ItemStack[] st = te.harvest_automated(false); + te.setSize((byte) cc.maxSize()); + if (st == null) continue; + if (st.length == 0) continue; + for (ItemStack s : st) if (s == null) continue out; + generations.add(new ArrayList<>(Arrays.asList(st))); + } + if (generations.isEmpty()) return; + rn = new Random(); - int dur = cc.growthDuration(te); - int rate = te.calcGrowthRate(); - if (rate == 0) return; // should not be possible with those stats - growthticks = dur / rate; - if (growthticks < 1) growthticks = 1; + // CHECK GROWTH SPEED + te.humidity = (byte) (noHumidity ? 0 : 12); // humidity with full water storage or 0 humidity + te.airQuality = 6; // air quality when sky is seen + te.nutrients = 8; // nutrients with full nutrient storage - input.stackSize--; - if (tobeused != null) tobeused.stackSize--; + int dur = cc.growthDuration(te); + int rate = te.calcGrowthRate(); + if (rate == 0) return; // should not be possible with those stats + growthticks = (int) Math.ceil( + ((double) dur / (double) rate) * (double) cc.maxSize() * (double) TileEntityCrop.tickRate); + if (growthticks < 1) growthticks = 1; - this.isValid = true; - } catch (Exception e) { - e.printStackTrace(System.err); - } finally { - if (!cheating) world.setBlock(xyz[0], xyz[1] - 2, xyz[2], GregTech_API.sBlockCasings4, 1, 0); - world.setBlockToAir(xyz[0], xyz[1], xyz[2]); + if (tobeused != null) tobeused.stackSize--; + + this.isValid = true; + } catch (Exception e) { + e.printStackTrace(System.err); + } finally { + if (!cheating) world.setBlock(xyz[0], xyz[1] - 2, xyz[2], GregTech_API.sBlockCasings4, 1, 0); + world.setBlockToAir(xyz[0], xyz[1], xyz[2]); + } + } else { + drops = new ArrayList<>(); + addDrops(world, input.stackSize); } } @@ -885,8 +945,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse return drops; } - Map dropprogress = new HashMap<>(); - static Map dropstacks = new HashMap<>(); + final Map dropprogress = new HashMap<>(); + static final Map dropstacks = new HashMap<>(); public List getIC2Drops(double timeelapsed) { int r = rn.nextInt(10); @@ -913,17 +973,39 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse return copied; } - public int addDrops(World world, int count, boolean autocraft) { - drops = new ArrayList<>(); - for (int i = 0; i < count; i++) { - List d = crop.getDrops(world, 0, 0, 0, optimalgrowth, 0); - for (ItemStack x : drops) - for (ItemStack y : d) + public int addDrops(World world, int count) { + if (drops == null) drops = new ArrayList<>(); + if (customDrops != null && customDrops.size() > 0) { + @SuppressWarnings("unchecked") + ArrayList d = (ArrayList) customDrops.clone(); + for (ItemStack x : drops) { + for (Iterator iterator = d.iterator(); iterator.hasNext(); ) { + ItemStack y = iterator.next(); if (GT_Utility.areStacksEqual(x, y)) { - x.stackSize += y.stackSize; - y.stackSize = 0; + x.stackSize += y.stackSize * count; + iterator.remove(); } - for (ItemStack x : d) if (x.stackSize > 0) drops.add(x.copy()); + } + } + final int finalCount = count; + d.forEach(stack -> { + ItemStack i = stack.copy(); + i.stackSize *= finalCount; + drops.add(i); + }); + return 0; + } else { + if (crop == null) return count; + for (int i = 0; i < count; i++) { + List d = crop.getDrops(world, 0, 0, 0, optimalgrowth, 0); + for (ItemStack x : drops) + for (ItemStack y : d) + if (GT_Utility.areStacksEqual(x, y)) { + x.stackSize += y.stackSize; + y.stackSize = 0; + } + for (ItemStack x : d) if (x.stackSize > 0) drops.add(x.copy()); + } } if (!needsreplanting) return 0; for (int i = 0; i < drops.size(); i++) { @@ -940,21 +1022,19 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } } } - if (autocraft) { - if (!findCropRecipe(world)) return count; - int totake = count / recipe.getCraftingResult(this).stackSize + 1; - for (int i = 0; i < drops.size(); i++) { - if (GT_Utility.areStacksEqual(drops.get(i), recipeInput)) { - int took = Math.min(drops.get(i).stackSize, totake); - drops.get(i).stackSize -= took; - totake -= took; - if (drops.get(i).stackSize == 0) { - drops.remove(i); - i--; - } - if (totake == 0) { - return 0; - } + if (!findCropRecipe(world)) return count; + int totake = count / recipe.getCraftingResult(this).stackSize + 1; + for (int i = 0; i < drops.size(); i++) { + if (GT_Utility.areStacksEqual(drops.get(i), recipeInput)) { + int took = Math.min(drops.get(i).stackSize, totake); + drops.get(i).stackSize -= took; + totake -= took; + if (drops.get(i).stackSize == 0) { + drops.remove(i); + i--; + } + if (totake == 0) { + return 0; } } } @@ -964,7 +1044,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse private static class GreenHouseWorld extends GT_DummyWorld { - public int x = 0, y = 0, z = 0, meta = 0; + public int x, y, z, meta = 0; public Block block; GreenHouseWorld(int x, int y, int z) { -- cgit From 07f4cecbd9de7b7ecf2e25197d76a8102c7fa077 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Tue, 3 Jan 2023 17:53:10 +0100 Subject: Add enchanced GUI to EIG (GTNewHorizons/bartworks#255) * Add enchanced GUI to EIG * Spawn 1 render entity instead of 8 * Spawn 1 render entity instead of 5 in EIC * Spelling * Dont overshot --- .../java/kubatech/client/effect/CropRenderer.java | 20 +- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 380 +++++++++++++++++++-- 2 files changed, 369 insertions(+), 31 deletions(-) (limited to 'src/main/java/kubatech/client/effect/CropRenderer.java') diff --git a/src/main/java/kubatech/client/effect/CropRenderer.java b/src/main/java/kubatech/client/effect/CropRenderer.java index d225ee74db..38721f427e 100644 --- a/src/main/java/kubatech/client/effect/CropRenderer.java +++ b/src/main/java/kubatech/client/effect/CropRenderer.java @@ -13,16 +13,16 @@ import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class CropRenderer extends EntityFX { - int meta; + int[] meta = new int[8]; static Field tessellatorHasBrightnessField = null; - public CropRenderer(World world, int x, int y, int z, int meta, int age) { + public CropRenderer(World world, int x, int y, int z, int age) { super(world, (double) x, ((double) y - 0.0625d), (double) z); this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; this.particleMaxAge = age; - this.meta = meta; + for (int i = 0; i < 8; i++) this.meta[i] = this.rand.nextInt(8); } @Override @@ -42,9 +42,6 @@ public class CropRenderer extends EntityFX { Tessellator tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); - double f11 = this.prevPosX + (this.posX - this.prevPosX) * (double) p_70539_2_ - interpPosX; - double f12 = this.prevPosY + (this.posY - this.prevPosY) * (double) p_70539_2_ - interpPosY; - double f13 = this.prevPosZ + (this.posZ - this.prevPosZ) * (double) p_70539_2_ - interpPosZ; try { if (tessellatorHasBrightnessField == null) { tessellatorHasBrightnessField = Tessellator.class.getDeclaredField( @@ -58,7 +55,16 @@ public class CropRenderer extends EntityFX { throw new RuntimeException(e); } tessellator.setColorRGBA(255, 255, 255, 255); - RenderBlocks.getInstance().renderBlockCropsImpl(Blocks.wheat, meta, f11, f12, f13); + double f12 = this.posY - interpPosY; + int i = 0; + for (int x = -1; x <= 1; x++) + for (int z = -1; z <= 1; z++) { + if (x == 0 && z == 0) continue; + double f11 = (this.posX + (double) x) - interpPosX; + double f13 = (this.posZ + (double) z) - interpPosZ; + RenderBlocks.getInstance().renderBlockCropsImpl(Blocks.wheat, meta[i++], f11, f12, f13); + } + GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthMask(true); } diff --git a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java index 979141e5f0..53ee7bde80 100644 --- a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java +++ b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java @@ -25,12 +25,24 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; import com.github.bartimaeusnek.bartworks.API.LoaderReference; +import com.github.bartimaeusnek.bartworks.MainMod; import kubatech.client.effect.CropRenderer; +import com.github.bartimaeusnek.bartworks.common.net.EIGPacket; import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import com.github.bartimaeusnek.bartworks.util.Coords; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.*; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -38,6 +50,7 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -54,12 +67,16 @@ import ic2.api.crops.CropCard; import ic2.api.crops.Crops; import ic2.core.Ic2Items; import ic2.core.crop.TileEntityCrop; +import java.io.IOException; import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.block.BlockStem; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.InventoryCrafting; @@ -79,10 +96,11 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse private static final boolean debug = false; private static final int EIG_MATH_VERSION = 0; + private static final int CONFIGURATION_WINDOW_ID = 999; private int oldVersion = 0; private int mCasing = 0; - private int mMaxSlots = 0; + public int mMaxSlots = 0; private int setupphase = 1; private boolean isIC2Mode = false; private byte glasTier = 0; @@ -161,18 +179,18 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { if (this.mMaxProgresstime > 0) { - GT_Utility.sendChatToPlayer(aPlayer, "You cant change IC2 mode if the machine is working!"); + GT_Utility.sendChatToPlayer(aPlayer, "You can't change IC2 mode if the machine is working!"); return; } if (!mStorage.isEmpty()) { - GT_Utility.sendChatToPlayer(aPlayer, "You cant change IC2 mode if there are seeds inside!"); + GT_Utility.sendChatToPlayer(aPlayer, "You can't change IC2 mode if there are seeds inside!"); return; } this.isIC2Mode = !this.isIC2Mode; GT_Utility.sendChatToPlayer(aPlayer, "IC2 mode is now " + (this.isIC2Mode ? "enabled" : "disabled.")); } else { if (this.mMaxProgresstime > 0) { - GT_Utility.sendChatToPlayer(aPlayer, "You cant enable/disable setup if the machine is working!"); + GT_Utility.sendChatToPlayer(aPlayer, "You can't enable/disable setup if the machine is working!"); return; } this.setupphase++; @@ -302,8 +320,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } @SideOnly(Side.CLIENT) - public void spawnVisualCrop(World world, int x, int y, int z, int meta, int age) { - CropRenderer crop = new CropRenderer(world, x, y, z, meta, age); + public void spawnVisualCrops(World world, int x, int y, int z, int age) { + CropRenderer crop = new CropRenderer(world, x, y, z, age); Minecraft.getMinecraft().effectRenderer.addEffect(crop); } @@ -312,25 +330,27 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isClientSide()) { if (aBaseMetaTileEntity.isActive() && aTick % 40 == 0) { - for (int x = -1; x <= 1; x++) - for (int z = -1; z <= 1; z++) { - if (x == 0 && z == 0) continue; - int[] abc = new int[] {x, -2, z + 2}; - int[] xyz = new int[] {0, 0, 0}; - this.getExtendedFacing().getWorldOffset(abc, xyz); - xyz[0] += aBaseMetaTileEntity.getXCoord(); - xyz[1] += aBaseMetaTileEntity.getYCoord(); - xyz[2] += aBaseMetaTileEntity.getZCoord(); - spawnVisualCrop( - aBaseMetaTileEntity.getWorld(), - xyz[0], - xyz[1], - xyz[2], - aBaseMetaTileEntity.getRandomNumber(8), - 40); - } + int[] abc = new int[] {0, -2, 2}; + int[] xyz = new int[] {0, 0, 0}; + this.getExtendedFacing().getWorldOffset(abc, xyz); + xyz[0] += aBaseMetaTileEntity.getXCoord(); + xyz[1] += aBaseMetaTileEntity.getYCoord(); + xyz[2] += aBaseMetaTileEntity.getZCoord(); + spawnVisualCrops(aBaseMetaTileEntity.getWorld(), xyz[0], xyz[1], xyz[2], 40); } } + if (aBaseMetaTileEntity.isServerSide()) { + MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + aBaseMetaTileEntity.getWorld(), + new EIGPacket( + new Coords( + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord()), + mMaxSlots), + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getZCoord()); + } } @Override @@ -369,7 +389,10 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse if (setupphase == 1) { List inputs = getStoredInputs(); - for (ItemStack input : inputs) addCrop(input); + for (ItemStack input : inputs) { + addCrop(input); + if (mStorage.size() >= mMaxSlots) break; + } } else if (setupphase == 2) { int emptySlots = 0; boolean ignoreEmptiness = false; @@ -514,6 +537,315 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse return false; } + @Override + public boolean useModularUI() { + return true; + } + + private final Function isFixed = widget -> getIdealStatus() == getRepairStatus() && mMachine; + + private static final Function toggleButtonBackgroundGetter = val -> { + if (val == 0) return new IDrawable[] {GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CROSS}; + else return new IDrawable[] {GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CHECKMARK}; + }; + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget(new DrawableWidget() + .setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) + .setPos(7, 4) + .setSize(143, 75) + .setEnabled(widget -> !isFixed.apply(widget))); + + buildContext.addSyncedWindow(CONFIGURATION_WINDOW_ID, this::createConfigurationWindow); + EntityPlayer player = buildContext.getPlayer(); + + // Slot is not needed + + builder.widget(new DynamicPositionedColumn() + .setSynced(false) + .widget(new CycleButtonWidget() + .setToggle(() -> getBaseMetaTileEntity().isAllowedToWork(), works -> { + if (works) getBaseMetaTileEntity().enableWorking(); + else getBaseMetaTileEntity().disableWorking(); + + if (!(player instanceof EntityPlayerMP)) return; + String tChat = GT_Utility.trans("090", "Machine Processing: ") + + (works + ? GT_Utility.trans("088", "Enabled") + : GT_Utility.trans("087", "Disabled")); + if (hasAlternativeModeText()) tChat = getAlternativeModeText(); + GT_Utility.sendChatToPlayer(player, tChat); + }) + .addTooltip(0, new Text("Disabled").color(Color.RED.dark(3))) + .addTooltip(1, new Text("Enabled").color(Color.GREEN.dark(3))) + .setVariableBackgroundGetter(toggleButtonBackgroundGetter) + .setSize(18, 18) + .addTooltip("Working status")) + .widget(new ButtonWidget() + .setOnClick((clickData, widget) -> { + if (!widget.isClient()) widget.getContext().openSyncedWindow(CONFIGURATION_WINDOW_ID); + }) + .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CYCLIC) + .addTooltip("Configuration") + .setSize(18, 18)) + .setPos(151, 4)); + + final List drawables = new ArrayList<>(mMaxSlots); + final int perRow = 7; + + Scrollable cropsContainer = new Scrollable().setVerticalScroll(); + + if (mMaxSlots > 0) + for (int i = 0, imax = ((mMaxSlots - 1) / perRow); i <= imax; i++) { + DynamicPositionedRow row = new DynamicPositionedRow().setSynced(false); + for (int j = 0, jmax = (i == imax ? (mMaxSlots - 1) % perRow : (perRow - 1)); j <= jmax; j++) { + final int finalI = i * perRow; + final int finalJ = j; + final int ID = finalI + finalJ; + row.widget(new ButtonWidget() + .setOnClick((clickData, widget) -> { + if (!(player instanceof EntityPlayerMP)) return; + if (mStorage.size() <= ID) return; + if (this.mMaxProgresstime > 0) { + GT_Utility.sendChatToPlayer(player, "Can't eject while running !"); + return; + } + GreenHouseSlot removed = mStorage.remove(ID); + addOutput(removed.input); + GT_Utility.sendChatToPlayer(player, "Crop ejected !"); + }) + .setBackground(() -> new IDrawable[] { + getBaseMetaTileEntity().getGUITextureSet().getItemSlot(), + new ItemDrawable(drawables.size() > ID ? drawables.get(ID) : null) + .withFixedSize(16, 16, 1, 1) + }) + .dynamicTooltip(() -> { + if (drawables.size() > ID) + return Arrays.asList( + drawables.get(ID).getDisplayName(), + "Amount: " + drawables.get(ID).stackSize, + EnumChatFormatting.GRAY + "Left click to eject"); + return Collections.emptyList(); + }) + .setSize(18, 18)); + } + cropsContainer.widget(row.setPos(0, i * 18).setEnabled(widget -> { + int y = widget.getPos().y; + int cy = cropsContainer.getVerticalScrollOffset(); + int ch = cropsContainer.getVisibleHeight(); + return y >= cy - ch && y <= cy + ch; + })); + } + cropsContainer.attachSyncer( + new FakeSyncWidget.ListSyncer<>( + () -> mStorage.stream().map(s -> s.input).collect(Collectors.toList()), + l -> { + drawables.clear(); + drawables.addAll(l); + }, + (buffer, i) -> { + try { + buffer.writeItemStackToBuffer(i); + } catch (IOException e) { + throw new RuntimeException(e); + } + }, + buffer -> { + try { + return buffer.readItemStackFromBuffer(); + } catch (IOException e) { + throw new RuntimeException(e); + } + }), + builder); + + builder.widget(cropsContainer.setPos(10, 16).setSize(128, 60)); + + final DynamicPositionedColumn screenElements = new DynamicPositionedColumn(); + drawTexts(screenElements, null); + builder.widget(screenElements); + } + + protected ModularWindow createConfigurationWindow(final EntityPlayer player) { + ModularWindow.Builder builder = ModularWindow.builder(200, 100); + builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); + builder.widget(new DrawableWidget() + .setDrawable(GT_UITextures.OVERLAY_BUTTON_CYCLIC) + .setPos(5, 5) + .setSize(16, 16)) + .widget(new TextWidget("Configuration").setPos(25, 9)) + .widget(ButtonWidget.closeWindowButton(true).setPos(185, 3)) + .widget(new Column() + .widget(new CycleButtonWidget() + .setLength(3) + .setGetter(() -> setupphase) + .setSetter(val -> { + if (!(player instanceof EntityPlayerMP)) return; + if (this.mMaxProgresstime > 0) { + GT_Utility.sendChatToPlayer( + player, "You can't enable/disable setup if the machine is working!"); + return; + } + this.setupphase = val; + GT_Utility.sendChatToPlayer( + player, + "EIG is now running in " + + (this.setupphase == 1 + ? "setup mode (input)." + : (this.setupphase == 2 + ? "setup mode (output)." + : "normal operation."))); + }) + .addTooltip(0, new Text("Operating").color(Color.GREEN.dark(3))) + .addTooltip(1, new Text("Input").color(Color.YELLOW.dark(3))) + .addTooltip(2, new Text("Output").color(Color.YELLOW.dark(3))) + .setVariableBackgroundGetter(i -> new IDrawable[] { + ModularUITextures.VANILLA_BACKGROUND, + GT_UITextures.OVERLAY_BUTTON_CYCLIC.withFixedSize(18, 18), + i == 0 + ? new Text("Operating") + .color(Color.GREEN.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) + : i == 1 + ? new Text("Input") + .color(Color.YELLOW.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) + : new Text("Output") + .color(Color.YELLOW.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) + }) + .setSize(70, 18) + .addTooltip("Setup mode")) + .widget(new CycleButtonWidget() + .setLength(2) + .setGetter(() -> isIC2Mode ? 1 : 0) + .setSetter(val -> { + if (!(player instanceof EntityPlayerMP)) return; + if (this.mMaxProgresstime > 0) { + GT_Utility.sendChatToPlayer( + player, "You can't change IC2 mode if the machine is working!"); + return; + } + if (!mStorage.isEmpty()) { + GT_Utility.sendChatToPlayer( + player, "You can't change IC2 mode if there are seeds inside!"); + return; + } + this.isIC2Mode = val == 1; + GT_Utility.sendChatToPlayer( + player, "IC2 mode is now " + (this.isIC2Mode ? "enabled" : "disabled.")); + }) + .addTooltip(0, new Text("Disabled").color(Color.RED.dark(3))) + .addTooltip(1, new Text("Enabled").color(Color.GREEN.dark(3))) + .setVariableBackgroundGetter(i -> new IDrawable[] { + ModularUITextures.VANILLA_BACKGROUND, + GT_UITextures.OVERLAY_BUTTON_CYCLIC.withFixedSize(18, 18), + i == 0 + ? new Text("Disabled") + .color(Color.RED.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) + : new Text("Enabled") + .color(Color.GREEN.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) + }) + .setSize(70, 18) + .addTooltip("IC2 mode")) + .widget(new CycleButtonWidget() + .setLength(2) + .setGetter(() -> isNoHumidity ? 1 : 0) + .setSetter(val -> { + if (!(player instanceof EntityPlayerMP)) return; + isNoHumidity = val == 1; + GT_Utility.sendChatToPlayer( + player, "Give incoming crops no humidity " + isNoHumidity); + }) + .addTooltip(0, new Text("Disabled").color(Color.RED.dark(3))) + .addTooltip(1, new Text("Enabled").color(Color.GREEN.dark(3))) + .setVariableBackgroundGetter(i -> new IDrawable[] { + ModularUITextures.VANILLA_BACKGROUND, + GT_UITextures.OVERLAY_BUTTON_CYCLIC.withFixedSize(18, 18), + i == 0 + ? new Text("Disabled") + .color(Color.RED.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) + : new Text("Enabled") + .color(Color.GREEN.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) + }) + .setSize(70, 18) + .addTooltip("No Humidity mode")) + .setEnabled(widget -> !getBaseMetaTileEntity().isActive()) + .setPos(10, 30)) + .widget(new Column() + .widget(new TextWidget("Setup mode").setSize(100, 18)) + .widget(new TextWidget("IC2 mode").setSize(100, 18)) + .widget(new TextWidget("No Humidity mode").setSize(100, 18)) + .setEnabled(widget -> !getBaseMetaTileEntity().isActive()) + .setPos(80, 30)) + .widget(new DrawableWidget() + .setDrawable(GT_UITextures.OVERLAY_BUTTON_CROSS) + .setSize(18, 18) + .setPos(10, 30) + .addTooltip(new Text("Can't change configuration when running !").color(Color.RED.dark(3))) + .setEnabled(widget -> getBaseMetaTileEntity().isActive())); + return builder.build(); + } + + @Override + protected void drawTexts(DynamicPositionedColumn screenElements, SlotWidget inventorySlot) { + screenElements.setSynced(false).setSpace(0).setPos(10, 7); + + screenElements.widget(new DynamicPositionedRow() + .setSynced(false) + .widget(new TextWidget("Status: ").setDefaultColor(COLOR_TEXT_GRAY.get())) + .widget(new DynamicTextWidget(() -> { + if (getBaseMetaTileEntity().isActive()) return new Text("Working !").color(Color.GREEN.dark(3)); + else if (getBaseMetaTileEntity().isAllowedToWork()) + return new Text("Enabled").color(Color.GREEN.dark(3)); + else if (getBaseMetaTileEntity().wasShutdown()) + return new Text("Shutdown (CRITICAL)").color(Color.RED.dark(3)); + else return new Text("Disabled").color(Color.RED.dark(3)); + })) + .setEnabled(isFixed)); + + screenElements + .widget(new TextWidget(GT_Utility.trans("132", "Pipe is loose.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mWrench)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mWrench, val -> mWrench = val)); + screenElements + .widget(new TextWidget(GT_Utility.trans("133", "Screws are loose.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mScrewdriver)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mScrewdriver, val -> mScrewdriver = val)); + screenElements + .widget(new TextWidget(GT_Utility.trans("134", "Something is stuck.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mSoftHammer)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mSoftHammer, val -> mSoftHammer = val)); + screenElements + .widget(new TextWidget(GT_Utility.trans("135", "Platings are dented.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mHardHammer)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mHardHammer, val -> mHardHammer = val)); + screenElements + .widget(new TextWidget(GT_Utility.trans("136", "Circuitry burned out.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mSolderingTool)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mSolderingTool, val -> mSolderingTool = val)); + screenElements + .widget(new TextWidget(GT_Utility.trans("137", "That doesn't belong there.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mCrowbar)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mCrowbar, val -> mCrowbar = val)); + screenElements + .widget(new TextWidget(GT_Utility.trans("138", "Incomplete Structure.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setEnabled(widget -> !mMachine)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> mMachine, val -> mMachine = val)); + } + @Override public String[] getInfoData() { List info = new ArrayList<>(Arrays.asList( -- cgit From 59eb7c249125da489eac3f224a0777fbe658de1c Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Mon, 30 Jan 2023 10:37:15 -0800 Subject: spotlessApply with the new settings --- .../java/kubatech/client/effect/CropRenderer.java | 34 +- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 782 +++++++++------------ 2 files changed, 361 insertions(+), 455 deletions(-) (limited to 'src/main/java/kubatech/client/effect/CropRenderer.java') diff --git a/src/main/java/kubatech/client/effect/CropRenderer.java b/src/main/java/kubatech/client/effect/CropRenderer.java index 38721f427e..5a5217776c 100644 --- a/src/main/java/kubatech/client/effect/CropRenderer.java +++ b/src/main/java/kubatech/client/effect/CropRenderer.java @@ -1,18 +1,22 @@ package kubatech.client.effect; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.lang.reflect.Field; + import net.minecraft.client.particle.EntityFX; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.init.Blocks; import net.minecraft.launchwrapper.Launch; import net.minecraft.world.World; + import org.lwjgl.opengl.GL11; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + @SideOnly(Side.CLIENT) public class CropRenderer extends EntityFX { + int[] meta = new int[8]; static Field tessellatorHasBrightnessField = null; @@ -31,22 +35,15 @@ public class CropRenderer extends EntityFX { } @Override - public void renderParticle( - Tessellator p_70539_1_, - float p_70539_2_, - float p_70539_3_, - float p_70539_4_, - float p_70539_5_, - float p_70539_6_, - float p_70539_7_) { + public void renderParticle(Tessellator p_70539_1_, float p_70539_2_, float p_70539_3_, float p_70539_4_, + float p_70539_5_, float p_70539_6_, float p_70539_7_) { Tessellator tessellator = Tessellator.instance; GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); try { if (tessellatorHasBrightnessField == null) { tessellatorHasBrightnessField = Tessellator.class.getDeclaredField( - (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment") - ? "hasBrightness" + (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment") ? "hasBrightness" : "field_78414_p"); tessellatorHasBrightnessField.setAccessible(true); } @@ -57,13 +54,12 @@ public class CropRenderer extends EntityFX { tessellator.setColorRGBA(255, 255, 255, 255); double f12 = this.posY - interpPosY; int i = 0; - for (int x = -1; x <= 1; x++) - for (int z = -1; z <= 1; z++) { - if (x == 0 && z == 0) continue; - double f11 = (this.posX + (double) x) - interpPosX; - double f13 = (this.posZ + (double) z) - interpPosZ; - RenderBlocks.getInstance().renderBlockCropsImpl(Blocks.wheat, meta[i++], f11, f12, f13); - } + for (int x = -1; x <= 1; x++) for (int z = -1; z <= 1; z++) { + if (x == 0 && z == 0) continue; + double f11 = (this.posX + (double) x) - interpPosX; + double f13 = (this.posZ + (double) z) - interpPosZ; + RenderBlocks.getInstance().renderBlockCropsImpl(Blocks.wheat, meta[i++], f11, f12, f13); + } GL11.glEnable(GL11.GL_CULL_FACE); GL11.glDepthMask(true); diff --git a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java index 9036ff94dd..96b806bc21 100644 --- a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java +++ b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java @@ -1,18 +1,10 @@ /* - * Copyright (C) 2022 kuba6000 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * Copyright (C) 2022 kuba6000 This program is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ package kubatech.tileentity.gregtech.multiblock; @@ -23,6 +15,32 @@ import static gregtech.api.enums.GT_Values.AuthorKuba; import static gregtech.api.enums.Textures.BlockIcons.*; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; +import java.io.IOException; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockFlower; +import net.minecraft.block.BlockStem; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.*; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.IPlantable; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; import com.github.bartimaeusnek.bartworks.API.LoaderReference; import com.github.bartimaeusnek.bartworks.MainMod; @@ -43,6 +61,7 @@ import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import com.gtnewhorizons.modularui.api.widget.Widget; import com.gtnewhorizons.modularui.common.widget.*; + import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -68,30 +87,6 @@ import ic2.api.crops.CropCard; import ic2.api.crops.Crops; import ic2.core.Ic2Items; import ic2.core.crop.TileEntityCrop; -import java.io.IOException; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; -import net.minecraft.block.Block; -import net.minecraft.block.BlockFlower; -import net.minecraft.block.BlockStem; -import net.minecraft.client.Minecraft; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.*; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import net.minecraftforge.common.IPlantable; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEntity_EnhancedMultiBlockBase { @@ -113,63 +108,59 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse private static final String STRUCTURE_PIECE_MAIN = "main"; private static final Item forestryfertilizer = GameRegistry.findItem("Forestry", "fertilizerCompound"); private static final Fluid weedex = Materials.WeedEX9000.mFluid; - private static final IStructureDefinition STRUCTURE_DEFINITION = - StructureDefinition.builder() - .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][] { - {"ccccc", "ccccc", "ccccc", "ccccc", "ccccc"}, - {"ccccc", "clllc", "clllc", "clllc", "ccccc"}, - {"ggggg", "g---g", "g---g", "g---g", "ggggg"}, - {"ggggg", "g---g", "g---g", "g---g", "ggggg"}, - {"ccccc", "cdddc", "cdwdc", "cdddc", "ccccc"}, - {"cc~cc", "cCCCc", "cCCCc", "cCCCc", "ccccc"}, - })) - .addElement( - 'c', - ofChain( - onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings4, 1)), - ofHatchAdder( - GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addEnergyInputToMachineList, - CASING_INDEX, - 1), - ofHatchAdder( - GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addMaintenanceToMachineList, - CASING_INDEX, - 1), - ofHatchAdder( - GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addInputToMachineList, - CASING_INDEX, - 1), - ofHatchAdder( - GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addOutputToMachineList, - CASING_INDEX, - 1))) - .addElement('C', onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings4, 1))) - .addElement( - 'l', - LoaderReference.ProjRedIllumination - ? ofBlock( - Block.getBlockFromName("ProjRed|Illumination:projectred.illumination.lamp"), - 10) - : ofBlock(Blocks.redstone_lamp, 0)) - .addElement( - 'g', - debug - ? ofBlock(Blocks.glass, 0) - : BorosilicateGlass.ofBoroGlass( - (byte) 0, - (byte) 1, - Byte.MAX_VALUE, - (te, t) -> te.glasTier = t, - te -> te.glasTier)) - .addElement( - 'd', - ofBlock( - LoaderReference.RandomThings - ? Block.getBlockFromName("RandomThings:fertilizedDirt_tilled") - : Blocks.farmland, - 0)) - .addElement('w', ofBlock(Blocks.water, 0)) - .build(); + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition + .builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { { "ccccc", "ccccc", "ccccc", "ccccc", "ccccc" }, + { "ccccc", "clllc", "clllc", "clllc", "ccccc" }, + { "ggggg", "g---g", "g---g", "g---g", "ggggg" }, + { "ggggg", "g---g", "g---g", "g---g", "ggggg" }, + { "ccccc", "cdddc", "cdwdc", "cdddc", "ccccc" }, + { "cc~cc", "cCCCc", "cCCCc", "cCCCc", "ccccc" }, })) + .addElement( + 'c', + ofChain( + onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings4, 1)), + ofHatchAdder( + GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addEnergyInputToMachineList, + CASING_INDEX, + 1), + ofHatchAdder( + GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addMaintenanceToMachineList, + CASING_INDEX, + 1), + ofHatchAdder( + GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addInputToMachineList, + CASING_INDEX, + 1), + ofHatchAdder( + GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addOutputToMachineList, + CASING_INDEX, + 1))) + .addElement('C', onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings4, 1))) + .addElement( + 'l', + LoaderReference.ProjRedIllumination + ? ofBlock(Block.getBlockFromName("ProjRed|Illumination:projectred.illumination.lamp"), 10) + : ofBlock(Blocks.redstone_lamp, 0)) + .addElement( + 'g', + debug ? ofBlock(Blocks.glass, 0) + : BorosilicateGlass.ofBoroGlass( + (byte) 0, + (byte) 1, + Byte.MAX_VALUE, + (te, t) -> te.glasTier = t, + te -> te.glasTier)) + .addElement( + 'd', + ofBlock( + LoaderReference.RandomThings ? Block.getBlockFromName("RandomThings:fertilizedDirt_tilled") + : Blocks.farmland, + 0)) + .addElement('w', ofBlock(Blocks.water, 0)).build(); public GT_MetaTileEntity_ExtremeIndustrialGreenhouse(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -201,16 +192,14 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse if (this.setupphase == 3) this.setupphase = 0; GT_Utility.sendChatToPlayer( aPlayer, - "EIG is now running in " - + (this.setupphase == 1 - ? "setup mode (input)." - : (this.setupphase == 2 ? "setup mode (output)." : "normal operation."))); + "EIG is now running in " + (this.setupphase == 1 ? "setup mode (input)." + : (this.setupphase == 2 ? "setup mode (output)." : "normal operation."))); } } @Override - public boolean onWireCutterRightClick( - byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + public boolean onWireCutterRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, + float aZ) { isNoHumidity = !isNoHumidity; GT_Utility.sendChatToPlayer(aPlayer, "Give incoming crops no humidity " + isNoHumidity); return true; @@ -238,10 +227,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse @Override protected GT_Multiblock_Tooltip_Builder createTooltip() { GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Crop Farm") - .addInfo("Controller block for the Extreme Industrial Greenhouse") - .addInfo(AuthorKuba) - .addInfo("Grow your crops like a chad !") + tt.addMachineType("Crop Farm").addInfo("Controller block for the Extreme Industrial Greenhouse") + .addInfo(AuthorKuba).addInfo("Grow your crops like a chad !") .addInfo("Use screwdriver to enable/change/disable setup mode") .addInfo("Use screwdriver while sneaking to enable/disable IC2 mode") .addInfo("Use wire cutters to give incoming IC2 crops 0 humidity") @@ -249,15 +236,13 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse .addInfo("If there are >= 1000 crops -> Uses 1L of Weed-EX 9000 per crop per second") .addInfo("Otherwise, around 1% of crops will die each operation") .addInfo("You can insert fertilizer each operation to get more drops (max +400%)") - .addInfo("-------------------- SETUP MODE --------------------") - .addInfo("Does not take power") + .addInfo("-------------------- SETUP MODE --------------------").addInfo("Does not take power") .addInfo("There are two modes: input / output") .addInfo("Input mode: machine will take seeds from input bus and plant them") .addInfo("[IC2] You need to also input block that is required under the crop") .addInfo("Output mode: machine will take planted seeds and output them") .addInfo("-------------------- NORMAL CROPS --------------------") - .addInfo("Minimal tier: " + tierString(4)) - .addInfo("Starting with 1 slot") + .addInfo("Minimal tier: " + tierString(4)).addInfo("Starting with 1 slot") .addInfo("Every slot gives 64 crops") .addInfo("Every tier past " + tierString(4) + ", slots are multiplied by 2") .addInfo("Base process time: 5 sec") @@ -266,18 +251,12 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse .addInfo("Will automatically craft seeds if they are not dropped") .addInfo("1 Fertilizer per 1 crop +200%") .addInfo("-------------------- IC2 CROPS --------------------") - .addInfo("Minimal tier: " + tierString(6)) - .addInfo("Need " + tierString(6) + " glass tier") - .addInfo("Starting with 4 slots") - .addInfo("Every slot gives 1 crop") + .addInfo("Minimal tier: " + tierString(6)).addInfo("Need " + tierString(6) + " glass tier") + .addInfo("Starting with 4 slots").addInfo("Every slot gives 1 crop") .addInfo("Every tier past " + tierString(6) + ", slots are multiplied by 4") - .addInfo("Process time: 5 sec") - .addInfo("All crops are accelerated by x32 times") - .addInfo("1 Fertilizer per 1 crop +10%") - .addInfo(BW_Tooltip_Reference.TT_BLUEPRINT) - .addSeparator() - .beginStructureBlock(5, 6, 5, false) - .addController("Front bottom center") + .addInfo("Process time: 5 sec").addInfo("All crops are accelerated by x32 times") + .addInfo("1 Fertilizer per 1 crop +10%").addInfo(BW_Tooltip_Reference.TT_BLUEPRINT).addSeparator() + .beginStructureBlock(5, 6, 5, false).addController("Front bottom center") .addCasingInfo("Clean Stainless Steel Casings", 70) .addOtherStructurePart("Borosilicate Glass", "Hollow two middle layers") .addStructureInfo("The glass tier limits the Energy Input tier") @@ -309,8 +288,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse aNBT.setBoolean("isIC2Mode", isIC2Mode); aNBT.setBoolean("isNoHumidity", isNoHumidity); aNBT.setInteger("mStorageSize", mStorage.size()); - for (int i = 0; i < mStorage.size(); i++) - aNBT.setTag("mStorage." + i, mStorage.get(i).toNBTTagCompound()); + for (int i = 0; i < mStorage.size(); i++) aNBT.setTag("mStorage." + i, mStorage.get(i).toNBTTagCompound()); } @Override @@ -336,8 +314,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isClientSide()) { if (aBaseMetaTileEntity.isActive() && aTick % 40 == 0) { - int[] abc = new int[] {0, -2, 2}; - int[] xyz = new int[] {0, 0, 0}; + int[] abc = new int[] { 0, -2, 2 }; + int[] xyz = new int[] { 0, 0, 0 }; this.getExtendedFacing().getWorldOffset(abc, xyz); xyz[0] += aBaseMetaTileEntity.getXCoord(); xyz[1] += aBaseMetaTileEntity.getYCoord(); @@ -384,8 +362,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse updateMaxSlots(); if (oldVersion != EIG_MATH_VERSION) { - for (GreenHouseSlot slot : mStorage) - slot.recalculate(this, getBaseMetaTileEntity().getWorld()); + for (GreenHouseSlot slot : mStorage) slot.recalculate(this, getBaseMetaTileEntity().getWorld()); oldVersion = EIG_MATH_VERSION; } @@ -413,8 +390,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse while (mStorage.size() > 0) { if (!ignoreEmptiness && (emptySlots -= 2) < 0) break; this.addOutput(this.mStorage.get(0).input.copy()); - if (this.mStorage.get(0).undercrop != null) - this.addOutput(this.mStorage.get(0).undercrop.copy()); + if (this.mStorage.get(0).undercrop != null) this.addOutput(this.mStorage.get(0).undercrop.copy()); this.mStorage.remove(0); } } @@ -466,7 +442,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse if (weedexusage > 0 && !this.depleteInput(new FluidStack(weedex, isIC2Mode ? weedexusage * 5 : weedexusage))) { IGregTechTileEntity baseMTE = this.getBaseMetaTileEntity(); int tokill = baseMTE.getRandomNumber((int) ((double) weedexusage * 0.02d) + 1); - for (int i = 0; i < tokill; ) { + for (int i = 0; i < tokill;) { GreenHouseSlot removed = mStorage.remove(baseMTE.getRandomNumber(mStorage.size())); i -= removed.input.stackSize; } @@ -474,7 +450,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse // OVERCLOCK // FERTILIZER IDEA: - // IC2 +10% per fertilizer per crop per operation + // IC2 +10% per fertilizer per crop per operation // NORMAL +200% per fertilizer per crop per operation int boost = 0; @@ -563,98 +539,90 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse private final Function isFixed = widget -> getIdealStatus() == getRepairStatus() && mMachine; private static final Function toggleButtonBackgroundGetter = val -> { - if (val == 0) return new IDrawable[] {GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CROSS}; - else return new IDrawable[] {GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CHECKMARK}; + if (val == 0) return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CROSS }; + else return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CHECKMARK }; }; @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - builder.widget(new DrawableWidget() - .setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK) - .setPos(7, 4) - .setSize(143, 75) - .setEnabled(widget -> !isFixed.apply(widget))); + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK).setPos(7, 4).setSize(143, 75) + .setEnabled(widget -> !isFixed.apply(widget))); buildContext.addSyncedWindow(CONFIGURATION_WINDOW_ID, this::createConfigurationWindow); EntityPlayer player = buildContext.getPlayer(); // Slot is not needed - builder.widget(new DynamicPositionedColumn() - .setSynced(false) - .widget(new CycleButtonWidget() - .setToggle(() -> getBaseMetaTileEntity().isAllowedToWork(), works -> { + builder.widget( + new DynamicPositionedColumn().setSynced(false).widget( + new CycleButtonWidget().setToggle(() -> getBaseMetaTileEntity().isAllowedToWork(), works -> { if (works) getBaseMetaTileEntity().enableWorking(); else getBaseMetaTileEntity().disableWorking(); if (!(player instanceof EntityPlayerMP)) return; String tChat = GT_Utility.trans("090", "Machine Processing: ") - + (works - ? GT_Utility.trans("088", "Enabled") + + (works ? GT_Utility.trans("088", "Enabled") : GT_Utility.trans("087", "Disabled")); if (hasAlternativeModeText()) tChat = getAlternativeModeText(); GT_Utility.sendChatToPlayer(player, tChat); - }) - .addTooltip(0, new Text("Disabled").color(Color.RED.dark(3))) - .addTooltip(1, new Text("Enabled").color(Color.GREEN.dark(3))) - .setVariableBackgroundGetter(toggleButtonBackgroundGetter) - .setSize(18, 18) - .addTooltip("Working status")) - .widget(new ButtonWidget() - .setOnClick((clickData, widget) -> { - if (!widget.isClient()) widget.getContext().openSyncedWindow(CONFIGURATION_WINDOW_ID); - }) - .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CYCLIC) - .addTooltip("Configuration") - .setSize(18, 18)) - .setPos(151, 4)); + }).addTooltip(0, new Text("Disabled").color(Color.RED.dark(3))) + .addTooltip(1, new Text("Enabled").color(Color.GREEN.dark(3))) + .setVariableBackgroundGetter(toggleButtonBackgroundGetter).setSize(18, 18) + .addTooltip("Working status")) + .widget( + new ButtonWidget() + .setOnClick( + (clickData, widget) -> { + if (!widget.isClient()) + widget.getContext().openSyncedWindow(CONFIGURATION_WINDOW_ID); + }) + .setBackground( + GT_UITextures.BUTTON_STANDARD, + GT_UITextures.OVERLAY_BUTTON_CYCLIC) + .addTooltip("Configuration").setSize(18, 18)) + .setPos(151, 4)); final List drawables = new ArrayList<>(mMaxSlots); final int perRow = 7; Scrollable cropsContainer = new Scrollable().setVerticalScroll(); - if (mMaxSlots > 0) - for (int i = 0, imax = ((mMaxSlots - 1) / perRow); i <= imax; i++) { - DynamicPositionedRow row = new DynamicPositionedRow().setSynced(false); - for (int j = 0, jmax = (i == imax ? (mMaxSlots - 1) % perRow : (perRow - 1)); j <= jmax; j++) { - final int finalI = i * perRow; - final int finalJ = j; - final int ID = finalI + finalJ; - row.widget(new ButtonWidget() - .setOnClick((clickData, widget) -> { - if (!(player instanceof EntityPlayerMP)) return; - if (mStorage.size() <= ID) return; - if (this.mMaxProgresstime > 0) { - GT_Utility.sendChatToPlayer(player, "Can't eject while running !"); - return; - } - GreenHouseSlot removed = mStorage.remove(ID); - addOutput(removed.input); - GT_Utility.sendChatToPlayer(player, "Crop ejected !"); - }) - .setBackground(() -> new IDrawable[] { - getBaseMetaTileEntity().getGUITextureSet().getItemSlot(), + if (mMaxSlots > 0) for (int i = 0, imax = ((mMaxSlots - 1) / perRow); i <= imax; i++) { + DynamicPositionedRow row = new DynamicPositionedRow().setSynced(false); + for (int j = 0, jmax = (i == imax ? (mMaxSlots - 1) % perRow : (perRow - 1)); j <= jmax; j++) { + final int finalI = i * perRow; + final int finalJ = j; + final int ID = finalI + finalJ; + row.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!(player instanceof EntityPlayerMP)) return; + if (mStorage.size() <= ID) return; + if (this.mMaxProgresstime > 0) { + GT_Utility.sendChatToPlayer(player, "Can't eject while running !"); + return; + } + GreenHouseSlot removed = mStorage.remove(ID); + addOutput(removed.input); + GT_Utility.sendChatToPlayer(player, "Crop ejected !"); + }).setBackground( + () -> new IDrawable[] { getBaseMetaTileEntity().getGUITextureSet().getItemSlot(), new ItemDrawable(drawables.size() > ID ? drawables.get(ID) : null) - .withFixedSize(16, 16, 1, 1) - }) - .dynamicTooltip(() -> { - if (drawables.size() > ID) - return Arrays.asList( - drawables.get(ID).getDisplayName(), - "Amount: " + drawables.get(ID).stackSize, - EnumChatFormatting.GRAY + "Left click to eject"); - return Collections.emptyList(); - }) - .setSize(18, 18)); - } - cropsContainer.widget(row.setPos(0, i * 18).setEnabled(widget -> { - int y = widget.getPos().y; - int cy = cropsContainer.getVerticalScrollOffset(); - int ch = cropsContainer.getVisibleHeight(); - return y >= cy - ch && y <= cy + ch; - })); + .withFixedSize(16, 16, 1, 1) }) + .dynamicTooltip(() -> { + if (drawables.size() > ID) return Arrays.asList( + drawables.get(ID).getDisplayName(), + "Amount: " + drawables.get(ID).stackSize, + EnumChatFormatting.GRAY + "Left click to eject"); + return Collections.emptyList(); + }).setSize(18, 18)); } + cropsContainer.widget(row.setPos(0, i * 18).setEnabled(widget -> { + int y = widget.getPos().y; + int cy = cropsContainer.getVerticalScrollOffset(); + int ch = cropsContainer.getVisibleHeight(); + return y >= cy - ch && y <= cy + ch; + })); + } cropsContainer.attachSyncer( new FakeSyncWidget.ListSyncer<>( () -> mStorage.stream().map(s -> s.input).collect(Collectors.toList()), @@ -688,125 +656,102 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse protected ModularWindow createConfigurationWindow(final EntityPlayer player) { ModularWindow.Builder builder = ModularWindow.builder(200, 100); builder.setBackground(ModularUITextures.VANILLA_BACKGROUND); - builder.widget(new DrawableWidget() - .setDrawable(GT_UITextures.OVERLAY_BUTTON_CYCLIC) - .setPos(5, 5) - .setSize(16, 16)) + builder.widget( + new DrawableWidget().setDrawable(GT_UITextures.OVERLAY_BUTTON_CYCLIC).setPos(5, 5).setSize(16, 16)) .widget(new TextWidget("Configuration").setPos(25, 9)) .widget(ButtonWidget.closeWindowButton(true).setPos(185, 3)) - .widget(new Column() - .widget(new CycleButtonWidget() - .setLength(3) - .setGetter(() -> setupphase) - .setSetter(val -> { + .widget( + new Column().widget( + new CycleButtonWidget().setLength(3).setGetter(() -> setupphase).setSetter(val -> { if (!(player instanceof EntityPlayerMP)) return; if (this.mMaxProgresstime > 0) { GT_Utility.sendChatToPlayer( - player, "You can't enable/disable setup if the machine is working!"); + player, + "You can't enable/disable setup if the machine is working!"); return; } this.setupphase = val; GT_Utility.sendChatToPlayer( player, - "EIG is now running in " - + (this.setupphase == 1 - ? "setup mode (input)." - : (this.setupphase == 2 - ? "setup mode (output)." - : "normal operation."))); - }) - .addTooltip(0, new Text("Operating").color(Color.GREEN.dark(3))) - .addTooltip(1, new Text("Input").color(Color.YELLOW.dark(3))) - .addTooltip(2, new Text("Output").color(Color.YELLOW.dark(3))) - .setVariableBackgroundGetter(i -> new IDrawable[] { - ModularUITextures.VANILLA_BACKGROUND, - GT_UITextures.OVERLAY_BUTTON_CYCLIC.withFixedSize(18, 18), - i == 0 - ? new Text("Operating") - .color(Color.GREEN.dark(3)) - .withFixedSize(70 - 18, 18, 15, 0) - : i == 1 - ? new Text("Input") - .color(Color.YELLOW.dark(3)) - .withFixedSize(70 - 18, 18, 15, 0) - : new Text("Output") - .color(Color.YELLOW.dark(3)) - .withFixedSize(70 - 18, 18, 15, 0) - }) - .setSize(70, 18) - .addTooltip("Setup mode")) - .widget(new CycleButtonWidget() - .setLength(2) - .setGetter(() -> isIC2Mode ? 1 : 0) - .setSetter(val -> { - if (!(player instanceof EntityPlayerMP)) return; - if (this.mMaxProgresstime > 0) { - GT_Utility.sendChatToPlayer( - player, "You can't change IC2 mode if the machine is working!"); - return; - } - if (!mStorage.isEmpty()) { - GT_Utility.sendChatToPlayer( - player, "You can't change IC2 mode if there are seeds inside!"); - return; - } - this.isIC2Mode = val == 1; - GT_Utility.sendChatToPlayer( - player, "IC2 mode is now " + (this.isIC2Mode ? "enabled" : "disabled.")); - }) - .addTooltip(0, new Text("Disabled").color(Color.RED.dark(3))) - .addTooltip(1, new Text("Enabled").color(Color.GREEN.dark(3))) - .setVariableBackgroundGetter(i -> new IDrawable[] { - ModularUITextures.VANILLA_BACKGROUND, - GT_UITextures.OVERLAY_BUTTON_CYCLIC.withFixedSize(18, 18), - i == 0 - ? new Text("Disabled") - .color(Color.RED.dark(3)) - .withFixedSize(70 - 18, 18, 15, 0) - : new Text("Enabled") - .color(Color.GREEN.dark(3)) - .withFixedSize(70 - 18, 18, 15, 0) - }) - .setSize(70, 18) - .addTooltip("IC2 mode")) - .widget(new CycleButtonWidget() - .setLength(2) - .setGetter(() -> isNoHumidity ? 1 : 0) - .setSetter(val -> { - if (!(player instanceof EntityPlayerMP)) return; - isNoHumidity = val == 1; - GT_Utility.sendChatToPlayer( - player, "Give incoming crops no humidity " + isNoHumidity); - }) - .addTooltip(0, new Text("Disabled").color(Color.RED.dark(3))) - .addTooltip(1, new Text("Enabled").color(Color.GREEN.dark(3))) - .setVariableBackgroundGetter(i -> new IDrawable[] { - ModularUITextures.VANILLA_BACKGROUND, - GT_UITextures.OVERLAY_BUTTON_CYCLIC.withFixedSize(18, 18), - i == 0 - ? new Text("Disabled") - .color(Color.RED.dark(3)) - .withFixedSize(70 - 18, 18, 15, 0) - : new Text("Enabled") - .color(Color.GREEN.dark(3)) - .withFixedSize(70 - 18, 18, 15, 0) - }) - .setSize(70, 18) - .addTooltip("No Humidity mode")) - .setEnabled(widget -> !getBaseMetaTileEntity().isActive()) - .setPos(10, 30)) - .widget(new Column() - .widget(new TextWidget("Setup mode").setSize(100, 18)) - .widget(new TextWidget("IC2 mode").setSize(100, 18)) - .widget(new TextWidget("No Humidity mode").setSize(100, 18)) - .setEnabled(widget -> !getBaseMetaTileEntity().isActive()) - .setPos(80, 30)) - .widget(new DrawableWidget() - .setDrawable(GT_UITextures.OVERLAY_BUTTON_CROSS) - .setSize(18, 18) - .setPos(10, 30) - .addTooltip(new Text("Can't change configuration when running !").color(Color.RED.dark(3))) - .setEnabled(widget -> getBaseMetaTileEntity().isActive())); + "EIG is now running in " + (this.setupphase == 1 ? "setup mode (input)." + : (this.setupphase == 2 ? "setup mode (output)." + : "normal operation."))); + }).addTooltip(0, new Text("Operating").color(Color.GREEN.dark(3))) + .addTooltip(1, new Text("Input").color(Color.YELLOW.dark(3))) + .addTooltip(2, new Text("Output").color(Color.YELLOW.dark(3))) + .setVariableBackgroundGetter( + i -> new IDrawable[] { ModularUITextures.VANILLA_BACKGROUND, + GT_UITextures.OVERLAY_BUTTON_CYCLIC.withFixedSize(18, 18), + i == 0 ? new Text("Operating").color(Color.GREEN.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) + : i == 1 ? new Text("Input").color(Color.YELLOW.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) + : new Text("Output").color(Color.YELLOW.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) }) + .setSize(70, 18).addTooltip("Setup mode")) + .widget( + new CycleButtonWidget().setLength(2).setGetter(() -> isIC2Mode ? 1 : 0) + .setSetter(val -> { + if (!(player instanceof EntityPlayerMP)) return; + if (this.mMaxProgresstime > 0) { + GT_Utility.sendChatToPlayer( + player, + "You can't change IC2 mode if the machine is working!"); + return; + } + if (!mStorage.isEmpty()) { + GT_Utility.sendChatToPlayer( + player, + "You can't change IC2 mode if there are seeds inside!"); + return; + } + this.isIC2Mode = val == 1; + GT_Utility.sendChatToPlayer( + player, + "IC2 mode is now " + + (this.isIC2Mode ? "enabled" : "disabled.")); + }).addTooltip(0, new Text("Disabled").color(Color.RED.dark(3))) + .addTooltip(1, new Text("Enabled").color(Color.GREEN.dark(3))) + .setVariableBackgroundGetter( + i -> new IDrawable[] { ModularUITextures.VANILLA_BACKGROUND, + GT_UITextures.OVERLAY_BUTTON_CYCLIC + .withFixedSize(18, 18), + i == 0 ? new Text("Disabled").color(Color.RED.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) + : new Text("Enabled").color(Color.GREEN.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) }) + .setSize(70, 18).addTooltip("IC2 mode")) + .widget( + new CycleButtonWidget().setLength(2).setGetter(() -> isNoHumidity ? 1 : 0) + .setSetter(val -> { + if (!(player instanceof EntityPlayerMP)) return; + isNoHumidity = val == 1; + GT_Utility.sendChatToPlayer( + player, + "Give incoming crops no humidity " + isNoHumidity); + }).addTooltip(0, new Text("Disabled").color(Color.RED.dark(3))) + .addTooltip(1, new Text("Enabled").color(Color.GREEN.dark(3))) + .setVariableBackgroundGetter( + i -> new IDrawable[] { ModularUITextures.VANILLA_BACKGROUND, + GT_UITextures.OVERLAY_BUTTON_CYCLIC + .withFixedSize(18, 18), + i == 0 ? new Text("Disabled").color(Color.RED.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) + : new Text("Enabled").color(Color.GREEN.dark(3)) + .withFixedSize(70 - 18, 18, 15, 0) }) + .setSize(70, 18).addTooltip("No Humidity mode")) + .setEnabled(widget -> !getBaseMetaTileEntity().isActive()).setPos(10, 30)) + .widget( + new Column().widget(new TextWidget("Setup mode").setSize(100, 18)) + .widget(new TextWidget("IC2 mode").setSize(100, 18)) + .widget(new TextWidget("No Humidity mode").setSize(100, 18)) + .setEnabled(widget -> !getBaseMetaTileEntity().isActive()).setPos(80, 30)) + .widget( + new DrawableWidget().setDrawable(GT_UITextures.OVERLAY_BUTTON_CROSS).setSize(18, 18) + .setPos(10, 30) + .addTooltip( + new Text("Can't change configuration when running !").color(Color.RED.dark(3))) + .setEnabled(widget -> getBaseMetaTileEntity().isActive())); return builder.build(); } @@ -814,74 +759,79 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse protected void drawTexts(DynamicPositionedColumn screenElements, SlotWidget inventorySlot) { screenElements.setSynced(false).setSpace(0).setPos(10, 7); - screenElements.widget(new DynamicPositionedRow() - .setSynced(false) - .widget(new TextWidget("Status: ").setDefaultColor(COLOR_TEXT_GRAY.get())) - .widget(new DynamicTextWidget(() -> { - if (getBaseMetaTileEntity().isActive()) return new Text("Working !").color(Color.GREEN.dark(3)); - else if (getBaseMetaTileEntity().isAllowedToWork()) - return new Text("Enabled").color(Color.GREEN.dark(3)); - else if (getBaseMetaTileEntity().wasShutdown()) - return new Text("Shutdown (CRITICAL)").color(Color.RED.dark(3)); - else return new Text("Disabled").color(Color.RED.dark(3)); - })) - .setEnabled(isFixed)); + screenElements.widget( + new DynamicPositionedRow().setSynced(false) + .widget(new TextWidget("Status: ").setDefaultColor(COLOR_TEXT_GRAY.get())) + .widget(new DynamicTextWidget(() -> { + if (getBaseMetaTileEntity().isActive()) + return new Text("Working !").color(Color.GREEN.dark(3)); + else if (getBaseMetaTileEntity().isAllowedToWork()) + return new Text("Enabled").color(Color.GREEN.dark(3)); + else if (getBaseMetaTileEntity().wasShutdown()) + return new Text("Shutdown (CRITICAL)").color(Color.RED.dark(3)); + else return new Text("Disabled").color(Color.RED.dark(3)); + })).setEnabled(isFixed)); screenElements - .widget(new TextWidget(GT_Utility.trans("132", "Pipe is loose.")) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setEnabled(widget -> !mWrench)) + .widget( + new TextWidget(GT_Utility.trans("132", "Pipe is loose.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()).setEnabled(widget -> !mWrench)) .widget(new FakeSyncWidget.BooleanSyncer(() -> mWrench, val -> mWrench = val)); screenElements - .widget(new TextWidget(GT_Utility.trans("133", "Screws are loose.")) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setEnabled(widget -> !mScrewdriver)) + .widget( + new TextWidget(GT_Utility.trans("133", "Screws are loose.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()).setEnabled(widget -> !mScrewdriver)) .widget(new FakeSyncWidget.BooleanSyncer(() -> mScrewdriver, val -> mScrewdriver = val)); screenElements - .widget(new TextWidget(GT_Utility.trans("134", "Something is stuck.")) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setEnabled(widget -> !mSoftHammer)) + .widget( + new TextWidget(GT_Utility.trans("134", "Something is stuck.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()).setEnabled(widget -> !mSoftHammer)) .widget(new FakeSyncWidget.BooleanSyncer(() -> mSoftHammer, val -> mSoftHammer = val)); screenElements - .widget(new TextWidget(GT_Utility.trans("135", "Platings are dented.")) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setEnabled(widget -> !mHardHammer)) + .widget( + new TextWidget(GT_Utility.trans("135", "Platings are dented.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()).setEnabled(widget -> !mHardHammer)) .widget(new FakeSyncWidget.BooleanSyncer(() -> mHardHammer, val -> mHardHammer = val)); screenElements - .widget(new TextWidget(GT_Utility.trans("136", "Circuitry burned out.")) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setEnabled(widget -> !mSolderingTool)) + .widget( + new TextWidget(GT_Utility.trans("136", "Circuitry burned out.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()).setEnabled(widget -> !mSolderingTool)) .widget(new FakeSyncWidget.BooleanSyncer(() -> mSolderingTool, val -> mSolderingTool = val)); screenElements - .widget(new TextWidget(GT_Utility.trans("137", "That doesn't belong there.")) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setEnabled(widget -> !mCrowbar)) + .widget( + new TextWidget(GT_Utility.trans("137", "That doesn't belong there.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()).setEnabled(widget -> !mCrowbar)) .widget(new FakeSyncWidget.BooleanSyncer(() -> mCrowbar, val -> mCrowbar = val)); screenElements - .widget(new TextWidget(GT_Utility.trans("138", "Incomplete Structure.")) - .setDefaultColor(COLOR_TEXT_WHITE.get()) - .setEnabled(widget -> !mMachine)) + .widget( + new TextWidget(GT_Utility.trans("138", "Incomplete Structure.")) + .setDefaultColor(COLOR_TEXT_WHITE.get()).setEnabled(widget -> !mMachine)) .widget(new FakeSyncWidget.BooleanSyncer(() -> mMachine, val -> mMachine = val)); } @Override public String[] getInfoData() { - List info = new ArrayList<>(Arrays.asList( - "Running in mode: " + EnumChatFormatting.GREEN - + (setupphase == 0 - ? (isIC2Mode ? "IC2 crops" : "Normal crops") - : ("Setup mode " + (setupphase == 1 ? "(input)" : "(output)"))) - + EnumChatFormatting.RESET, - "Uses " + waterusage + "L/operation of water", - "Uses " + weedexusage + "L/second of Weed-EX 9000", - "Max slots: " + EnumChatFormatting.GREEN + this.mMaxSlots + EnumChatFormatting.RESET, - "Used slots: " + ((mStorage.size() > mMaxSlots) ? EnumChatFormatting.RED : EnumChatFormatting.GREEN) - + this.mStorage.size() + EnumChatFormatting.RESET)); + List info = new ArrayList<>( + Arrays.asList( + "Running in mode: " + EnumChatFormatting.GREEN + + (setupphase == 0 ? (isIC2Mode ? "IC2 crops" : "Normal crops") + : ("Setup mode " + (setupphase == 1 ? "(input)" : "(output)"))) + + EnumChatFormatting.RESET, + "Uses " + waterusage + "L/operation of water", + "Uses " + weedexusage + "L/second of Weed-EX 9000", + "Max slots: " + EnumChatFormatting.GREEN + this.mMaxSlots + EnumChatFormatting.RESET, + "Used slots: " + + ((mStorage.size() > mMaxSlots) ? EnumChatFormatting.RED : EnumChatFormatting.GREEN) + + this.mStorage.size() + + EnumChatFormatting.RESET)); HashMap storageList = new HashMap<>(); for (GreenHouseSlot greenHouseSlot : mStorage) { if (!greenHouseSlot.isValid) continue; - StringBuilder a = new StringBuilder(EnumChatFormatting.GREEN + "x" + greenHouseSlot.input.stackSize + " " - + greenHouseSlot.input.getDisplayName()); + StringBuilder a = new StringBuilder( + EnumChatFormatting.GREEN + "x" + + greenHouseSlot.input.stackSize + + " " + + greenHouseSlot.input.getDisplayName()); if (this.isIC2Mode) { a.append(" | Humidity: ").append(greenHouseSlot.noHumidity ? 0 : 12); } @@ -889,60 +839,36 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse storageList.merge(a.toString(), 1, Integer::sum); } storageList.forEach((k, v) -> info.add("x" + v + " " + k)); - if (mStorage.size() > mMaxSlots) - info.add(EnumChatFormatting.DARK_RED + "There are too many crops inside to run !" - + EnumChatFormatting.RESET); + if (mStorage.size() > mMaxSlots) info.add( + EnumChatFormatting.DARK_RED + "There are too many crops inside to run !" + EnumChatFormatting.RESET); info.addAll(Arrays.asList(super.getInfoData())); return info.toArray(new String[0]); } @Override - public ITexture[] getTexture( - IGregTechTileEntity aBaseMetaTileEntity, - byte aSide, - byte aFacing, - byte aColorIndex, - boolean aActive, - boolean aRedstone) { + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, + boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - if (aActive) - return new ITexture[] { - Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), - TextureFactory.builder() - .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE) - .extFacing() - .build(), - TextureFactory.builder() - .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW) - .extFacing() - .glow() - .build() - }; - return new ITexture[] { - Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), - TextureFactory.builder() - .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER) - .extFacing() - .build(), - TextureFactory.builder() - .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW) - .extFacing() - .glow() - .build() - }; + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), + TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW).extFacing().glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX), + TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW).extFacing().glow() + .build() }; } - return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(CASING_INDEX)}; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(CASING_INDEX) }; } public final List mStorage = new ArrayList<>(); public boolean addCrop(ItemStack input) { if (!isIC2Mode) - for (GreenHouseSlot g : mStorage) - if (g.input.stackSize < 64 && GT_Utility.areStacksEqual(g.input, input)) { - g.addAll(this.getBaseMetaTileEntity().getWorld(), input); - if (input.stackSize == 0) return true; - } + for (GreenHouseSlot g : mStorage) if (g.input.stackSize < 64 && GT_Utility.areStacksEqual(g.input, input)) { + g.addAll(this.getBaseMetaTileEntity().getWorld(), input); + if (input.stackSize == 0) return true; + } GreenHouseSlot h = new GreenHouseSlot(this, input, isIC2Mode, isNoHumidity); if (h.isValid) { mStorage.add(h); @@ -995,12 +921,10 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse if (undercrop != null) aNBT.setTag("undercrop", undercrop.writeToNBT(new NBTTagCompound())); aNBT.setInteger("generationscount", generations.size()); for (int i = 0; i < generations.size(); i++) { - aNBT.setInteger( - "generation." + i + ".count", generations.get(i).size()); - for (int j = 0; j < generations.get(i).size(); j++) - aNBT.setTag( - "generation." + i + "." + j, - generations.get(i).get(j).writeToNBT(new NBTTagCompound())); + aNBT.setInteger("generation." + i + ".count", generations.get(i).size()); + for (int j = 0; j < generations.get(i).size(); j++) aNBT.setTag( + "generation." + i + "." + j, + generations.get(i).get(j).writeToNBT(new NBTTagCompound())); } aNBT.setInteger("growthticks", growthticks); aNBT.setBoolean("noHumidity", noHumidity); @@ -1033,10 +957,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse generations = new ArrayList<>(); for (int i = 0; i < aNBT.getInteger("generationscount"); i++) { generations.add(new ArrayList<>()); - for (int j = 0; j < aNBT.getInteger("generation." + i + ".count"); j++) - generations - .get(i) - .add(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("generation." + i + "." + j))); + for (int j = 0; j < aNBT.getInteger("generation." + i + ".count"); j++) generations.get(i) + .add(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("generation." + i + "." + j))); } growthticks = aNBT.getInteger("growthticks"); noHumidity = aNBT.getBoolean("noHumidity"); @@ -1056,14 +978,10 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse public boolean findCropRecipe(World world) { if (recipe != null) return true; - out: - for (ItemStack drop : drops) { + out: for (ItemStack drop : drops) { recipeInput = drop; - for (int j = 0; - j < CraftingManager.getInstance().getRecipeList().size(); - j++) { - recipe = (IRecipe) - CraftingManager.getInstance().getRecipeList().get(j); + for (int j = 0; j < CraftingManager.getInstance().getRecipeList().size(); j++) { + recipe = (IRecipe) CraftingManager.getInstance().getRecipeList().get(j); if (recipe.matches(this, world) && GT_Utility.areStacksEqual(recipe.getCraftingResult(this), input)) { break out; @@ -1093,10 +1011,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse @Override public void setInventorySlotContents(int par1, ItemStack par2ItemStack) {} - public GreenHouseSlot( - GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, - ItemStack input, - boolean IC2, + public GreenHouseSlot(GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, ItemStack input, boolean IC2, boolean noHumidity) { super(null, 3, 3); World world = tileEntity.getBaseMetaTileEntity().getWorld(); @@ -1158,11 +1073,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } } - public void GreenHouseSlotIC2( - GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, - World world, - ItemStack input, - boolean noHumidity) { + public void GreenHouseSlotIC2(GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, World world, + ItemStack input, boolean noHumidity) { if (!ItemList.IC2_Crop_Seeds.isStackEqual(input, true, true)) return; this.isIC2Crop = true; recalculate(tileEntity, world); @@ -1181,7 +1093,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse z, b, GT_TileEntity_Ores.getHarvestData( - tDamage, ((GT_Block_Ores_Abstract) b).getBaseBlockHarvestLevel(tDamage % 16000 / 1000)), + tDamage, + ((GT_Block_Ores_Abstract) b).getBaseBlockHarvestLevel(tDamage % 16000 / 1000)), 0)) { return false; } @@ -1200,8 +1113,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse byte gr = nbt.getByte("growth"); byte ga = nbt.getByte("gain"); byte re = nbt.getByte("resistance"); - int[] abc = new int[] {0, -2, 3}; - int[] xyz = new int[] {0, 0, 0}; + int[] abc = new int[] { 0, -2, 3 }; + int[] xyz = new int[] { 0, 0, 0 }; tileEntity.getExtendedFacing().getWorldOffset(abc, xyz); xyz[0] += tileEntity.getBaseMetaTileEntity().getXCoord(); xyz[1] += tileEntity.getBaseMetaTileEntity().getYCoord(); @@ -1260,8 +1173,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse // GENERATE DROPS generations = new ArrayList<>(); - out: - for (int i = 0; i < 10; i++) // get 10 generations + out: for (int i = 0; i < 10; i++) // get 10 generations { ItemStack[] st = te.harvest_automated(false); te.setSize((byte) cc.maxSize()); @@ -1323,12 +1235,11 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse if (!dropstacks.containsKey(s.toString())) dropstacks.put(s.toString(), s.copy()); } copied.clear(); - for (Map.Entry entry : dropprogress.entrySet()) - if (entry.getValue() >= 1d) { - copied.add(dropstacks.get(entry.getKey()).copy()); - copied.get(copied.size() - 1).stackSize = entry.getValue().intValue(); - entry.setValue(entry.getValue() - (double) entry.getValue().intValue()); - } + for (Map.Entry entry : dropprogress.entrySet()) if (entry.getValue() >= 1d) { + copied.add(dropstacks.get(entry.getKey()).copy()); + copied.get(copied.size() - 1).stackSize = entry.getValue().intValue(); + entry.setValue(entry.getValue() - (double) entry.getValue().intValue()); + } return copied; } @@ -1338,7 +1249,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse @SuppressWarnings("unchecked") ArrayList d = (ArrayList) customDrops.clone(); for (ItemStack x : drops) { - for (Iterator iterator = d.iterator(); iterator.hasNext(); ) { + for (Iterator iterator = d.iterator(); iterator.hasNext();) { ItemStack y = iterator.next(); if (GT_Utility.areStacksEqual(x, y)) { x.stackSize += y.stackSize * count; @@ -1357,12 +1268,10 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse if (crop == null) return count; for (int i = 0; i < count; i++) { List d = crop.getDrops(world, 0, 0, 0, optimalgrowth, 0); - for (ItemStack x : drops) - for (ItemStack y : d) - if (GT_Utility.areStacksEqual(x, y)) { - x.stackSize += y.stackSize; - y.stackSize = 0; - } + for (ItemStack x : drops) for (ItemStack y : d) if (GT_Utility.areStacksEqual(x, y)) { + x.stackSize += y.stackSize; + y.stackSize = 0; + } for (ItemStack x : d) if (x.stackSize > 0) drops.add(x.copy()); } } @@ -1442,6 +1351,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } private static class GreenHouseRandom extends Random { + @Override public int nextInt(int bound) { return 0; -- cgit From 793b11aa3d432c1e2cd31f56c60c3dec436ff4a2 Mon Sep 17 00:00:00 2001 From: kuba6000 Date: Thu, 16 Mar 2023 18:25:27 +0100 Subject: License --- src/main/java/kubatech/client/effect/CropRenderer.java | 10 ++++++++++ .../GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 13 +++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src/main/java/kubatech/client/effect/CropRenderer.java') diff --git a/src/main/java/kubatech/client/effect/CropRenderer.java b/src/main/java/kubatech/client/effect/CropRenderer.java index 5a5217776c..e9b6aac3dc 100644 --- a/src/main/java/kubatech/client/effect/CropRenderer.java +++ b/src/main/java/kubatech/client/effect/CropRenderer.java @@ -1,3 +1,13 @@ +/* + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * . + */ + package kubatech.client.effect; import java.lang.reflect.Field; diff --git a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java index c228fe225a..94e46a83fa 100644 --- a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java +++ b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java @@ -1,10 +1,11 @@ /* - * Copyright (C) 2022 kuba6000 This program is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. You should have received a copy of the GNU General Public License along with - * this program. If not, see . + * KubaTech - Gregtech Addon Copyright (C) 2022 - 2023 kuba6000 This library is free software; you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software + * Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in + * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have + * received a copy of the GNU Lesser General Public License along with this library. If not, see + * . */ package kubatech.tileentity.gregtech.multiblock; -- cgit