diff options
author | Alkalus <3060479+draknyte1@users.noreply.github.com> | 2022-02-11 17:44:53 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-11 18:44:53 +0100 |
commit | 15c164f8471acc37c530afa0e44852251900e5e4 (patch) | |
tree | c2e3212613acbab4b0c615b485cbae680a355b49 | |
parent | 7d0a7ab7bc196b496ea974562d349589c495ddbe (diff) | |
download | GT5-Unofficial-15c164f8471acc37c530afa0e44852251900e5e4.tar.gz GT5-Unofficial-15c164f8471acc37c530afa0e44852251900e5e4.tar.bz2 GT5-Unofficial-15c164f8471acc37c530afa0e44852251900e5e4.zip |
Fix LRE not working. (#119)
Fix Air Intakes.
Fix Tree Simulator.
4 files changed, 250 insertions, 254 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java index d4b8b3a064..c7e07b7534 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_FluidGenerator.java @@ -132,18 +132,19 @@ public abstract class GT_MetaTileEntity_Hatch_FluidGenerator extends GT_MetaTile } public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - + super.onPostTick(aBaseMetaTileEntity, aTick); if (!aBaseMetaTileEntity.isAllowedToWork()) { - aBaseMetaTileEntity.setActive(false); - mProgresstime = 0; - mMaxProgresstime = 0; + aBaseMetaTileEntity.setActive(false); + mProgresstime = 0; + mMaxProgresstime = 0; } else { aBaseMetaTileEntity.setActive(true); mMaxProgresstime = getMaxTickTime(); if (++mProgresstime >= mMaxProgresstime) { - addFluidToHatch(aTick); + if (this.canTankBeFilled()) { + addFluidToHatch(aTick); + } mProgresstime = 0; } } @@ -184,22 +185,23 @@ public abstract class GT_MetaTileEntity_Hatch_FluidGenerator extends GT_MetaTile if (!doesHatchMeetConditionsToGenerate()) { return false; } - boolean didFill = false; - if (canTankBeFilled()) { - didFill = this.fill(FluidUtils.getFluidStack(getFluidToGenerate(), getAmountOfFluidToGenerate()), true) > 0; - if (didFill) { - this.generateParticles(this.getBaseMetaTileEntity().getWorld(), "cloud"); - } + int aFillAmount = this.fill(FluidUtils.getFluidStack(getFluidToGenerate(), getAmountOfFluidToGenerate()), true); + if (aFillAmount > 0) { + if (this.getBaseMetaTileEntity().isClientSide()) { + generateParticles(this.getBaseMetaTileEntity().getWorld(), "cloud"); + } } - return didFill; + return aFillAmount > 0; } @Override public boolean canTankBeFilled() { - //Logger.INFO("Total Space: "+this.getCapacity()); - //Logger.INFO("Current capacity: "+this.getFluidAmount()); - //Logger.INFO("To add: "+this.getAmountOfFluidToGenerate()); - //Logger.INFO("Space Free: "+(this.getCapacity()-this.getFluidAmount())); + if (this.getCapacity()-this.getFluidAmount() > 0) { + //Logger.INFO("Total Space: "+this.getCapacity()); + //Logger.INFO("Current amount: "+this.getFluidAmount()); + //Logger.INFO("To add: "+this.getAmountOfFluidToGenerate()); + //Logger.INFO("Space Free: "+(this.getCapacity()-this.getFluidAmount())); + } if (this.mFluid == null || (this.mFluid != null && (this.getCapacity() - this.getFluidAmount() >= this.getAmountOfFluidToGenerate()))) { return true; } @@ -218,8 +220,41 @@ public abstract class GT_MetaTileEntity_Hatch_FluidGenerator extends GT_MetaTile @Override public int fill(FluidStack aFluid, boolean doFill) { - return super.fill(aFluid, doFill); - } + if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || aFluid.getFluid() != getFluidToGenerate() || !canTankBeFilled()) { + return 0; + } + + if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { + if (aFluid.amount <= getCapacity()) { + if (doFill) { + setFillableStack(aFluid.copy()); + getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) { + setFillableStack(aFluid.copy()); + getFillableStack().amount = getCapacity(); + getBaseMetaTileEntity().markDirty(); + } + return getCapacity(); + } + + if (!getFillableStack().isFluidEqual(aFluid)) + return 0; + + int space = getCapacity() - getFillableStack().amount; + if (aFluid.amount <= space) { + if (doFill) { + getFillableStack().amount += aFluid.amount; + getBaseMetaTileEntity().markDirty(); + } + return aFluid.amount; + } + if (doFill) + getFillableStack().amount = getCapacity(); + return space; + } @Override public boolean canFill(ForgeDirection aSide, Fluid aFluid) { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java index 2ff2712952..4e63dc8cb3 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -257,6 +257,11 @@ public class TreeFarmHelper { return true; } + + public static boolean isValidForGUI(final ItemStack aStack) { + return isCorrectMachinePart(aStack) != SAWTOOL.NONE; + } + public static SAWTOOL isCorrectMachinePart(final ItemStack aStack) { if (aStack != null){ //Utils.LOG_WARNING("Found "+aStack.getDisplayName()+" in the GUI slot."); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java index f2ebb93b26..3a97df6065 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityTreeFarm.java @@ -15,7 +15,9 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.*; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL; import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.helpers.TreeFarmHelper; @@ -24,6 +26,7 @@ import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import java.util.ArrayList; import java.util.HashMap; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; @@ -37,23 +40,13 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< private ItemStack mTreeType; private int mCasing; private IStructureDefinition<GregtechMetaTileEntityTreeFarm> STRUCTURE_DEFINITION = null; - private HashMap<String, ItemStack> sLogCache = new HashMap<String, ItemStack>(); - + private static HashMap<String, ItemStack> sLogCache = new HashMap<String, ItemStack>(); + + private SAWTOOL mToolType; private ItemStack currSapling; private int currSlot = 0; private GT_MetaTileEntity_Hatch_InputBus currInputBus; - static { - new Thread("GTPP-TreeDataWorker") { - @Override - public void run() { - mTreeData = new TreeGenerator(); - } - }.start(); - } - - private static ItemStack aLeaves; - public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); @@ -77,29 +70,32 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< protected GT_Multiblock_Tooltip_Builder createTooltip() { 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("Add a sapling in the input bus to change wood type output") - .addPollutionAmount(getPollutionPerSecond(null)) - .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(CORE.GT_Tooltip_Builder); + .addInfo("Converts EU to Oak Logs") + .addInfo("Eu Usage: 100% | Parallel: 1") + .addInfo("Requires a Saw or Chainsaw in GUI slot") + .addInfo("Output multiplier:") + .addInfo("Saw = 1x") + .addInfo("Buzzsaw = 2x") + .addInfo("Chainsaw = 4x") + .addInfo("Add a sapling in the input bus to change wood type output") + .addInfo("Tools can also be fed to the controller via input bus") + .addPollutionAmount(getPollutionPerSecond(null)) + .addSeparator() + .beginStructureBlock(3, 3, 3, true) + .addController("Front center") + .addCasingInfo("Sterile Farm Casing", 8) + .addInputBus("Any casing", 1) + .addOutputBus("Any casing", 1) + .addEnergyHatch("Any casing", 1) + .addMaintenanceHatch("Any casing", 1) + .addMufflerHatch("Any casing", 1) + .toolTipFinisher(CORE.GT_Tooltip_Builder); return tt; } - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, - final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID), - TextureFactory.of(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; + return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID), TextureFactory.of(aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced)}; } return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(CASING_TEXTURE_ID)}; } @@ -125,17 +121,21 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< public boolean isCorrectMachinePart(final ItemStack aStack) { // is correct part && either not powered tool or have enough power - return TreeFarmHelper.getPartType(aStack) != null && !GT_ModHandler.isElectricItem(aStack) || GT_ModHandler.canUseElectricItem(aStack, 1); + return TreeFarmHelper.isValidForGUI(aStack) && !GT_ModHandler.isElectricItem(aStack) || GT_ModHandler.canUseElectricItem(aStack, 1); } public boolean checkRecipe(final ItemStack aStack) { - if (aStack == null && !replaceTool()) + if (aStack == null && !replaceTool()) { // no tool return false; - if (!isCorrectMachinePart(aStack)) + } + if (!isCorrectMachinePart(aStack)) { // not a tool return false; + } + mToolType = TreeFarmHelper.isCorrectMachinePart(aStack); + int aModifier = mToolType == SAWTOOL.SAW ? 1 : mToolType == SAWTOOL.BUZZSAW ? 2 : mToolType == SAWTOOL.CHAINSAW ? 4 : 0; long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); @@ -156,67 +156,29 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< this.mMaxProgresstime /= 2; } } - if (this.mEUt > 0) { this.mEUt = (-this.mEUt); } - - /* Old Methods with FakeWorld - int aChance = MathUtils.randInt(0, 10); - - try { - if (aChance < 8) { - ItemStackMap<Integer> allOutputs = new ItemStackMap<>(); - if (aLeaves == null) - aLeaves = ItemUtils.getSimpleStack(Blocks.leaves); - //1% Chance per Tick - for (int u = 0; u < (Math.max(4, (MathUtils.randInt((3 * tTier), 100) * tTier * tTier) / 14)); u++) { - AutoMap<ItemStack> aOutputs = mTreeData.generateOutput(0); - if (aOutputs.size() > 0) { - for (ItemStack aOutputItemStack : aOutputs) { - if (!GT_Utility.areStacksEqual(aLeaves, aOutputItemStack)) { - Integer oldStackSize = allOutputs.get(aOutputItemStack); - int oldStackSizeUnboxed = oldStackSize == null ? 0 : oldStackSize; - allOutputs.put(aOutputItemStack, oldStackSizeUnboxed + aOutputItemStack.stackSize); - } - } - } - } - - mOutputItems = allOutputs.entries().stream() - .map(e -> { - e.key.stackSize = e.value; - return e.key; - }).toArray(ItemStack[]::new); - } - } catch (Throwable t) { - t.printStackTrace(GT_Log.err); - */ getWoodFromSapling(); try { - int outputAmount = ((2 * (tTier * tTier)) - (2 * tTier) + 5)*(mMaxProgresstime/20); - int lastStack = outputAmount % 64; - mTreeType.stackSize = 64; - for (int i = 0; i < (outputAmount - lastStack) / 64; i++) { - this.addOutput(mTreeType); + int aOutputAmount = ((2 * (tTier * tTier)) - (2 * tTier) + 5)*(mMaxProgresstime/20) * aModifier; + int aFullStacks = aOutputAmount / 64; + for (int i = 0; i < aFullStacks; i++) { + this.addOutput(ItemUtils.getSimpleStack(mTreeType, 64)); + aOutputAmount -= 64; } - mTreeType.stackSize = lastStack; - this.addOutput(mTreeType); + this.addOutput(ItemUtils.getSimpleStack(mTreeType, aOutputAmount)); this.updateSlots(); } catch (Throwable t) { t.printStackTrace(GT_Log.err); } return true; } - @Override - public boolean checkHatch() { - return super.checkHatch() && mEnergyHatches.size() == 1; - } @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mCasing = 0; - return checkPiece(mName, 1, 1, 0) && mCasing >= 10 - 8 && checkHatch(); + return checkPiece(mName, 1, 1, 0) && mCasing >= 8 && checkHatch(); } @Override @@ -232,27 +194,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< @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(); + 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; } @@ -260,7 +202,8 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< public final boolean addTreeFarmList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { if (aTileEntity == null) { return false; - } else { + } + else { return addToMachineList(aTileEntity, aBaseCasingIndex); } } @@ -281,35 +224,51 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< return false; } + private int mPossibleRecursion = 0; public boolean replaceTool() { + if (mPossibleRecursion > 32) { + mPossibleRecursion = 0; + return false; + } 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.getPartType(uStack) != null) { - this.setGUIItemStack(uStack); - return true; - } + ArrayList<ItemStack> aInputs = getStoredInputs(); + for (ItemStack aStack : aInputs) { + if (aStack != null && isCorrectMachinePart(aStack)) { + this.setGUIItemStack(aStack.copy()); + this.depleteInput(aStack); + mPossibleRecursion = 0; + return true; } } } + else { + if (GT_ModHandler.isElectricItem(invItem)) { + if (ic2.api.item.ElectricItem.manager.getCharge(invItem) < 32) { + this.addOutput(invItem.copy()); + this.setGUIItemStack(null); + mPossibleRecursion++; + return replaceTool(); + } + } + } + mPossibleRecursion = 0; return false; } public void getWoodFromSapling() { - if(sLogCache.size() == 0) + if (sLogCache.size() == 0) { loadMapWoodFromSapling(); - - if(this.currSapling != null && this.currInputBus != null){ + } + if (this.currSapling != null && this.currInputBus != null) { ItemStack uStack = this.currInputBus.mInventory[this.currSlot]; - if(uStack == this.currSapling) + if (uStack == this.currSapling) return; } 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) { + if (uStack != null) { String registryName = Item.itemRegistry.getNameForObject(uStack.getItem()); ItemStack aWood = sLogCache.get(registryName + ":" + uStack.getItemDamage()); if (aWood != null) { @@ -321,54 +280,60 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< } } } - this.mTreeType = new ItemStack(Blocks.log, 1,0); //default to oak wood + this.mTreeType = new ItemStack(Blocks.log, 1, 0); } } public void loadMapWoodFromSapling() { - //minecraft - sLogCache.put("minecraft:sapling:0", new ItemStack(Blocks.log, 1, 0)); //oak - sLogCache.put("minecraft:sapling:1", new ItemStack(Blocks.log, 1, 1)); //spruce - sLogCache.put("minecraft:sapling:2", new ItemStack(Blocks.log, 1, 2)); //birch - sLogCache.put("minecraft:sapling:3", new ItemStack(Blocks.log, 1, 3)); //jungle - sLogCache.put("minecraft:sapling:4", new ItemStack(Blocks.log2, 1, 0)); //acacia - sLogCache.put("minecraft:sapling:5", new ItemStack(Blocks.log2, 1, 1)); //dark oak - - //galaxySpace - sLogCache.put("GalaxySpace:barnardaCsapling:0", GT_ModHandler.getModItem("GalaxySpace", "barnardaClog", 1)); //barnarda c - - //ic2 - sLogCache.put("IC2:blockRubSapling:0", GT_ModHandler.getModItem("IC2", "blockRubWood", 1)); //rubber - - //natura - sLogCache.put("Natura:florasapling:1", GT_ModHandler.getModItem("Natura","tree", 1, 0)); //eucalyptus - sLogCache.put("Natura:florasapling:2", GT_ModHandler.getModItem("Natura","tree", 1, 3)); //hopseed - sLogCache.put("Natura:florasapling:3", GT_ModHandler.getModItem("Natura","tree", 1, 1)); //sakura - sLogCache.put("Natura:florasapling:4", GT_ModHandler.getModItem("Natura","tree", 1, 2)); //ghostwood - sLogCache.put("Natura:florasapling:5", GT_ModHandler.getModItem("Natura","bloodwood", 1, 0)); //bloodwood - sLogCache.put("Natura:florasapling:6", GT_ModHandler.getModItem("Natura","Dark Tree", 1, 0)); //darkwood - sLogCache.put("Natura:florasapling:7", GT_ModHandler.getModItem("Natura","Dark Tree", 1, 1)); //fusewood - - sLogCache.put("Natura:Rare Sapling:0", GT_ModHandler.getModItem("Natura","Rare Tree", 1, 0)); //maple - sLogCache.put("Natura:Rare Sapling:1", GT_ModHandler.getModItem("Natura","Rare Tree", 1, 1)); //silverbell - sLogCache.put("Natura:Rare Sapling:2", GT_ModHandler.getModItem("Natura","Rare Tree", 1, 2)); //amaranth - sLogCache.put("Natura:Rare Sapling:3", GT_ModHandler.getModItem("Natura","Rare Tree", 1, 3)); //tigerwood - sLogCache.put("Natura:Rare Sapling:4", GT_ModHandler.getModItem("Natura","willow", 1, 0)); //willow - - //TConstruct - sLogCache.put("TConstruct:slime.sapling:0", GT_ModHandler.getModItem("TConstruct","slime.gel", 1)); //green slime blocks - - //TaintedMagic - sLogCache.put("TaintedMagic:BlockWarpwoodSapling:0", GT_ModHandler.getModItem("TaintedMagic","BlockWarpwoodLog", 1)); //warpwood - - //Thaumcraft - sLogCache.put("Thaumcraft:blockCustomPlant:0", GT_ModHandler.getModItem("Thaumcraft","blockMagicalLog", 1, 0)); //greatwood - sLogCache.put("Thaumcraft:blockCustomPlant:1", GT_ModHandler.getModItem("Thaumcraft","blockMagicalLog", 1, 1)); //silverwood - - //gt++ - sLogCache.put("miscutils:blockRainforestOakSapling:0", GT_ModHandler.getModItem("miscutils","blockRainforestOakLog", 1)); //gt++ rainforest - sLogCache.put("miscutils:blockPineSapling:0", GT_ModHandler.getModItem("miscutils","blockPineLogLog", 1)); //gt++ pine + // minecraft + sLogCache.put("minecraft:sapling:0", new ItemStack(Blocks.log, 1, 0)); // oak + sLogCache.put("minecraft:sapling:1", new ItemStack(Blocks.log, 1, 1)); // spruce + sLogCache.put("minecraft:sapling:2", new ItemStack(Blocks.log, 1, 2)); // birch + sLogCache.put("minecraft:sapling:3", new ItemStack(Blocks.log, 1, 3)); // jungle + sLogCache.put("minecraft:sapling:4", new ItemStack(Blocks.log2, 1, 0)); // acacia + sLogCache.put("minecraft:sapling:5", new ItemStack(Blocks.log2, 1, 1)); // dark + // oak + + // galaxySpace + sLogCache.put("GalaxySpace:barnardaCsapling:0", GT_ModHandler.getModItem("GalaxySpace", "barnardaClog", 1)); // barnarda + // c + + // ic2 + sLogCache.put("IC2:blockRubSapling:0", GT_ModHandler.getModItem("IC2", "blockRubWood", 1)); // rubber + + // natura + sLogCache.put("Natura:florasapling:1", GT_ModHandler.getModItem("Natura", "tree", 1, 0)); // eucalyptus + sLogCache.put("Natura:florasapling:2", GT_ModHandler.getModItem("Natura", "tree", 1, 3)); // hopseed + sLogCache.put("Natura:florasapling:3", GT_ModHandler.getModItem("Natura", "tree", 1, 1)); // sakura + sLogCache.put("Natura:florasapling:4", GT_ModHandler.getModItem("Natura", "tree", 1, 2)); // ghostwood + sLogCache.put("Natura:florasapling:5", GT_ModHandler.getModItem("Natura", "bloodwood", 1, 0)); // bloodwood + sLogCache.put("Natura:florasapling:6", GT_ModHandler.getModItem("Natura", "Dark Tree", 1, 0)); // darkwood + sLogCache.put("Natura:florasapling:7", GT_ModHandler.getModItem("Natura", "Dark Tree", 1, 1)); // fusewood + + sLogCache.put("Natura:Rare Sapling:0", GT_ModHandler.getModItem("Natura", "Rare Tree", 1, 0)); // maple + sLogCache.put("Natura:Rare Sapling:1", GT_ModHandler.getModItem("Natura", "Rare Tree", 1, 1)); // silverbell + sLogCache.put("Natura:Rare Sapling:2", GT_ModHandler.getModItem("Natura", "Rare Tree", 1, 2)); // amaranth + sLogCache.put("Natura:Rare Sapling:3", GT_ModHandler.getModItem("Natura", "Rare Tree", 1, 3)); // tigerwood + sLogCache.put("Natura:Rare Sapling:4", GT_ModHandler.getModItem("Natura", "willow", 1, 0)); // willow + + // TConstruct + sLogCache.put("TConstruct:slime.sapling:0", GT_ModHandler.getModItem("TConstruct", "slime.gel", 1)); // green + // slime + // blocks + + // TaintedMagic + sLogCache.put("TaintedMagic:BlockWarpwoodSapling:0", GT_ModHandler.getModItem("TaintedMagic", "BlockWarpwoodLog", 1)); // warpwood + + // Thaumcraft + sLogCache.put("Thaumcraft:blockCustomPlant:0", GT_ModHandler.getModItem("Thaumcraft", "blockMagicalLog", 1, 0)); // greatwood + sLogCache.put("Thaumcraft:blockCustomPlant:1", GT_ModHandler.getModItem("Thaumcraft", "blockMagicalLog", 1, 1)); // silverwood + + // gt++ + sLogCache.put("miscutils:blockRainforestOakSapling:0", GT_ModHandler.getModItem("miscutils", "blockRainforestOakLog", 1)); // gt++ + // rainforest + sLogCache.put("miscutils:blockPineSapling:0", GT_ModHandler.getModItem("miscutils", "blockPineLogLog", 1)); // gt++ + // pine } public boolean tryDamageTool(ItemStack invItem) { @@ -376,7 +341,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) { - return GT_ModHandler.damageOrDechargeItem(invItem, 1, 0, null); + return GT_ModHandler.damageOrDechargeItem(invItem, 1, 32, null); } } return false; @@ -391,11 +356,10 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< } if (CORE.RANDOM.nextInt(200) == 0) { if (!tryDamageTool(tSaw)) { - if (tSaw.getItem().isDamageable()) - addOutput(tSaw); this.mInventory[1] = null; - if (!replaceTool()) + if (!replaceTool()) { this.getBaseMetaTileEntity().disableWorking(); + } tryDamageTool(tSaw); } } @@ -410,6 +374,6 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase< @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - buildPiece(mName , stackSize, hintsOnly, 1, 1, 0); + buildPiece(mName, stackSize, hintsOnly, 1, 1, 0); } } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java index 5d6ba7f2eb..e8380d2748 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_LargeRocketEngine.java @@ -15,6 +15,7 @@ import gregtech.api.metatileentity.implementations.*; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.*; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.item.chemistry.RocketFuels; import gtPlusPlus.core.lib.*; @@ -111,52 +112,13 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi {"C~C", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "SIS", "CMC"}, {"CCC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CSC", "CCC"}, })) - .addElement( - 'C', - ofBlock( - getCasingBlock(), getCasingMeta() - ) - ) - .addElement( - 'I', - ofBlock( - getGearboxBlock(), getGearboxMeta() - ) - ) - .addElement( - 'T', - ofChain( - ofHatchAdder( - GregtechMetaTileEntity_LargeRocketEngine::addLargeRocketEngineTopList, getCasingTextureIndex(), 2 - ), - onElementPass( - x -> ++x.mCasing, - ofBlock( - getCasingBlock(), getCasingMeta() - ) - ) - ) - ) - .addElement( - 'S', - ofChain( - ofHatchAdder( - GregtechMetaTileEntity_LargeRocketEngine::addLargeRocketEngineSideList, getCasingTextureIndex(), 1 - ), - onElementPass( - x -> ++x.mCasing, - ofBlock( - getCasingBlock(), getCasingMeta() - ) - ) - ) - ) - .addElement( - 'M', - ofHatchAdder( - GregtechMetaTileEntity_LargeRocketEngine::addLargeRocketEngineBackList, getCasingTextureIndex(), 3 - ) - ) + .addElement('C', ofBlock(getCasingBlock(), getCasingMeta())) + .addElement('I', ofBlock(getGearboxBlock(), getGearboxMeta())) + .addElement('T', ofChain(ofHatchAdder(GregtechMetaTileEntity_LargeRocketEngine::addLargeRocketEngineTopList, getCasingTextureIndex(), 2), + onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement('S', ofChain(ofHatchAdder(GregtechMetaTileEntity_LargeRocketEngine::addLargeRocketEngineSideList, getCasingTextureIndex(), 1), + onElementPass(x -> ++x.mCasing, ofBlock(getCasingBlock(), getCasingMeta())))) + .addElement('M', ofHatchAdder(GregtechMetaTileEntity_LargeRocketEngine::addLargeRocketEngineBackList, getCasingTextureIndex(), 3)) .build(); } return this.STRUCTURE_DEFINITION; @@ -270,7 +232,6 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi int totalAir = 0; for (GT_MetaTileEntity_Hatch_AirIntake u : this.mAirIntakes) { if (u != null && u.mFluid != null) { - // had this trow errors cousing the machine to stop probebly fixed FluidStack f = u.mFluid; if (f.isFluidEqual(sAirFluidStack)) { totalAir += f.amount; @@ -289,51 +250,84 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi @Override public boolean checkRecipe(final ItemStack aStack) { final ArrayList<FluidStack> tFluids = this.getStoredFluids(); - + this.clearRecipeMapForAllInputHatches(); int aircount = getAir() ; - if (aircount < this.euProduction/100) { - //log("Not Enough Air to Run "+aircount); + int aAirToConsume = this.euProduction/100; + if (aircount < aAirToConsume) { + log("Not Enough Air to Run "+aircount); return false; } else { - boolean hasIntakeAir = this.depleteInput(FluidUtils.getFluidStack(sAirFluid, this.euProduction/100)); - if (!hasIntakeAir) { - //log("Could not consume Air to run "+aircount); - this.freeFuelTicks = 0; - return false; + int aTotalAir = 0; + for (GT_MetaTileEntity_Hatch_AirIntake aAirHatch : this.mAirIntakes) { + if (aAirHatch.mFluid != null) { + aTotalAir += aAirHatch.getFluidAmount(); + } + } + log("Total Air: "+aTotalAir); + if (aTotalAir >= aAirToConsume) { + int aSplitAmount = (aAirToConsume / this.mAirIntakes.size()); + if (aSplitAmount > 0) { + for (GT_MetaTileEntity_Hatch_AirIntake aAirHatch : mAirIntakes) { + boolean hasIntakeAir = aAirHatch.drain(aSplitAmount, true) != null; + if (!hasIntakeAir) { + log("Could not consume Air to run "+aSplitAmount); + this.freeFuelTicks = 0; + return false; + } + log("Consumed Air to run "+aSplitAmount); + } + } } } - // reste fuel ticks incase it does not reset when it stops + // reset fuel ticks in case it does not reset when it stops if (this.freeFuelTicks != 0 && this.mProgresstime == 0 && this.mEfficiency == 0) this.freeFuelTicks = 0; - //log("Running "+aircount); + log("Running "+aircount); log("looking at hatch"); if (tFluids.size() > 0 && getRecipeMap() != null) { - - if (tFluids.contains(MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1)) || tFluids.contains(FluidUtils.getFluidStack("carbondioxide", (this.boostEu ? 3 : 1)))) { + FluidStack aCO2 = MISC_MATERIALS.CARBON_DIOXIDE.getFluidStack(this.boostEu ? 3 : 1); + FluidStack aCO2Fallback = FluidUtils.getWildcardFluidStack("carbondioxide", (this.boostEu ? 3 : 1)); + + + boolean aHasCO2 = false; + for (FluidStack aFluid : tFluids) { + if (aCO2 != null && aFluid.isFluidEqual(aCO2)) { + log("Found CO2 (1)"); + aHasCO2 = true; + break; + } + if (aCO2Fallback != null && aFluid.isFluidEqual(aCO2Fallback)) { + log("Found CO2 (2)"); + aHasCO2 = true; + break; + } + log("Found: "+aFluid.getUnlocalizedName()); + } + if (aHasCO2) { if (this.mRuntime % 72 == 0 || this.mRuntime == 0) { if (!consumeCO2()) { this.freeFuelTicks = 0; + log("Bad Return 1"); return false; } } - } else - { + } + else { this.freeFuelTicks = 0; + log("Bad Return 2 | "+aHasCO2+" | "+(aCO2 != null)+" | "+(aCO2Fallback != null)); return false; } - - if (this.freeFuelTicks == 0) + if (this.freeFuelTicks == 0) { this.boostEu = consumeLOH(); - + } for (final FluidStack hatchFluid1 : tFluids) { if (hatchFluid1.isFluidEqual(sAirFluidStack)) { continue; } - if (this.freeFuelTicks == 0) { for (final GT_Recipe aFuel : getRecipeMap().mRecipeList) { final FluidStack tLiquid; @@ -349,12 +343,10 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi this.mMaxProgresstime = 1; this.mEfficiencyIncrease = this.euProduction/2000; return true; - //log(""); } } - - } else - { + } + else { this.mEfficiencyIncrease = this.euProduction/2000; this.freeFuelTicks--; this.mEUt = (int) ((this.mEfficiency < 1000) ? 0 : GT_Values.V[5]<<1); @@ -362,12 +354,12 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi this.mMaxProgresstime = 1; return true; } - } } this.mEUt = 0; this.mEfficiency = 0; this.freeFuelTicks = 0; + log("Bad Return 3"); return false; } @@ -398,13 +390,13 @@ public class GregtechMetaTileEntity_LargeRocketEngine extends GregtechMeta_Multi public void setEUProduction(int energy){ energy /= 20; double energyEfficiency; - double tDevideEnergy = Math.cbrt(energy); + double tDivideEnergy = Math.cbrt(energy); if (energy > 10000) { //cbrt(10 000) / - energyEfficiency = (21.5443469/tDevideEnergy); + energyEfficiency = (21.5443469/tDivideEnergy); if (energy >= 40000) //cbrt(40 000) / - energyEfficiency *= (34.19951893/tDevideEnergy); + energyEfficiency *= (34.19951893/tDivideEnergy); energyEfficiency *= energy; } else { |