diff options
| author | â€huajijam <strhuaji@gmail.com> | 2019-04-25 23:37:09 +0800 |
|---|---|---|
| committer | â€huajijam <strhuaji@gmail.com> | 2019-04-25 23:37:09 +0800 |
| commit | ff60c00c1fc17acf9200cdf794c185ee329b8446 (patch) | |
| tree | 1372baf2a6a08cc34e9771e5826bb6ee492b2428 /src/Java/gtPlusPlus/xmod/gregtech | |
| parent | de9f7710d6f32af0d941085e1029a106b5bc22ff (diff) | |
| parent | fccb5447bc424c482f45d3d41e037bdbbd99d823 (diff) | |
| download | GT5-Unofficial-ff60c00c1fc17acf9200cdf794c185ee329b8446.tar.gz GT5-Unofficial-ff60c00c1fc17acf9200cdf794c185ee329b8446.tar.bz2 GT5-Unofficial-ff60c00c1fc17acf9200cdf794c185ee329b8446.zip | |
Automatic synchronization
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech')
10 files changed, 425 insertions, 633 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 516f78038d..e352712138 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -577,6 +577,7 @@ GT_MetaTileEntity_MultiBlockBase { tTier = (byte) aControlCoreTier; } + tTier = (byte) MathUtils.getValueWithinRange(tTier, 0, 9); GT_Recipe tRecipe = aRecipe != null ? aRecipe : findRecipe( getBaseMetaTileEntity(), mLastRecipe, false, @@ -1922,8 +1923,8 @@ GT_MetaTileEntity_MultiBlockBase { return true; } else if (aFoundBlock != aExpectedBlock) { - log("A1 - Found: "+aFoundBlock.getLocalizedName()+":"+aFoundMeta+", Expected: "+aExpectedBlock.getLocalizedName()+":"+aExpectedMeta); if (GTplusplus.CURRENT_LOAD_PHASE == INIT_PHASE.STARTED) { + log("A1 - Found: "+aFoundBlock.getLocalizedName()+":"+aFoundMeta+", Expected: "+aExpectedBlock.getLocalizedName()+":"+aExpectedMeta); log("Loc: "+(new BlockPos(aBaseMetaTileEntity).getLocationString())); } return false; 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..b94ebf2918 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,32 @@ import net.minecraftforge.common.util.ForgeDirection; public class TreeGenerator { - public static AutoMap<ItemStack> generateOutput(int aTreeSize){ - AutoMap<ItemStack> aOutputMap = new AutoMap<ItemStack>(); - - - return aOutputMap; + private static final FakeTreeInFakeWorldGenerator mTreeData; + + static { + Logger.WARNING("Created Fake Tree Generator."); + mTreeData = new FakeTreeInFakeWorldGenerator(); } - public class FakeWorldGenerator extends WorldGenAbstractTree + + public TreeGenerator() { + if (!mTreeData.hasGenerated) { + mTreeData.generate(null, CORE.RANDOM, 0, 0, 0); + } + } + + public AutoMap<ItemStack> generateOutput(int aTreeSize){ + AutoMap<ItemStack> aTemp = new AutoMap<ItemStack>(); + AutoMap<ItemStack> aOutputMap = mTreeData.getOutputFromTree(); + if (aOutputMap != null && aOutputMap.size() > 0) { + Logger.WARNING("Valid tree data output"); + return aOutputMap; + } + Logger.WARNING("Invalid tree data output"); + return aTemp; + } + + public static class FakeTreeInFakeWorldGenerator extends WorldGenAbstractTree { /** The minimum height of a generated tree. */ private final int minTreeHeight; @@ -33,42 +56,105 @@ public class TreeGenerator { /** The metadata value of the leaves to use in tree generation. */ private final int metaLeaves; + private final AutoMap<FakeWorld> mFakeWorld; + private final int mTreesToGenerate; + + private int mCurrentGeneratorIteration = 0; + private boolean hasGenerated = false; private AutoMap<ItemStack> aOutputsFromGenerator = new AutoMap<ItemStack>(); - 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<FakeWorld>(); + this.mTreesToGenerate = aTreeCount; + Logger.WARNING("Created Fake Tree In Fake World Instance."); } public AutoMap<ItemStack> getOutputFromTree(){ if (!hasGenerated) { + Logger.WARNING("Generating Tree sample data"); generate(null, CORE.RANDOM, 0, 0, 0); } - return aOutputsFromGenerator; + AutoMap<ItemStack> aOutputMap = new AutoMap<ItemStack>(); + int aRandomTreeID = MathUtils.randInt(0, this.mFakeWorld.size()-1); + FakeWorld aWorld = this.mFakeWorld.get(aRandomTreeID); + if (aWorld != null) { + //Logger.WARNING("Getting all block data from fake world"); + 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<mTreesToGenerate;yy++) { + generateTree(0, 0, 0); + mCurrentGeneratorIteration++; + } + hasGenerated = true; + if (this.mFakeWorld.size() > 0) { + for (FakeWorld aWorld : this.mFakeWorld) { + for (ItemStack aBlockInFakeWorld : aWorld.getAllBlocksStoredInFakeWorld()) { + aOutputsFromGenerator.add(aBlockInFakeWorld); + } + } + return true; + } + else { + return false; + } + } + } + + private FakeWorld aFakeWorld; + + public FakeWorld getWorld() { + FakeWorld aWorld = this.mFakeWorld.get(mCurrentGeneratorIteration); + if (aWorld == null) { + this.mFakeWorld.set(mCurrentGeneratorIteration, new FakeWorld(200)); + aWorld = this.mFakeWorld.get(mCurrentGeneratorIteration); } + return aWorld; + } + + public boolean generateTree(int aWorldX, int aWorldRealY, int aWorldZ) { + FakeWorld aWorld = getWorld(); //Set some static values - + + Logger.WARNING("Stepping through generateTree [0]"); //Dummy Value int aWorldY = 10; @@ -77,6 +163,7 @@ public class TreeGenerator { if (aWorldY >= 1 && aWorldY + l + 1 <= 256) { + Logger.WARNING("Stepping through generateTree [1]"); byte b0; int k1; Block block; @@ -103,7 +190,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; } @@ -118,16 +205,20 @@ public class TreeGenerator { if (!flag) { + Logger.WARNING("Stepping through generateTree [2]"); return false; } else { + Logger.WARNING("Stepping through generateTree [3]"); 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) + if (/*isSoil &&*/ aWorldY < 256 - l - 1) { - block2.onPlantGrow(aWorld, aWorldX, aWorldY - 1, aWorldZ, aWorldX, aWorldY, aWorldZ); + Logger.WARNING("Stepping through generateTree [4]"); + aBlockToGrowPlantOn.onPlantGrow(aWorld, aWorldX, aWorldY - 1, aWorldZ, aWorldX, aWorldY, aWorldZ); b0 = 3; byte b1 = 0; int l1; @@ -152,7 +243,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); } @@ -160,12 +251,13 @@ public class TreeGenerator { } } } + Logger.WARNING("Stepping through generateTree [5]"); for (k1 = 0; k1 < l; ++k1) { 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); @@ -193,9 +285,11 @@ public class TreeGenerator { } } } + Logger.WARNING("Stepping through generateTree [6]"); if (this.vinesGrow) { + Logger.WARNING("Stepping through generateTree [7]"); for (k1 = aWorldY - 3 + l; k1 <= aWorldY + l; ++k1) { i3 = k1 - (aWorldY + l); @@ -205,24 +299,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); } @@ -230,6 +324,7 @@ public class TreeGenerator { } } } + Logger.WARNING("Stepping through generateTree [8]"); if (CORE.RANDOM.nextInt(5) == 0 && l > 5) { @@ -246,48 +341,45 @@ public class TreeGenerator { } } } - - hasGenerated = true; + Logger.WARNING("Stepping through generateTree [9]"); return true; } else { + Logger.WARNING("Stepping through generateTree [10]"); return false; } } } else { + Logger.WARNING("Stepping through generateTree [11]"); return false; } } - /** + /** * 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<aLoopSize;i++) { + this.setBlockAndNotifyAdequately(aWorld, aX, aY, aZ, Blocks.vine, aMeta); } } @Override - protected void setBlockAndNotifyAdequately(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMeta) { - - super.setBlockAndNotifyAdequately(aWorld, aX, aY, aZ, aBlock, aMeta); + protected void setBlockAndNotifyAdequately(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMeta) { + setBlockAndNotifyAdequately(getWorld(), aX, aY, aZ, aBlock, aMeta); + } + + protected void setBlockAndNotifyAdequately(FakeWorld aWorld, int aX, int aY, int aZ, Block aBlock, int aMeta) { + if (aBlock != null && (aMeta >= 0 && aMeta <= Short.MAX_VALUE)) { + Logger.WARNING("Setting block "+aX+", "+aY+", "+aZ+" | "+aBlock.getLocalizedName()+" | "+aMeta); + 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..fc4611686f 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,103 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + import 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 gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.ThreadFakeWorldGenerator; 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.init.Blocks; 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); } + + + /* + * Static thread for Fake World Handling + */ + + + private static ScheduledExecutorService executor; + private static ThreadFakeWorldGenerator aThread; + 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); + + /*if (executor == null || mTreeData == null) { + if (executor == null) { + executor = Executors.newScheduledThreadPool(10); + } + if (executor != null) { + if (aThread == null) { + aThread = new ThreadFakeWorldGenerator(); + executor.scheduleAtFixedRate(aThread, 0, 1, TimeUnit.SECONDS); + while (aThread.mGenerator == null) { + if (aThread.mGenerator != null) { + break; + } + } + if (aThread.mGenerator != null) { + mTreeData = aThread.mGenerator; + } + } + } + }*/ + + if (mTreeData == null) { + mTreeData = new TreeGenerator(); + } + + + + } - public boolean isCurrentlyWorking() { - return this.mIsCurrentlyWorking; + public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (IMetaTileEntity) new GregtechMetaTileEntityTreeFarm(this.mName); } @Override @@ -50,206 +105,136 @@ 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; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[CASING_TEXTURE_ID]}; } - - @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) { + public boolean hasSlotInGUI() { 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); - } - + @Override - public boolean hasSlotInGUI() { + public boolean requiresVanillaGtGUI() { 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"); + return "VacuumFreezer"; } - @Override - public Object getServerGUI(final int aID, final InventoryPlayer aPlayerInventory, final IGregTechTileEntity aBaseMetaTileEntity) { - return new CONTAINER_TreeFarmer(aPlayerInventory, aBaseMetaTileEntity); + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return null; } - @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 isCorrectMachinePart(final ItemStack aStack) { + //return TreeFarmHelper.isCorrectPart(aStack); 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<mSuper.length;i++) { - mDesc[i+1] = mSuper[i]; - } - return mDesc; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack p0) { - return false; - } - @Override - public boolean onRunningTick(final ItemStack aStack) { - //Logger.INFO("s"); - - return super.onRunningTick(aStack); - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - //Do Main Multi Logic first - super.onPostTick(aBaseMetaTileEntity, aTick); - - //Do Tree Farm logic next on server side, once per second - if (aBaseMetaTileEntity.isServerSide() && (aTick % 20 == 0)) { - - //Simple Repairs for a simple machine - if (isCurrentlyWorking()) { - this.mSolderingTool = true; + public boolean isFacingValid(final byte aFacing) { + return aFacing > 1; + } + + public boolean checkRecipe(final ItemStack aStack) { + //Logger.WARNING("Trying to process virtual tree farming"); + if (mTreeData != null) { + //Logger.WARNING("Tree Data is valid"); + + long tVoltage = getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + + this.mMaxProgresstime = 100; + this.mEUt = (int) tVoltage; + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + // Overclock + if (this.mEUt <= 16) { + this.mEUt = (this.mE |
