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 --- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 720 +++++++++++++++++++++ 1 file changed, 720 insertions(+) create mode 100644 src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java (limited to 'src/main/java/kubatech/tileentity') 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 new file mode 100644 index 0000000000..3e65bb0ce0 --- /dev/null +++ b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java @@ -0,0 +1,720 @@ +package kubatech.tileentity.gregtech.multiblock; + +import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; +import com.github.bartimaeusnek.bartworks.API.LoaderReference; +import kubatech.client.effect.CropRenderer; +import com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Utility; +import ic2.api.crops.CropCard; +import ic2.api.crops.Crops; +import ic2.core.Ic2Items; +import ic2.core.crop.TileEntityCrop; +import net.minecraft.block.Block; +import net.minecraft.block.BlockCrops; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemSeeds; +import net.minecraft.item.ItemStack; +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.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import java.util.*; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.Textures.BlockIcons.*; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_GLOW; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEntity_EnhancedMultiBlockBase { + + private int mCasing = 0; + private int mMaxSlots = 0; + private int setupphase = 1; + private boolean isIC2Mode = false; + private byte glasTier = 0; + private int waterusage = 0; + private static final int CASING_INDEX = 49; + private static final String STRUCTURE_PIECE_MAIN = "main"; + 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('l', LoaderReference.ProjRedIllumination ? ofBlock(Block.getBlockFromName("ProjRed|Illumination:projectred.illumination.lamp"), 10) : ofBlock(Blocks.redstone_lamp, 0)) + .addElement('g', 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); + } + + public GT_MetaTileEntity_ExtremeIndustrialGreenhouse(String aName) { + super(aName); + } + + @Override + 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!"); + return; + } + 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) + { + 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."))); + } + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_ExtremeIndustrialGreenhouse(this.mName); + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated() && f.isNotFlipped(); + } + + @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("-------------------- 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("Output mode: machine will take planted seeds and output them"). + addInfo("-------------------- NORMAL CROPS --------------------"). + addInfo("Minimal tier: EV"). + addInfo("Starting with 1 slot"). + addInfo("Every slot gives 64 crops"). + addInfo("Every tier past EV adds additional 2 slots"). + addInfo("Base process time: 5 sec"). + addInfo("Process time is divided by number of tiers past HV (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("-------------------- IC2 CROPS --------------------"). + addInfo("Minimal tier: UV"). + addInfo("Need UV glass tier"). + addInfo("Starting with 4 slots"). + addInfo("Every slot gives 1 crop"). + addInfo("Every tier past UV, slots are multiplied by 4"). + addInfo("Process time: 5 sec"). + addInfo("All crops are accelerated by x32 times"). + 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"). + addMaintenanceHatch("Any casing", 1). + addInputBus("Any casing", 1). + addOutputBus("Any casing", 1). + addInputHatch("Any casing", 1). + addEnergyHatch("Any casing", 1). + toolTipFinisher("Added by " + ChatColorHelper.GOLD + "kuba6000" + ChatColorHelper.RESET + ChatColorHelper.GREEN + " via " + BW_Tooltip_Reference.BW); + return tt; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setByte("glasTier", glasTier); + aNBT.setInteger("setupphase", setupphase); + aNBT.setBoolean("isIC2Mode", isIC2Mode); + aNBT.setInteger("mStorageSize", mStorage.size()); + for(int i = 0; i < mStorage.size(); i++) + aNBT.setTag("mStorage." + i, mStorage.get(i).toNBTTagCompound()); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + glasTier = aNBT.getByte("glasTier"); + setupphase = aNBT.getInteger("setupphase"); + isIC2Mode = aNBT.getBoolean("isIC2Mode"); + 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){ + CropRenderer crop = new CropRenderer(world, x, y, z, meta, age); + Minecraft.getMinecraft().effectRenderer.addEffect(crop); + } + + @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}; + 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); + } + } + } + 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; + this.updateSlots(); + } + else if(setupphase == 2 && mStorage.size() > 0) + { + this.addOutput(this.mStorage.get(0).input.copy()); + this.mStorage.remove(0); + this.updateSlots(); + } + } + } + + @Override + public void construct(ItemStack itemStack, boolean b) { + buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 2, 5, 0); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + long v = this.getMaxInputVoltage(); + int tier = GT_Utility.getTier(v); + if(tier < (isIC2Mode ? 8 : 4)) + mMaxSlots = 0; + else if(isIC2Mode) + mMaxSlots = 4 << (2 * (tier - 8)); + else + mMaxSlots = Math.max((tier - 4) * 2, 1); + if(mStorage.size() > mMaxSlots) + { + // Void if user just downgraded power + for(int i = mMaxSlots; i < mStorage.size(); i++) + { + mStorage.remove(i); + i--; + } + } + if(setupphase > 0) { + if((mStorage.size() >= mMaxSlots && setupphase == 1) || (mStorage.size() == 0 && setupphase == 2)) + return false; + this.mMaxProgresstime = 20; + this.mEUt = 0; + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + return true; + } + if(mStorage.isEmpty()) + return false; + + waterusage = 0; + for(GreenHouseSlot s : mStorage) + waterusage += s.input.stackSize; + + if(!depleteInput(new FluidStack(FluidRegistry.WATER, waterusage * 1000))) + return false; + + // OVERCLOCK + if(isIC2Mode) + { + if(glasTier < 8) + 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(this.mMaxProgresstime / 8)); + this.mOutputItems = outputs.toArray(new ItemStack[0]); + } + 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()) + outputs.add(drop.copy()); + } + this.mOutputItems = outputs.toArray(new ItemStack[0]); + } + this.mEUt = -(int)((double)v * 0.99d); + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + return true; + } + + + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + mCasing = 0; + glasTier = 0; + + 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; + + return this.mMaintenanceHatches.size() == 1 && + this.mEnergyHatches.size() >= 1 && + this.mCasing >= 70; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @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/s of water", + "Max slots: " + EnumChatFormatting.GREEN + this.mMaxSlots + EnumChatFormatting.RESET, + "Used slots: " + EnumChatFormatting.GREEN + this.mStorage.size() + EnumChatFormatting.RESET + )); + for(int i = 0; i < mStorage.size(); i++) + info.add("Slot " + i + ": " + EnumChatFormatting.GREEN + "x" + this.mStorage.get(i).input.stackSize + " " + this.mStorage.get(i).input.getDisplayName() + 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) { + 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()}; + } + 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)) + { + g.addAll(this.getBaseMetaTileEntity().getWorld(), input); + 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; + mStorage.add(h); + return true; + } + return false; + } + + private static class GreenHouseSlot extends InventoryCrafting { + + ItemStack input; + BlockCrops crop; + List drops; + boolean isValid; + boolean isIC2Crop; + int growthticks; + List> generations; + + Random rn; + IRecipe recipe; + ItemStack recipeInput; + + public NBTTagCompound toNBTTagCompound(){ + NBTTagCompound aNBT = new NBTTagCompound(); + aNBT.setTag("input", input.writeToNBT(new NBTTagCompound())); + 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())); + } + else { + 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.setBoolean("isValid", isValid); + aNBT.setBoolean("isIC2Crop", isIC2Crop); + if(isIC2Crop) aNBT.setInteger("growthticks", growthticks); + return 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) { + crop = (BlockCrops) 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))); + } + else + { + 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))); + } + 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; + int toconsume = Math.min(64 - this.input.stackSize, input.stackSize); + int left = addDrops(world, toconsume, true); + input.stackSize -= toconsume - left; + return left == 0; + } + + 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)) { + break out; + } else + recipe = null; + } + } + return recipe != null; + } + + @Override + public ItemStack getStackInSlot(int p_70301_1_) { + if(p_70301_1_ == 0) + return recipeInput.copy(); + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int par1) { + return null; + } + + @Override + public ItemStack decrStackSize(int par1, int par2) + { + return null; + } + + @Override + public void setInventorySlotContents(int par1, ItemStack par2ItemStack) { + return; + } + + 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) + { + GreenHouseSlotIC2(tileEntity, world, input); + return; + } + if (!(input.getItem() instanceof ItemSeeds)) { + return; + } + Block b = ((ItemSeeds) input.getItem()).getPlant(world, 0, 0, 0); + if (!(b instanceof BlockCrops)) + return; + crop = (BlockCrops) b; + isIC2Crop = false; + if(addDrops(world, input.stackSize, autocraft) == 0){ + this.isValid = true; + } + } + + 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); + if(cc.tier() > 15) // dont process primordial + return; + 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(); + try{ + world.setBlock(xyz[0], xyz[1], xyz[2], Block.getBlockFromItem(Ic2Items.crop.getItem()), 0, 3); + 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.setSize((byte) cc.maxSize()); + te.setGrowth(gr); + te.setGain(ga); + te.setResistance(re); + + if(!cc.canBeHarvested(te)) + return; + // GENERATE DROPS + generations = new ArrayList<>(); + for(int i = 0; i < 10; i++) // get 10 generations + { + ItemStack[] st = te.harvest_automated(false); + te.setSize((byte) cc.maxSize()); + if (st == null){ + i--; + continue; + } + if (st.length == 0) + continue; + generations.add(new ArrayList<>(Arrays.asList(st))); + } + if(generations.isEmpty()) + return; + rn = new Random(); + input.stackSize --; + + // 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 + + int dur = cc.growthDuration(te); + int rate = te.calcGrowthRate(); + if(rate == 0) // should not be possible with those stats + return; + growthticks = dur / rate; + if(growthticks < 1) + growthticks = 1; + + this.isValid = true; + } + catch (Exception e){ + e.printStackTrace(System.err); + } + finally { + world.setBlockToAir(xyz[0], xyz[1], xyz[2]); + } + } + + public List getDrops(){ + return drops; + } + + Map dropprogress = new HashMap<>(); + static Map dropstacks = new HashMap<>(); + + public List getIC2Drops(int timeelapsed){ + int r = rn.nextInt(10); + if(generations.size() <= r) + return new ArrayList<>(); + double growthPercent = ((double)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); + s.stackSize = 1; + 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()); + } + 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()); + } + 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, 7, 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()); + } + 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) { + drops.remove(i); + i--; + } + if(count == 0) { + return 0; + } + } + } + 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; + } + } + } + } + return count; + } + } + + +} -- cgit From 265ef6ca5b909200660b562e80042601064c2534 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Wed, 25 May 2022 17:37:11 +0200 Subject: EIC Fix crops from mods (GTNewHorizons/bartworks#126) * Fix Natura crops * Correct info about water * Update repositories.gradle Co-authored-by: Martin Robertz --- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 3e65bb0ce0..7348ee951f 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 @@ -8,6 +8,7 @@ import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; @@ -26,7 +27,7 @@ import ic2.api.crops.Crops; import ic2.core.Ic2Items; import ic2.core.crop.TileEntityCrop; import net.minecraft.block.Block; -import net.minecraft.block.BlockCrops; +import net.minecraft.block.IGrowable; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -167,6 +168,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn addInfo("Every tier past UV, slots are multiplied by 4"). addInfo("Process time: 5 sec"). addInfo("All crops are accelerated by x32 times"). + addInfo("Cannot process primordial"). addInfo(BW_Tooltip_Reference.TT_BLUEPRINT). addSeparator(). beginStructureBlock(5, 4, 5, false). @@ -360,7 +362,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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/s of water", + "Uses " + waterusage * 1000 + "/operation of water", "Max slots: " + EnumChatFormatting.GREEN + this.mMaxSlots + EnumChatFormatting.RESET, "Used slots: " + EnumChatFormatting.GREEN + this.mStorage.size() + EnumChatFormatting.RESET )); @@ -412,7 +414,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn private static class GreenHouseSlot extends InventoryCrafting { ItemStack input; - BlockCrops crop; + Block crop; List drops; boolean isValid; boolean isIC2Crop; @@ -423,6 +425,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn IRecipe recipe; ItemStack recipeInput; + int optimalgrowth = 7; + public NBTTagCompound toNBTTagCompound(){ NBTTagCompound aNBT = new NBTTagCompound(); aNBT.setTag("input", input.writeToNBT(new NBTTagCompound())); @@ -431,6 +435,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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); } else { aNBT.setInteger("generationscount", generations.size()); @@ -453,10 +458,12 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn isValid = aNBT.getBoolean("isValid"); input = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("input")); if(!isIC2Crop) { - crop = (BlockCrops) Block.getBlockById(aNBT.getInteger("crop")); + 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; } else { @@ -480,6 +487,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn int toconsume = Math.min(64 - this.input.stackSize, input.stackSize); int left = addDrops(world, toconsume, true); input.stackSize -= toconsume - left; + this.input.stackSize += toconsume - left; return left == 0; } @@ -536,11 +544,14 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn return; } Block b = ((ItemSeeds) input.getItem()).getPlant(world, 0, 0, 0); - if (!(b instanceof BlockCrops)) + if (!(b instanceof IGrowable)) return; - crop = (BlockCrops) b; + GameRegistry.UniqueIdentifier u = GameRegistry.findUniqueIdentifierFor(input.getItem()); + if(u != null && Objects.equals(u.modId, "Natura")) + optimalgrowth = 8; + crop = b; isIC2Crop = false; - if(addDrops(world, input.stackSize, autocraft) == 0){ + if(addDrops(world, input.stackSize, autocraft) == 0 && !drops.isEmpty()){ this.isValid = true; } } @@ -664,7 +675,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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, 7, 0); + List d = crop.getDrops(world, 0, 0, 0, optimalgrowth, 0); for(ItemStack x : drops) for(ItemStack y : d) if(GT_Utility.areStacksEqual(x, y)) -- cgit From ea24e119149d3f8eb1ddd1f24ccf5811ffcdbcbf Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Fri, 10 Jun 2022 08:40:02 +0200 Subject: EIG fix + info changes (GTNewHorizons/bartworks#130) * Fix power usage * Add info about internal structure parts * Add more info to tricorder * Add structure description info * More checks * Remove endless loop possibility --- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 47 +++++++++++++++++----- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 7348ee951f..3054fbe721 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 @@ -12,6 +12,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -52,6 +53,8 @@ import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEntity_EnhancedMultiBlockBase { + private static final boolean debug = false; + private int mCasing = 0; private int mMaxSlots = 0; private int setupphase = 1; @@ -77,7 +80,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn ofHatchAdder(GT_MetaTileEntity_ExtremeIndustrialGreenhouse::addOutputToMachineList, CASING_INDEX, 1) )) .addElement('l', LoaderReference.ProjRedIllumination ? ofBlock(Block.getBlockFromName("ProjRed|Illumination:projectred.illumination.lamp"), 10) : ofBlock(Blocks.redstone_lamp, 0)) - .addElement('g', BorosilicateGlass.ofBoroGlass((byte) 0, (byte) 1, Byte.MAX_VALUE, (te, t) -> te.glasTier = t, te -> te.glasTier)) + .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(); @@ -176,6 +179,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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", 1). addInputBus("Any casing", 1). addOutputBus("Any casing", 1). @@ -185,6 +190,14 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn return tt; } + @Override + 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"); + return info.toArray(new String[]{}); + } + @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); @@ -255,6 +268,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 2, 5, 0); } + + @Override public boolean isCorrectMachinePart(ItemStack itemStack) { return true; @@ -295,7 +310,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn for(GreenHouseSlot s : mStorage) waterusage += s.input.stackSize; - if(!depleteInput(new FluidStack(FluidRegistry.WATER, waterusage * 1000))) + if(!depleteInput(new FluidStack(FluidRegistry.WATER, waterusage * 1000)) && !debug) return false; // OVERCLOCK @@ -318,7 +333,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn } this.mOutputItems = outputs.toArray(new ItemStack[0]); } - this.mEUt = -(int)((double)v * 0.99d); + this.mEUt = -(int)((double) GT_Values.V[tier] * 0.99d); this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; return true; @@ -329,6 +344,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { mCasing = 0; glasTier = 0; + if(debug) + glasTier = 8; if(!checkPiece(STRUCTURE_PIECE_MAIN, 2, 5, 0)) return false; @@ -362,12 +379,21 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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 + "/operation of water", + "Uses " + waterusage * 1000 + "L/operation of water", "Max slots: " + EnumChatFormatting.GREEN + this.mMaxSlots + EnumChatFormatting.RESET, "Used slots: " + EnumChatFormatting.GREEN + this.mStorage.size() + EnumChatFormatting.RESET )); - for(int i = 0; i < mStorage.size(); i++) - info.add("Slot " + i + ": " + EnumChatFormatting.GREEN + "x" + this.mStorage.get(i).input.stackSize + " " + this.mStorage.get(i).input.getDisplayName() + 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) + for(Map.Entry entry : mStorage.get(i).dropprogress.entrySet()) + a.append((int) (entry.getValue() * 100d)).append("% "); + a.append(EnumChatFormatting.RESET); + info.add(a.toString()); + } + info.addAll(Arrays.asList(super.getInfoData())); return info.toArray(new String[0]); } @@ -594,16 +620,17 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn return; // GENERATE DROPS generations = new ArrayList<>(); - 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){ - i--; + 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()) -- cgit From 8818a746c5b5a85044d3adbc4881c8d07cdfa846 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Sat, 18 Jun 2022 13:21:50 +0200 Subject: EIG - Add under crop block as requirement (GTNewHorizons/bartworks#133) * Add under crop block as requirement * Bug fix * Fix potential casing dupe --- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 68 ++++++++++++++++++++-- 1 file changed, 62 insertions(+), 6 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 3054fbe721..47506d0173 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 @@ -33,6 +33,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.Item; import net.minecraft.item.ItemSeeds; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; @@ -153,6 +154,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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: EV"). @@ -257,6 +259,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn else if(setupphase == 2 && mStorage.size() > 0) { this.addOutput(this.mStorage.get(0).input.copy()); + if(this.mStorage.get(0).undercrop != null) + this.addOutput(this.mStorage.get(0).undercrop.copy()); this.mStorage.remove(0); this.updateSlots(); } @@ -386,10 +390,12 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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) - for(Map.Entry entry : mStorage.get(i).dropprogress.entrySet()) + 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()) a.append((int) (entry.getValue() * 100d)).append("% "); + } a.append(EnumChatFormatting.RESET); info.add(a.toString()); } @@ -441,6 +447,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn ItemStack input; Block crop; + ItemStack undercrop = null; List drops; boolean isValid; boolean isIC2Crop; @@ -464,6 +471,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn aNBT.setInteger("optimalgrowth", optimalgrowth); } else { + if(undercrop != null) + aNBT.setTag("undercrop", undercrop.writeToNBT(new NBTTagCompound())); aNBT.setInteger("generationscount", generations.size()); for(int i = 0; i < generations.size(); i++) { @@ -493,6 +502,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn } else { + if(aNBT.hasKey("undercrop")) + undercrop = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("undercrop")); generations = new ArrayList<>(); for(int i = 0; i < aNBT.getInteger("generationscount"); i++) { @@ -600,8 +611,16 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn xyz[0] += tileEntity.getBaseMetaTileEntity().getXCoord(); xyz[1] += tileEntity.getBaseMetaTileEntity().getYCoord(); xyz[2] += tileEntity.getBaseMetaTileEntity().getZCoord(); + boolean cheating = false; try{ - world.setBlock(xyz[0], xyz[1], xyz[2], Block.getBlockFromItem(Ic2Items.crop.getItem()), 0, 3); + 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)) { @@ -611,13 +630,44 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn TileEntityCrop te = (TileEntityCrop)wte; te.ticker = 1; // dont even think about ticking once te.setCrop(cc); - te.setSize((byte) cc.maxSize()); + 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) + { + 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; + } + + if(!cangrow) + return; + } + + te.setSize((byte) cc.maxSize()); + if(!cc.canBeHarvested(te)) return; + // GENERATE DROPS generations = new ArrayList<>(); out: for(int i = 0; i < 10; i++) // get 10 generations @@ -636,7 +686,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn if(generations.isEmpty()) return; rn = new Random(); - input.stackSize --; + // CHECK GROWTH SPEED te.humidity = 12; // humidity with full water storage @@ -651,12 +701,18 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn if(growthticks < 1) growthticks = 1; + input.stackSize --; + 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]); } } -- cgit From 0db41bf94044b28d5dd0a33f9ef913d36d1792be Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Sun, 3 Jul 2022 14:44:19 +0200 Subject: Buff Extreme Industrial Greenhouse's Speed and Lower IC2 Tier to LuV (GTNewHorizons/bartworks#141) * Add possibility to get more outputs with fertilizer * Lower IC2 mode tier from UV to LUV * Typo * Add color formatting to description * License * Make Forestry fertilizer static and check if it exists * Buff EIG normal mode * Change color formatting --- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 88 +++++++++++++++++----- 1 file changed, 68 insertions(+), 20 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 47506d0173..aebf792088 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,3 +1,20 @@ +/* + * 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; import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass; @@ -32,6 +49,7 @@ import net.minecraft.block.IGrowable; import net.minecraft.client.Minecraft; 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.ItemSeeds; @@ -49,7 +67,6 @@ import java.util.*; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; import static gregtech.api.enums.Textures.BlockIcons.*; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_GLOW; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEntity_EnhancedMultiBlockBase { @@ -64,6 +81,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn private int waterusage = 0; 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"}, @@ -140,6 +158,10 @@ 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){ + 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(); @@ -150,6 +172,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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"). @@ -157,22 +180,24 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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: EV"). + addInfo("Minimal tier: " + tierString(4)). addInfo("Starting with 1 slot"). addInfo("Every slot gives 64 crops"). - addInfo("Every tier past EV adds additional 2 slots"). + 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 HV (Minimum 1 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: UV"). - addInfo("Need UV glass tier"). + 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 UV, slots are multiplied by 4"). + 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("Cannot process primordial"). addInfo(BW_Tooltip_Reference.TT_BLUEPRINT). addSeparator(). @@ -272,8 +297,6 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 2, 5, 0); } - - @Override public boolean isCorrectMachinePart(ItemStack itemStack) { return true; @@ -283,12 +306,12 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn public boolean checkRecipe(ItemStack itemStack) { long v = this.getMaxInputVoltage(); int tier = GT_Utility.getTier(v); - if(tier < (isIC2Mode ? 8 : 4)) + if(tier < (isIC2Mode ? 6 : 4)) mMaxSlots = 0; else if(isIC2Mode) - mMaxSlots = 4 << (2 * (tier - 8)); + mMaxSlots = 4 << (2 * (tier - 6)); else - mMaxSlots = Math.max((tier - 4) * 2, 1); + mMaxSlots = 1 << (tier - 4); if(mStorage.size() > mMaxSlots) { // Void if user just downgraded power @@ -318,32 +341,58 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn return false; // OVERCLOCK + // 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); + + 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))) + { + int used = Math.min(i.stackSize, maxboost - boost); + i.stackSize -= used; + boost += used; + } + if(boost == maxboost) + break; + } + + double multiplier = 1.d + (((double)boost/(double)maxboost) * 4d); + if(isIC2Mode) { - if(glasTier < 8) + 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(this.mMaxProgresstime / 8)); + outputs.addAll(mStorage.get(i).getIC2Drops(((double)this.mMaxProgresstime / 8d) * multiplier)); this.mOutputItems = outputs.toArray(new ItemStack[0]); } 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()) - outputs.add(drop.copy()); + for (ItemStack drop : mStorage.get(i).getDrops()) { + ItemStack s = drop.copy(); + 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.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; + this.updateSlots(); return true; } - @Override public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { mCasing = 0; @@ -724,11 +773,11 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn Map dropprogress = new HashMap<>(); static Map dropstacks = new HashMap<>(); - public List getIC2Drops(int timeelapsed){ + public List getIC2Drops(double timeelapsed){ int r = rn.nextInt(10); if(generations.size() <= r) return new ArrayList<>(); - double growthPercent = ((double)timeelapsed / (double)growthticks); + double growthPercent = (timeelapsed / (double)growthticks); List generation = generations.get(r); List copied = new ArrayList<>(); for(ItemStack g : generation) @@ -810,5 +859,4 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn } } - } -- cgit From 31ea1dd407e70b305b295fcd25c463cd8567813b Mon Sep 17 00:00:00 2001 From: miozune Date: Tue, 5 Jul 2022 20:20:51 +0900 Subject: Fix tooltip wierdness (GTNewHorizons/bartworks#148) --- .../multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main/java/kubatech/tileentity') 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 aebf792088..57569c1eb9 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 @@ -65,6 +65,7 @@ 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; @@ -213,7 +214,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn addOutputBus("Any casing", 1). addInputHatch("Any casing", 1). addEnergyHatch("Any casing", 1). - toolTipFinisher("Added by " + ChatColorHelper.GOLD + "kuba6000" + ChatColorHelper.RESET + ChatColorHelper.GREEN + " via " + BW_Tooltip_Reference.BW); + toolTipFinisher(MULTIBLOCK_ADDED_VIA_BARTWORKS.apply(ChatColorHelper.GOLD + "kuba6000")); return tt; } -- cgit From 65ebc9397ffda673681769ed11daa494bc9b9487 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Tue, 5 Jul 2022 13:45:47 +0200 Subject: Block hatches on inner bottom casings. (GTNewHorizons/bartworks#151) --- .../GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 57569c1eb9..0daead9348 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 @@ -90,7 +90,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn {"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"}, + {"cc~cc", "cCCCc", "cCCCc", "cCCCc", "ccccc"}, })) .addElement('c', ofChain( onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings4, 1)), @@ -99,6 +99,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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)) @@ -209,11 +210,11 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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", 1). - addInputBus("Any casing", 1). - addOutputBus("Any casing", 1). - addInputHatch("Any casing", 1). - addEnergyHatch("Any casing", 1). + 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; } -- cgit From 5bd92289da7ac9801830f7d7f2a65c9f1b589e16 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Mon, 11 Jul 2022 00:11:51 +0200 Subject: Fix EIG structure (GTNewHorizons/bartworks#157) --- .../multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 0daead9348..cf8d865ba0 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 @@ -87,8 +87,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn .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"}, + {"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"}, })) -- cgit From 0ef7d84a1abf0c4afe911781fc4d5968b582ea1f Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Mon, 18 Jul 2022 12:47:08 +0200 Subject: EIG: Refuse to run instead of voiding when power is downgraded (GTNewHorizons/bartworks#161) * Just refuse to run instead of voiding * Update GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java Co-authored-by: Martin Robertz --- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 38 +++++++++++++--------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 cf8d865ba0..b7614770aa 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 @@ -304,8 +304,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn return true; } - @Override - public boolean checkRecipe(ItemStack itemStack) { + private void updateMaxSlots() + { long v = this.getMaxInputVoltage(); int tier = GT_Utility.getTier(v); if(tier < (isIC2Mode ? 6 : 4)) @@ -314,15 +314,13 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn mMaxSlots = 4 << (2 * (tier - 6)); else mMaxSlots = 1 << (tier - 4); - if(mStorage.size() > mMaxSlots) - { - // Void if user just downgraded power - for(int i = mMaxSlots; i < mStorage.size(); i++) - { - mStorage.remove(i); - i--; - } - } + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + 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)) return false; @@ -332,6 +330,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn this.mEfficiencyIncrease = 10000; return true; } + if(mStorage.size() > mMaxSlots) + return false; if(mStorage.isEmpty()) return false; @@ -410,9 +410,14 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn if (this.glasTier < hatchEnergy.mTier) return false; - return 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(); + + return valid; } @Override @@ -436,7 +441,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn "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: " + EnumChatFormatting.GREEN + this.mStorage.size() + 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) @@ -450,7 +455,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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); info.addAll(Arrays.asList(super.getInfoData())); return info.toArray(new String[0]); } -- cgit From 40c043000dfd12dc65f7d385321340dce2e1e45a Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Wed, 27 Jul 2022 04:33:37 +0200 Subject: EIG: Add support for several seeds (GTNewHorizons/bartworks#167) * Support seed food (carrot/potato) * Fix netherwart * Fix stem seeds (melon like) * Add support for cactus and sugar cane --- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 110 +++++++++++++++++++-- 1 file changed, 101 insertions(+), 9 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 b7614770aa..a25c7b0410 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 @@ -40,18 +40,21 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energ 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 ic2.api.crops.CropCard; import ic2.api.crops.Crops; import ic2.core.Ic2Items; import ic2.core.crop.TileEntityCrop; import net.minecraft.block.Block; -import net.minecraft.block.IGrowable; +import net.minecraft.block.BlockBush; +import net.minecraft.block.BlockStem; import net.minecraft.client.Minecraft; 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.crafting.CraftingManager; @@ -60,6 +63,7 @@ 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.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -517,15 +521,22 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn int optimalgrowth = 7; + boolean needsreplanting = true; + + static GreenHouseWorld fakeworld = new GreenHouseWorld(5, 5, 5); + public NBTTagCompound toNBTTagCompound(){ NBTTagCompound aNBT = new NBTTagCompound(); aNBT.setTag("input", input.writeToNBT(new NBTTagCompound())); + aNBT.setBoolean("isValid", isValid); + aNBT.setBoolean("isIC2Crop", 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) @@ -537,10 +548,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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("isValid", isValid); - aNBT.setBoolean("isIC2Crop", isIC2Crop); - if(isIC2Crop) aNBT.setInteger("growthticks", growthticks); return aNBT; } @@ -556,6 +565,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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 { @@ -634,15 +644,45 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn GreenHouseSlotIC2(tileEntity, world, input); return; } - if (!(input.getItem() instanceof ItemSeeds)) { - 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; + else { + b = Block.getBlockFromItem(i); + if(!(b == Blocks.cactus)) + return; + } + needsreplanting = false; } - Block b = ((ItemSeeds) input.getItem()).getPlant(world, 0, 0, 0); - if (!(b instanceof IGrowable)) + if (!(b instanceof IPlantable)) return; - GameRegistry.UniqueIdentifier u = GameRegistry.findUniqueIdentifierFor(input.getItem()); + 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; + } + crop = b; isIC2Crop = false; if(addDrops(world, input.stackSize, autocraft) == 0 && !drops.isEmpty()){ @@ -827,6 +867,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn 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)) @@ -867,4 +909,54 @@ 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 Block block; + GreenHouseWorld(int x, int y, int z){ + super(); + this.x = x; + this.y = y; + this.z = z; + this.rand = new GreenHouseRandom(); + } + + @Override + public int getBlockMetadata(int aX, int aY, int aZ) { + 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; + return Blocks.air; + } + + @Override + public int getBlockLightValue(int p_72957_1_, int p_72957_2_, int p_72957_3_) { + return 10; + } + + @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; + block = aBlock; + meta = aMeta; + return true; + } + } + + private static class GreenHouseRandom extends Random{ + @Override + public int nextInt(int bound) { + return 0; + } + } + } -- cgit From 322884ddd24bfa7c2758879e1c8813c0f5ba3b45 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Fri, 29 Jul 2022 07:59:39 +0200 Subject: Enable back piston work and use compacted inputs to check the recipe. (GTNewHorizons/bartworks#169) * Piston and compacted inputs * tx * Input Hatch in structure info * Maintenance hatch in structure info * Rewrite piston process * Config value --- .../multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 1 - 1 file changed, 1 deletion(-) (limited to 'src/main/java/kubatech/tileentity') 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 a25c7b0410..77c5e7dd67 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,7 +46,6 @@ import ic2.api.crops.Crops; import ic2.core.Ic2Items; import ic2.core.crop.TileEntityCrop; import net.minecraft.block.Block; -import net.minecraft.block.BlockBush; import net.minecraft.block.BlockStem; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; -- cgit From 4f16da3c5bbded4efa66de39ede680021526aecc Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Mon, 1 Aug 2022 03:06:22 +0200 Subject: Unlock primordial crop (GTNewHorizons/bartworks#174) --- .../multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 77c5e7dd67..dcbdbd3e0d 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 @@ -203,7 +203,6 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn addInfo("Process time: 5 sec"). addInfo("All crops are accelerated by x32 times"). addInfo("1 Fertilizer per 1 crop +10%"). - addInfo("Cannot process primordial"). addInfo(BW_Tooltip_Reference.TT_BLUEPRINT). addSeparator(). beginStructureBlock(5, 4, 5, false). @@ -693,8 +692,6 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse extends GT_MetaTileEn if(!ItemList.IC2_Crop_Seeds.isStackEqual(input, true, true)) return; CropCard cc = Crops.instance.getCropCard(input); - if(cc.tier() > 15) // dont process primordial - return; this.input.stackSize = 1; NBTTagCompound nbt = input.getTagCompound(); byte gr = nbt.getByte("growth"); -- 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/tileentity') 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 b3152688bdbb40267d594de229befafa546cb1e0 Mon Sep 17 00:00:00 2001 From: Maxim Date: Mon, 26 Sep 2022 15:10:16 +0200 Subject: Added start and end processing calls to machines that work with inputs in onPostTick (GTNewHorizons/bartworks#206) --- .../multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main/java/kubatech/tileentity') 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 c0fe877df1..5e571be54e 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 @@ -313,6 +313,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } } if (aBaseMetaTileEntity.isServerSide() && this.mMaxProgresstime > 0 && setupphase > 0 && aTick % 5 == 0) { + startRecipeProcessing(); if (setupphase == 1 && mStorage.size() < mMaxSlots) { List inputs = getStoredInputs(); for (ItemStack input : inputs) if (addCrop(input)) break; @@ -324,6 +325,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse this.mStorage.remove(0); this.updateSlots(); } + endRecipeProcessing(); } } -- cgit From 0c85bd2d030f3c8ae6ec124c66de5926955650eb Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Sat, 8 Oct 2022 13:11:26 +0200 Subject: EIG: Fix multiple input hatches beeing ignored & Make setup modes faster. (GTNewHorizons/bartworks#210) * Deplete water from all hatches * Make setup modes fast * spotlessApply (GTNewHorizons/bartworks#211) Co-authored-by: Jakub <53441451+kuba6000@users.noreply.github.com> Co-authored-by: GitHub GTNH Actions <> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 59 ++++++++++++++++++---- 1 file changed, 49 insertions(+), 10 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 5e571be54e..784e080c36 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 @@ -40,12 +40,12 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.*; 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.tileentities.machines.GT_MetaTileEntity_Hatch_OutputBus_ME; import ic2.api.crops.CropCard; import ic2.api.crops.Crops; import ic2.core.Ic2Items; @@ -316,13 +316,26 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse startRecipeProcessing(); if (setupphase == 1 && mStorage.size() < mMaxSlots) { List inputs = getStoredInputs(); - for (ItemStack input : inputs) if (addCrop(input)) break; + for (ItemStack input : inputs) addCrop(input); this.updateSlots(); } else if (setupphase == 2 && mStorage.size() > 0) { - this.addOutput(this.mStorage.get(0).input.copy()); - if (this.mStorage.get(0).undercrop != null) - this.addOutput(this.mStorage.get(0).undercrop.copy()); - this.mStorage.remove(0); + int emptySlots = 0; + boolean ignoreEmptiness = false; + for (GT_MetaTileEntity_Hatch_OutputBus i : mOutputBusses) { + if (i instanceof GT_MetaTileEntity_Hatch_OutputBus_ME) { + ignoreEmptiness = true; + break; + } + for (int j = 0; j < i.getSizeInventory(); j++) + if (i.isValidSlot(j)) if (i.getStackInSlot(j) == null) emptySlots++; + } + 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()); + this.mStorage.remove(0); + } this.updateSlots(); } endRecipeProcessing(); @@ -366,8 +379,34 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse waterusage = 0; for (GreenHouseSlot s : mStorage) waterusage += s.input.stackSize; - - if (!depleteInput(new FluidStack(FluidRegistry.WATER, waterusage * 1000)) && !debug) return false; + waterusage *= 1000; + + List fluids = mInputHatches; + List fluidsToUse = new ArrayList<>(fluids.size()); + int watercheck = waterusage; + FluidStack waterStack = new FluidStack(FluidRegistry.WATER, 1); + for (GT_MetaTileEntity_Hatch_Input i : fluids) { + if (!isValidMetaTileEntity(i)) continue; + if (i instanceof GT_MetaTileEntity_Hatch_MultiInput) { + int amount = ((GT_MetaTileEntity_Hatch_MultiInput) i).getFluidAmount(waterStack); + if (amount == 0) continue; + watercheck -= amount; + } else { + FluidStack stack = i.getDrainableStack(); + if (stack == null) continue; + if (!stack.isFluidEqual(waterStack)) continue; + if (stack.amount <= 0) continue; + watercheck -= stack.amount; + } + fluidsToUse.add(i); + if (watercheck <= 0) break; + } + if (watercheck > 0 && !debug) return false; + watercheck = waterusage; + for (GT_MetaTileEntity_Hatch_Input i : fluidsToUse) { + int used = i.drain(watercheck, true).amount; + watercheck -= used; + } // OVERCLOCK // FERTILIZER IDEA - IC2 +10% per fertilizer per crop per operation, NORMAL +200% per fertilizer per crop per @@ -459,7 +498,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse ? (isIC2Mode ? "IC2 crops" : "Normal crops") : ("Setup mode " + (setupphase == 1 ? "(input)" : "(output)"))) + EnumChatFormatting.RESET, - "Uses " + waterusage * 1000 + "L/operation of water", + "Uses " + waterusage + "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)); -- cgit From efda40f98de748e76eaede29df7b300c43bcd857 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Thu, 13 Oct 2022 20:38:03 +0200 Subject: Fix accidental block dupe (GTNewHorizons/bartworks#216) * Fix dupe * Move setup process to checkRecipe --- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 56 +++++++++++----------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 784e080c36..bb3293992f 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 @@ -312,34 +312,6 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } } } - if (aBaseMetaTileEntity.isServerSide() && this.mMaxProgresstime > 0 && setupphase > 0 && aTick % 5 == 0) { - startRecipeProcessing(); - if (setupphase == 1 && mStorage.size() < mMaxSlots) { - List inputs = getStoredInputs(); - for (ItemStack input : inputs) addCrop(input); - this.updateSlots(); - } else if (setupphase == 2 && mStorage.size() > 0) { - int emptySlots = 0; - boolean ignoreEmptiness = false; - for (GT_MetaTileEntity_Hatch_OutputBus i : mOutputBusses) { - if (i instanceof GT_MetaTileEntity_Hatch_OutputBus_ME) { - ignoreEmptiness = true; - break; - } - for (int j = 0; j < i.getSizeInventory(); j++) - if (i.isValidSlot(j)) if (i.getStackInSlot(j) == null) emptySlots++; - } - 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()); - this.mStorage.remove(0); - } - this.updateSlots(); - } - endRecipeProcessing(); - } } @Override @@ -368,7 +340,32 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse if (setupphase > 0) { if ((mStorage.size() >= mMaxSlots && setupphase == 1) || (mStorage.size() == 0 && setupphase == 2)) return false; - this.mMaxProgresstime = 20; + + if (setupphase == 1) { + List inputs = getStoredInputs(); + for (ItemStack input : inputs) addCrop(input); + } else if (setupphase == 2) { + int emptySlots = 0; + boolean ignoreEmptiness = false; + for (GT_MetaTileEntity_Hatch_OutputBus i : mOutputBusses) { + if (i instanceof GT_MetaTileEntity_Hatch_OutputBus_ME) { + ignoreEmptiness = true; + break; + } + for (int j = 0; j < i.getSizeInventory(); j++) + if (i.isValidSlot(j)) if (i.getStackInSlot(j) == null) emptySlots++; + } + 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()); + this.mStorage.remove(0); + } + } + + this.updateSlots(); + this.mMaxProgresstime = 5; this.mEUt = 0; this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; @@ -802,6 +799,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse 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); -- cgit From 7353a8c4ea895e6b22f4756bbcc7b944e3c38abb Mon Sep 17 00:00:00 2001 From: Maxim Date: Mon, 17 Oct 2022 21:11:57 +0200 Subject: Fix EIG structure tooltip (GTNewHorizons/bartworks#221) * Added coil and glass count to the tooltip * Fixed EIG structure tooltip --- .../multiblock/GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 bb3293992f..513188dd22 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 @@ -237,10 +237,10 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse .addInfo("1 Fertilizer per 1 crop +10%") .addInfo(BW_Tooltip_Reference.TT_BLUEPRINT) .addSeparator() - .beginStructureBlock(5, 4, 5, false) + .beginStructureBlock(5, 6, 5, false) .addController("Front bottom center") .addCasingInfo("Clean Stainless Steel Casings", 70) - .addOtherStructurePart("Borosilicate Glass", "Hollow two middle layers", 2) + .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") -- 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/tileentity') 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 bd2dbb4030c7d11def45a2b8c1334f896e2f3fb0 Mon Sep 17 00:00:00 2001 From: xSkewer <43712386+xSkewer@users.noreply.github.com> Date: Sat, 5 Nov 2022 14:11:06 -0400 Subject: No Humidity Mode for the EIG (GTNewHorizons/bartworks#233) * Add 0 humidity mode to the EIG * Readd imports that got removed for some reason * Remove static and add scanner info * Fix NBT saving * Add import that got lost for some reason * Add tooltip and change scanner display to only IC2 mode * Import got lost again --- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 a3dcde7c7f..94e1ebbc43 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 @@ -84,6 +84,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse private boolean isIC2Mode = false; private byte glasTier = 0; private int waterusage = 0; + private boolean isNoHumidity = false; private static final int CASING_INDEX = 49; private static final String STRUCTURE_PIECE_MAIN = "main"; private static final Item forestryfertilizer = GameRegistry.findItem("Forestry", "fertilizerCompound"); @@ -182,6 +183,14 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } } + @Override + 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; + } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { return new GT_MetaTileEntity_ExtremeIndustrialGreenhouse(this.mName); @@ -210,6 +219,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse .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") .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 --------------------") @@ -269,6 +279,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse aNBT.setByte("glasTier", glasTier); aNBT.setInteger("setupphase", setupphase); 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()); @@ -280,6 +291,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse glasTier = aNBT.getByte("glasTier"); setupphase = aNBT.getInteger("setupphase"); isIC2Mode = aNBT.getBoolean("isIC2Mode"); + isNoHumidity = aNBT.getBoolean("isNoHumidity"); for (int i = 0; i < aNBT.getInteger("mStorageSize"); i++) mStorage.add(new GreenHouseSlot(aNBT.getCompoundTag("mStorage." + i))); } @@ -507,7 +519,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse "Slot " + i + ": " + EnumChatFormatting.GREEN + "x" + this.mStorage.get(i).input.stackSize + " " + this.mStorage.get(i).input.getDisplayName()); if (this.isIC2Mode) { - a.append(" : "); + a.append(" | Humidity: " + (this.mStorage.get(i).noHumidity ? 0 : 12) + " : "); for (Map.Entry entry : mStorage.get(i).dropprogress.entrySet()) a.append((int) (entry.getValue() * 100d)).append("% "); @@ -569,7 +581,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); + GreenHouseSlot h = new GreenHouseSlot(this, input, true, isIC2Mode, isNoHumidity); if (h.isValid) { mStorage.add(h); return true; @@ -585,6 +597,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse List drops; boolean isValid; boolean isIC2Crop; + boolean noHumidity; int growthticks; List> generations; @@ -622,6 +635,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse generations.get(i).get(j).writeToNBT(new NBTTagCompound())); } aNBT.setInteger("growthticks", growthticks); + aNBT.setBoolean("noHumidity", noHumidity); } return aNBT; } @@ -651,6 +665,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse .add(ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("generation." + i + "." + j))); } growthticks = aNBT.getInteger("growthticks"); + noHumidity = aNBT.getBoolean("noHumidity"); rn = new Random(); } } @@ -706,13 +721,18 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } public GreenHouseSlot( - GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, ItemStack input, boolean autocraft, boolean IC2) { + GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, + ItemStack input, + boolean autocraft, + boolean IC2, + boolean noHumidity) { super(null, 3, 3); World world = tileEntity.getBaseMetaTileEntity().getWorld(); this.input = input.copy(); this.isValid = false; + this.noHumidity = noHumidity; if (IC2) { - GreenHouseSlotIC2(tileEntity, world, input); + GreenHouseSlotIC2(tileEntity, world, input, noHumidity); return; } Item i = input.getItem(); @@ -754,7 +774,10 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } public void GreenHouseSlotIC2( - GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, World world, ItemStack input) { + GT_MetaTileEntity_ExtremeIndustrialGreenhouse tileEntity, + World world, + ItemStack input, + boolean noHumidity) { if (!ItemList.IC2_Crop_Seeds.isStackEqual(input, true, true)) return; CropCard cc = Crops.instance.getCropCard(input); this.input.stackSize = 1; @@ -836,7 +859,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse rn = new Random(); // CHECK GROWTH SPEED - te.humidity = 12; // humidity with full water storage + 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 -- 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/tileentity') 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 9b12b5c8495d83adbb99601c86ce6dcd963fe541 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Thu, 24 Nov 2022 21:44:23 +0100 Subject: Prevent player inventory corruption (GTNewHorizons/bartworks#235) * Ugh * Merge same slots * Remove growth progress * Update GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java Co-authored-by: Martin Robertz --- .../GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 da7a634c0d..e29aa42d8c 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 @@ -525,20 +525,18 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse "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()); + 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()); if (this.isIC2Mode) { - a.append(" | Humidity: " + (this.mStorage.get(i).noHumidity ? 0 : 12) + " : "); - for (Map.Entry entry : - mStorage.get(i).dropprogress.entrySet()) - a.append((int) (entry.getValue() * 100d)).append("% "); + a.append(" | Humidity: ").append(greenHouseSlot.noHumidity ? 0 : 12); } a.append(EnumChatFormatting.RESET); - info.add(a.toString()); + 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); -- cgit From a5b30b5b6c268d3e5611542ea6f7cacd38f5179b Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Thu, 29 Dec 2022 23:38:35 +0100 Subject: Add flowers to EIG (GTNewHorizons/bartworks#254) * Add flowers to EIG * There are custom handlers now --- .../GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/main/java/kubatech/tileentity') 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 e29aa42d8c..979141e5f0 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 @@ -56,6 +56,7 @@ import ic2.core.Ic2Items; import ic2.core.crop.TileEntityCrop; import java.util.*; 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; @@ -758,7 +759,16 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse Item i = input.getItem(); Block b = null; boolean detectedCustomHandler = false; - // There will be custom handlers here some day + // Custom handlers + // FLOWERS // + Block bb = Block.getBlockFromItem(i); + if (bb == Blocks.air) bb = null; + if (bb instanceof BlockFlower) { + detectedCustomHandler = true; + needsreplanting = false; + customDrops = new ArrayList<>(Collections.singletonList(input.copy())); + customDrops.get(0).stackSize = 1; + } if (!detectedCustomHandler) { if (i instanceof IPlantable) { if (i instanceof ItemSeeds) b = ((ItemSeeds) i).getPlant(world, 0, 0, 0); -- 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/tileentity') 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 fd9a588a9f30b8cf06d8fcfe1836ceafb379318b Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Sat, 7 Jan 2023 13:02:07 +0100 Subject: Add Weed-EX 9000 consumption in EIG (GTNewHorizons/bartworks#257) * Update GT5 * Add Weed-EX Consumption * Add info --- ...GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/main/java/kubatech/tileentity') 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 53ee7bde80..9036ff94dd 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 @@ -49,6 +49,7 @@ import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; import gregtech.api.enums.Textures; import gregtech.api.gui.modularui.GT_UITextures; import gregtech.api.interfaces.ITexture; @@ -88,6 +89,7 @@ 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; @@ -105,10 +107,12 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse private boolean isIC2Mode = false; private byte glasTier = 0; private int waterusage = 0; + private int weedexusage = 0; private boolean isNoHumidity = false; 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 Fluid weedex = Materials.WeedEX9000.mFluid; private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][] { @@ -242,6 +246,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse .addInfo("Use screwdriver while sneaking to enable/disable IC2 mode") .addInfo("Use wire cutters to give incoming IC2 crops 0 humidity") .addInfo("Uses 1000L of water per crop per operation") + .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") @@ -424,7 +430,9 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse if (mStorage.isEmpty()) return false; waterusage = 0; + weedexusage = 0; for (GreenHouseSlot s : mStorage) waterusage += s.input.stackSize; + if (waterusage >= 1000) weedexusage = waterusage; waterusage *= 1000; List fluids = mInputHatches; @@ -454,6 +462,16 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse watercheck -= used; } + // weedex + 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; ) { + GreenHouseSlot removed = mStorage.remove(baseMTE.getRandomNumber(mStorage.size())); + i -= removed.input.stackSize; + } + } + // OVERCLOCK // FERTILIZER IDEA: // IC2 +10% per fertilizer per crop per operation @@ -855,6 +873,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse : ("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)); -- 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/tileentity') 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 a3fe2855dd6b25ca189e281aed9e5728937ad548 Mon Sep 17 00:00:00 2001 From: Maxim Date: Mon, 27 Feb 2023 21:28:41 +0100 Subject: Override GUI size (GTNewHorizons/bartworks#294) --- .../GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/main/java/kubatech/tileentity') 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 96b806bc21..e6a86f48a0 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 @@ -57,6 +57,7 @@ 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.math.Pos2d; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import com.gtnewhorizons.modularui.api.widget.Widget; @@ -543,6 +544,21 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse else return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CHECKMARK }; }; + @Override + public int getGUIHeight() { + return 166; + } + + @Override + public int getGUIWidth() { + return 176; + } + + @Override + public void bindPlayerInventoryUI(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.bindPlayerInventory(buildContext.getPlayer(), new Pos2d(7, 83), this.getGUITextureSet().getItemSlot()); + } + @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { builder.widget( -- cgit From e7be1d784ccefa76fac31bfb2cda2ff713290ea0 Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Mon, 27 Feb 2023 22:09:18 +0100 Subject: Fix GUI scrolling in EIG (GTNewHorizons/bartworks#295) --- .../GT_MetaTileEntity_ExtremeIndustrialGreenhouse.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/main/java/kubatech/tileentity') 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 e6a86f48a0..c228fe225a 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 @@ -632,12 +632,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse 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.widget( + row.setPos(0, i * 18).setEnabled(widget -> widget.getPos().y < cropsContainer.getVisibleHeight())); } cropsContainer.attachSyncer( new FakeSyncWidget.ListSyncer<>( @@ -1033,7 +1029,6 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse World world = tileEntity.getBaseMetaTileEntity().getWorld(); this.input = input.copy(); this.isValid = false; - this.noHumidity = noHumidity; if (IC2) { GreenHouseSlotIC2(tileEntity, world, input, noHumidity); return; @@ -1093,6 +1088,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse ItemStack input, boolean noHumidity) { if (!ItemList.IC2_Crop_Seeds.isStackEqual(input, true, true)) return; this.isIC2Crop = true; + this.noHumidity = noHumidity; recalculate(tileEntity, world); if (this.isValid) input.stackSize--; } -- 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/tileentity') 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 From c5f2184b6b0e9375f75a860c51ec54d8c40c689e Mon Sep 17 00:00:00 2001 From: kuba6000 Date: Thu, 16 Mar 2023 21:27:13 +0100 Subject: Its working --- src/main/java/kubatech/api/LoaderReference.java | 2 + src/main/java/kubatech/api/enums/ItemList.java | 1 + src/main/java/kubatech/loaders/RecipeLoader.java | 29 ++++++- ...MetaTileEntity_ExtremeIndustrialGreenhouse.java | 98 ++++++++-------------- 4 files changed, 65 insertions(+), 65 deletions(-) (limited to 'src/main/java/kubatech/tileentity') diff --git a/src/main/java/kubatech/api/LoaderReference.java b/src/main/java/kubatech/api/LoaderReference.java index 5ae387ed63..5d6545adae 100644 --- a/src/main/java/kubatech/api/LoaderReference.java +++ b/src/main/java/kubatech/api/LoaderReference.java @@ -18,4 +18,6 @@ public class LoaderReference { public static final boolean Forestry = Loader.isModLoaded("Forestry"); public static final boolean DraconicEvolution = Loader.isModLoaded("DraconicEvolution"); public static final boolean Avaritia = Loader.isModLoaded("Avaritia"); + public static final boolean ProjRedIllumination = Loader.isModLoaded("ProjRed|Illumination"); + public static final boolean RandomThings = Loader.isModLoaded("RandomThings"); } diff --git a/src/main/java/kubatech/api/enums/ItemList.java b/src/main/java/kubatech/api/enums/ItemList.java index 426cac0df5..55621888ee 100644 --- a/src/main/java/kubatech/api/enums/ItemList.java +++ b/src/main/java/kubatech/api/enums/ItemList.java @@ -19,6 +19,7 @@ public enum ItemList implements IItemContainer { ExtremeExterminationChamber, ExtremeIndustrialApiary, + ExtremeIndustrialGreenhouse, LegendaryBlackTea, LegendaryButterflyTea, LegendaryEarlGrayTea, diff --git a/src/main/java/kubatech/loaders/RecipeLoader.java b/src/main/java/kubatech/loaders/RecipeLoader.java index dc70c183e8..cf8c0e0163 100644 --- a/src/main/java/kubatech/loaders/RecipeLoader.java +++ b/src/main/java/kubatech/loaders/RecipeLoader.java @@ -18,9 +18,11 @@ import kubatech.Tags; import kubatech.api.LoaderReference; import kubatech.api.enums.ItemList; import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber; +import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeIndustrialGreenhouse; import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_MegaIndustrialApiary; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -86,6 +88,25 @@ public class RecipeLoader { 6000, 2_048_000); } + if (registerMTEUsingID( + 12_792, + ExtremeIndustrialGreenhouse, + GT_MetaTileEntity_ExtremeIndustrialGreenhouse.class, + "multimachine.extremegreenhouse", + "Extreme Industrial Greenhouse", + true /* IC2 is always loaded */)) { + GT_ModHandler.addCraftingRecipe( + ExtremeIndustrialGreenhouse.get(1), + bitsd, + new Object[] { "AZA", "BRB", "AZA", 'B', gregtech.api.enums.ItemList.Casing_CleanStainlessSteel, + 'R', + GT_ModHandler + .getModItem("EnderIO", "blockFarmStation", 1, new ItemStack(Items.diamond_hoe)), + 'A', + LoaderReference.GTNHCoreMod ? CustomItemList.AcceleratorIV.get(1) + : gregtech.api.enums.ItemList.Robot_Arm_IV, + 'Z', OrePrefixes.circuit.get(Materials.Ultimate) }); + } RegisterTeaLine(); if (MTEID > MTEIDMax + 1) throw new RuntimeException("MTE ID's"); } @@ -108,6 +129,13 @@ public class RecipeLoader { private static boolean registerMTE(ItemList item, Class mte, String aName, String aNameRegional, boolean dep) { if (MTEID > MTEIDMax) throw new RuntimeException("MTE ID's"); + registerMTEUsingID(MTEID, item, mte, aName, aNameRegional, dep); + MTEID++; + return dep; + } + + private static boolean registerMTEUsingID(int ID, ItemList item, Class mte, String aName, + String aNameRegional, boolean dep) { if (dep) { try { item.set( @@ -123,7 +151,6 @@ public class RecipeLoader { throw new RuntimeException(ex.getMessage()); } } - MTEID++; return dep; } 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 94e46a83fa..8cf0ce802f 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 @@ -10,17 +10,23 @@ 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; +import static kubatech.api.Variables.Author; +import static kubatech.api.Variables.StructureHologram; import java.io.IOException; import java.util.*; -import java.util.function.Function; import java.util.stream.Collectors; +import kubatech.Tags; +import kubatech.api.LoaderReference; +import kubatech.api.implementations.KubaTechGTMultiBlockBase; +import kubatech.api.network.CustomTileEntityPacket; +import kubatech.api.tileentity.CustomTileEntityPacketHandler; +import kubatech.client.effect.CropRenderer; + import net.minecraft.block.Block; import net.minecraft.block.BlockFlower; import net.minecraft.block.BlockStem; @@ -43,13 +49,6 @@ 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; -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; @@ -61,7 +60,6 @@ import com.gtnewhorizons.modularui.api.math.Color; import com.gtnewhorizons.modularui.api.math.Pos2d; 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; @@ -90,8 +88,10 @@ import ic2.api.crops.Crops; import ic2.core.Ic2Items; import ic2.core.crop.TileEntityCrop; +@SuppressWarnings("unused") public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse - extends GT_MetaTileEntity_EnhancedMultiBlockBase { + extends KubaTechGTMultiBlockBase + implements CustomTileEntityPacketHandler { private static final boolean debug = false; private static final int EIG_MATH_VERSION = 0; @@ -149,13 +149,12 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse : 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)) + LoaderReference.Bartworks ? BorosilicateGlass.ofBoroGlass( + (byte) 0, + (byte) 1, + Byte.MAX_VALUE, + (te, t) -> te.glasTier = t, + te -> te.glasTier) : onElementPass(t -> t.glasTier = 100, ofBlock(Blocks.glass, 0))) .addElement( 'd', ofBlock( @@ -223,15 +222,14 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } private static String tierString(int tier) { - return GT_Values.TIER_COLORS[tier] + GT_Values.VN[tier] + ChatColorHelper.RESET + ChatColorHelper.GRAY; + return GT_Values.TIER_COLORS[tier] + GT_Values.VN[tier] + EnumChatFormatting.RESET + EnumChatFormatting.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(AuthorKuba).addInfo("Grow your crops like a chad !") - .addInfo("Use screwdriver to enable/change/disable setup mode") + tt.addMachineType("Crop Farm").addInfo("Controller block for the Extreme Industrial Greenhouse").addInfo(Author) + .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") .addInfo("Uses 1000L of water per crop per operation") @@ -257,7 +255,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse .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() + .addInfo("1 Fertilizer per 1 crop +10%").addInfo(StructureHologram).addSeparator() .beginStructureBlock(5, 6, 5, false).addController("Front bottom center") .addCasingInfo("Clean Stainless Steel Casings", 70) .addOtherStructurePart("Borosilicate Glass", "Hollow two middle layers") @@ -268,8 +266,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse .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")); + .addEnergyHatch("Any casing (Except inner bottom ones)", 1).toolTipFinisher(Tags.MODNAME); return tt; } @@ -311,6 +308,8 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse Minecraft.getMinecraft().effectRenderer.addEffect(crop); } + private CustomTileEntityPacket packet = null; + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); @@ -326,27 +325,21 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse } } 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()); + if (packet == null) packet = new CustomTileEntityPacket((TileEntity) aBaseMetaTileEntity, null); + packet.resetHelperData(); + packet.addData(mMaxSlots); + packet.sendToAllAround(20); } } @Override - public void construct(ItemStack itemStack, boolean b) { - buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 2, 5, 0); + public void HandleCustomPacket(CustomTileEntityPacket customdata) { + mMaxSlots = customdata.getDataInt(); } @Override - public boolean isCorrectMachinePart(ItemStack itemStack) { - return true; + public void construct(ItemStack itemStack, boolean b) { + buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 2, 5, 0); } private void updateMaxSlots() { @@ -518,33 +511,11 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse return valid; } - @Override - public int getMaxEfficiency(ItemStack itemStack) { - return 10000; - } - - @Override - public int getDamageToComponent(ItemStack itemStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack itemStack) { - 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 int getGUIHeight() { return 166; @@ -633,8 +604,7 @@ public class GT_MetaTileEntity_ExtremeIndustrialGreenhouse return Collections.emptyList(); }).setSize(18, 18)); } - cropsContainer.widget( - row.setPos(0, i * 18).setEnabled(widget -> widget.getPos().y < cropsContainer.getVisibleHeight())); + cropsContainer.widget(row.setPos(0, i * 18)); } cropsContainer.attachSyncer( new FakeSyncWidget.ListSyncer<>( -- cgit