From ddefc4f7b11a3c0fab7f89416beac017634e58e0 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Wed, 24 Apr 2019 17:55:18 +1000 Subject: % More work on rewriting the Tree Farmer. % Renamed Tree Farmer Casing. % Cleaned up a few imports. $ Fixed assorted minor bugs with Multis. $ Fixed Issue with GT_Utilities via ASM. --- .../common/blocks/GregtechMetaCasingBlocks2.java | 2 +- .../blocks/textures/CasingTextureHandler2.java | 5 +- .../gregtech/common/helpers/TreeFarmHelper.java | 31 ++ .../common/helpers/treefarm/TreeGenerator.java | 152 ++++++-- .../production/GregtechMetaTileEntityTreeFarm.java | 431 +++++++-------------- ...egtechMetaTileEntity_IndustrialFishingPond.java | 3 - ...gtechMetaTileEntity_BedrockMiningPlatform1.java | 2 - ...chMetaTileEntity_BedrockMiningPlatformBase.java | 2 +- 8 files changed, 290 insertions(+), 338 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java index 8dd52c7074..528aed2029 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechMetaCasingBlocks2.java @@ -60,7 +60,7 @@ extends GregtechMetaCasingBlocksAbstract { GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".12.name", "Autocrafter Frame"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".13.name", "Cutting Factory Frame"); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".14.name", "Tesla Containment Casing"); - GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Casing "); //Tree Farmer Textures + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + ".15.name", "Sterile Farm Casing"); //Tree Farmer Textures GregtechItemList.Casing_ThermalCentrifuge.set(new ItemStack(this, 1, 0)); GregtechItemList.Casing_Refinery_External.set(new ItemStack(this, 1, 1)); GregtechItemList.Casing_Refinery_Structural.set(new ItemStack(this, 1, 2)); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java index 8f107b8ab6..1c7109fad2 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java @@ -60,7 +60,8 @@ public class CasingTextureHandler2 { case 14: return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); case 15: - if (aSide <2) { + return TexturesGtBlock.Casing_Machine_Acacia_Log.getIcon(); + /*if (aSide <2) { if (aSide == 1) { return TexturesGtBlock.Casing_Machine_Podzol.getIcon(); } @@ -68,7 +69,7 @@ public class CasingTextureHandler2 { } else { return TexturesGtBlock.Casing_Machine_Farm_Manager.getIcon(); - } + }*/ default: return TexturesGtBlock.Overlay_UU_Matter.getIcon(); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java index 624058f356..a87fac1dfd 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -285,6 +285,37 @@ public class TreeFarmHelper { } return SAWTOOL.NONE; } + + public static boolean isCorrectPart(final ItemStack aStack) { + if (aStack != null){ + //Utils.LOG_WARNING("Found "+aStack.getDisplayName()+" in the GUI slot."); + if ((aStack.getItem() instanceof GT_MetaGenerated_Item_02) || (aStack.getItem() instanceof GT_MetaGenerated_Tool)){ + if (OrePrefixes.craftingTool.contains(aStack)){ + if (aStack.getDisplayName().toLowerCase().contains("saw") || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01")){ + if (aStack.getItemDamage() == 10){ + return true; + } + else if (aStack.getItemDamage() == 140 || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01.140")){ + return true; + } + else if (aStack.getItemDamage() == 110 || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01.110")){ + return true; + } + else if (aStack.getItemDamage() == 112 || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01.112")){ + return true; + } + else if (aStack.getItemDamage() == 114 || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01.114")){ + return true; + } + else { + return false; + } + } + } + } + } + return false; + } public static boolean isHumusLoaded = false; public static boolean isForestryLogsLoaded = false; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java index 7437bf19da..c9f2d493ab 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java @@ -2,10 +2,15 @@ package gtPlusPlus.xmod.gregtech.common.helpers.treefarm; import java.util.Random; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.FakeBlockPos; +import gtPlusPlus.api.objects.minecraft.FakeWorld; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.Block; import net.minecraft.block.BlockSapling; +import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; @@ -15,14 +20,26 @@ import net.minecraftforge.common.util.ForgeDirection; public class TreeGenerator { - public static AutoMap generateOutput(int aTreeSize){ - AutoMap aOutputMap = new AutoMap(); - - - return aOutputMap; + private final FakeTreeInFakeWorldGenerator mTreeData; + + public TreeGenerator() { + Logger.INFO("Created Fake Tree Generator."); + mTreeData = new FakeTreeInFakeWorldGenerator(); + if (!mTreeData.hasGenerated) { + mTreeData.generate(null, CORE.RANDOM, 0, 0, 0); + } + } + + public AutoMap generateOutput(int aTreeSize){ + AutoMap aTemp = new AutoMap(); + AutoMap aOutputMap = mTreeData.getOutputFromTree(); + if (aOutputMap != null && aOutputMap.size() > 0) { + return aOutputMap; + } + return aTemp; } - public class FakeWorldGenerator extends WorldGenAbstractTree + public class FakeTreeInFakeWorldGenerator extends WorldGenAbstractTree { /** The minimum height of a generated tree. */ private final int minTreeHeight; @@ -33,21 +50,29 @@ public class TreeGenerator { /** The metadata value of the leaves to use in tree generation. */ private final int metaLeaves; + private final AutoMap mFakeWorld; + private final int mTreesToGenerate; + + private int mCurrentGeneratorIteration = 0; + private boolean hasGenerated = false; private AutoMap aOutputsFromGenerator = new AutoMap(); - public FakeWorldGenerator() + public FakeTreeInFakeWorldGenerator() { - this(4, 0, 0, false); + this(4, 0, 0, false, 5000); } - public FakeWorldGenerator(int aMinHeight, int aWoodMeta, int aLeafMeta, boolean aVines) + public FakeTreeInFakeWorldGenerator(int aMinHeight, int aWoodMeta, int aLeafMeta, boolean aVines, int aTreeCount) { super(false); this.minTreeHeight = aMinHeight; this.metaWood = aWoodMeta; this.metaLeaves = aLeafMeta; this.vinesGrow = aVines; + this.mFakeWorld = new AutoMap(); + this.mTreesToGenerate = aTreeCount; + Logger.INFO("Created Fake Tree In Fake World Instance."); } @@ -55,17 +80,66 @@ public class TreeGenerator { if (!hasGenerated) { generate(null, CORE.RANDOM, 0, 0, 0); } - return aOutputsFromGenerator; + AutoMap aOutputMap = new AutoMap(); + int aRandomTreeID = MathUtils.randInt(0, this.mFakeWorld.size()-1); + FakeWorld aWorld = this.mFakeWorld.get(aRandomTreeID); + if (aWorld != null) { + aOutputMap = aWorld.getAllBlocksStoredInFakeWorld(); + } + return aOutputMap; + } + @Override + protected boolean func_150523_a(Block p_150523_1_) + { + return p_150523_1_.getMaterial() == Material.air || p_150523_1_.getMaterial() == Material.leaves || p_150523_1_ == Blocks.grass || p_150523_1_ == Blocks.dirt || p_150523_1_ == Blocks.log || p_150523_1_ == Blocks.log2 || p_150523_1_ == Blocks.sapling || p_150523_1_ == Blocks.vine; + } + + @Override + protected boolean isReplaceable(World world, int x, int y, int z) + { + FakeWorld aWorld = getWorld(); + Block block = aWorld.getBlock(x, y, z); + return block.isAir(null, x, y, z) || block.isLeaves(null, x, y, z) || block.isWood(null, x, y, z) || func_150523_a(block); + } @Override - public boolean generate(World aWorld, Random aRand, int aWorldX, int aWorldRealY, int aWorldZ){ - + public boolean generate(World world, Random aRand, int aWorldX, int aWorldRealY, int aWorldZ){ //Only Generate Once - This object is Cached if (hasGenerated) { return hasGenerated; + } + else { + for (int yy=0;yy 0) { + for (FakeWorld aWorld : this.mFakeWorld) { + for (ItemStack aBlockInFakeWorld : aWorld.getAllBlocksStoredInFakeWorld()) { + aOutputsFromGenerator.add(aBlockInFakeWorld); + } + } + return true; + } + else { + return false; + } + } + } + + public FakeWorld getWorld() { + FakeWorld aWorld = this.mFakeWorld.get(mCurrentGeneratorIteration); + if (aWorld == null) { + aWorld = (this.mFakeWorld.set(mCurrentGeneratorIteration, new FakeWorld(200))); } + return aWorld; + } + + public boolean generateTree(int aWorldX, int aWorldRealY, int aWorldZ) { + FakeWorld aWorld = getWorld(); //Set some static values @@ -103,7 +177,7 @@ public class TreeGenerator { { block = aWorld.getBlock(j1, i1, k1); - if (!this.isReplaceable(aWorld, j1, i1, k1)) + if (!this.isReplaceable(null, j1, i1, k1)) { flag = false; } @@ -123,11 +197,12 @@ public class TreeGenerator { else { Block block2 = aWorld.getBlock(aWorldX, aWorldY - 1, aWorldZ); + FakeBlockPos aBlockToGrowPlantOn = aWorld.getBlockAtCoords(aWorldX, aWorldY-1, aWorldZ); boolean isSoil = block2.canSustainPlant(aWorld, aWorldX, aWorldY - 1, aWorldZ, ForgeDirection.UP, (BlockSapling)Blocks.sapling); if (isSoil && aWorldY < 256 - l - 1) { - block2.onPlantGrow(aWorld, aWorldX, aWorldY - 1, aWorldZ, aWorldX, aWorldY, aWorldZ); + aBlockToGrowPlantOn.onPlantGrow(aWorld, aWorldX, aWorldY - 1, aWorldZ, aWorldX, aWorldY, aWorldZ); b0 = 3; byte b1 = 0; int l1; @@ -152,7 +227,7 @@ public class TreeGenerator { { Block block1 = aWorld.getBlock(i2, k1, k2); - if (block1.isAir(aWorld, i2, k1, k2) || block1.isLeaves(aWorld, i2, k1, k2)) + if (block1.isAir(null, i2, k1, k2) || block1.isLeaves(null, i2, k1, k2)) { this.setBlockAndNotifyAdequately(aWorld, i2, k1, k2, Blocks.leaves, this.metaLeaves); } @@ -165,7 +240,7 @@ public class TreeGenerator { { block = aWorld.getBlock(aWorldX, aWorldY + k1, aWorldZ); - if (block.isAir(aWorld, aWorldX, aWorldY + k1, aWorldZ) || block.isLeaves(aWorld, aWorldX, aWorldY + k1, aWorldZ)) + if (block.isAir(null, aWorldX, aWorldY + k1, aWorldZ) || block.isLeaves(null, aWorldX, aWorldY + k1, aWorldZ)) { this.setBlockAndNotifyAdequately(aWorld, aWorldX, aWorldY + k1, aWorldZ, Blocks.log, this.metaWood); @@ -205,24 +280,24 @@ public class TreeGenerator { { for (j2 = aWorldZ - l1; j2 <= aWorldZ + l1; ++j2) { - if (aWorld.getBlock(i2, k1, j2).isLeaves(aWorld, i2, k1, j2)) + if (aWorld.getBlock(i2, k1, j2).isLeaves(null, i2, k1, j2)) { - if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2 - 1, k1, j2).isAir(aWorld, i2 - 1, k1, j2)) + if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2 - 1, k1, j2).isAir(null, i2 - 1, k1, j2)) { this.growVines(aWorld, i2 - 1, k1, j2, 8); } - if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2 + 1, k1, j2).isAir(aWorld, i2 + 1, k1, j2)) + if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2 + 1, k1, j2).isAir(null, i2 + 1, k1, j2)) { this.growVines(aWorld, i2 + 1, k1, j2, 2); } - if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2, k1, j2 - 1).isAir(aWorld, i2, k1, j2 - 1)) + if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2, k1, j2 - 1).isAir(null, i2, k1, j2 - 1)) { this.growVines(aWorld, i2, k1, j2 - 1, 1); } - if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2, k1, j2 + 1).isAir(aWorld, i2, k1, j2 + 1)) + if (CORE.RANDOM.nextInt(4) == 0 && aWorld.getBlock(i2, k1, j2 + 1).isAir(null, i2, k1, j2 + 1)) { this.growVines(aWorld, i2, k1, j2 + 1, 4); } @@ -246,8 +321,6 @@ public class TreeGenerator { } } } - - hasGenerated = true; return true; } else @@ -262,32 +335,27 @@ public class TreeGenerator { } } - /** + /** * Grows vines downward from the given block for a given length. Args: World, x, starty, z, vine-length */ - private void growVines(World aWorld, int aX, int aY, int aZ, int aMeta) + private void growVines(FakeWorld aWorld, int aX, int aY, int aZ, int aMeta) { - this.setBlockAndNotifyAdequately(aWorld, aX, aY, aZ, Blocks.vine, aMeta); - int i1 = 4; - - while (true) - { - --aY; - - if (!aWorld.getBlock(aX, aY, aZ).isAir(aWorld, aX, aY, aZ) || i1 <= 0) - { - return; - } - - this.setBlockAndNotifyAdequately(aWorld, aX, aY, aZ, Blocks.vine, aMeta); - --i1; + int aLoopSize = vinesGrow ? MathUtils.randInt(0, 4) : 0; + for (int i=0;i= 0 && aMeta <= Short.MAX_VALUE)) { + aWorld.setBlockAtCoords(aX, aY, aZ, aBlock, aMeta); + //aOutputsFromGenerator.put(ItemUtils.simpleMetaStack(aBlock, aMeta, 1)); + } } } 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 9081e6bc64..5968ea189c 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,48 +1,58 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.objects.GT_ItemStack; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL; -import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_TreeFarmer; -import gtPlusPlus.xmod.gregtech.api.gui.GUI_TreeFarmer; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.minecraft.FluidUtils; +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; +import gtPlusPlus.xmod.gregtech.common.helpers.treefarm.TreeGenerator; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase { - public final static int TEX_INDEX = 31; - protected boolean mIsCurrentlyWorking = false; - - - + public static int CASING_TEXTURE_ID; + public static String mCryoFuelName = "Gelid Cryotheum"; + public static String mCasingName = "Advanced Cryogenic Casing"; + public static String mHatchName = "Cryotheum Hatch"; + public static FluidStack mFuelStack; + public static TreeGenerator mTreeData; public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); + mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); + CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); + mCryoFuelName = mFuelStack.getLocalizedName(); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); } public GregtechMetaTileEntityTreeFarm(final String aName) { super(aName); + mFuelStack = FluidUtils.getFluidStack("cryotheum", 1); + CASING_TEXTURE_ID = TAE.getIndexFromPage(1, 15); + mCryoFuelName = mFuelStack.getLocalizedName(); + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); } - public boolean isCurrentlyWorking() { - return this.mIsCurrentlyWorking; + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (IMetaTileEntity) new GregtechMetaTileEntityTreeFarm(this.mName); } @Override @@ -50,206 +60,106 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase return "Tree Farm"; } - @Override public String[] getTooltip() { - return new String[]{ - "THIS MULTIBLOCK IS DISABLED - DO NOT BUILD", - }; - } - - @Override - public long maxEUStore() { - return 3244800; //13*13*150*128 - } - @Override - public boolean drainEnergyInput(final long aEU) { - if (aEU <= 0L) { - return true; + if (mCasingName.toLowerCase().contains(".name")) { + mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); } - - //Special Override, so that this function uses internally stored power first. - if (this.getEUVar() >= aEU) { - this.setEUVar(this.getEUVar()-aEU); - return true; + if (mCryoFuelName.toLowerCase().contains(".")) { + mCryoFuelName = FluidUtils.getFluidStack("cryotheum", 1).getLocalizedName(); } - - for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { - if (isValidMetaTileEntity((MetaTileEntity) tHatch) - && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)) { - return true; - } + if (mHatchName.toLowerCase().contains(".name")) { + mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); } - return false; + + return new String[]{ + "Factory Grade Tree Growth Simulator", + "Speed: Very Fast | Eu Usage: 100% | Parallel: 1", + //"Consumes 1L of "+mCryoFuelName+"/t during operation", + "Constructed exactly the same as a normal Vacuum Freezer", + "Use "+mCasingName+"s (10 at least!)", + "1x " + mHatchName + " (Required)", + "TAG_HIDE_HATCHES" + }; } - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == 0) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log)}; + 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.CASING_BLOCKS[CASING_TEXTURE_ID], + new GT_RenderedTexture((IIconContainer) (aActive ? TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active : TexturesGtBlock.Overlay_Machine_Controller_Advanced))}; } - if (aSide == 1) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log), new GT_RenderedTexture(isCurrentlyWorking() ? TexturesGtBlock.Overlay_Machine_Vent_Fast : TexturesGtBlock.Overlay_Machine_Vent)}; - } - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; - } - - @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { - return null; - } - - - @Override - public void loadNBTData(NBTTagCompound arg0) { - super.loadNBTData(arg0); - } - - - @Override - public void saveNBTData(NBTTagCompound arg0) { - super.saveNBTData(arg0); - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean allowCoverOnSide(final byte aSide, final GT_ItemStack aCoverID) { - return (GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover()) && (super.allowCoverOnSide(aSide, aCoverID)); - } - - @Override - public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaTileEntityTreeFarm(this.mName); + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID]}; } @Override public boolean hasSlotInGUI() { return true; } - - @Override - public String getCustomGUIResourceName() { - return "TreeFarmer"; - } - - @Override - public Object getClientGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new GUI_TreeFarmer(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "TreeFarmer.png"); - } - - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_TreeFarmer(aPlayerInventory, aBaseMetaTileEntity); - } - + @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide() || aBaseMetaTileEntity.getWorld().isRemote) { - Logger.WARNING("Doing nothing Client Side."); - return false; - } - aBaseMetaTileEntity.openGUI(aPlayer); + public boolean requiresVanillaGtGUI() { return true; } - public Block getCasingBlock() { - return ModBlocks.blockCasings2Misc; - } - - - public byte getCasingMeta() { - return 15; - } - - - public byte getCasingTextureIndex() { - return (byte) TAE.GTPP_INDEX(31); - } - - @Override - public int getMaxEfficiency(ItemStack p0) { - return 10000; - } - @Override - public String[] getExtraInfoData() { - String[] mSuper = new String[0]; - String[] mDesc = new String[mSuper.length+1]; - mDesc[0] = "Yggdrasil"; // Machine name - for (int i=0;i 0) { - for (GT_MetaTileEntity_Hatch_Energy j : this.mEnergyHatches) { - //Logger.INFO(""+j.getInputTier()); - if (this.getEUVar() <= (this.maxEUStore()-GT_Values.V[(int) j.getInputTier()])) { - this.setEUVar(this.getEUVar()+GT_Values.V[(int) j.getInputTier()]); - j.setEUVar(j.getEUVar()-GT_Values.V[(int) j.getInputTier()]); - } - else if (this.getEUVar() > (this.maxEUStore()-GT_Values.V[(int) j.getInputTier()])) { - long diff = (this.maxEUStore()-this.getEUVar()); - this.setEUVar(this.getEUVar()+diff); - j.setEUVar(j.getEUVar()-diff); - } + public boolean isCorrectMachinePart(final ItemStack aStack) { + return TreeFarmHelper.isCorrectPart(aStack); + } + + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(final ItemStack aStack) { + Logger.INFO("Trying to process virtual tree farming"); + if (mTreeData != null) { + Logger.INFO("Tree Data is valid"); + this.getBaseMetaTileEntity().enableWorking(); + this.mMaxProgresstime = 100; + this.mEUt = -500; + this.mEfficiencyIncrease = 10000; + + int aChance = MathUtils.randInt(0, 10000); + AutoMap aOutputs = new AutoMap(); + + try { + Logger.INFO("Output Chance - "+aChance+" | Valid number? "+(aChance < 100)); + if (aChance < 100) { + //1% Chance per Tick + aOutputs = mTreeData.generateOutput(0); + if (aOutputs.size() > 0) { + Logger.INFO("Generated some Loot, adding it to the output busses"); + for (ItemStack aOutputItemStack : aOutputs) { + this.addOutput(aOutputItemStack); } + Logger.INFO("Updating Slots"); + this.updateSlots(); } + } } - - - //Try Work - if (this.drainEnergyInput(32)) { - BlockPos t; - if ((t = TreeFarmHelper.checkForLogsInGrowArea(this.getBaseMetaTileEntity())) != null) { - //Logger.INFO("Lets try find new logs/branches."); - TreeFarmHelper.findTreeFromBase(this.getBaseMetaTileEntity().getWorld(), t); - } + catch (Throwable t) { + t.printStackTrace(); } - - + + Logger.INFO("Valid Recipe"); + return true; + } + else { + Logger.INFO("Invalid Recipe"); + this.getBaseMetaTileEntity().disableWorking(); + return false; } + //return this.checkRecipeGeneric(4, 100, 100); } - - - @Override - public boolean checkRecipe(ItemStack p0) { - mIsCurrentlyWorking = (isCorrectMachinePart(p0) && this.getEUVar() > 0); - if (isCurrentlyWorking()) { - return true; - } - return false; - } @Override public int getMaxParallelRecipes() { @@ -261,121 +171,68 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase return 0; } - - @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - boolean isValid = false; - final SAWTOOL currentInputItem = TreeFarmHelper.isCorrectMachinePart(aStack); - if (currentInputItem != SAWTOOL.NONE){ - isValid = true; - } - return isValid; - } - - @Override public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - Logger.WARNING("Step 1"); - final int xDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 7; - final int zDir = net.minecraftforge.common.util.ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 7; - - for (int i = -7; i <= 7; i++) { - Logger.WARNING("Step 2"); - for (int j = -7; j <= 7; j++) { - Logger.WARNING("Step 3"); - for (int h = 0; h <= 1; h++) { - Logger.WARNING("Step 4"); - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - //Farm Floor inner 14x14 - if (((i != -7) && (i != 7)) && ((j != -7) && (j != 7))) { - Logger.WARNING("Step 5 - H:"+h); - // Farm Dirt Floor and Inner Air/Log space. - if (h == 0) { - //Dirt Floor - if (!TreeFarmHelper.isDirtBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) { - Logger.MACHINE_INFO("Dirt like block missing from inner 14x14."); - Logger.MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); - return false; - } - } - } - //Dealt with inner 5x5, now deal with the exterior. - else { - Logger.WARNING("Step 6 - H:"+h); - //Deal with all 4 sides (Fenced area) - if (h == 1) { - if (!TreeFarmHelper.isFenceBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) { - Logger.MACHINE_INFO("Fence/Gate missing from outside the second layer."); - Logger.MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + int tAmount = 0; + if (!aBaseMetaTileEntity.getAirOffset(xDir, 0, zDir)) { + 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.INFO("Bad centrifuge casing"); return false; } - } - //Deal with Bottom edges (Add Hatches/Busses first, othercheck make sure it's dirt) //TODO change the casings to not dirt~? - else if (h == 0) { - if (tTileEntity != null) - if ((!this.addMaintenanceToMachineList(tTileEntity, TAE.GTPP_INDEX(TEX_INDEX))) && (!this.addInputToMachineList(tTileEntity, TAE.GTPP_INDEX(TEX_INDEX))) && (!this.addOutputToMachineList(tTileEntity, TAE.GTPP_INDEX(TEX_INDEX))) && (!this.addEnergyInputToMachineList(tTileEntity, TAE.GTPP_INDEX(TEX_INDEX)))) { - if (((xDir + i) != 0) || ((zDir + j) != 0)) {//no controller + ++tAmount; - if (tTileEntity.getMetaTileID() != 752) { - Logger.MACHINE_INFO("Farm Keeper Casings Missing from one of the edges on the bottom edge. x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j)+" | "+aBaseMetaTileEntity.getClass()); - Logger.MACHINE_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()+" "+tTileEntity.getMetaTileID()); - return false; - } - Logger.WARNING("Found a farm keeper."); - } - } } } } } + return tAmount >= 10; } + } - //Must have at least one energy hatch. - if (this.mEnergyHatches != null) { - for (int i = 0; i < this.mEnergyHatches.size(); i++) { - if (this.mEnergyHatches.get(i).mTier < 1){ - Logger.MACHINE_INFO("You require at LEAST MV tier Energy Hatches."); - Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord()); - return false; - } - } - } - //Must have at least one output hatch. - if (this.mOutputHatches != null) { - for (int i = 0; i < this.mOutputHatches.size(); i++) { - - if (this.mOutputHatches.get(i).mTier < 1){ - Logger.MACHINE_INFO("You require at LEAST MV tier Output Hatches."); - Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord()); - Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName()); - return false; - } - } - } - //Must have at least one input hatch. - if (this.mInputHatches != null) { - for (int i = 0; i < this.mInputHatches.size(); i++) { - if (this.mInputHatches.get(i).mTier < 1){ - Logger.MACHINE_INFO("You require at LEAST MV tier Input Hatches."); - Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord()); - Logger.MACHINE_INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName()); - return false; - } - } - } - Logger.MACHINE_INFO("Multiblock Formed."); - return true; + public int getMaxEfficiency(final ItemStack aStack) { + return 10000; } + public int getPollutionPerTick(final ItemStack aStack) { + return 25; + } - @Override - public int getPollutionPerTick(ItemStack arg0) { + public int getDamageToComponent(final ItemStack aStack) { return 0; } + public boolean explodesOnComponentBreak(final ItemStack aStack) { + return false; + } @Override - public void onServerStart() { - super.onServerStart(); + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (mTreeData == null) { + mTreeData = new TreeGenerator(); + } + if (mTreeData != null) { + //this.getBaseMetaTileEntity().enableWorking(); + } + + + /*if (this.getBaseMetaTileEntity().isActive()) { + if (!this.depleteInput(mFuelStack.copy())) { + this.getBaseMetaTileEntity().setActive(false); + } + } */ + super.onPostTick(aBaseMetaTileEntity, aTick); } - } \ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java index fc0cb85bac..031bf16b17 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_IndustrialFishingPond.java @@ -6,7 +6,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.Map; -import cofh.asmhooks.block.BlockWater; import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -18,7 +17,6 @@ import gregtech.api.util.FishPondFakeRecipe; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; @@ -31,7 +29,6 @@ import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.Gregtech import ic2.core.init.BlocksItems; import ic2.core.init.InternalName; import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java index 7c1cc343ed..d5b7337187 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java @@ -3,10 +3,8 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.b import gregtech.api.enums.TAE; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.Material; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; public class GregtechMetaTileEntity_BedrockMiningPlatform1 extends GregtechMetaTileEntity_BedrockMiningPlatformBase { public GregtechMetaTileEntity_BedrockMiningPlatform1(final int aID, final String aName, final String aNameRegional) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java index fb4884e278..2a94804937 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java @@ -168,7 +168,7 @@ public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends G } } - this.mEUt = 8000; + this.mEUt = -8000; this.mMaxProgresstime = 1; this.mEfficiencyIncrease = 10000; -- cgit From fa9eef605bdf6017cc09f603f7e7f9582a76d69a Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Wed, 24 Apr 2019 18:52:36 +1000 Subject: $ More Adjustments to the Client Proxy ASM Patch. % Adjusted some Tree Farm code. --- .../xmod/gregtech/common/helpers/treefarm/TreeGenerator.java | 3 ++- .../multi/production/GregtechMetaTileEntityTreeFarm.java | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java index c9f2d493ab..a8603849b8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/treefarm/TreeGenerator.java @@ -133,7 +133,8 @@ public class TreeGenerator { public FakeWorld getWorld() { FakeWorld aWorld = this.mFakeWorld.get(mCurrentGeneratorIteration); if (aWorld == null) { - aWorld = (this.mFakeWorld.set(mCurrentGeneratorIteration, new FakeWorld(200))); + this.mFakeWorld.set(mCurrentGeneratorIteration, new FakeWorld(200)); + aWorld = this.mFakeWorld.get(mCurrentGeneratorIteration); } return aWorld; } 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 5968ea189c..23ab9afd61 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 @@ -49,6 +49,11 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase mCryoFuelName = mFuelStack.getLocalizedName(); mCasingName = ItemUtils.getLocalizedNameOfBlock(ModBlocks.blockCasings2Misc, 15); mHatchName = ItemUtils.getLocalizedNameOfBlock(GregTech_API.sBlockMachines, 967); + + if (mTreeData == null) { + mTreeData = new TreeGenerator(); + } + } public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { @@ -219,10 +224,7 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase } @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (mTreeData == null) { - mTreeData = new TreeGenerator(); - } + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (mTreeData != null) { //this.getBaseMetaTileEntity().enableWorking(); } -- cgit From e9f05b60123ad5f5a855c1896e4e5a120e55d8c9 Mon Sep 17 00:00:00 2001 From: Alkalus <3060479+draknyte1@users.noreply.github.com> Date: Wed, 24 Apr 2019 19:17:45 +1000 Subject: $ Made DEDP use the GT++ Base Multi Meta Tile. % Cleaned up lots of commented useless code. --- ...gtechMetaTileEntity_BedrockMiningPlatform1.java | 2 +- ...gtechMetaTileEntity_BedrockMiningPlatform2.java | 2 +- ...chMetaTileEntity_BedrockMiningPlatformBase.java | 331 +++------------------ 3 files changed, 39 insertions(+), 296 deletions(-) (limited to 'src/Java/gtPlusPlus/xmod/gregtech/common') diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java index d5b7337187..a3e288c33c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform1.java @@ -15,7 +15,7 @@ public class GregtechMetaTileEntity_BedrockMiningPlatform1 extends GregtechMetaT super(aName); } - public String[] getDescription() { + public String[] getTooltip() { return this.getDescriptionInternal("I"); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform2.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform2.java index 0ea38f685f..6910f4e97c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatform2.java @@ -15,7 +15,7 @@ public class GregtechMetaTileEntity_BedrockMiningPlatform2 extends GregtechMetaT super(aName); } - public String[] getDescription() { + public String[] getTooltip() { return this.getDescriptionInternal("II"); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java index 2a94804937..d264a759ec 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/bedrock/GregtechMetaTileEntity_BedrockMiningPlatformBase.java @@ -1,8 +1,5 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.bedrock; -import java.util.ArrayList; -import java.util.HashMap; - import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Textures; @@ -11,7 +8,6 @@ import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; @@ -19,8 +15,6 @@ import gregtech.common.GT_Worldgen_GT_Ore_Layer; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.Material; @@ -30,24 +24,22 @@ import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.minecraft.MiningUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.ChunkPosition; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; -public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends GT_MetaTileEntity_MultiBlockBase { - - private static final ItemStack miningPipe; - private static final ItemStack miningPipeTip; - private static final Block miningPipeBlock; - private static final Block miningPipeTipBlock; +public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends GregtechMeta_MultiBlockBase { - private final ArrayList oreBlockPositions; protected double mProductionModifier = 0; + + private static final ItemStack miningPipe; + private static final ItemStack miningPipeTip; + private Block casingBlock; private int casingMeta; // private int frameMeta; @@ -61,36 +53,22 @@ public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends G private int[] xCenter = new int[5]; private int[] zCenter = new int[5]; - private int[] yHead = new int[5]; - private boolean[] isPickingPipes = new boolean[5]; public GregtechMetaTileEntity_BedrockMiningPlatformBase(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); - this.oreBlockPositions = new ArrayList(); this.initFields(); } public GregtechMetaTileEntity_BedrockMiningPlatformBase(final String aName) { super(aName); - this.oreBlockPositions = new ArrayList(); this.initFields(); } private void initFields() { this.casingBlock = this.getCasingBlockItem().getBlock(); this.casingMeta = this.getCasingBlockItem().get(0L, new Object[0]).getItemDamage(); - /* - * final int frameId = 4096 + this.getFrameMaterial().mMetaItemSubID; - * this.frameMeta = ((GregTech_API.METATILEENTITIES[frameId] != null) ? - * GregTech_API.METATILEENTITIES[frameId].getTileEntityBaseType() : - * 32767); - */ this.casingTextureIndex = this.getCasingTextureIndex(); - - for (int g = 0; g < 5; g++) { - this.isPickingPipes[g] = false; - } } public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, @@ -186,30 +164,6 @@ public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends G return false; } - private boolean tryPickPipe(int pipe) { - if (this.yHead[pipe] == this.yDrill) { - return false; - } - boolean didWork[] = new boolean[3]; - didWork[0] = this.checkBlockAndMeta(this.xCenter[pipe], this.yHead[pipe] + 1, this.zCenter[pipe], - GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipeBlock, 32767); - if (didWork[0]) { - didWork[1] = this.getBaseMetaTileEntity().getWorld().setBlock(this.xCenter[pipe], this.yHead[pipe] + 1, - this.zCenter[pipe], GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipeTipBlock); - } - if (didWork[1]) { - mMiningHeads.put(pipe, new BlockPos(this.xCenter[pipe], this.yHead[pipe] + 1, this.zCenter[pipe], - this.getBaseMetaTileEntity().getWorld())); - didWork[2] = this.getBaseMetaTileEntity().getWorld().setBlockToAir(this.xCenter[pipe], this.yHead[pipe], - this.zCenter[pipe]); - } - - if (didWork[0] && didWork[1] && didWork[2]) { - return true; - } - return false; - } - private void setElectricityStats() { //this.mEfficiency = this.getCurrentEfficiency((ItemStack) null); this.mEfficiencyIncrease = 10000; @@ -218,52 +172,12 @@ public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends G Logger.INFO("Trying to set EU to "+(12 * overclock * overclock)); int mCombinedAvgTime = 0; for (int g = 0; g < 5; g++) { - mCombinedAvgTime += (this.isPickingPipes[g] ? 80 : this.getBaseProgressTime()) / overclock; + mCombinedAvgTime += this.getBaseProgressTime() / overclock; } Logger.INFO("Trying to set Max Time to "+(mCombinedAvgTime)); //this.mMaxProgresstime = (mCombinedAvgTime / 5); } - /* - * private ItemStack[] getOutputByDrops(final ArrayList - * oreBlockDrops) { final long voltage = this.getMaxInputVoltage(); final - * ArrayList outputItems = new ArrayList(); while - * (!oreBlockDrops.isEmpty()) { final ItemStack currentItem = - * oreBlockDrops.remove(0).copy(); if - * (!this.doUseMaceratorRecipe(currentItem)) { - * this.multiplyStackSize(currentItem); outputItems.add(currentItem); } else - * { final GT_Recipe tRecipe = - * GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.findRecipe( - * (IHasWorldObjectAndCoords) this.getBaseMetaTileEntity(), false, voltage, - * (FluidStack[]) null, new ItemStack[]{currentItem}); if (tRecipe == null) - * { outputItems.add(currentItem); } else { for (int i = 0; i < - * tRecipe.mOutputs.length; ++i) { final ItemStack recipeOutput = - * tRecipe.mOutputs[i].copy(); if - * (this.getBaseMetaTileEntity().getRandomNumber(10000) < - * tRecipe.getOutputChance(i)) { this.multiplyStackSize(recipeOutput); } - * outputItems.add(recipeOutput); } } } } return outputItems.toArray(new - * ItemStack[0]); } - */ - - /* - * private boolean doUseMaceratorRecipe(final ItemStack currentItem) { final - * ItemData itemData = GT_OreDictUnificator.getItemData(currentItem); return - * itemData == null || (itemData.mPrefix != OrePrefixes.crushed && - * itemData.mPrefix != OrePrefixes.dustImpure && itemData.mPrefix != - * OrePrefixes.dust && itemData.mMaterial.mMaterial != Materials.Oilsands); - * } private void multiplyStackSize(final ItemStack itemStack) { - * itemStack.stackSize *= this.getBaseMetaTileEntity().getRandomNumber(4) + - * 1; } private ArrayList getBlockDrops(final Block oreBlock, - * final int posX, final int posY, final int posZ) { final int blockMeta = - * this.getBaseMetaTileEntity().getMetaID(posX, posY, posZ); if - * (oreBlock.canSilkHarvest(this.getBaseMetaTileEntity().getWorld(), - * (EntityPlayer) null, posX, posY, posZ, blockMeta)) { return new - * ArrayList() { { this.add(new ItemStack(oreBlock, 1, - * blockMeta)); } }; } return (ArrayList) - * oreBlock.getDrops(this.getBaseMetaTileEntity().getWorld(), posX, posY, - * posZ, blockMeta, 1); } - */ - private boolean tryConsumeDrillingFluid() { boolean consumed = false; boolean g = (this.getBaseMetaTileEntity().getWorld().getTotalWorldTime() % 2 == 0); @@ -285,30 +199,8 @@ public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends G return this.depleteInput(FluidUtils.getFluidStack("cryotheum", 4)); } - private boolean lowerProduction(int reduce) { - if ((mProductionModifier - reduce) >= 10) { - this.mProductionModifier -= reduce; - return true; - } - else { - this.mProductionModifier = 10; - return false; - } - } - - private boolean increaseProduction(int increase) { - if ((mProductionModifier + increase) <= 150) { - this.mProductionModifier += increase; - return true; - } - else { - this.mProductionModifier = 150; - return false; - } - } - private void putMiningPipesFromInputsInController() { - final int maxPipes = GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipe.getMaxStackSize(); + final int maxPipes = 64; if (this.isHasMiningPipes(maxPipes)) { return; } @@ -335,74 +227,7 @@ public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends G this.updateSlots(); } - /* - * private void fillMineListIfEmpty() { if - * (!this.oreBlockPositions.isEmpty()) { return; } - * this.tryAddOreBlockToMineList(this.xCenter, this.yHead - 1, - * this.zCenter); if (this.yHead == this.yDrill) { return; } for (int radius - * = this.getRadiusInChunks() << 4, xOff = -radius; xOff <= radius; ++xOff) - * { for (int zOff = -radius; zOff <= radius; ++zOff) { - * this.tryAddOreBlockToMineList(this.xDrill + xOff, this.yHead, this.zDrill - * + zOff); } } } private void tryAddOreBlockToMineList(final int x, final - * int y, final int z) { final Block block = - * this.getBaseMetaTileEntity().getBlock(x, y, z); final int blockMeta = - * this.getBaseMetaTileEntity().getMetaID(x, y, z); final ChunkPosition - * blockPos = new ChunkPosition(x, y, z); if - * (this.oreBlockPositions.contains(blockPos)) { return; } if (block - * instanceof GT_Block_Ores_Abstract) { final TileEntity tTileEntity = - * this.getBaseMetaTileEntity().getTileEntity(x, y, z); if (tTileEntity != - * null && tTileEntity instanceof GT_TileEntity_Ores && - * ((GT_TileEntity_Ores) tTileEntity).mNatural) { - * this.oreBlockPositions.add(blockPos); } } else { final ItemData - * association = GT_OreDictUnificator.getAssociation(new ItemStack(block, 1, - * blockMeta)); if (association != null && - * association.mPrefix.toString().startsWith("ore")) { - * this.oreBlockPositions.add(blockPos); } } } - */ - private HashMap mMiningHeads = new HashMap(); - - private boolean tryLowerPipe(int pipe) { - if (!this.isHasMiningPipes()) { - Logger.INFO("[Bedrock Miner] No Pipes to Lower."); - return false; - } - boolean didWork[] = new boolean[3]; - - /*if (this.checkBlockAndMeta(this.xCenter[pipe], this.yHead[pipe] - 1, this.zCenter[pipe], Blocks.bedrock, - 32767)) { - // Logger.INFO("[Bedrock Miner] Pipe "+pipe+" is at Bedrock."); - return false; - }*/ - didWork[0] = this.getBaseMetaTileEntity().getWorld().setBlock(this.xCenter[pipe], this.yHead[pipe] - 1, - this.zCenter[pipe], GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipeTipBlock); - if (didWork[0]) { - mMiningHeads.put(pipe, new BlockPos(this.xCenter[pipe], this.yHead[pipe] - 1, this.zCenter[pipe], - this.getBaseMetaTileEntity().getWorld())); - } - - didWork[1] = (this.yHead[pipe] != this.yDrill); - Logger.INFO("A: " + this.yHead[pipe] + " | B: " + this.yDrill); - - if (didWork[1]) { - didWork[2] = this.getBaseMetaTileEntity().getWorld().setBlock(this.xCenter[pipe], this.yHead[pipe], - this.zCenter[pipe], GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipeBlock); - } - - if (didWork[0] && didWork[1] && didWork[2]) { - this.getBaseMetaTileEntity().decrStackSize(1, 1); - Logger.INFO("[Bedrock Miner] Lowered Pipe " + pipe + "."); - return true; - } - - Logger.INFO("[Bedrock Miner] Issue when lowering Pipe " + pipe + ". 1: " + didWork[0] + " | 2: " + didWork[1] - + " | 3: " + didWork[2]); - return false; - } - - private boolean isHasMiningPipes() { - return this.isHasMiningPipes(1); - } private boolean isHasMiningPipes(final int minCount) { final ItemStack pipe = this.getStackInSlot(1); @@ -410,11 +235,8 @@ public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends G && pipe.isItemEqual(GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipe); } - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - this.updateCoordinates(); - - - + public boolean checkMultiblock(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { + this.updateCoordinates(); int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; int tAmount = 0; @@ -459,66 +281,6 @@ public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends G return tAmount >= 10; } - - - - - - - - - - - - - - - - - - - /*for (int xOff = -1 + this.back.offsetX; xOff <= 1 + this.back.offsetX; ++xOff) { - for (int zOff = -1 + this.back.offsetZ; zOff <= 1 + this.back.offsetZ; ++zOff) { - if (xOff != 0 || zOff != 0) { - final Block tBlock = aBaseMetaTileEntity.getBlockOffset(xOff, 0, zOff); - final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, - zOff); - if (!this.checkCasingBlock(xOff, 0, zOff) - && !this.addMaintenanceToMachineList(tTileEntity, this.casingTextureIndex) - && !this.addInputToMachineList(tTileEntity, this.casingTextureIndex) - && !this.addOutputToMachineList(tTileEntity, this.casingTextureIndex) - && !this.addEnergyInputToMachineList(tTileEntity, this.casingTextureIndex)) { - Logger.INFO("[Bedrock Miner] Found bad block in Structure."); - if (tBlock != null) { - //Logger.INFO("[Bedrock Miner] Found "+(new ItemStack(tBlock, tBlock.getDamageValue(aBaseMetaTileEntity.getWorld(), xOff, 0, zOff))).getDisplayName()+", expected "+this.getCasingBlockItem().get(0L, new Object[0]).getDisplayName()); - } - return false; - } - } - } - } - if (this.mMaintenanceHatches.isEmpty() || this.mInputHatches.isEmpty() || this.mOutputBusses.isEmpty() - || this.mEnergyHatches.isEmpty()) { - Logger.INFO("[Bedrock Miner] Missing Hatches/Busses."); - return false; - } - if (GT_Utility.getTier(this.getMaxInputVoltage()) < this.getMinTier()) { - Logger.INFO("[Bedrock Miner] getMaxInputVoltage() < getMinTier()."); - return false; - } - for (int yOff = 1; yOff < 4; ++yOff) { - if (!this.checkCasingBlock(this.back.offsetX, yOff, this.back.offsetZ) - || !this.checkFrameBlock(this.back.offsetX + 1, yOff, this.back.offsetZ) - || !this.checkFrameBlock(this.back.offsetX - 1, yOff, this.back.offsetZ) - || !this.checkFrameBlock(this.back.offsetX, yOff, this.back.offsetZ + 1) - || !this.checkFrameBlock(this.back.offsetX, yOff, this.back.offsetZ - 1) - || !this.checkFrameBlock(this.back.offsetX, yOff + 3, this.back.offsetZ)) { - Logger.INFO("[Bedrock Miner] Missing Frames? yOff = " + yOff); - return false; - } - } - Logger.INFO("[Bedrock Miner] Built."); - return true;*/ } private void updateCoordinates() { @@ -545,46 +307,6 @@ public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends G } - private boolean checkPipesAndSetYHead() { - for (int g = 0; g < 5; g++) { - this.yHead[g] = this.yDrill -5; - // Logger.INFO("[Bedrock Miner] Set yHead["+g+"] to - // "+this.yHead[g]+"."); - while (this.checkBlockAndMeta(this.xCenter[g], this.yHead[g], this.zCenter[g], - GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipeBlock, 32767)) { - --this.yHead[g]; - } - if (this.checkBlockAndMeta(this.xCenter[g], this.yHead[g], this.zCenter[g], - GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipeTipBlock, 32767) - || ++this.yHead[g] == this.yDrill || GT_Utility.isBlockAir(this.getBaseMetaTileEntity().getWorld(), this.xCenter[g], this.yHead[g], this.zCenter[g])) { - continue; - } - this.getBaseMetaTileEntity().getWorld().setBlock(this.xCenter[g], this.yHead[g], this.zCenter[g], - GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipeTipBlock); - - } - return true; - } - - private boolean checkCasingBlock(final int xOff, final int yOff, final int zOff) { - return this.checkBlockAndMetaOffset(xOff, yOff, zOff, this.casingBlock, this.casingMeta); - } - - private boolean checkFrameBlock(final int xOff, final int yOff, final int zOff) { - return this.checkBlockAndMetaOffset(xOff, yOff, zOff, - Block.getBlockFromItem(this.getFrameMaterial().getFrameBox(1).getItem()), 0); - } - - private boolean checkBlockAndMetaOffset(final int xOff, final int yOff, final int zOff, final Block block, - final int meta) { - return this.checkBlockAndMeta(this.xDrill + xOff, this.yDrill + yOff, this.zDrill + zOff, block, meta); - } - - private boolean checkBlockAndMeta(final int x, final int y, final int z, final Block block, final int meta) { - Logger.INFO("Found "+this.getBaseMetaTileEntity().getBlock(x, y, z).getLocalizedName()+":"+this.getBaseMetaTileEntity().getMetaID(x, y, z)+" | Expected: "+block.getUnlocalizedName()+":"+meta); - return (this.getBaseMetaTileEntity().getMetaID(x, y, z) == meta) && this.getBaseMetaTileEntity().getBlock(x, y, z) == block; - } - public boolean isCorrectMachinePart(final ItemStack aStack) { return true; } @@ -640,12 +362,6 @@ public abstract class GregtechMetaTileEntity_BedrockMiningPlatformBase extends G static { miningPipe = GT_ModHandler.getIC2Item("miningPipe", 0L); miningPipeTip = GT_ModHandler.getIC2Item("miningPipeTip", 0L); - // miningPipeBlock = - // GT_Utility.getBlockFromStack(GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipe); - // miningPipeTipBlock = - // GT_Utility.getBlockFromStack(GregtechMetaTileEntity_BedrockMiningPlatformBase.miningPipeTip); - miningPipeBlock = ModBlocks.blockF