From ac33a276db6419087e6fd209e2c025cf06622709 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Wed, 18 Jan 2017 12:22:41 +1000 Subject: + Added ItemStack[] getBlockDrops(ArrayList blockDrops) to ItemUtils.java. % More Tree Farmer Logic improvements. --- src/Java/gtPlusPlus/core/util/item/ItemUtils.java | 46 ++++++++++++++-------- .../multi/GregtechMetaTileEntityTreeFarm.java | 41 +++++++++++++------ 2 files changed, 60 insertions(+), 27 deletions(-) (limited to 'src/Java') diff --git a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java index 140d3511a1..468940ac59 100644 --- a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java @@ -311,7 +311,7 @@ public class ItemUtils { ToolMaterial customMaterial = Utils.generateToolMaterial(material); return generateMultiPick(true, customMaterial, material.getLocalizedName(), (int) material.vDurability, material.getRGBA()); } - + public static MultiPickaxeBase generateMultiPick(boolean GT_Durability, ToolMaterial customMaterial, String name, int durability, short[] rgba){ Utils.LOG_INFO("Generating a Multi-Pick out of "+name); short[] rgb = rgba; @@ -342,17 +342,17 @@ public class ItemUtils { Utils.LOG_INFO("Pickaxe was not valid."); return null; } - - - - - - + + + + + + public static MultiSpadeBase generateMultiShovel(boolean GT_Durability, Materials material){ ToolMaterial customMaterial = Utils.generateToolMaterialFromGT(material); return generateMultiShovel(GT_Durability, customMaterial, material.mDefaultLocalName, material.mDurability, material.mRGBa); } - + public static MultiSpadeBase generateMultiShovel(Material material){ ToolMaterial customMaterial = Utils.generateToolMaterial(material); return generateMultiShovel(true, customMaterial, material.getLocalizedName(), (int) material.vDurability, material.getRGBA()); @@ -389,14 +389,14 @@ public class ItemUtils { } - - - - - - - - + + + + + + + + public static BaseItemDecidust generateDecidust(Materials material){ @@ -505,5 +505,19 @@ public class ItemUtils { public static ItemStack getGregtechCircuit(int Meta){ return ItemUtils.getItemStackWithMeta(LoadedMods.Gregtech, "gregtech:gt.integrated_circuit", "Gregtech Circuit", Meta, 0); } + public static ItemStack[] getBlockDrops(ArrayList blockDrops) { + if (blockDrops == null){ + return null; + } + if (blockDrops.isEmpty()){ + return null; + } + ItemStack outputs[] = new ItemStack[blockDrops.size()]; + short forCounter = 0; + for (ItemStack I : blockDrops){ + outputs[forCounter] = I; + } + return outputs; + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java index 0587c26b85..e93a5496ff 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityTreeFarm.java @@ -330,7 +330,6 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock if (mMachine){ //Set Machine State if (treeCheckTicks == 200){ - //mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); Utils.LOG_INFO("Looking For Trees - Serverside | "+treeCheckTicks); //Find wood to Cut findLogs(aBaseMetaTileEntity); @@ -347,7 +346,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock //Try Grow some Saplings findSaplings(aBaseMetaTileEntity); //Set can work state - mMachine = true; + mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); } } //Call Cleanup Task last, before ticking. @@ -379,7 +378,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock //Farm Inner 13*13 if (TreefarmManager.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)) || TreefarmManager.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))){ //Utils.LOG_INFO("Found A log of some kind I can chop."); - if (this.mEnergyHatches != null) { + if (this.mEnergyHatches.size() > 0) { for (final GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches){ if (isValidMetaTileEntity(tHatch)) { //Utils.LOG_INFO("Hatch ["+"]| can hold:"+maxEUStore()+" | holding:"+tHatch.getEUVar()); @@ -477,6 +476,21 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock Utils.LOG_INFO("Tried to grow saplings: | "+saplings ); return true; } + + public ArrayList getStoredInputsEx() { + ArrayList rList = new ArrayList(); + for (GT_MetaTileEntity_Hatch_InputBus tHatch : this.mInputBusses) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch)) { + for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; --i) { + if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) == null) + continue; + rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); + } + } + } + return rList; + } private boolean plantSaplings(final IGregTechTileEntity aBaseMetaTileEntity){ Utils.LOG_INFO("called plantSaplings()"); @@ -516,6 +530,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock saplingToPlace = Block.getBlockFromItem(n.getItem()); } + //If sapling block is not null if (saplingToPlace != null){ @@ -525,7 +540,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock world.setBlockMetadataWithNotify(posX, posY, posZ, n.getItemDamage(), 4); //Deplete Input stack depleteInput(n); - r = getStoredInputs(); + //r = getStoredInputs(); break; } Utils.LOG_INFO(n.getDisplayName()+" did not have a valid block."); @@ -536,7 +551,7 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock } } else{ - Utils.LOG_INFO("Input stack empty or null"); + Utils.LOG_INFO("Input stack empty or null - hatch count "+this.mInputBusses.size()); } } else { @@ -557,12 +572,16 @@ public class GregtechMetaTileEntityTreeFarm extends GT_MetaTileEntity_MultiBlock final Block block = world.getBlock(x, y, z); //Add the stack to the bus. - ItemStack outputStack = ItemUtils.getSimpleStack(block); - if (outputStack != null){ - Utils.LOG_INFO("Adding 1x "+outputStack.getDisplayName()); - addOutput(outputStack); - //Update bus contents. - updateSlots(); + int dropMeta = world.getBlockMetadata(x, y, z); + ArrayList blockDrops = block.getDrops(world, x, y, z, dropMeta, 0); + ItemStack[] drops = ItemUtils.getBlockDrops(blockDrops); + if (drops != null){ + for (ItemStack outputs : drops){ + Utils.LOG_INFO("Adding 1x "+outputs.getDisplayName()); + addOutput(outputs); + //Update bus contents. + updateSlots(); + } //Remove drop that was added to the bus. world.setBlockToAir(x, y, z); return true; -- cgit