From 621165d82bbac52f03fbf7d0627ddff7df3922d6 Mon Sep 17 00:00:00 2001 From: Sphyix Date: Sat, 20 Nov 2021 16:20:13 +0100 Subject: enabled, balanced(?) wood multiblock --- .../multi/production/GregtechMetaTileEntityTreeFarm.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index ed101e7ab9..a136bf33b8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -154,12 +154,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase } public boolean checkRecipe(final ItemStack aStack) { - - if (true) { - return false; - } - - + //Logger.WARNING("Trying to process virtual tree farming"); if (mTreeData != null) { //Logger.WARNING("Tree Data is valid"); @@ -197,7 +192,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase //Logger.WARNING("Output Chance - "+aChance+" | Valid number? "+(aChance < 1000)); if (aChance < 8) { //1% Chance per Tick - for (int u=0; u<(Math.max(20, (MathUtils.randInt((3*tTier), 100)*tTier*tTier)/8));u++) { + for (int u=0; u<(Math.max(4, (MathUtils.randInt((3*tTier), 100)*tTier*tTier)/14));u++) { aOutputs = mTreeData.generateOutput(0); if (aOutputs.size() > 0) { Logger.WARNING("Generated some Loot, adding it to the output busses"); -- cgit From 3b9804b1b4ee2d11b46794a1336afc4f0372a205 Mon Sep 17 00:00:00 2001 From: Sphyix Date: Sat, 20 Nov 2021 16:42:31 +0100 Subject: uncommented multi --- .../xmod/gregtech/api/enums/GregtechItemList.java | 2 +- .../gregtech/api/gui/CONTAINER_TreeFarmer.java | 4 +-- .../xmod/gregtech/api/gui/GUI_TreeFarmer.java | 3 +- .../gregtech/common/helpers/TreeFarmHelper.java | 10 +++---- .../production/GregtechMetaTileEntityTreeFarm.java | 33 ++++++++-------------- .../gregtech/GregtechIndustrialTreeFarm.java | 4 +-- 6 files changed, 22 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 205aad3546..fd5ceed89b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -266,7 +266,7 @@ public enum GregtechItemList implements GregtechItemContainer { //Tree Farm - /*Industrial_TreeFarm, */ + Industrial_TreeFarm, TreeFarmer_Structural, Casing_PLACEHOLDER_TreeFarmer, diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java index 0a8624354b..bf4dffb904 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java @@ -1,4 +1,4 @@ -/* + package gtPlusPlus.xmod.gregtech.api.gui; import java.util.List; @@ -68,4 +68,4 @@ public class CONTAINER_TreeFarmer extends GT_ContainerMetaTile_Machine { } } -}*/ +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java index 762dcbf640..b236b0ff32 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java @@ -1,4 +1,4 @@ -/* + package gtPlusPlus.xmod.gregtech.api.gui; @@ -44,4 +44,3 @@ public class GUI_TreeFarmer extends GT_GUIContainerMetaTile_Machine { this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); } } -*/ diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java index 8b3fb9a42f..c728c5d8e8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -202,7 +202,7 @@ public class TreeFarmHelper { )){ if (!testBlock.getUnlocalizedName().toLowerCase().contains("air") || !testBlock.getUnlocalizedName().toLowerCase().contains("pumpkin")) { - Logger.WARNING("5:"+testBlock.getUnlocalizedName()); + //Logger.WARNING("5:"+testBlock.getUnlocalizedName()); } else { aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getXCoord()+xDir+i, aBaseMetaTileEntity.getYCoord()+h, aBaseMetaTileEntity.getZCoord()+zDir+j, Blocks.bookshelf); } @@ -222,14 +222,14 @@ public class TreeFarmHelper { ){ if (!testBlock.getUnlocalizedName().toLowerCase().contains("air") || !testBlock.getUnlocalizedName().toLowerCase().contains("pumpkin")) { - Logger.WARNING("0:"+testBlock.getUnlocalizedName()); + //Logger.WARNING("0:"+testBlock.getUnlocalizedName()); } else { aBaseMetaTileEntity.getWorld().setBlock(aBaseMetaTileEntity.getXCoord()+xDir+i, aBaseMetaTileEntity.getYCoord()+h, aBaseMetaTileEntity.getZCoord()+zDir+j, Blocks.melon_block); } if (isLeaves(testBlock) || isWoodLog(testBlock)){ - Logger.WARNING("1:"+testBlock.getUnlocalizedName()); + //Logger.WARNING("1:"+testBlock.getUnlocalizedName()); int posiX, posiY, posiZ; posiX = aBaseMetaTileEntity.getXCoord()+xDir+i; posiY = aBaseMetaTileEntity.getYCoord()+h; @@ -440,10 +440,10 @@ public class TreeFarmHelper { public static boolean isSapling(final Block log){ if (log != null){ if (OrePrefixes.sapling.contains(new ItemStack(log, 1))){ - Logger.WARNING(""+log.getLocalizedName()); + //Logger.WARNING(""+log.getLocalizedName()); } if (log.getLocalizedName().toLowerCase().contains("sapling")){ - Logger.WARNING(""+log.getLocalizedName()); + //Logger.WARNING(""+log.getLocalizedName()); return true; } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index a136bf33b8..164301a22b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -1,4 +1,4 @@ -/* + package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; import java.util.concurrent.ScheduledExecutorService; @@ -48,10 +48,9 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase - */ /* * Static thread for Fake World Handling - *//* + */ @@ -63,8 +62,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); - */ -/*if (executor == null || mTreeData == null) { +if (executor == null || mTreeData == null) { if (executor == null) { executor = Executors.newScheduledThreadPool(10); } @@ -82,7 +80,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase } } } - }*//* + } @@ -106,7 +104,6 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase } return new String[]{ - "[WIP] Disabled", "Converts EU to Oak Logs", "Speed: Very Fast | Eu Usage: 100% | Parallel: 1", "Requires a Saw, Buzz Saw or Chainsaw in GUI slot", @@ -155,9 +152,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase public boolean checkRecipe(final ItemStack aStack) { - //Logger.WARNING("Trying to process virtual tree farming"); if (mTreeData != null) { - //Logger.WARNING("Tree Data is valid"); long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); @@ -189,13 +184,11 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase AutoMap aOutputs = new AutoMap(); try { - //Logger.WARNING("Output Chance - "+aChance+" | Valid number? "+(aChance < 1000)); if (aChance < 8) { //1% Chance per Tick for (int u=0; u<(Math.max(4, (MathUtils.randInt((3*tTier), 100)*tTier*tTier)/14));u++) { aOutputs = mTreeData.generateOutput(0); if (aOutputs.size() > 0) { - Logger.WARNING("Generated some Loot, adding it to the output busses"); ItemStack aLeaves = ItemUtils.getSimpleStack(Blocks.leaves); @@ -204,7 +197,6 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase this.addOutput(aOutputItemStack); } } - Logger.WARNING("Updating Slots"); this.updateSlots(); } } @@ -214,12 +206,9 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase catch (Throwable t) { t.printStackTrace(); } - - //Logger.WARNING("Valid Recipe"); return true; } else { - //Logger.WARNING("Invalid Recipe"); return false; } //return this.checkRecipeGeneric(4, 100, 100); @@ -253,7 +242,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, true, aBlock, aMeta, ModBlocks.blockCasings2Misc, 15)) { - Logger.WARNING("Bad centrifuge casing"); + //Logger.WARNING("Bad centrifuge casing"); return false; } ++tAmount; @@ -295,19 +284,19 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); if (EU.getCharge(invItem) >= tVoltage) { - Logger.WARNING("Can drain."); + //Logger.WARNING("Can drain."); if (EU.discharge(invItem, (int) tVoltage, -1)) { - Logger.WARNING("Drained Power."); + //Logger.WARNING("Drained Power."); didElectricDamage = true; } else { - Logger.WARNING("Failed when draining Power."); + //Logger.WARNING("Failed when draining Power."); this.getBaseMetaTileEntity().disableWorking(); } } } } - Logger.WARNING("Drained Power? "+didElectricDamage); + //Logger.WARNING("Drained Power? "+didElectricDamage); @@ -315,7 +304,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase long aDmg = GT_MetaGenerated_Tool.getToolDamage(invItem); long aDmgMax = GT_MetaGenerated_Tool.getToolMaxDamage(invItem); if (aDmg < aDmgMax && GT_MetaGenerated_Tool.getPrimaryMaterial(invItem) != Materials._NULL) { - Logger.WARNING("dmg: "+aDmg+" | max: "+aDmgMax); + //Logger.WARNING("dmg: "+aDmg+" | max: "+aDmgMax); GT_MetaGenerated_Tool.setToolDamage(invItem, aDmg+getDamageToComponent(invItem)); } else if (aDmg >= aDmgMax) { @@ -325,4 +314,4 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase } } } -}*/ +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialTreeFarm.java index 8d259d9d2e..47dd3c265f 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechIndustrialTreeFarm.java @@ -1,4 +1,4 @@ -/* + package gtPlusPlus.xmod.gregtech.registration.gregtech; import gtPlusPlus.api.objects.Logger; @@ -25,4 +25,4 @@ public class GregtechIndustrialTreeFarm { .getStackForm(1L)); } -}*/ +} -- cgit From bd1900c61fd3947053f54cf4cc9b9cc9244ee637 Mon Sep 17 00:00:00 2001 From: Sphyix Date: Sat, 20 Nov 2021 17:00:32 +0100 Subject: partial structurelib, more stuff uncommented --- .../gtPlusPlus/core/handler/COMPAT_HANDLER.java | 2 +- .../gtPlusPlus/core/recipe/RECIPES_Machines.java | 10 ++-- .../production/GregtechMetaTileEntityTreeFarm.java | 58 ++++++++++++++++------ 3 files changed, 49 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index fc0627a0cc..4fda17ee8a 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -118,7 +118,7 @@ public class COMPAT_HANDLER { Gregtech4Content.run(); GregtechIndustrialFuelRefinery.run(); GregtechTreeFarmerTE.run(); - //GregtechIndustrialTreeFarm.run(); + GregtechIndustrialTreeFarm.run(); GregtechIndustrialSifter.run(); GregtechSimpleWasher.run(); GregtechRTG.run(); diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 1efa09c096..0a4e760a17 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -1116,22 +1116,22 @@ public class RECIPES_Machines { if (CORE.ConfigSwitches.enableMultiblock_TreeFarmer){ //Industrial Tree Farmer - /*RECIPE_TreeFarmController = GregtechItemList.Industrial_TreeFarm.get(1);*/ + RECIPE_TreeFarmController = GregtechItemList.Industrial_TreeFarm.get(1); RECIPE_TreeFarmFrame = GregtechItemList.Casing_PLACEHOLDER_TreeFarmer.get(Casing_Amount); //Industrial Tree Farm Controller if (!GTNH) { - /*RecipeUtils.addShapedGregtechRecipe( + RecipeUtils.addShapedGregtechRecipe( "plateEglinSteel", "rotorEglinSteel", "plateEglinSteel", "cableGt02Steel", "pipeMediumSteel", "cableGt02Steel", "plateEglinSteel", CI.machineCasing_MV, "plateEglinSteel", - RECIPE_TreeFarmController);*/ + RECIPE_TreeFarmController); } else { - /*RecipeUtils.addShapedGregtechRecipe( + RecipeUtils.addShapedGregtechRecipe( "plateEglinSteel", "rotorEglinSteel", "plateEglinSteel", "cableGt02Silver", "pipeMediumStainlessSteel", "cableGt02Silver", "plateEglinSteel", CI.machineCasing_HV, "plateEglinSteel", - RECIPE_TreeFarmController);*/ + RECIPE_TreeFarmController); } //Industrial Tree Farm Frame RecipeUtils.addShapedGregtechRecipe( diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index 164301a22b..a2ce83522b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -1,8 +1,11 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; +import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import gregtech.api.enums.Materials; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; @@ -12,6 +15,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; @@ -64,12 +68,12 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase if (executor == null || mTreeData == null) { if (executor == null) { - executor = Executors.newScheduledThreadPool(10); + executor = Executors.newScheduledThreadPool(10); } if (executor != null) { if (aThread == null) { aThread = new ThreadFakeWorldGenerator(); - executor.scheduleAtFixedRate(aThread, 0, 1, TimeUnit.SECONDS); + executor.scheduleAtFixedRate(aThread, 0, 1, TimeUnit.SECONDS); while (aThread.mGenerator == null) { if (aThread.mGenerator != null) { break; @@ -97,20 +101,29 @@ if (executor == null || mTreeData == null) { return "Tree Farm"; } - public String[] getTooltip() { - + @Override + protected GT_Multiblock_Tooltip_Builder createTooltip() { if (mCasingName.toLowerCase().contains(".name")) { mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); } - - return new String[]{ - "Converts EU to Oak Logs", - "Speed: Very Fast | Eu Usage: 100% | Parallel: 1", - "Requires a Saw, Buzz Saw or Chainsaw in GUI slot", - "Constructed exactly the same as a normal Vacuum Freezer", - "Use "+mCasingName+"s (10 at least!)", - "TAG_HIDE_HATCHES" - }; + GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType(getMachineType()) + .addInfo("Converts EU to Oak Logs") + .addInfo("Eu Usage: 100% | Parallel: 1") + .addInfo("Requires a Saw or Chainsaw in GUI slot") + .addInfo("Constructed exactly the same as a normal Vacuum Freezer") + .addPollutionAmount(getPollutionPerTick(null) * 20) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo(mCasingName, 10) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher("GT++"); + return tt; } public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, @@ -146,8 +159,13 @@ if (executor == null || mTreeData == null) { //return true; } - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; +// public boolean isFacingValid(final byte aFacing) { +// return aFacing > 1; +// } + + @Override + public IStructureDefinition getStructureDefinition() { + return null; } public boolean checkRecipe(final ItemStack aStack) { @@ -214,6 +232,11 @@ if (executor == null || mTreeData == null) { //return this.checkRecipeGeneric(4, 100, 100); } + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return false; + } + @Override public int getMaxParallelRecipes() { return 1; @@ -314,4 +337,9 @@ if (executor == null || mTreeData == null) { } } } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + + } } -- cgit From 1100e8d6d7709c02955080137324da47c97fb666 Mon Sep 17 00:00:00 2001 From: Sphyix Date: Sat, 20 Nov 2021 17:19:15 +0100 Subject: rest of structurelib --- .../production/GregtechMetaTileEntityTreeFarm.java | 108 ++++++++++++++------- 1 file changed, 75 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index a2ce83522b..ed97ca097d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -6,6 +6,7 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.enums.Materials; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; @@ -14,6 +15,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; +import gregtech.api.metatileentity.implementations.*; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -29,16 +31,22 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.Gregtech import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.helpers.TreeFarmHelper; import gtPlusPlus.xmod.gregtech.common.helpers.treefarm.TreeGenerator; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialSifter; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase { public static int CASING_TEXTURE_ID; public static String mCasingName = "Advanced Cryogenic Casing"; public static TreeGenerator mTreeData; + private int mCasing; + private IStructureDefinition STRUCTURE_DEFINITION = null; static { mTreeData = new TreeGenerator(); @@ -163,11 +171,6 @@ if (executor == null || mTreeData == null) { // return aFacing > 1; // } - @Override - public IStructureDefinition getStructureDefinition() { - return null; - } - public boolean checkRecipe(final ItemStack aStack) { if (mTreeData != null) { @@ -233,8 +236,9 @@ if (executor == null || mTreeData == null) { } @Override - public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return false; + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 - 8 && checkHatch(); } @Override @@ -247,35 +251,73 @@ if (executor == null || mTreeData == null) { return 0; } - public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - int tAmount = 0; - if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + @Override + public IStructureDefinition getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(mName, transpose(new String[][]{ + {"XXX", "CCC", "CCC"}, + {"XXX", "C-C", "CCC"}, + {"X~X", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntityTreeFarm::addTreeFarmList, getCasingTextureIndex(), 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasingsMisc, 0 + ) + ) + ) + ) + .addElement( + 'X', + ofBlock( + ModBlocks.blockCasingsMisc, 0 + ) + ) + .build(); + } + return STRUCTURE_DEFINITION; + } + + public final boolean addTreeFarmList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { return false; } else { - for (int i = -1; i < 2; ++i) { - for (int j = -1; j < 2; ++j) { - for (int h = -1; h < 2; ++h) { - if (h != 0 || (xDir + i != 0 || zDir + j != 0) && (i != 0 || j != 0)) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, - h, zDir + j); - Block aBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - int aMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - - if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, true, aBlock, aMeta, - ModBlocks.blockCasings2Misc, 15)) { - //Logger.WARNING("Bad centrifuge casing"); - return false; - } - ++tAmount; - - } - } - } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus)aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance)aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy)aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); } - return tAmount >= 10; } + return false; + } + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(0); } public int getMaxEfficiency(final ItemStack aStack) { @@ -340,6 +382,6 @@ if (executor == null || mTreeData == null) { @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); } } -- cgit From e8b7c6d5f47dd6ca0eb7f1cdd9fc69aa53b37a44 Mon Sep 17 00:00:00 2001 From: Sphyix Date: Sat, 20 Nov 2021 18:17:27 +0100 Subject: fixes --- .../multi/production/GregtechMetaTileEntityTreeFarm.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index ed97ca097d..8b248ff2ad 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -93,11 +93,6 @@ if (executor == null || mTreeData == null) { } } } - - - - - } public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { @@ -119,12 +114,11 @@ if (executor == null || mTreeData == null) { .addInfo("Converts EU to Oak Logs") .addInfo("Eu Usage: 100% | Parallel: 1") .addInfo("Requires a Saw or Chainsaw in GUI slot") - .addInfo("Constructed exactly the same as a normal Vacuum Freezer") .addPollutionAmount(getPollutionPerTick(null) * 20) .addSeparator() .beginStructureBlock(3, 3, 3, true) .addController("Front center") - .addCasingInfo(mCasingName, 10) + .addCasingInfo("Sterile Farm Casing", 10) .addInputBus("Any casing", 1) .addOutputBus("Any casing", 1) .addEnergyHatch("Any casing", 1) @@ -257,8 +251,8 @@ if (executor == null || mTreeData == null) { STRUCTURE_DEFINITION = StructureDefinition.builder() .addShape(mName, transpose(new String[][]{ {"XXX", "CCC", "CCC"}, - {"XXX", "C-C", "CCC"}, - {"X~X", "CCC", "CCC"}, + {"X~X", "C-C", "CCC"}, + {"XXX", "CCC", "CCC"}, })) .addElement( 'C', @@ -269,7 +263,7 @@ if (executor == null || mTreeData == null) { onElementPass( x -> ++x.mCasing, ofBlock( - ModBlocks.blockCasingsMisc, 0 + ModBlocks.blockCasings2Misc, 0 ) ) ) @@ -277,7 +271,7 @@ if (executor == null || mTreeData == null) { .addElement( 'X', ofBlock( - ModBlocks.blockCasingsMisc, 0 + ModBlocks.blockCasings2Misc, 0 ) ) .build(); -- cgit From 5a5f23ffd19ae6190706886fd45a5db565706e0e Mon Sep 17 00:00:00 2001 From: Sphyix Date: Sat, 20 Nov 2021 19:06:26 +0100 Subject: clean, fixed textures --- .../multi/production/GregtechMetaTileEntityTreeFarm.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index 8b248ff2ad..8429617c00 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -20,7 +20,6 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.minecraft.ThreadFakeWorldGenerator; import gtPlusPlus.core.block.ModBlocks; @@ -31,11 +30,8 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.Gregtech import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.helpers.TreeFarmHelper; import gtPlusPlus.xmod.gregtech.common.helpers.treefarm.TreeGenerator; -import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.GregtechMetaTileEntity_IndustrialSifter; -import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; @@ -258,12 +254,12 @@ if (executor == null || mTreeData == null) { 'C', ofChain( ofHatchAdder( - GregtechMetaTileEntityTreeFarm::addTreeFarmList, getCasingTextureIndex(), 1 + GregtechMetaTileEntityTreeFarm::addTreeFarmList, CASING_TEXTURE_ID, 1 ), onElementPass( x -> ++x.mCasing, ofBlock( - ModBlocks.blockCasings2Misc, 0 + ModBlocks.blockCasings2Misc, 15 ) ) ) @@ -271,7 +267,7 @@ if (executor == null || mTreeData == null) { .addElement( 'X', ofBlock( - ModBlocks.blockCasings2Misc, 0 + ModBlocks.blockCasings2Misc, 15 ) ) .build(); @@ -310,10 +306,6 @@ if (executor == null || mTreeData == null) { return false; } - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(0); - } - public int getMaxEfficiency(final ItemStack aStack) { return 10000; } -- cgit From a12bf17bee03e10a64a90cbd58639a29a0b18dc2 Mon Sep 17 00:00:00 2001 From: Sphyix Date: Sun, 21 Nov 2021 13:54:31 +0100 Subject: disabled item damage item can't be replaced automatically currently --- .../production/GregtechMetaTileEntityTreeFarm.java | 95 ++++++++-------------- 1 file changed, 32 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index 8429617c00..7e165d3d72 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -17,6 +17,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.metatileentity.implementations.*; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -54,8 +55,6 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); } - - /* * Static thread for Fake World Handling */ @@ -279,31 +278,8 @@ if (executor == null || mTreeData == null) { if (aTileEntity == null) { return false; } else { - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus){ - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); - return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus)aMetaTileEntity); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance){ - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); - return this.mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance)aMetaTileEntity); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy){ - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); - return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy)aMetaTileEntity); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return this.mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return this.mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - } + return addToMachineList(aTileEntity, aBaseCasingIndex); } - return false; } public int getMaxEfficiency(final ItemStack aStack) { @@ -324,46 +300,39 @@ if (executor == null || mTreeData == null) { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); + super.onPostTick(aBaseMetaTileEntity, aTick); if (this.mInventory[1] != null && aTick % 200 == 0 && this.getBaseMetaTileEntity().isServerSide()) { - ItemStack invItem = this.mInventory[1]; + ItemStack invItem = this.mInventory[1]; if (isCorrectMachinePart(invItem)) { - boolean didElectricDamage = false; - if (EU.isElectricItem(invItem)) { - if (EU.hasCharge(invItem)) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - if (EU.getCharge(invItem) >= tVoltage) { - //Logger.WARNING("Can drain."); - if (EU.discharge(invItem, (int) tVoltage, -1)) { - //Logger.WARNING("Drained Power."); - didElectricDamage = true; - } - else { - //Logger.WARNING("Failed when draining Power."); - this.getBaseMetaTileEntity().disableWorking(); - } - } - } - } - //Logger.WARNING("Drained Power? "+didElectricDamage); - - - - if (!didElectricDamage && invItem.getItem() instanceof GT_MetaGenerated_Tool) { - long aDmg = GT_MetaGenerated_Tool.getToolDamage(invItem); - long aDmgMax = GT_MetaGenerated_Tool.getToolMaxDamage(invItem); - if (aDmg < aDmgMax && GT_MetaGenerated_Tool.getPrimaryMaterial(invItem) != Materials._NULL) { - //Logger.WARNING("dmg: "+aDmg+" | max: "+aDmgMax); - GT_MetaGenerated_Tool.setToolDamage(invItem, aDmg+getDamageToComponent(invItem)); - } - else if (aDmg >= aDmgMax) { - this.mInventory[1] = null; - } - } - } - } + //Damage and discharge to the internal tool disabled for now +// if (EU.isElectricItem(invItem)) { +// if (EU.hasCharge(invItem)) { +// long tVoltage = getMaxInputVoltage(); +// byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); +// if (EU.getCharge(invItem) >= tVoltage) { +// if (EU.discharge(invItem, (int) tVoltage, -1)) { +// didElectricDamage = true; +// } +// else { +// this.getBaseMetaTileEntity().disableWorking(); +// } +// } +// } +// } + +// if (!didElectricDamage && invItem.getItem() instanceof GT_MetaGenerated_Tool) { +// long aDmg = GT_MetaGenerated_Tool.getToolDamage(invItem); +// long aDmgMax = GT_MetaGenerated_Tool.getToolMaxDamage(invItem); +// if (aDmg < aDmgMax && GT_MetaGenerated_Tool.getPrimaryMaterial(invItem) != Materials._NULL) { +// GT_ModHandler.damageOrDechargeItem(invItem, 1, 0, null); +// } +// else if (aDmg >= aDmgMax) { +// this.mInventory[1] = null; +// } +// } + } + } } @Override -- cgit From 967b5a7f23404c8c57bc3bf329affb29d9918048 Mon Sep 17 00:00:00 2001 From: Sphyix Date: Sun, 21 Nov 2021 16:19:35 +0100 Subject: tool damage re-enabled --- .../production/GregtechMetaTileEntityTreeFarm.java | 51 +++++++++++----------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index 7e165d3d72..77487d795e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -305,32 +305,31 @@ if (executor == null || mTreeData == null) { ItemStack invItem = this.mInventory[1]; if (isCorrectMachinePart(invItem)) { boolean didElectricDamage = false; - //Damage and discharge to the internal tool disabled for now -// if (EU.isElectricItem(invItem)) { -// if (EU.hasCharge(invItem)) { -// long tVoltage = getMaxInputVoltage(); -// byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); -// if (EU.getCharge(invItem) >= tVoltage) { -// if (EU.discharge(invItem, (int) tVoltage, -1)) { -// didElectricDamage = true; -// } -// else { -// this.getBaseMetaTileEntity().disableWorking(); -// } -// } -// } -// } - -// if (!didElectricDamage && invItem.getItem() instanceof GT_MetaGenerated_Tool) { -// long aDmg = GT_MetaGenerated_Tool.getToolDamage(invItem); -// long aDmgMax = GT_MetaGenerated_Tool.getToolMaxDamage(invItem); -// if (aDmg < aDmgMax && GT_MetaGenerated_Tool.getPrimaryMaterial(invItem) != Materials._NULL) { -// GT_ModHandler.damageOrDechargeItem(invItem, 1, 0, null); -// } -// else if (aDmg >= aDmgMax) { -// this.mInventory[1] = null; -// } -// } + if (EU.isElectricItem(invItem)) { + if (EU.hasCharge(invItem)) { + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + if (EU.getCharge(invItem) >= tVoltage) { + if (EU.discharge(invItem, (int) tVoltage, -1)) { + didElectricDamage = true; + } + else { + this.getBaseMetaTileEntity().disableWorking(); + } + } + } + } + + if (!didElectricDamage && invItem.getItem() instanceof GT_MetaGenerated_Tool) { + long aDmg = GT_MetaGenerated_Tool.getToolDamage(invItem); + long aDmgMax = GT_MetaGenerated_Tool.getToolMaxDamage(invItem); + if (aDmg < aDmgMax && GT_MetaGenerated_Tool.getPrimaryMaterial(invItem) != Materials._NULL) { + GT_ModHandler.damageOrDechargeItem(invItem, 1, 0, null); + } + else if (aDmg >= aDmgMax) { + this.mInventory[1] = null; + } + } } } } -- cgit From 656c9cdc5aa57c66ebe3e4cf5f09e0a8466531d7 Mon Sep 17 00:00:00 2001 From: Sphyix Date: Sun, 21 Nov 2021 20:04:48 +0100 Subject: tool replacement & extraction, accept hatches in front aswell --- .../production/GregtechMetaTileEntityTreeFarm.java | 56 +++++++++++++--------- 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index 77487d795e..2b8d1d9e03 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -31,7 +31,10 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.Gregtech import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.helpers.TreeFarmHelper; import gtPlusPlus.xmod.gregtech.common.helpers.treefarm.TreeGenerator; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechItems; +import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools; import net.minecraft.init.Blocks; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; @@ -245,9 +248,9 @@ if (executor == null || mTreeData == null) { if (STRUCTURE_DEFINITION == null) { STRUCTURE_DEFINITION = StructureDefinition.builder() .addShape(mName, transpose(new String[][]{ - {"XXX", "CCC", "CCC"}, - {"X~X", "C-C", "CCC"}, - {"XXX", "CCC", "CCC"}, + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, })) .addElement( 'C', @@ -263,12 +266,6 @@ if (executor == null || mTreeData == null) { ) ) ) - .addElement( - 'X', - ofBlock( - ModBlocks.blockCasings2Misc, 15 - ) - ) .build(); } return STRUCTURE_DEFINITION; @@ -298,25 +295,37 @@ if (executor == null || mTreeData == null) { return false; } + public boolean replaceTool() { + ItemStack invItem = this.mInventory[1]; + if (invItem == null) { + for (GT_MetaTileEntity_Hatch_InputBus mInputBus : this.mInputBusses) { + for (int i = 0; i < mInputBus.mInventory.length ; i++) { + ItemStack uStack = mInputBus.mInventory[i]; + if(uStack != null && TreeFarmHelper.isCorrectPart(uStack)) { + this.setGUIItemStack(uStack); + return true; + } + } + } + } + return false; + } + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); - if (this.mInventory[1] != null && aTick % 200 == 0 && this.getBaseMetaTileEntity().isServerSide()) { - ItemStack invItem = this.mInventory[1]; + replaceTool(); + ItemStack invItem = this.mInventory[1]; + if (invItem != null && aTick % 200 == 0 && this.getBaseMetaTileEntity().isServerSide()) { if (isCorrectMachinePart(invItem)) { - boolean didElectricDamage = false; + boolean didElectricDamage = true; if (EU.isElectricItem(invItem)) { - if (EU.hasCharge(invItem)) { - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - if (EU.getCharge(invItem) >= tVoltage) { - if (EU.discharge(invItem, (int) tVoltage, -1)) { - didElectricDamage = true; - } - else { - this.getBaseMetaTileEntity().disableWorking(); - } - } + if (!GT_ModHandler.damageOrDechargeItem(invItem, 2, 0, null)) { + didElectricDamage = false; + addOutput(invItem); + this.mInventory[1] = null; + if(!replaceTool()) + this.getBaseMetaTileEntity().disableWorking(); } } @@ -328,6 +337,7 @@ if (executor == null || mTreeData == null) { } else if (aDmg >= aDmgMax) { this.mInventory[1] = null; + replaceTool(); } } } -- cgit From 46218deff159fc88d2a746dd93d4d827b2dee765 Mon Sep 17 00:00:00 2001 From: Sphyix Date: Sun, 21 Nov 2021 21:12:27 +0100 Subject: rewrite, more readable --- .../production/GregtechMetaTileEntityTreeFarm.java | 86 +++++++++++----------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index 2b8d1d9e03..4990c49709 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -47,9 +47,9 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase public static TreeGenerator mTreeData; private int mCasing; private IStructureDefinition STRUCTURE_DEFINITION = null; - + static { - mTreeData = new TreeGenerator(); + mTreeData = new TreeGenerator(); } public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) { @@ -58,12 +58,11 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); } -/* + /* * Static thread for Fake World Handling */ - private static ScheduledExecutorService executor; private static ThreadFakeWorldGenerator aThread; @@ -72,24 +71,24 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); -if (executor == null || mTreeData == null) { + if (executor == null || mTreeData == null) { if (executor == null) { executor = Executors.newScheduledThreadPool(10); } - if (executor != null) { + if (executor != null) { if (aThread == null) { - aThread = new ThreadFakeWorldGenerator(); + aThread = new ThreadFakeWorldGenerator(); executor.scheduleAtFixedRate(aThread, 0, 1, TimeUnit.SECONDS); while (aThread.mGenerator == null) { if (aThread.mGenerator != null) { break; } - } + } if (aThread.mGenerator != null) { mTreeData = aThread.mGenerator; } } - } + } } } @@ -127,7 +126,7 @@ if (executor == null || mTreeData == null) { } public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { if (aSide == aFacing) { return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID), new GT_RenderedTexture((IIconContainer) (aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced))}; @@ -150,7 +149,7 @@ if (executor == null || mTreeData == null) { return "VacuumFreezer"; } - public GT_Recipe.GT_Recipe_Map getRecipeMap() { + public GT_Recipe.GT_Recipe_Map getRecipeMap() { return null; } @@ -192,15 +191,14 @@ if (executor == null || mTreeData == null) { } - int aChance = MathUtils.randInt(0, 10); AutoMap aOutputs = new AutoMap(); try { if (aChance < 8) { //1% Chance per Tick - for (int u=0; u<(Math.max(4, (MathUtils.randInt((3*tTier), 100)*tTier*tTier)/14));u++) { - aOutputs = mTreeData.generateOutput(0); + for (int u = 0; u < (Math.max(4, (MathUtils.randInt((3 * tTier), 100) * tTier * tTier) / 14)); u++) { + aOutputs = mTreeData.generateOutput(0); if (aOutputs.size() > 0) { ItemStack aLeaves = ItemUtils.getSimpleStack(Blocks.leaves); @@ -211,17 +209,15 @@ if (executor == null || mTreeData == null) { } } this.updateSlots(); - } - } + } + } - } - } - catch (Throwable t) { + } + } catch (Throwable t) { t.printStackTrace(); } return true; - } - else { + } else { return false; } //return this.checkRecipeGeneric(4, 100, 100); @@ -299,9 +295,9 @@ if (executor == null || mTreeData == null) { ItemStack invItem = this.mInventory[1]; if (invItem == null) { for (GT_MetaTileEntity_Hatch_InputBus mInputBus : this.mInputBusses) { - for (int i = 0; i < mInputBus.mInventory.length ; i++) { + for (int i = 0; i < mInputBus.mInventory.length; i++) { ItemStack uStack = mInputBus.mInventory[i]; - if(uStack != null && TreeFarmHelper.isCorrectPart(uStack)) { + if (uStack != null && TreeFarmHelper.isCorrectPart(uStack)) { this.setGUIItemStack(uStack); return true; } @@ -311,34 +307,38 @@ if (executor == null || mTreeData == null) { return false; } + public boolean tryDamageTool(ItemStack invItem) { + if (invItem != null && invItem.getItem() instanceof GT_MetaGenerated_Tool) { + long aDmg = GT_MetaGenerated_Tool.getToolDamage(invItem); + long aDmgMax = GT_MetaGenerated_Tool.getToolMaxDamage(invItem); + if (aDmg < aDmgMax && GT_MetaGenerated_Tool.getPrimaryMaterial(invItem) != Materials._NULL) { + return GT_ModHandler.damageOrDechargeItem(invItem, 1, 0, null); + } + } + return false; + } + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); replaceTool(); ItemStack invItem = this.mInventory[1]; - if (invItem != null && aTick % 200 == 0 && this.getBaseMetaTileEntity().isServerSide()) { - if (isCorrectMachinePart(invItem)) { - boolean didElectricDamage = true; - if (EU.isElectricItem(invItem)) { - if (!GT_ModHandler.damageOrDechargeItem(invItem, 2, 0, null)) { - didElectricDamage = false; - addOutput(invItem); - this.mInventory[1] = null; - if(!replaceTool()) - this.getBaseMetaTileEntity().disableWorking(); - } - } + if (invItem != null && aTick % 200 == 0 && this.getBaseMetaTileEntity().isServerSide() && isCorrectMachinePart(invItem)) { - if (!didElectricDamage && invItem.getItem() instanceof GT_MetaGenerated_Tool) { - long aDmg = GT_MetaGenerated_Tool.getToolDamage(invItem); - long aDmgMax = GT_MetaGenerated_Tool.getToolMaxDamage(invItem); - if (aDmg < aDmgMax && GT_MetaGenerated_Tool.getPrimaryMaterial(invItem) != Materials._NULL) { - GT_ModHandler.damageOrDechargeItem(invItem, 1, 0, null); + if (!tryDamageTool(invItem)) { + if (!invItem.getItem().isDamageable()) { //item durability is <= 0 + this.mInventory[1] = null; + if (!replaceTool()) { + this.getBaseMetaTileEntity().disableWorking(); } - else if (aDmg >= aDmgMax) { - this.mInventory[1] = null; - replaceTool(); + tryDamageTool(invItem); + } else { + addOutput(invItem); + this.mInventory[1] = null; + if (!replaceTool()) { + this.getBaseMetaTileEntity().disableWorking(); } + tryDamageTool(invItem); } } } -- cgit