diff options
author | bombcar <github@bombcar.com> | 2021-11-22 08:46:30 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-22 08:46:30 -0600 |
commit | db511ee36c4179283d3738ad27cdd232c1885888 (patch) | |
tree | 6a4420be1342199617ff2ea1614cd4b2abb7e187 /src/Java/gtPlusPlus/xmod | |
parent | 1949ecd687822eb674afffe243c13b6a408c50fc (diff) | |
parent | fb4fecbf3f8858988e33279f35a49517d079eee4 (diff) | |
download | GT5-Unofficial-db511ee36c4179283d3738ad27cdd232c1885888.tar.gz GT5-Unofficial-db511ee36c4179283d3738ad27cdd232c1885888.tar.bz2 GT5-Unofficial-db511ee36c4179283d3738ad27cdd232c1885888.zip |
Merge branch 'GTNewHorizons:master' into master
Diffstat (limited to 'src/Java/gtPlusPlus/xmod')
6 files changed, 158 insertions, 141 deletions
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 ed101e7ab9..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 @@ -1,8 +1,12 @@ -/* + 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 com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.enums.Materials; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; @@ -11,10 +15,12 @@ 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_ModHandler; +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; @@ -25,19 +31,25 @@ 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 net.minecraft.block.Block; +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 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<GregtechMetaTileEntityTreeFarm> STRUCTURE_DEFINITION = null; + static { - mTreeData = new TreeGenerator(); + mTreeData = new TreeGenerator(); } public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) { @@ -46,13 +58,9 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); } - - - */ -/* + /* * Static thread for Fake World Handling - *//* - + */ private static ScheduledExecutorService executor; @@ -63,31 +71,25 @@ 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); + executor = Executors.newScheduledThreadPool(10); } - if (executor != null) { + if (executor != null) { if (aThread == null) { - aThread = new ThreadFakeWorldGenerator(); - executor.scheduleAtFixedRate(aThread, 0, 1, TimeUnit.SECONDS); + 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; } } - } - }*//* - - - - - + } + } } public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { @@ -99,25 +101,32 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase 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[]{ - "[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", - "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") + .addPollutionAmount(getPollutionPerTick(null) * 20) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Sterile Farm Casing", 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, - 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))}; @@ -140,7 +149,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase return "VacuumFreezer"; } - public GT_Recipe.GT_Recipe_Map getRecipeMap() { + public GT_Recipe.GT_Recipe_Map getRecipeMap() { return null; } @@ -149,20 +158,13 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase //return true; } - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } +// public boolean isFacingValid(final byte aFacing) { +// return aFacing > 1; +// } 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"); long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); @@ -189,18 +191,15 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase } - int aChance = MathUtils.randInt(0, 10); AutoMap<ItemStack> aOutputs = new AutoMap<ItemStack>(); try { - //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++) { - 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) { - Logger.WARNING("Generated some Loot, adding it to the output busses"); ItemStack aLeaves = ItemUtils.getSimpleStack(Blocks.leaves); @@ -209,28 +208,28 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase this.addOutput(aOutputItemStack); } } - Logger.WARNING("Updating Slots"); this.updateSlots(); - } - } + } + } - } - } - catch (Throwable t) { + } + } catch (Throwable t) { t.printStackTrace(); } - - //Logger.WARNING("Valid Recipe"); return true; - } - else { - //Logger.WARNING("Invalid Recipe"); + } else { return false; } //return this.checkRecipeGeneric(4, 100, 100); } @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasing = 0; + return checkPiece(mName, 1, 1, 0) && mCasing >= 10 - 8 && checkHatch(); + } + + @Override public int getMaxParallelRecipes() { return 1; } @@ -240,34 +239,39 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase 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<GregtechMetaTileEntityTreeFarm> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntityTreeFarm>builder() + .addShape(mName, transpose(new String[][]{ + {"CCC", "CCC", "CCC"}, + {"C~C", "C-C", "CCC"}, + {"CCC", "CCC", "CCC"}, + })) + .addElement( + 'C', + ofChain( + ofHatchAdder( + GregtechMetaTileEntityTreeFarm::addTreeFarmList, CASING_TEXTURE_ID, 1 + ), + onElementPass( + x -> ++x.mCasing, + ofBlock( + ModBlocks.blockCasings2Misc, 15 + ) + ) + ) + ) + .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; - - } - } - } - } - return tAmount >= 10; + return addToMachineList(aTileEntity, aBaseCasingIndex); } } @@ -287,47 +291,61 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase 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]; - 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(); - } - } + 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; } } - Logger.WARNING("Drained Power? "+didElectricDamage); - + } + } + 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; + } - 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)); + @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() && isCorrectMachinePart(invItem)) { + + 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; + tryDamageTool(invItem); + } else { + addOutput(invItem); + this.mInventory[1] = null; + if (!replaceTool()) { + this.getBaseMetaTileEntity().disableWorking(); } + tryDamageTool(invItem); } - } - } + } + } + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); } -}*/ +} 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)); } -}*/ +} |