diff options
Diffstat (limited to 'src/Java')
93 files changed, 2985 insertions, 837 deletions
diff --git a/src/Java/gregtech/api/util/FishPondFakeRecipe.java b/src/Java/gregtech/api/util/FishPondFakeRecipe.java index d8661c23bd..9cb82bf5e0 100644 --- a/src/Java/gregtech/api/util/FishPondFakeRecipe.java +++ b/src/Java/gregtech/api/util/FishPondFakeRecipe.java @@ -3,8 +3,8 @@ package gregtech.api.util; import java.util.ArrayList; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.array.AutoMap; import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.item.ItemStack; import net.minecraft.util.WeightedRandomFishable; diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index b06ca00752..d782df664c 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -1,6 +1,6 @@ package gtPlusPlus; -import static gtPlusPlus.api.objects.ChunkManager.mChunkLoaderManagerMap; +import static gtPlusPlus.api.objects.minecraft.ChunkManager.mChunkLoaderManagerMap; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableCustomCapes; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableUpdateChecker; @@ -20,25 +20,26 @@ import gregtech.api.enums.Materials; import gregtech.api.util.GT_Recipe; import gregtech.api.util.Recipe_GT; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gtPlusPlus.api.analytics.SegmentAnalytics; -import gtPlusPlus.api.analytics.SegmentHelper; -import gtPlusPlus.api.objects.ChunkManager; -import gtPlusPlus.api.objects.DimChunkPos; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.api.objects.minecraft.ChunkManager; +import gtPlusPlus.api.objects.minecraft.DimChunkPos; import gtPlusPlus.core.commands.CommandMath; import gtPlusPlus.core.common.CommonProxy; import gtPlusPlus.core.config.ConfigHandler; import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.handler.Recipes.RegistrationHandler; +import gtPlusPlus.core.handler.analytics.SegmentAnalytics; +import gtPlusPlus.core.handler.analytics.SegmentHelper; import gtPlusPlus.core.handler.events.BlockEventHandler; import gtPlusPlus.core.handler.events.LoginEventHandler; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Triplet; import gtPlusPlus.core.util.geo.GeoUtils; import gtPlusPlus.core.util.item.ItemUtils; +import gtPlusPlus.core.util.locale.LocaleUtils; import gtPlusPlus.core.util.networking.NetworkUtils; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.plugin.manager.Core_Manager; @@ -47,6 +48,7 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtTools; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntityChunkLoader; import gtPlusPlus.xmod.gregtech.loaders.GT_Material_Loader; +import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_Recycling; import net.minecraft.launchwrapper.Launch; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.common.ForgeChunkManager; @@ -134,6 +136,11 @@ public class GTplusplus implements ActionListener { BlockEventHandler.fluoriteOre = FLUORIDES.FLUORITE.getOre(1); Core_Manager.init(); + //Used by foreign players to generate .lang files for translation. + if (CORE.ConfigSwitches.dumpItemAndBlockData) { + LocaleUtils.GenerateFakeLocaleFile(); + } + } // Post-Init @@ -142,6 +149,7 @@ public class GTplusplus implements ActionListener { proxy.postInit(event); BookHandler.runLater(); Core_Manager.postInit(); + RecipeGen_Recycling.executeGenerators(); Logger.INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Logger.INFO("| Recipes succesfully Loaded: " + RegistrationHandler.recipesSuccess + " | Failed: " + RegistrationHandler.recipesFailed + " |"); @@ -158,10 +166,10 @@ public class GTplusplus implements ActionListener { @EventHandler public void serverStarting(final FMLServerStartingEvent event) { event.registerServerCommand(new CommandMath()); - + //Chunk Loading Timer h = ChunkManager.createChunkQueue(); - + } diff --git a/src/Java/gtPlusPlus/api/damage/DamageTeslaTower.java b/src/Java/gtPlusPlus/api/damage/DamageTeslaTower.java index ada2ba5c3d..ecde9fe930 100644 --- a/src/Java/gtPlusPlus/api/damage/DamageTeslaTower.java +++ b/src/Java/gtPlusPlus/api/damage/DamageTeslaTower.java @@ -1,5 +1,6 @@ package gtPlusPlus.api.damage; +import gtPlusPlus.core.world.damage.BaseCustomDamageSource; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ChatComponentTranslation; diff --git a/src/Java/gtPlusPlus/api/objects/MaterialHelper.java b/src/Java/gtPlusPlus/api/helpers/MaterialHelper.java index d63ab7a15a..bb30727992 100644 --- a/src/Java/gtPlusPlus/api/objects/MaterialHelper.java +++ b/src/Java/gtPlusPlus/api/helpers/MaterialHelper.java @@ -1,4 +1,4 @@ -package gtPlusPlus.api.objects; +package gtPlusPlus.api.helpers; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; diff --git a/src/Java/gtPlusPlus/api/interfaces/IEntityCatcher.java b/src/Java/gtPlusPlus/api/interfaces/IEntityCatcher.java index ca2d80de53..12813e1dd0 100644 --- a/src/Java/gtPlusPlus/api/interfaces/IEntityCatcher.java +++ b/src/Java/gtPlusPlus/api/interfaces/IEntityCatcher.java @@ -1,6 +1,6 @@ package gtPlusPlus.api.interfaces; -import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.api.objects.minecraft.BlockPos; import net.minecraft.entity.Entity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; diff --git a/src/Java/gtPlusPlus/api/interfaces/IGregtechPower.java b/src/Java/gtPlusPlus/api/interfaces/IGregtechPower.java new file mode 100644 index 0000000000..de639c6bae --- /dev/null +++ b/src/Java/gtPlusPlus/api/interfaces/IGregtechPower.java @@ -0,0 +1,149 @@ +package gtPlusPlus.api.interfaces; + +import gregtech.api.interfaces.IDescribable; +import gregtech.api.interfaces.tileentity.IBasicEnergyContainer; +import gregtech.api.interfaces.tileentity.IGearEnergyTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechDeviceInformation; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.ITurnable; +import gtPlusPlus.core.tileentities.base.TilePoweredGT; +import net.minecraft.block.Block; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public abstract interface IGregtechPower extends IGearEnergyTileEntity, ITurnable, IGregTechDeviceInformation, IDescribable, IBasicEnergyContainer { + + @Override + public String[] getDescription(); + + @Override + default boolean isUniversalEnergyStored(long p0) { + return false; + } + + @Override + public long getOutputAmperage(); + + @Override + public long getOutputVoltage(); + + @Override + public long getInputAmperage(); + + @Override + public long getInputVoltage(); + + @Override + public boolean decreaseStoredEnergyUnits(long p0, boolean p1); + + @Override + public boolean increaseStoredEnergyUnits(long p0, boolean p1); + + @Override + public boolean drainEnergyUnits(byte p0, long p1, long p2); + + @Override + public long getAverageElectricInput(); + + @Override + public long getAverageElectricOutput(); + + @Override + public long getStoredEU(); + + @Override + public long getEUCapacity(); + + @Override + public long getStoredSteam(); + + @Override + public long getSteamCapacity(); + + @Override + public boolean increaseStoredSteam(long p0, boolean p1); + + @Override + public Block getBlockAtSide(byte p0); + + @Override + public Block getBlockAtSideAndDistance(byte p0, int p1); + + @Override + public Block getBlockOffset(int p0, int p1, int p2); + + + @Override + public TileEntity getTileEntity(int p0, int p1, int p2); + + @Override + public TileEntity getTileEntityAtSide(byte p0); + + @Override + public TileEntity getTileEntityAtSideAndDistance(byte p0, int p1); + + @Override + public TileEntity getTileEntityOffset(int p0, int p1, int p2); + + @Override + public World getWorld(); + + @Override + public int getXCoord(); + + @Override + public short getYCoord(); + + @Override + public int getZCoord(); + + @Override + public boolean isClientSide(); + + @Override + public boolean isDead(); + + @Override + public boolean isInvalidTileEntity(); + + @Override + public boolean isServerSide(); + + @Override + public void readFromNBT(NBTTagCompound p0); + + @Override + public void writeToNBT(NBTTagCompound p0); + + @Override + public boolean acceptsRotationalEnergy(byte p0); + + @Override + public boolean injectRotationalEnergy(byte p0, long p1, long p2); + + @Override + public long injectEnergyUnits(byte p0, long p1, long p2); + + @Override + public boolean inputEnergyFrom(byte p0); + + @Override + public boolean outputsEnergyTo(byte p0); + + @Override + public String[] getInfoData(); + + @Override + default public boolean isGivingInformation() { + return true; + } + + boolean onPreTick(TilePoweredGT tilePoweredGT, long mTickTimer2); + + boolean onTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2); + + boolean onPostTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2); + + +} diff --git a/src/Java/gtPlusPlus/core/util/array/AutoMap.java b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java index ea5e1dd25e..a8d24d36d8 100644 --- a/src/Java/gtPlusPlus/core/util/array/AutoMap.java +++ b/src/Java/gtPlusPlus/api/objects/data/AutoMap.java @@ -1,4 +1,4 @@ -package gtPlusPlus.core.util.array; +package gtPlusPlus.api.objects.data; import java.io.Serializable; import java.util.*; diff --git a/src/Java/gtPlusPlus/core/util/array/Pair.java b/src/Java/gtPlusPlus/api/objects/data/Pair.java index 1d2c0ef7cb..6ab781cf1e 100644 --- a/src/Java/gtPlusPlus/core/util/array/Pair.java +++ b/src/Java/gtPlusPlus/api/objects/data/Pair.java @@ -1,4 +1,4 @@ -package gtPlusPlus.core.util.array; +package gtPlusPlus.api.objects.data; import java.io.Serializable; diff --git a/src/Java/gtPlusPlus/core/util/array/Quad.java b/src/Java/gtPlusPlus/api/objects/data/Quad.java index 417c3b6ebc..01c62e95e6 100644 --- a/src/Java/gtPlusPlus/core/util/array/Quad.java +++ b/src/Java/gtPlusPlus/api/objects/data/Quad.java @@ -1,4 +1,4 @@ -package gtPlusPlus.core.util.array; +package gtPlusPlus.api.objects.data; public class Quad<K,V,C,R> { diff --git a/src/Java/gtPlusPlus/core/util/array/Triplet.java b/src/Java/gtPlusPlus/api/objects/data/Triplet.java index 01f836ae72..affb03d868 100644 --- a/src/Java/gtPlusPlus/core/util/array/Triplet.java +++ b/src/Java/gtPlusPlus/api/objects/data/Triplet.java @@ -1,4 +1,4 @@ -package gtPlusPlus.core.util.array; +package gtPlusPlus.api.objects.data; public class Triplet<K,V,C> { diff --git a/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java b/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java new file mode 100644 index 0000000000..d258d1fe73 --- /dev/null +++ b/src/Java/gtPlusPlus/api/objects/minecraft/BlockPos.java @@ -0,0 +1,85 @@ +package gtPlusPlus.api.objects.minecraft; + +import java.io.Serializable; + +public class BlockPos implements Serializable{ + + private static final long serialVersionUID = -7271947491316682006L; + public final int xPos; + public final int yPos; + public final int zPos; + public final int dim; + + public BlockPos(int x, int y, int z){ + this(x, y, z, 0); + } + + public BlockPos(int x, int y, int z, int dim){ + this.xPos = x; + this.yPos = y; + this.zPos = z; + this.dim = dim; + } + + public String getLocationString() { + return "[X: "+this.xPos+"][Y: "+this.yPos+"][Z: "+this.zPos+"][Dim: "+this.dim+"]"; + } + + @Override + public int hashCode() { + int hash = 5; + hash += (13 * this.xPos); + hash += (19 * this.yPos); + hash += (31 * this.zPos); + hash += (17 * this.dim); + return hash; + } + + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + if (other == this) { + return true; + } + if(!(other instanceof BlockPos)) { + return false; + } + BlockPos otherPoint = (BlockPos)other; + return this.xPos == otherPoint.xPos && this.yPos == otherPoint.yPos && this.zPos == otherPoint.zPos && this.dim == otherPoint.dim; + } + + public int distanceFrom(BlockPos target) { + if (target.dim != this.dim) { + return Short.MIN_VALUE; + } + return distanceFrom(target.xPos, target.yPos, target.zPos); + } + + /** + * + * @param x X coordinate of target. + * @param y Y coordinate of target. + * @param z Z coordinate of target. + * @return square of distance + */ + public int distanceFrom(int x, int y, int z) { + int distanceX = this.xPos - x; + int distanceY = this.yPos - y; + int distanceZ = this.zPos - z; + return distanceX * distanceX + distanceY * distanceY + distanceZ * distanceZ; + } + + public boolean isWithinRange(BlockPos target, int range) { + if (target.dim != this.dim) { + return false; + } + return isWithinRange(target.xPos, target.yPos, target.zPos, range); + } + + public boolean isWithinRange(int x, int y, int z, int range) { + return distanceFrom(x, y, z) <= (range * range); + } + +} diff --git a/src/Java/gtPlusPlus/api/objects/ChunkManager.java b/src/Java/gtPlusPlus/api/objects/minecraft/ChunkManager.java index 0bace04bf8..b411e8875a 100644 --- a/src/Java/gtPlusPlus/api/objects/ChunkManager.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/ChunkManager.java @@ -6,14 +6,14 @@ * permission unless otherwise specified on the * license page at http://railcraft.info/wiki/info:license. */ -package gtPlusPlus.api.objects; +package gtPlusPlus.api.objects.minecraft; import com.google.common.collect.LinkedListMultimap; import com.google.common.collect.ListMultimap; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gtPlusPlus.GTplusplus; -import gtPlusPlus.core.util.array.BlockPos; -import gtPlusPlus.core.util.array.Triplet; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Triplet; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaTileEntityChunkLoader; import java.util.HashSet; diff --git a/src/Java/gtPlusPlus/api/objects/DimChunkPos.java b/src/Java/gtPlusPlus/api/objects/minecraft/DimChunkPos.java index bea0a4ec3b..010e522a14 100644 --- a/src/Java/gtPlusPlus/api/objects/DimChunkPos.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/DimChunkPos.java @@ -1,6 +1,5 @@ -package gtPlusPlus.api.objects; +package gtPlusPlus.api.objects.minecraft; -import gtPlusPlus.core.util.array.BlockPos; import net.minecraft.client.Minecraft; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; diff --git a/src/Java/gtPlusPlus/api/objects/GenericStack.java b/src/Java/gtPlusPlus/api/objects/minecraft/GenericStack.java index b3bc94364f..f5db1d9e3a 100644 --- a/src/Java/gtPlusPlus/api/objects/GenericStack.java +++ b/src/Java/gtPlusPlus/api/objects/minecraft/GenericStack.java @@ -1,4 +1,4 @@ -package gtPlusPlus.api.objects; +package gtPlusPlus.api.objects.minecraft; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; diff --git a/src/Java/gtPlusPlus/api/objects/CSPRNG_DO_NOT_USE.java b/src/Java/gtPlusPlus/api/objects/random/CSPRNG_DO_NOT_USE.java index 19200846ca..b2dc984456 100644 --- a/src/Java/gtPlusPlus/api/objects/CSPRNG_DO_NOT_USE.java +++ b/src/Java/gtPlusPlus/api/objects/random/CSPRNG_DO_NOT_USE.java @@ -33,7 +33,7 @@ * http://www.opensource.org/licenses/bsd-license.php */ -package gtPlusPlus.api.objects; +package gtPlusPlus.api.objects.random; import java.math.BigInteger; import java.security.SecureRandom; import java.util.Random; diff --git a/src/Java/gtPlusPlus/api/objects/XSTR.java b/src/Java/gtPlusPlus/api/objects/random/XSTR.java index 3ff0792f6e..7f83df52c4 100644 --- a/src/Java/gtPlusPlus/api/objects/XSTR.java +++ b/src/Java/gtPlusPlus/api/objects/random/XSTR.java @@ -1,4 +1,4 @@ -package gtPlusPlus.api.objects; +package gtPlusPlus.api.objects.random; /** * A subclass of java.util.random that implements the Xorshift random number * generator diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java index c2b77ebdae..f8a9eb2b2f 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseModular.java @@ -53,11 +53,11 @@ public class BlockBaseModular extends BasicBlock{ } if (this.thisBlockType.equals(BlockTypes.STANDARD.name().toUpperCase())){ - LanguageRegistry.addName(this, "Block of "+blockMaterial); + //LanguageRegistry.addName(this, "Block of "+blockMaterial); //Utils.LOG_INFO("Registered Block in Language Registry as: "+"Block of "+blockMaterial); } else if (this.thisBlockType.equals(BlockTypes.FRAME.name().toUpperCase())){ - LanguageRegistry.addName(this, blockMaterial+ " Frame Box"); + //LanguageRegistry.addName(this, blockMaterial+ " Frame Box"); //Utils.LOG_INFO("Registered Block in Language Registry as: "+blockMaterial+ " Frame Box"); } diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java index da308e270b..7ac07880c9 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseNBT.java @@ -32,7 +32,7 @@ public abstract class BlockBaseNBT extends BlockContainer this.setBlockName(unlocalName); this.setCreativeTab(AddToCreativeTab.tabMachines); GameRegistry.registerBlock(this, ItemBlockNBT.class, unlocalName); - LanguageRegistry.addName(this, displayName); + //LanguageRegistry.addName(this, displayName); } /** diff --git a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java index 2bea09d806..2f2050f21b 100644 --- a/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java +++ b/src/Java/gtPlusPlus/core/block/base/BlockBaseOre.java @@ -53,7 +53,7 @@ public class BlockBaseOre extends BasicBlock implements ITexturedBlock { try { GameRegistry.registerBlock(this, ItemBlockOre.class, Utils.sanitizeString("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()))); GT_OreDictUnificator.registerOre("ore"+Utils.sanitizeString(this.blockMaterial.getLocalizedName()), ItemUtils.getSimpleStack(this)); - LanguageRegistry.addName(this, blockMaterial.getLocalizedName()+ " Ore"); + //LanguageRegistry.addName(this, blockMaterial.getLocalizedName()+ " Ore"); } catch (Throwable t){ t.printStackTrace(); diff --git a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java index ea55a9177d..56ba60a5f3 100644 --- a/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java +++ b/src/Java/gtPlusPlus/core/block/general/BlockTankXpConverter.java @@ -9,12 +9,12 @@ import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gtPlusPlus.api.objects.data.Triplet; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.itemblock.ItemBlockEntityBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.tileentities.general.TileEntityXpConverter; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Triplet; import gtPlusPlus.core.util.enchanting.EnchantingUtils; import gtPlusPlus.core.util.player.PlayerUtils; import net.minecraft.block.BlockContainer; diff --git a/src/Java/gtPlusPlus/core/block/general/HellFire.java b/src/Java/gtPlusPlus/core/block/general/HellFire.java index a682a0d98d..ef15f373ae 100644 --- a/src/Java/gtPlusPlus/core/block/general/HellFire.java +++ b/src/Java/gtPlusPlus/core/block/general/HellFire.java @@ -17,7 +17,7 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.math.MathUtils; diff --git a/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java b/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java index d093bf2e2f..3d97fb0aa3 100644 --- a/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java +++ b/src/Java/gtPlusPlus/core/block/general/antigrief/BlockWitherProof.java @@ -30,9 +30,8 @@ public class BlockWitherProof extends Block{ this.setResistance(5000.0F); this.setHarvestLevel("pickaxe", 3); this.setStepSound(soundTypeMetal); - LanguageRegistry.addName(this, "Wither Cage"); + //LanguageRegistry.addName(this, "Wither Cage"); GameRegistry.registerBlock(this, Utils.sanitizeString("blockBlackGate")); - } public String GetProperName(){ diff --git a/src/Java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java b/src/Java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java index f505824bc9..cb17793c59 100644 --- a/src/Java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java +++ b/src/Java/gtPlusPlus/core/client/renderer/RenderPlasmaBolt.java @@ -3,7 +3,7 @@ package gtPlusPlus.core.client.renderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.entity.EntityTeslaTowerLightning; import java.util.Random; diff --git a/src/Java/gtPlusPlus/core/commands/CommandMath.java b/src/Java/gtPlusPlus/core/commands/CommandMath.java index 27c963bf81..8e8dfbc36c 100644 --- a/src/Java/gtPlusPlus/core/commands/CommandMath.java +++ b/src/Java/gtPlusPlus/core/commands/CommandMath.java @@ -4,10 +4,13 @@ import java.util.ArrayList; import java.util.List; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.player.PlayerUtils; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityXPOrb; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChunkCoordinates; @@ -21,61 +24,82 @@ public class CommandMath implements ICommand protected String fullEntityName; protected Entity conjuredEntity; - public CommandMath() - { + public CommandMath(){ this.aliases = new ArrayList<>(); - - this.aliases.add("hometele"); - - this.aliases.add("warphome"); - + //this.aliases.add("hometele"); + //this.aliases.add("warphome"); } @Override - public int compareTo(final Object o) - { + public int compareTo(final Object o){ return 0; } @Override - public String getCommandName() - { - return "bed"; + public String getCommandName(){ + return "alkalus"; } @Override - public String getCommandUsage(final ICommandSender var1) - { - return "/bed [Teleports you to your bed for XP]"; + public String getCommandUsage(final ICommandSender var1){ + return "/alkalus [Dev Command]"; } @Override - public List<String> getCommandAliases() - { + public List<String> getCommandAliases(){ return this.aliases; } @Override - public void processCommand(final ICommandSender S, final String[] argString) - { + public void processCommand(final ICommandSender S, final String[] argString){ final World W = S.getEntityWorld(); - final CommandUtils C = new CommandUtils(); - final EntityPlayer P = C.getPlayer(S); - //System.out.println(P.getCommandSenderName()); - //System.out.println(P.getDisplayName()); - if (W.isRemote) - - { - - System.out.println("Not processing on Client side"); - + final EntityPlayer P = CommandUtils.getPlayer(S); + if (!W.isRemote){ + if (P.getDisplayName().toLowerCase().equals("draknyte1") || P.getCommandSenderName().toLowerCase().equals("draknyte1")) { + String[] prefixes = new String[] { + "ingot", + "plate", + "dust", + "gearGt", + "block", + "ore" + }; + String[] loots = new String[] { + "Iron", + "Iron", + "Iron", + "Copper", + "Copper", + "Copper", + "Tin", + "Mica", + "Steel", + "Steel", + "Steel", + "Invar", + "Titanium", + "Gold", + "Silver", + "Lead", + "Aluminium" + }; + AutoMap<EntityItem> itemEntities = new AutoMap<EntityItem>(); + for (String g : prefixes) { + for (String s : loots) { + itemEntities.put(new EntityItem(W, P.posX, P.posY, P.posZ, ItemUtils.getItemStackOfAmountFromOreDictNoBroken(g+s, 64))); + }} + for (EntityItem e : itemEntities.values()) { + e.lifespan = 30000; + } + + } } - else + /*else { @@ -167,36 +191,30 @@ public class CommandMath implements ICommand gregtech.api.util.GT_Utility.sendChatToPlayer(P, "You don't feel you're able to do this yet."); } - } + }*/ } @Override - public boolean canCommandSenderUseCommand(final ICommandSender var1) - { - return true; - + public boolean canCommandSenderUseCommand(final ICommandSender var1){ + final EntityPlayer P = CommandUtils.getPlayer(var1); + if (P.getDisplayName().toLowerCase().equals("draknyte1") || P.getCommandSenderName().toLowerCase().equals("draknyte1")) { + return true; + } + return false; } @Override - public List<?> addTabCompletionOptions(final ICommandSender var1, final String[] var2) - { - // TODO Auto-generated method stub - + public List<?> addTabCompletionOptions(final ICommandSender var1, final String[] var2){ return null; - } @Override - public boolean isUsernameIndex(final String[] var1, final int var2) - { + public boolean isUsernameIndex(final String[] var1, final int var2){ // TODO Auto-generated method stub - return false; - } - public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost) - { + public boolean playerUsesCommand(final World W, final EntityPlayer P, final int cost){ return true; diff --git a/src/Java/gtPlusPlus/core/commands/CommandUtils.java b/src/Java/gtPlusPlus/core/commands/CommandUtils.java index 4e74d53464..175925d40c 100644 --- a/src/Java/gtPlusPlus/core/commands/CommandUtils.java +++ b/src/Java/gtPlusPlus/core/commands/CommandUtils.java @@ -5,7 +5,7 @@ import net.minecraft.entity.player.EntityPlayer; public class CommandUtils { - public EntityPlayer getPlayer(final ICommandSender icommandsender){ + public static EntityPlayer getPlayer(final ICommandSender icommandsender){ EntityPlayer player; if(icommandsender instanceof EntityPlayer){ diff --git a/src/Java/gtPlusPlus/core/common/CommonProxy.java b/src/Java/gtPlusPlus/core/common/CommonProxy.java index d5f4d95aef..421a522945 100644 --- a/src/Java/gtPlusPlus/core/common/CommonProxy.java +++ b/src/Java/gtPlusPlus/core/common/CommonProxy.java @@ -5,8 +5,8 @@ import static gtPlusPlus.core.lib.CORE.DEBUG; import cpw.mods.fml.common.event.*; import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.GTplusplus; -import gtPlusPlus.api.objects.ChunkManager; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.ChunkManager; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.entity.InternalEntityRegistry; diff --git a/src/Java/gtPlusPlus/core/config/ConfigHandler.java b/src/Java/gtPlusPlus/core/config/ConfigHandler.java index 98c4320ce7..a9fbec55de 100644 --- a/src/Java/gtPlusPlus/core/config/ConfigHandler.java +++ b/src/Java/gtPlusPlus/core/config/ConfigHandler.java @@ -31,6 +31,8 @@ public class ConfigHandler { "Makes many machines display lots of debug logging."); showHiddenNEIItems = config.getBoolean("showHiddenNEIItems", "debug", false, "Makes all items hidden from NEI display."); + dumpItemAndBlockData = config.getBoolean("dumpItemAndBlockData", "debug", false, + "Dumps all GT++ and Toxic Everglade Data to en_US.lang in the config folder. This config option can be used by foreign players to generate blank .lang files, which they can populate with their language of choice."); // Machines diff --git a/src/Java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java b/src/Java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java index 0cd5bd85bf..d1528747a1 100644 --- a/src/Java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java +++ b/src/Java/gtPlusPlus/core/entity/EntityTeslaTowerLightning.java @@ -5,7 +5,7 @@ import java.util.UUID; import gtPlusPlus.api.damage.DamageTeslaTower; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.util.entity.EntityUtils; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; diff --git a/src/Java/gtPlusPlus/core/entity/projectile/EntityHydrofluoricAcidPotion.java b/src/Java/gtPlusPlus/core/entity/projectile/EntityHydrofluoricAcidPotion.java index c935409650..7517011673 100644 --- a/src/Java/gtPlusPlus/core/entity/projectile/EntityHydrofluoricAcidPotion.java +++ b/src/Java/gtPlusPlus/core/entity/projectile/EntityHydrofluoricAcidPotion.java @@ -1,7 +1,7 @@ package gtPlusPlus.core.entity.projectile; import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.Block; diff --git a/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java b/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java index cd4bec52bf..dfab6fa8ec 100644 --- a/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java +++ b/src/Java/gtPlusPlus/core/entity/projectile/EntitySulfuricAcidPotion.java @@ -1,7 +1,7 @@ package gtPlusPlus.core.entity.projectile; import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.Block; diff --git a/src/Java/gtPlusPlus/core/handler/BurnableFuelHandler.java b/src/Java/gtPlusPlus/core/handler/BurnableFuelHandler.java index 79ca0ad174..8bcdaca6a8 100644 --- a/src/Java/gtPlusPlus/core/handler/BurnableFuelHandler.java +++ b/src/Java/gtPlusPlus/core/handler/BurnableFuelHandler.java @@ -1,8 +1,8 @@ package gtPlusPlus.core.handler; import cpw.mods.fml.common.IFuelHandler; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; diff --git a/src/Java/gtPlusPlus/api/analytics/AnalyticsLoggingPlugin.java b/src/Java/gtPlusPlus/core/handler/analytics/AnalyticsLoggingPlugin.java index 2423eaa65c..808c62d7aa 100644 --- a/src/Java/gtPlusPlus/api/analytics/AnalyticsLoggingPlugin.java +++ b/src/Java/gtPlusPlus/core/handler/analytics/AnalyticsLoggingPlugin.java @@ -1,4 +1,4 @@ -package gtPlusPlus.api.analytics; +package gtPlusPlus.core.handler.analytics; import com.segment.analytics.Analytics; import com.segment.analytics.Callback; diff --git a/src/Java/gtPlusPlus/api/analytics/BlockingFlush.java b/src/Java/gtPlusPlus/core/handler/analytics/BlockingFlush.java index dddb37fefb..09d1cd5104 100644 --- a/src/Java/gtPlusPlus/api/analytics/BlockingFlush.java +++ b/src/Java/gtPlusPlus/core/handler/analytics/BlockingFlush.java @@ -1,4 +1,4 @@ -package gtPlusPlus.api.analytics; +package gtPlusPlus.core.handler.analytics; import com.segment.analytics.Analytics; import com.segment.analytics.Callback; diff --git a/src/Java/gtPlusPlus/api/analytics/SegmentAnalytics.java b/src/Java/gtPlusPlus/core/handler/analytics/SegmentAnalytics.java index c4ef82b9ef..a217f896cf 100644 --- a/src/Java/gtPlusPlus/api/analytics/SegmentAnalytics.java +++ b/src/Java/gtPlusPlus/core/handler/analytics/SegmentAnalytics.java @@ -1,4 +1,4 @@ -package gtPlusPlus.api.analytics; +package gtPlusPlus.core.handler.analytics; import java.util.LinkedHashMap; import java.util.Map; diff --git a/src/Java/gtPlusPlus/api/analytics/SegmentHelper.java b/src/Java/gtPlusPlus/core/handler/analytics/SegmentHelper.java index 6e264fe1d2..79b95eda24 100644 --- a/src/Java/gtPlusPlus/api/analytics/SegmentHelper.java +++ b/src/Java/gtPlusPlus/core/handler/analytics/SegmentHelper.java @@ -1,4 +1,4 @@ -package gtPlusPlus.api.analytics; +package gtPlusPlus.core.handler.analytics; import com.segment.analytics.Analytics; import com.segment.analytics.Callback; diff --git a/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java index cd79cf7fe6..0c6e798edd 100644 --- a/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java @@ -9,9 +9,9 @@ import java.util.Map; import java.util.Random; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import gtPlusPlus.api.analytics.SegmentAnalytics; -import gtPlusPlus.api.analytics.SegmentHelper; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.handler.analytics.SegmentAnalytics; +import gtPlusPlus.core.handler.analytics.SegmentHelper; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; diff --git a/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java index 09365e3caf..c8c6a23bca 100644 --- a/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/LoginEventHandler.java @@ -4,9 +4,9 @@ import java.util.*; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; -import gtPlusPlus.api.analytics.SegmentAnalytics; -import gtPlusPlus.api.analytics.SegmentHelper; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.handler.analytics.SegmentAnalytics; +import gtPlusPlus.core.handler.analytics.SegmentHelper; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.proxy.ClientProxy; diff --git a/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java index aa9155d654..bdc9489f1d 100644 --- a/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/PickaxeBlockBreakEventHandler.java @@ -5,10 +5,8 @@ import java.util.UUID; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.metatileentity.*; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaSafeBlockBase; -import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -20,25 +18,14 @@ public class PickaxeBlockBreakEventHandler { try{ final TileEntity entity = event.world.getTileEntity(event.x, event.y, event.z); if (entity != null){ - final EntityPlayer playerInternal = event.getPlayer(); - Logger.WARNING(entity.getClass().getSimpleName()); - if (entity.getClass().getSimpleName().equals("")){ - - } - if ((entity instanceof BaseTileEntity) && !(entity instanceof BaseMetaPipeEntity)){ + final EntityPlayer playerInternal = event.getPlayer(); + if ((entity instanceof BaseMetaTileEntity) && !(BaseMetaPipeEntity.class.isInstance(entity))){ final IMetaTileEntity X = ((BaseMetaTileEntity)entity).getMetaTileEntity(); - final Block ThisBlock = X.getBaseMetaTileEntity().getBlock(event.x, event.y, event.z); + //final Block ThisBlock = X.getBaseMetaTileEntity().getBlock(event.x, event.y, event.z); if (X instanceof GregtechMetaSafeBlockBase){ - final UUID ownerUUID = ((GregtechMetaSafeBlockBase)X).ownerUUID; final UUID accessorUUID = playerInternal.getUniqueID(); - Logger.WARNING("Owner UUID: "+ownerUUID); - Logger.WARNING("Accessor UUID: "+accessorUUID); - if (((GregtechMetaSafeBlockBase)X).bUnbreakable){ - - Logger.INFO("UUID info. Accessor: "+accessorUUID + " | Owner: "+ownerUUID); - if (accessorUUID == ownerUUID){ PlayerUtils.messagePlayer(playerInternal, "Since you own this block, it has been destroyed."); event.setCanceled(false); @@ -47,15 +34,13 @@ public class PickaxeBlockBreakEventHandler { event.setCanceled(true); PlayerUtils.messagePlayer(playerInternal, "Since you do not own this block, it has not been destroyed."); } - // } } } } - } catch (final NullPointerException e) { - System.out.print("Caught a NullPointerException involving Safe Blocks. Cause: "+e.getCause()); + //System.out.print("Caught a NullPointerException involving Safe Blocks. Cause: "+e.getCause()); } } diff --git a/src/Java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java index 877b0c6ced..572f52124f 100644 --- a/src/Java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/ZombieBackupSpawnEventHandler.java @@ -7,8 +7,8 @@ import org.apache.commons.lang3.reflect.FieldUtils; import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import gtPlusPlus.api.analytics.SegmentHelper; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.core.handler.analytics.SegmentHelper; import net.minecraftforge.event.entity.living.ZombieEvent; public class ZombieBackupSpawnEventHandler { diff --git a/src/Java/gtPlusPlus/core/item/base/BaseEuItem.java b/src/Java/gtPlusPlus/core/item/base/BaseEuItem.java index 8f8d0eed72..a32ff20353 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseEuItem.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseEuItem.java @@ -16,9 +16,9 @@ import gregtech.api.interfaces.IItemBehaviour; import gregtech.api.interfaces.IItemContainer; import gregtech.api.objects.ItemData; import gregtech.api.util.*; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.array.Pair; import ic2.api.item.*; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemBurnable.java b/src/Java/gtPlusPlus/core/item/base/BaseItemBurnable.java index 42aadfa91d..76d66069f5 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemBurnable.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemBurnable.java @@ -1,7 +1,7 @@ package gtPlusPlus.core.item.base; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; diff --git a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java index 7622838f68..8b68d955e3 100644 --- a/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/BaseItemComponent.java @@ -86,7 +86,7 @@ public class BaseItemComponent extends Item{ //return "gregtech" + ":" + "materialicons/"+metType+"/" + this.componentType.COMPONENT_NAME.toLowerCase(); } - @Override + /*@Override public String getItemStackDisplayName(final ItemStack p_77653_1_) { if (this.componentType == ComponentTypes.SMALLGEAR){ @@ -97,7 +97,7 @@ public class BaseItemComponent extends Item{ return (this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME); } return this.materialName+" Cell"; - } + }*/ public final String getMaterialName() { return this.materialName; diff --git a/src/Java/gtPlusPlus/core/item/base/CoreItem.java b/src/Java/gtPlusPlus/core/item/base/CoreItem.java index 3b0fa7b621..d80553de96 100644 --- a/src/Java/gtPlusPlus/core/item/base/CoreItem.java +++ b/src/Java/gtPlusPlus/core/item/base/CoreItem.java @@ -194,11 +194,11 @@ public class CoreItem extends Item } } - @Override +/* @Override public String getItemStackDisplayName(final ItemStack tItem) { if ((this.itemName == null) || this.itemName.equals("")) { return super.getItemStackDisplayName(tItem); } return this.itemName; - } + }*/ }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java index 4ac7c7f5ff..aed0145303 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java @@ -1,6 +1,9 @@ package gtPlusPlus.core.item.base.itemblock; +import java.util.List; + import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.interfaces.ITileTooltip; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.tileentities.base.TileEntityBase; import gtPlusPlus.core.util.player.PlayerUtils; @@ -15,10 +18,29 @@ import net.minecraft.world.World; public class ItemBlockNBT extends ItemBlock { + + protected final int mID; + public ItemBlockNBT(final Block block) { super(block); + this.mID = ((ITileTooltip) block).getTooltipID(); + } + + + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + //if () + + + + if (this.mID == 0){ //blockDarkWorldPortalFrame + list.add("Assembled in the same shape as the Nether Portal."); + } } + + @Override public void onCreated(ItemStack item, World world, EntityPlayer player) { addNBT(player, item); @@ -59,17 +81,13 @@ public class ItemBlockNBT extends ItemBlock { @Override public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) { - - - if (!(aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3))) { return false; } if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, aMeta); - } - + } TileEntityBase tTileEntity = (TileEntityBase) aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity != null && aPlayer != null) { if (tTileEntity.isServerSide()){ @@ -78,7 +96,6 @@ public class ItemBlockNBT extends ItemBlock { tTileEntity.setOwnerInformation(aNBT.getString("mOwner"), aNBT.getString("mUUID"), aNBT.getBoolean("mOP")); } } - return true; } diff --git a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java index e2de72fa57..d11deecc17 100644 --- a/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java +++ b/src/Java/gtPlusPlus/core/item/base/ore/BaseOreComponent.java @@ -57,10 +57,10 @@ public class BaseOreComponent extends Item{ return "gregtech" + ":" + "materialicons/METALLIC/" + this.componentType.COMPONENT_NAME; } - @Override + /*@Override public String getItemStackDisplayName(final ItemStack p_77653_1_) { return (this.componentType.getPrefix()+this.componentMaterial.getLocalizedName()+this.componentType.DISPLAY_NAME); - } + }*/ public final String getMaterialName() { return this.materialName; diff --git a/src/Java/gtPlusPlus/core/item/general/ItemAreaClear.java b/src/Java/gtPlusPlus/core/item/general/ItemAreaClear.java index fc92d5d82c..a3f7b78888 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemAreaClear.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemAreaClear.java @@ -3,11 +3,11 @@ package gtPlusPlus.core.item.general; import java.util.List; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.block.base.BlockBaseOre; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.item.base.CoreItem; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.array.BlockPos; import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.client.renderer.texture.IIconRegister; diff --git a/src/Java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java b/src/Java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java index 0463628e46..1ad12b69d4 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemHalfCompleteCasings.java @@ -32,7 +32,7 @@ public class ItemHalfCompleteCasings extends BaseItemColourable{ } } - @Override + /*@Override public String getItemStackDisplayName(final ItemStack tItem) { String prefix = "Half Complete Casing "; String casingType = ""; @@ -50,7 +50,7 @@ public class ItemHalfCompleteCasings extends BaseItemColourable{ } return (prefix+casingType); - } + }*/ @Override public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { diff --git a/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java b/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java index 1b8ab947e5..64f1c4e139 100644 --- a/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java +++ b/src/Java/gtPlusPlus/core/item/general/capture/ItemEntityCatcher.java @@ -6,10 +6,10 @@ import java.util.UUID; import cpw.mods.fml.common.registry.GameRegistry; import gtPlusPlus.api.interfaces.IEntityCatcher; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.BlockPos; import gtPlusPlus.core.util.nbt.NBTUtils; import gtPlusPlus.core.util.player.PlayerUtils; import net.minecraft.entity.*; diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java index 45e0bd8fe6..66b4d87511 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java @@ -6,10 +6,10 @@ import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.recipe.RecipeUtils; diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index c43c8dd3e7..67de9e64dd 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -6,10 +6,10 @@ import java.util.concurrent.ConcurrentHashMap; import com.mojang.authlib.GameProfile; import gregtech.api.GregTech_API; -import gtPlusPlus.api.objects.CSPRNG_DO_NOT_USE; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.api.objects.random.CSPRNG_DO_NOT_USE; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.geo.GeoUtils; import gtPlusPlus.core.util.gregtech.recipehandlers.GregtechRecipe; import gtPlusPlus.core.util.networking.NetworkUtils; @@ -47,7 +47,7 @@ public class CORE { public static final String name = "GT++"; public static final String MODID = "miscutils"; - public static final String VERSION = "1.7.0-prerelease-4"; + public static final String VERSION = "1.7.0-prerelease-5"; public static String MASTER_VERSION = NetworkUtils.getContentFromURL("https://raw.githubusercontent.com/draknyte1/GTplusplus/master/Recommended.txt").toLowerCase(); public static String USER_COUNTRY = GeoUtils.determineUsersCountry(); public static boolean isModUpToDate = Utils.isModUpToDate(); @@ -148,6 +148,7 @@ public class CORE { public static boolean disableEnderIOIngotTooltips = false; public static boolean MACHINE_INFO = true; public static boolean showHiddenNEIItems = false; + public static boolean dumpItemAndBlockData = false; //Tools public static boolean enableSkookumChoochers = true; diff --git a/src/Java/gtPlusPlus/core/material/Material.java b/src/Java/gtPlusPlus/core/material/Material.java index eca3c595ec..22c65c5a2b 100644 --- a/src/Java/gtPlusPlus/core/material/Material.java +++ b/src/Java/gtPlusPlus/core/material/Material.java @@ -7,13 +7,13 @@ import java.util.Map.Entry; import gregtech.api.enums.*; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.item.base.cell.BaseItemCell; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.StringUtils; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.array.ArrayUtils; -import gtPlusPlus.core.util.array.AutoMap; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.materials.MaterialUtils; diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index bd53c4f38a..969eb3aed8 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -27,7 +27,6 @@ import gtPlusPlus.core.util.reflect.AddGregtechRecipe; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; @@ -1040,16 +1039,53 @@ public class RECIPES_GREGTECH { //LFTR Fuel Related Compounds - //Hydroxide - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), - GT_Values.NF, - FluidUtils.getFluidStack("hydroxide", 2000), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), - 8*20); - //Ammonia + if(CORE.GTNH){ + //Hydroxide + AddGregtechRecipe.addChemicalRecipeForBasicMachineOnly( + ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), + GT_Values.NF, + FluidUtils.getFluidStack("hydroxide", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), + GT_Values.NI, + 8*20, 30); + //Beryllium Hydroxide + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustBeryllium", 7), + ItemUtils.getGregtechCircuit(3), + FluidUtils.getFluidStack("hydroxide", 1000), + FluidUtils.getFluidStack("berylliumhydroxide", 2000), + GT_Values.NI, + 8*20); + //Ammonium Bifluoride + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrofluoricAcid", 1), + ItemUtils.getGregtechCircuit(3), + FluidUtils.getFluidStack("ammonium", 1000), + FluidUtils.getFluidStack("ammoniumbifluoride", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1), + 26*20); + //Ammonium + AddGregtechRecipe.addChemicalRecipeForBasicMachineOnly( + ItemUtils.getItemStackOfAmountFromOreDict("cellAmmonia", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), + GT_Values.NF, + FluidUtils.getFluidStack("ammonium", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), + GT_Values.NI, + 20*20, 30); + } + if (!CORE.GTNH) { + //Hydroxide + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellOxygen", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), + GT_Values.NF, + FluidUtils.getFluidStack("hydroxide", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), + 8*20); + //Ammonia (moved to GTNH core mod) GT_Values.RA.addChemicalRecipe( ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 3), ItemUtils.getItemStackOfAmountFromOreDict("dustMagnetite", 0), @@ -1057,31 +1093,31 @@ public class RECIPES_GREGTECH { FluidUtils.getFluidStack("ammonia", 1000), ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 3), 14 * 20); - }//moved to GTNH core mod - //Ammonium - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellAmmonia", 1), - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), - GT_Values.NF, - FluidUtils.getFluidStack("ammonium", 2000), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), - 20*20); - //Ammonium Bifluoride - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("cellHydrofluoricAcid", 1), - GT_Values.NI, - FluidUtils.getFluidStack("ammonium", 1000), - FluidUtils.getFluidStack("ammoniumbifluoride", 2000), - ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1), - 26*20); - //Beryllium Hydroxide - GT_Values.RA.addChemicalRecipe( - ItemUtils.getItemStackOfAmountFromOreDict("dustBeryllium", 7), - GT_Values.NI, - FluidUtils.getFluidStack("hydroxide", 1000), - FluidUtils.getFluidStack("berylliumhydroxide", 2000), - GT_Values.NI, - 8*20); + //Beryllium Hydroxide + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("dustBeryllium", 7), + GT_Values.NI, + FluidUtils.getFluidStack("hydroxide", 1000), + FluidUtils.getFluidStack("berylliumhydroxide", 2000), + GT_Values.NI, + 8*20); + //Ammonium Bifluoride + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrofluoricAcid", 1), + GT_Values.NI, + FluidUtils.getFluidStack("ammonium", 1000), + FluidUtils.getFluidStack("ammoniumbifluoride", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 1), + 26*20); + //Ammonium + GT_Values.RA.addChemicalRecipe( + ItemUtils.getItemStackOfAmountFromOreDict("cellAmmonia", 1), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1), + GT_Values.NF, + FluidUtils.getFluidStack("ammonium", 2000), + ItemUtils.getItemStackOfAmountFromOreDict("cellEmpty", 2), + 20*20); + } } private static void blastFurnaceRecipes(){ diff --git a/src/Java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java b/src/Java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java index 85de0df60e..b6930dfe27 100644 --- a/src/Java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java +++ b/src/Java/gtPlusPlus/core/slots/SlotModularBaubleUpgrades.java @@ -7,7 +7,7 @@ import java.util.Iterator; import java.util.Map.Entry; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.array.Pair; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.util.nbt.ModularArmourUtils.BT; import gtPlusPlus.core.util.nbt.ModularArmourUtils.Modifiers; import net.minecraft.inventory.IInventory; diff --git a/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java b/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java index 81dfb1acf4..f8d4c3074e 100644 --- a/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java +++ b/src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java @@ -82,7 +82,6 @@ public abstract class TileEntityBase extends TileEntity implements ISidedInvento } public boolean onPreTick(){ - return true; } @@ -141,10 +140,7 @@ public abstract class TileEntityBase extends TileEntity implements ISidedInvento public boolean isServerSide(){ if (this.hasWorldObj()){ - if (this.getWorldObj().isRemote){ - return false; - } - else { + if (!this.getWorldObj().isRemote){ return true; } } diff --git a/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java b/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java new file mode 100644 index 0000000000..8b789f922f --- /dev/null +++ b/src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java @@ -0,0 +1,1171 @@ +package gtPlusPlus.core.tileentities.base; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.tileentity.IEnergyConnected; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.net.GT_Packet; +import gregtech.api.net.GT_Packet_Block_Event; +import gregtech.api.net.GT_Packet_TileEntity; +import gregtech.api.net.IGT_NetworkHandler; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.interfaces.IGregtechPower; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import ic2.api.info.Info; +import net.minecraft.block.Block; +import net.minecraft.block.BlockFire; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public abstract class TilePoweredGT extends TileEntityBase implements IGregtechPower { + + public static AutoMap<TilePoweredGT> mPoweredEntities = new AutoMap<TilePoweredGT>(); + + //Base Tile Fields + public boolean ignoreUnloadedChunks; + public boolean isDead; + //Meta Tile Fields + private long mAcceptedAmperes; + + private boolean[] mActiveEUInputs; + private boolean[] mActiveEUOutputs; + protected int[] mAverageEUInput; + protected int mAverageEUInputIndex; + protected int[] mAverageEUOutput; + protected int mAverageEUOutputIndex; + private final TileEntity[] mBufferedTileEntities; + private byte mFacing = 0; + private boolean mHasEnoughEnergy; + private boolean mNeedsUpdate; + private boolean mNeedsBlockUpdate; + private boolean mRunningThroughTick; + private boolean mSendClientData; + protected boolean mReleaseEnergy; + private long mTickTimer; + protected long mStoredEnergy; + protected long mStoredSteam; + + public TilePoweredGT() { + super(); + this.mBufferedTileEntities = new TileEntity[6]; + this.ignoreUnloadedChunks = true; + this.isDead = false; + mPoweredEntities.put(this); + } + + @Override + public boolean acceptsRotationalEnergy(byte p0) { + return false; + } + + private boolean canAccessData() { + return this.isInvalid() ? false : true; + } + + private final void clearNullMarkersFromTileEntityBuffer() { + for (int i = 0; i < this.mBufferedTileEntities.length; ++i) { + if (this.mBufferedTileEntities[i] == this) { + this.mBufferedTileEntities[i] = null; + } + } + } + + protected final void clearTileEntityBuffer() { + for (int i = 0; i < this.mBufferedTileEntities.length; ++i) { + this.mBufferedTileEntities[i] = null; + } + } + + private boolean crossedChunkBorder(final int aX, final int aZ) { + return aX >> 4 != this.xCoord >> 4 || aZ >> 4 != this.zCoord >> 4; + } + + @Override + public boolean decreaseStoredEnergyUnits(final long aEnergy, final boolean aIgnoreTooLessEnergy) { + return this.canAccessData() && (this.mHasEnoughEnergy = (this.decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) + || this.decreaseStoredSteam(aEnergy, false) + || (aIgnoreTooLessEnergy && this.decreaseStoredSteam(aEnergy, true)))); + } + + public boolean decreaseStoredEU(final long aEnergy, final boolean aIgnoreTooLessEnergy) { + if (!this.canAccessData()) { + return false; + } + if (this.getEUVar() - aEnergy < 0L && !aIgnoreTooLessEnergy) { + return false; + } + this.setStoredEU(this.getEUVar() - aEnergy); + if (this.getEUVar() < 0L) { + this.setStoredEU(0L); + return false; + } + return true; + } + + public boolean decreaseStoredSteam(final long aEnergy, final boolean aIgnoreTooLessEnergy) { + if (!this.canAccessData()) { + return false; + } + if (this.getSteamVar() - aEnergy < 0L && !aIgnoreTooLessEnergy) { + return false; + } + this.setStoredSteam(this.getSteamVar() - aEnergy); + if (this.getSteamVar() < 0L) { + this.setStoredSteam(0L); + return false; + } + return true; + } + + public void doExplosion(final long aExplosionPower) { + final float tStrength = (aExplosionPower < GT_Values.V[0]) + ? 1.0f + : ((aExplosionPower < GT_Values.V[1]) + ? 2.0f + : ((aExplosionPower < GT_Values.V[2]) + ? 3.0f + : ((aExplosionPower < GT_Values.V[3]) + ? 4.0f + : ((aExplosionPower < GT_Values.V[4]) + ? 5.0f + : ((aExplosionPower < GT_Values.V[4] * 2L) + ? 6.0f + : ((aExplosionPower < GT_Values.V[5]) + ? 7.0f + : ((aExplosionPower < GT_Values.V[6]) + ? 8.0f + : ((aExplosionPower < GT_Values.V[7]) + ? 9.0f + : 10.0f)))))))); + final int tX = this.getXCoord(); + final int tY = this.getYCoord(); + final int tZ = this.getZCoord(); + final World tWorld = this.getWorld(); + GT_Utility.sendSoundToPlayers(tWorld, (String) GregTech_API.sSoundList.get(209), 1.0f, -1.0f, tX, tY, tZ); + tWorld.setBlock(tX, tY, tZ, Blocks.air); + if (GregTech_API.sMachineExplosions) { + tWorld.createExplosion((Entity) null, tX + 0.5, tY + 0.5, tZ + 0.5, tStrength, true); + } + } + + public boolean drainEnergyUnits(final byte aSide, final long aVoltage, final long aAmperage) { + if (!this.canAccessData() || !this.isElectric() || !this.outputsEnergyTo(aSide) + || this.getStoredEU() - aVoltage * aAmperage < this.getMinimumStoredEU()) { + return false; + } + if (this.decreaseStoredEU(aVoltage * aAmperage, false)) { + final int[] mAverageEUOutput = this.mAverageEUOutput; + final int mAverageEUOutputIndex = this.mAverageEUOutputIndex; + mAverageEUOutput[mAverageEUOutputIndex] += (int) (aVoltage * aAmperage); + return true; + } + return false; + } + + @Override + public final boolean getAir(final int aX, final int aY, final int aZ) { + return (this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)) + || GT_Utility.isBlockAir(this.worldObj, aX, aY, aZ); + } + + @Override + public final boolean getAirAtSide(final byte aSide) { + return this.getAirAtSideAndDistance(aSide, 1); + } + + @Override + public final boolean getAirAtSideAndDistance(final byte aSide, final int aDistance) { + return this.getAir(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + @Override + public final boolean getAirOffset(final int aX, final int aY, final int aZ) { + return this.getAir(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public long getAverageElectricInput() { + int rEU = 0; + for (int i = 0; i < this.mAverageEUInput.length; ++i) { + if (i != this.mAverageEUInputIndex) { + rEU += this.mAverageEUInput[i]; + } + } + return rEU / (this.mAverageEUInput.length - 1); + } + + public long getAverageElectricOutput() { + int rEU = 0; + for (int i = 0; i < this.mAverageEUOutput.length; ++i) { + if (i != this.mAverageEUOutputIndex) { + rEU += this.mAverageEUOutput[i]; + } + } + return rEU / (this.mAverageEUOutput.length - 1); + } + + @Override + public byte getBackFacing() { + return GT_Utility.getOppositeSide((int) this.mFacing); + } + + @Override + public final Block getBlock(final int aX, final int aY, final int aZ) { + if (this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)) { + return Blocks.air; + } + return this.worldObj.getBlock(aX, aY, aZ); + } + + + @Override + public final Block getBlockAtSide(final byte aSide) { + return this.getBlockAtSideAndDistance(aSide, 1); + } + + @Override + public final Block getBlockAtSideAndDistance(final byte aSide, final int aDistance) { + return this.getBlock(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + @Override + public final Block getBlockOffset(final int aX, final int aY, final int aZ) { + return this.getBlock(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public String[] getDescription() { + // TODO Auto-generated method stub + return null; + } + + + + + + + + + @Override + public long getEUCapacity() { + if (this.canAccessData()) { + return this.maxEUStore(); + } + return 0L; + } + + public long getEUVar() { + return mStoredEnergy; + } + + @Override + public byte getFrontFacing() { + return this.mFacing; + } + + @Override + public final IGregTechTileEntity getIGregTechTileEntity(final int aX, final int aY, final int aZ) { + final TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + return (IGregTechTileEntity) tTileEntity; + } + return null; + } + + @Override + public final IGregTechTileEntity getIGregTechTileEntityAtSide(final byte aSide) { + final TileEntity tTileEntity = this.getTileEntityAtSide(aSide); + if (tTileEntity instanceof IGregTechTileEntity) { + return (IGregTechTileEntity) tTileEntity; + } + return null; + } + + @Override + public final IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(final byte aSide, final int aDistance) { + final TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); + if (tTileEntity instanceof IGregTechTileEntity) { + return (IGregTechTileEntity) tTileEntity; + } + return null; + } + + @Override + public final IGregTechTileEntity getIGregTechTileEntityOffset(final int aX, final int aY, final int aZ) { + final TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + return (IGregTechTileEntity) tTileEntity; + } + return null; + } + + @Override + public final IInventory getIInventory(final int aX, final int aY, final int aZ) { + final TileEntity tTileEntity = this.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IInventory) { + return (IInventory) tTileEntity; + } + return null; + } + + @Override + public final IInventory getIInventoryAtSide(final byte aSide) { + final TileEntity tTileEntity = this.getTileEntityAtSide(aSide); + if (tTileEntity instanceof IInventory) { + return (IInventory) tTileEntity; + } + return null; + } + + @Override + public final IInventory getIInventoryAtSideAndDistance(final byte aSide, final int aDistance) { + final TileEntity tTileEntity = this.getTileEntityAtSideAndDistance(aSide, aDistance); + if (tTileEntity instanceof IInventory) { + return (IInventory) tTileEntity; + } + return null; + } + + @Override + public final IInventory getIInventoryOffset(final int aX, final int aY, final int aZ) { + final TileEntity tTileEntity = this.getTileEntityOffset(aX, aY, aZ); + if (tTileEntity instanceof IInventory) { + return (IInventory) tTileEntity; + } + return null; + } + + @Override + public String[] getInfoData() { + // TODO Auto-generated method stub + return null; + } + + @Override + public long getInputAmperage() { + if (this.canAccessData() && this.isElectric()) { + return this.maxAmperesIn(); + } + return 0L; + } + + public long getInputTier() { + return GT_Utility.getTier(this.getInputVoltage()); + } + + @Override + public long getInputVoltage() { + if (this.canAccessData() && this.isElectric()) { + return this.maxEUInput(); + } + return 2147483647L; + } + + private long getMinimumStoredEU() { + return 0; + } + + @Override + public final int getOffsetX(final byte aSide, final int aMultiplier) { + return this.xCoord + ForgeDirection.getOrientation((int) aSide).offsetX * aMultiplier; + } + + public final short getOffsetY(final byte aSide, final int aMultiplier) { + return (short) (this.yCoord + ForgeDirection.getOrientation((int) aSide).offsetY * aMultiplier); + } + + public final int getOffsetZ(final byte aSide, final int aMultiplier) { + return this.zCoord + ForgeDirection.getOrientation((int) aSide).offsetZ * aMultiplier; + } + + @Override + public long getOutputAmperage() { + if (this.canAccessData() && this.isElectric()) { + return this.maxAmperesOut(); + } + return 0L; + } + + public long getOutputTier() { + return GT_Utility.getTier(this.getOutputVoltage()); + } + + @Override + public long getOutputVoltage() { + if (this.canAccessData() && this.isElectric() && this.isEnetOutput()) { + return this.maxEUOutput(); + } + return 0L; + } + + @Override + public int getRandomNumber(int p0) { + return CORE.RANDOM.nextInt(); + } + + @Override + public long getSteamCapacity() { + if (this.canAccessData()) { + return this.maxSteamStore(); + } + return 0L; + } + + public long getSteamVar() { + return mStoredSteam; + } + + @Override + public long getStoredEU() { + if (this.canAccessData()) { + return Math.min(this.getEUVar(), this.getEUCapacity()); + } + return 0L; + } + + + + + + + + + + @Override + public long getStoredSteam() { + if (this.canAccessData()) { + return Math.min(this.getSteamVar(), this.getSteamCapacity()); + } + return 0L; + } + + @Override + public final TileEntity getTileEntity(final int aX, final int aY, final int aZ) { + if (this.ignoreUnloadedChunks && this.crossedChunkBorder(aX, aZ) && !this.worldObj.blockExists(aX, aY, aZ)) { + return null; + } + return this.worldObj.getTileEntity(aX, aY, aZ); + } + + public final TileEntity getTileEntityAtSide(final byte aSide) { + if (aSide < 0 || aSide >= 6 || this.mBufferedTileEntities[aSide] == this) { + return null; + } + final int tX = this.getOffsetX(aSide, 1); + final int tY = this.getOffsetY(aSide, 1); + final int tZ = this.getOffsetZ(aSide, 1); + if (this.crossedChunkBorder(tX, tZ)) { + this.mBufferedTileEntities[aSide] = null; + if (this.ignoreUnloadedChunks && !this.worldObj.blockExists(tX, tY, tZ)) { + return null; + } + } + if (this.mBufferedTileEntities[aSide] == null) { + this.mBufferedTileEntities[aSide] = this.worldObj.getTileEntity(tX, tY, tZ); + if (this.mBufferedTileEntities[aSide] == null) { + this.mBufferedTileEntities[aSide] = this; + return null; + } + return this.mBufferedTileEntities[aSide]; + } else { + if (this.mBufferedTileEntities[aSide].isInvalid()) { + this.mBufferedTileEntities[aSide] = null; + return this.getTileEntityAtSide(aSide); + } + if (this.mBufferedTileEntities[aSide].xCoord == tX && this.mBufferedTileEntities[aSide].yCoord == tY + && this.mBufferedTileEntities[aSide].zCoord == tZ) { + return this.mBufferedTileEntities[aSide]; + } + return null; + } + } + + @Override + public final TileEntity getTileEntityAtSideAndDistance(final byte aSide, final int aDistance) { + if (aDistance == 1) { + return this.getTileEntityAtSide(aSide); + } + return this.getTileEntity(this.getOffsetX(aSide, aDistance), this.getOffsetY(aSide, aDistance), + this.getOffsetZ(aSide, aDistance)); + } + + + + + + + + + + + @Override + public final TileEntity getTileEntityOffset(final int aX, final int aY, final int aZ) { + return this.getTileEntity(this.xCoord + aX, this.yCoord + aY, this.zCoord + aZ); + } + + @Override + public long getUniversalEnergyCapacity() { + return 0; + } + + @Override + public long getUniversalEnergyStored() { + return 0; + } + + @Override + public World getWorld() { + return this.getWorldObj(); + } + + + + + + + @Override + public int getXCoord() { + return this.xCoord; + } + + + + + + @Override + public short getYCoord() { + return (short) this.yCoord; + } + + @Override + public int getZCoord() { + return this.zCoord; + } + + public boolean hasEnoughEnergy() { + return (this.getStoredEU() > 0 ? (mHasEnoughEnergy = true) : (mHasEnoughEnergy = false)); + } + + + + + @Override + public boolean increaseStoredEnergyUnits(final long aEnergy, final boolean aIgnoreTooMuchEnergy) { + if (!this.canAccessData()) { + return false; + } + if (this.getStoredEU() < this.getEUCapacity() || aIgnoreTooMuchEnergy) { + this.setStoredEU(this.getEUVar() + aEnergy); + return true; + } + return false; + } + + @Override + public boolean increaseStoredSteam(final long aEnergy, final boolean aIgnoreTooMuchEnergy) { + if (!this.canAccessData()) { + return false; + } + if (this.getSteamVar() < this.getSteamCapacity() || aIgnoreTooMuchEnergy) { + this.setStoredSteam(this.getSteamVar() + aEnergy); + return true; + } + return false; + } + + public long injectEnergyUnits(final byte aSide, final long aVoltage, long aAmperage) { + if (!this.canAccessData() || !this.isElectric() || !this.inputEnergyFrom(aSide) + || aAmperage <= 0L || aVoltage <= 0L || this.getStoredEU() >= this.getEUCapacity() + || this.maxAmperesIn() <= this.mAcceptedAmperes) { + return 0L; + } + if (aVoltage > this.getInputVoltage()) { + this.doExplosion(aVoltage); + return 0L; + } + if (this.increaseStoredEnergyUnits(aVoltage + * (aAmperage = Math.min(aAmperage, Math.min(this.maxAmperesIn() - this.mAcceptedAmperes, + 1L + (this.getEUCapacity() - this.getStoredEU()) / aVoltage))), + true)) { + final int[] mAverageEUInput = this.mAverageEUInput; + final int mAverageEUInputIndex = this.mAverageEUInputIndex; + mAverageEUInput[mAverageEUInputIndex] += (int) (aVoltage * aAmperage); + this.mAcceptedAmperes += aAmperage; + return aAmperage; + } + return 0L; + } + + @Override + public boolean injectRotationalEnergy(byte p0, long p1, long p2) { + return false; + } + + @Override + public boolean inputEnergyFrom(final byte aSide) { + if (aSide == 6) { + return true; + } + if (this.isServerSide()) { + return aSide >= 0 && aSide < 6 && this.mActiveEUInputs[aSide] && !this.mReleaseEnergy; + } + return this.isEnergyInputSide(aSide); + } + + + public final boolean isClientSide() { + return this.worldObj.isRemote; + } + + @Override + public boolean isDead() { + return this.isDead; + } + + private boolean isElectric() { + return true; + } + + private boolean isEnergyInputSide(final byte aSide) { + if (aSide >= 0 && aSide < 6) { + if (this.isInvalid() || this.mReleaseEnergy) { + return false; + } + if (this.canAccessData() && this.isElectric() && this.isEnetInput()) { + return this.isInputFacing(aSide); + } + } + return false; + } + + private boolean isEnergyOutputSide(final byte aSide) { + if (aSide >= 0 && aSide < 6) { + if (this.isInvalid() || this.mReleaseEnergy) { + return this.mReleaseEnergy; + } + if (this.canAccessData() && this.isElectric() && this.isEnetOutput()) { + return this.isOutputFacing(aSide); + } + } + return false; + } + + public boolean isEnetInput() { + return false; + } + + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isGivingInformation() { + return this.canAccessData() && this.isGivingInformation(); + } + + public boolean isInputFacing(final byte aSide) { + return false; + } + + + + + @Override + public boolean isInvalidTileEntity() { + return isDead() ? true : false; + } + + public boolean isOutputFacing(final byte aSide) { + return false; + } + + public final boolean isServerSide() { + return !this.worldObj.isRemote; + } + + public boolean isUniversalEnergyStored(final long aEnergyAmount) { + return this.getUniversalEnergyStored() >= aEnergyAmount || (this.mHasEnoughEnergy = false); + } + + @Override + public boolean isValidFacing(final byte aSide) { + return this.canAccessData(); + } + + public long maxAmperesIn() { + return 1L; + } + + public long maxAmperesOut() { + return 1L; + } + + public long maxEUInput() { + return 0L; + } + + public long maxEUOutput() { + return 0L; + } + + public long maxEUStore() { + return 0L; + } + + public long maxSteamStore() { + return 256000L; + } + + public final void onAdjacentBlockChange(final int aX, final int aY, final int aZ) { + this.clearNullMarkersFromTileEntityBuffer(); + } + + @Override + public boolean outputsEnergyTo(final byte aSide) { + if (aSide == 6) { + return true; + } + if (this.isServerSide()) { + if (aSide < 0 || aSide >= 6 || !this.mActiveEUOutputs[aSide]) { + if (!this.mReleaseEnergy) { + return false; + } + } + return true; + } + return this.isEnergyOutputSide(aSide); + } + + public final void sendBlockEvent(final byte aID, final byte aValue) { + GT_Values.NW.sendPacketToAllPlayersInRange(this.worldObj, + (GT_Packet) new GT_Packet_Block_Event(this.xCoord, (short) this.yCoord, this.zCoord, aID, aValue), + this.xCoord, this.zCoord); + } + + public void setEUVar(final long aEnergy) { + mStoredEnergy = aEnergy; + } + + @Override + public void setFrontFacing(byte aFacing) { + if (this.isValidFacing(aFacing)) { + this.mFacing = aFacing; + //this.onFacingChange(); + //this.onMachineBlockUpdate(); + } + } + + public void setSteamVar(final long aSteam) { + mStoredSteam = aSteam; + } + + public boolean setStoredEU(long aEnergy) { + if (!this.canAccessData()) { + return false; + } + if (aEnergy < 0L) { + aEnergy = 0L; + } + this.setEUVar(aEnergy); + return true; + } + + public boolean setStoredSteam(long aEnergy) { + if (!this.canAccessData()) { + return false; + } + if (aEnergy < 0L) { + aEnergy = 0L; + } + this.setSteamVar(aEnergy); + return true; + } + + @Override + public void writeToNBT(NBTTagCompound nbt) { + // TODO Auto-generated method stub + super.writeToNBT(nbt); + } + + @Override + public void readFromNBT(NBTTagCompound nbt) { + // TODO Auto-generated method stub + super.readFromNBT(nbt); + } + + + + + @Override + public boolean onPreTick() { + return onPreTick(this, this.mTickTimer); + } + + @Override + public boolean onTick() { + return onTick(this, this.mTickTimer); + } + + @Override + public boolean onPostTick() { + return onPostTick(this, this.mTickTimer); + } + + @Override + public boolean onPreTick(TilePoweredGT tilePoweredGT, long mTickTimer2) { + return super.onPreTick(); + } + + @Override + public boolean onTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2) { + return super.onTick(); + } + + @Override + public boolean onPostTick(TilePoweredGT iGregTechTileEntity, long mTickTimer2) { + return super.onPostTick(); + } + + @Override + public void markDirty() { + super.markDirty(); + } + + @Override + public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { + // TODO Auto-generated method stub + return super.receiveClientEvent(p_145842_1_, p_145842_2_); + } + + @Override + public void onChunkUnload() { + this.clearNullMarkersFromTileEntityBuffer(); + super.onChunkUnload(); + this.isDead = true; + } + + + public void updateEntity() { + super.updateEntity(); + this.isDead = false; + + this.mRunningThroughTick = true; + long tTime = System.currentTimeMillis(); + int tCode = 0; + final boolean aSideServer = this.isServerSide(); + final boolean aSideClient = this.isClientSide(); + /*try { + for (tCode = 0; this.hasValidMetaTileEntity() && tCode >= 0; tCode = -1) { + Label_1743 : { + switch (tCode) { + case 0 : { + ++tCode; + if (this.mTickTimer++ != 0L) { + break Label_1743; + } + this.oX = this.xCoord; + this.oY = this.yCoord; + this.oZ = this.zCoord; + + this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, + (TileEntity) this); + this.onFirstTick(this); + if (!this.hasValidMetaTileEntity()) { + this.mRunningThroughTick = false; + return; + } + break Label_1743; + } + case 1 : { + ++tCode; + if (!aSideClient) { + break Label_1743; + } + if (this.mNeedsUpdate) { + this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); + this.mNeedsUpdate = false; + } + break Label_1743; + } + case 2 : + case 3 : + case 4 : + case 5 : + case 6 : + case 7 : { + if (aSideServer && this.mTickTimer > 10L) { + for (byte i = (byte) (tCode - 2); i < 6; ++i) { + + } + } + } + case 8 : { + tCode = 9; + if (aSideServer) { + if (++this.mAverageEUInputIndex >= this.mAverageEUInput.length) { + this.mAverageEUInputIndex = 0; + } + if (++this.mAverageEUOutputIndex >= this.mAverageEUOutput.length) { + this.mAverageEUOutputIndex = 0; + } + this.mAverageEUInput[this.mAverageEUInputIndex] = 0; + this.mAverageEUOutput[this.mAverageEUOutputIndex] = 0; + } + } + case 9 : { + ++tCode; + this.onPreTick(this, this.mTickTimer); + if (!this.hasValidMetaTileEntity()) { + this.mRunningThroughTick = false; + return; + } + } + case 10 : { + ++tCode; + if (!aSideServer) { + break Label_1743; + } + + if (this.xCoord != this.oX || this.yCoord != this.oY || this.zCoord != this.oZ) { + this.oX = this.xCoord; + this.oY = this.yCoord; + this.oZ = this.zCoord; + this.issueClientUpdate(); + this.clearTileEntityBuffer(); + } + if (this.mFacing != this.oFacing) { + this.oFacing = this.mFacing; + this.issueBlockUpdate(); + } + if (this.mTickTimer > 20L && this.isElectric()) { + this.mAcceptedAmperes = 0L; + if (this.getOutputVoltage() != this.oOutput) { + this.oOutput = this.getOutputVoltage(); + } + if (this.isEnetOutput() || this.isEnetInput()) { + for (byte i = 0; i < 6; ++i) { + boolean temp = this.isEnergyInputSide(i); + if (temp != this.mActiveEUInputs[i]) { + this.mActiveEUInputs[i] = temp; + } + temp = this.isEnergyOutputSide(i); + if (temp != this.mActiveEUOutputs[i]) { + this.mActiveEUOutputs[i] = temp; + } + } + } + if (this.isEnetOutput() && this.oOutput > 0L) { + final long tOutputVoltage = Math.max(this.oOutput, + this.oOutput + (1 << GT_Utility.getTier(this.oOutput))); + final long tUsableAmperage = Math.min(this.getOutputAmperage(), + (this.getStoredEU() - this.getMinimumStoredEU()) + / tOutputVoltage); + if (tUsableAmperage > 0L) { + final long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork( + this.oOutput, tUsableAmperage, (IEnergyConnected) this); + final int[] mAverageEUOutput = this.mAverageEUOutput; + final int mAverageEUOutputIndex = this.mAverageEUOutputIndex; + mAverageEUOutput[mAverageEUOutputIndex] += (int) tEU; + this.decreaseStoredEU(tEU, true); + } + } + if (this.getEUCapacity() > 0L) { + if (GregTech_API.sMachineFireExplosions && this.getRandomNumber(1000) == 0) { + final Block tBlock = this.getBlockAtSide((byte) this.getRandomNumber(6)); + if (tBlock instanceof BlockFire) { + this.doEnergyExplosion(); + } + } + if (!this.hasValidMetaTileEntity()) { + this.mRunningThroughTick = false; + return; + } + } + } + if (!this.hasValidMetaTileEntity()) { + this.mRunningThroughTick = false; + return; + } + break Label_1743; + } + case 13 : { + ++tCode; + this.updateStatus(); + if (!this.hasValidMetaTileEntity()) { + this.mRunningThroughTick = false; + return; + } + } + case 14 : { + ++tCode; + this.onPostTick((IGregTechTileEntity) this, this.mTickTimer); + if (!this.hasValidMetaTileEntity()) { + this.mRunningThroughTick = false; + return; + } + } + case 15 : { + ++tCode; + if (!aSideServer) { + break; + } + if (this.mTickTimer % 10L == 0L && this.mSendClientData) { + final IGT_NetworkHandler nw = GT_Values.NW; + final World worldObj = this.worldObj; + final int xCoord = this.xCoord; + final short n = (short) this.yCoord; + final int zCoord = this.zCoord; + final short mid = this.mID; + final int n2 = this.mCoverSides[0]; + final int n3 = this.mCoverSides[1]; + final int n4 = this.mCoverSides[2]; + final int n5 = this.mCoverSides[3]; + final int n6 = this.mCoverSides[4]; + final int n7 = this.mCoverSides[5]; + final byte oTextureData = (byte) ((this.mFacing & 0x7) | (this.mActive ? 8 : 0) + | (this.mRedstone ? 16 : 0) | (this.mLockUpgrade ? 32 : 0)); + this.oTextureData = oTextureData; + final byte oTexturePage = (byte) ((this.hasValidMetaTileEntity() + && this.mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) + ? ((GT_MetaTileEntity_Hatch) this.mMetaTileEntity).getTexturePage() + : 0); + this.oTexturePage = oTexturePage; + final byte oUpdateData = (byte) (this.hasValidMetaTileEntity() + ? this.mMetaTileEntity.getUpdateData() + : 0); + this.oUpdateData = oUpdateData; + final byte oRedstoneData = (byte) (((this.mSidedRedstone[0] > 0) ? 1 : 0) + | ((this.mSidedRedstone[1] > 0) ? 2 : 0) + | ((this.mSidedRedstone[2] > 0) ? 4 : 0) + | ((this.mSidedRedstone[3] > 0) ? 8 : 0) + | ((this.mSidedRedstone[4] > 0) ? 16 : 0) + | ((this.mSidedRedstone[5] > 0) ? 32 : 0)); + this.oRedstoneData = oRedstoneData; + final byte mColor = this.mColor; + this.oColor = mColor; + nw.sendPacketToAllPlayersInRange(worldObj, + (GT_Packet) new GT_Packet_TileEntity(xCoord, n, zCoord, mid, n2, n3, n4, n5, n6, + n7, oTextureData, oTexturePage, oUpdateData, oRedstoneData, mColor), + this.xCoord, this.zCoord); + this.mSendClientData = false; + } + if (this.mTickTimer > 10L) { + byte tData = (byte) ((this.mFacing & 0x7) | (this.mActive ? 8 : 0) + | (this.mRedstone ? 16 : 0) | (this.mLockUpgrade ? 32 : 0)); + if (tData != this.oTextureData) { + this.sendBlockEvent((byte) 0, this.oTextureData = tData); + } + tData = this.mMetaTileEntity.getUpdateData(); + if (tData != this.oUpdateData) { + this.sendBlockEvent((byte) 1, this.oUpdateData = tData); + } + if (this.mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { + tData = ((GT_MetaTileEntity_Hatch) this.mMetaTileEntity).getTexturePage(); + if (tData != this.oTexturePage) { + final byte b = 1; + final byte oTexturePage2 = tData; + this.oTexturePage = oTexturePage2; + this.sendBlockEvent(b, (byte) (oTexturePage2 | 0x80)); + } + } + if (this.mColor != this.oColor) { + this.sendBlockEvent((byte) 2, this.oColor = this.mColor); + } + tData = (byte) (((this.mSidedRedstone[0] > 0) ? 1 : 0) + | ((this.mSidedRedstone[1] > 0) ? 2 : 0) + | ((this.mSidedRedstone[2] > 0) ? 4 : 0) + | ((this.mSidedRedstone[3] > 0) ? 8 : 0) + | ((this.mSidedRedstone[4] > 0) ? 16 : 0) + | ((this.mSidedRedstone[5] > 0) ? 32 : 0)); + if (tData != this.oRedstoneData) { + this.sendBlockEvent((byte) 3, this.oRedstoneData = tData); + } + if (this.mLightValue != this.oLightValue) { + this.worldObj.setLightValue(EnumSkyBlock.Block, this.xCoord, this.yCoord, + this.zCoord, (int) this.mLightValue); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, + this.zCoord); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord + 1, this.yCoord, + this.zCoord); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord - 1, this.yCoord, + this.zCoord); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord + 1, + this.zCoord); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord - 1, + this.zCoord); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, + this.zCoord + 1); + this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, + this.zCoord - 1); + this.issueTextureUpdate(); + this.sendBlockEvent((byte) 7, this.oLightValue = this.mLightValue); + } + } + if (this.mNeedsBlockUpdate) { + this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, + this.getBlockOffset(0, 0, 0)); + this.mNeedsBlockUpdate = false; + break; + } + break; + } + } + } + } + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } + if (aSideServer && this.hasValidMetaTileEntity()) { + tTime = System.currentTimeMillis() - tTime; + if (this.mTimeStatistics.length > 0) { + this.mTimeStatistics[this.mTimeStatisticsIndex = (this.mTimeStatisticsIndex + 1) + % this.mTimeStatistics.length] = (int) tTime; + } + if (tTime > 0L && tTime > GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING && this.mTickTimer > 1000L + && this.getMetaTileEntity().doTickProfilingMessageDuringThisTick() + && this.mLagWarningCount++ < 10) { + System.out.println("WARNING: Possible Lag Source at [" + this.xCoord + ", " + this.yCoord + ", " + + this.zCoord + "] in Dimension " + this.worldObj.provider.dimensionId + " with " + tTime + + "ms caused by an instance of " + this.getMetaTileEntity().getClass()); + } + } + final boolean mWorkUpdate = false; + this.mRunningThroughTick = mWorkUpdate; + this.mInventoryChanged = mWorkUpdate; + this.mWorkUpdate = mWorkUpdate;*/ + } + + private void onFirstTick(TilePoweredGT tilePoweredGT) { + // TODO Auto-generated method stub + + } + + private boolean hasValidMetaTileEntity() { + return Utils.invertBoolean(isDead()); + } + + public void issueBlockUpdate() { + this.mNeedsBlockUpdate = true; + } + + public void issueClientUpdate() { + this.mSendClientData = true; + } + + public Packet getDescriptionPacket() { + this.issueClientUpdate(); + return null; + } + +} diff --git a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java index 252b92984e..abff5fd755 100644 --- a/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java +++ b/src/Java/gtPlusPlus/core/tileentities/machines/TileEntityModularityTable.java @@ -5,12 +5,12 @@ import java.util.Map.Entry; import gregtech.api.enums.ItemList; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.container.Container_ModularityTable; import gtPlusPlus.core.inventories.modulartable.InventoryModularMain; import gtPlusPlus.core.inventories.modulartable.InventoryModularOutput; import gtPlusPlus.core.item.bauble.ModularBauble; import gtPlusPlus.core.tileentities.base.TileEntityBase; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.nbt.ModularArmourUtils; import gtPlusPlus.core.util.nbt.ModularArmourUtils.BT; diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 0909e4bf2d..e15f8ba202 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -34,10 +34,10 @@ import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; diff --git a/src/Java/gtPlusPlus/core/util/array/BlockPos.java b/src/Java/gtPlusPlus/core/util/array/BlockPos.java deleted file mode 100644 index b625ebec54..0000000000 --- a/src/Java/gtPlusPlus/core/util/array/BlockPos.java +++ /dev/null @@ -1,25 +0,0 @@ -package gtPlusPlus.core.util.array; - -public class BlockPos { - - public final int xPos; - public final int yPos; - public final int zPos; - public final int dim; - - public BlockPos(int x, int y, int z){ - this(x, y, z, 0); - } - - public BlockPos(int x, int y, int z, int dim){ - this.xPos = x; - this.yPos = y; - this.zPos = z; - this.dim = dim; - } - - public String getLocationString() { - return "[X: "+this.xPos+"][Y: "+this.yPos+"][Z: "+this.zPos+"]"; - } - -} diff --git a/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java b/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java index 79c643a95d..27412d647f 100644 --- a/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java +++ b/src/Java/gtPlusPlus/core/util/entity/EntityUtils.java @@ -5,7 +5,7 @@ import java.lang.reflect.Method; import cpw.mods.fml.common.registry.EntityRegistry; import gregtech.api.util.GT_Utility; -import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.reflect.ReflectionUtils; import ic2.core.IC2Potion; import ic2.core.item.armor.ItemArmorHazmat; diff --git a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java index 367539b49d..d5caad9dee 100644 --- a/src/Java/gtPlusPlus/core/util/item/ItemUtils.java +++ b/src/Java/gtPlusPlus/core/util/item/ItemUtils.java @@ -10,6 +10,7 @@ import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.item.base.BasicSpawnEgg; import gtPlusPlus.core.item.base.dusts.BaseItemDust; @@ -23,7 +24,6 @@ import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.core.util.wrapper.var; diff --git a/src/Java/gtPlusPlus/core/util/locale/LocaleUtils.java b/src/Java/gtPlusPlus/core/util/locale/LocaleUtils.java new file mode 100644 index 0000000000..aea38d341e --- /dev/null +++ b/src/Java/gtPlusPlus/core/util/locale/LocaleUtils.java @@ -0,0 +1,91 @@ +package gtPlusPlus.core.util.locale; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.registry.GameData; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.ItemUtils; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +public class LocaleUtils { + + public static boolean GenerateFakeLocaleFile() { + for (ModContainer modcontainer : Loader.instance().getModList()){ + if (modcontainer.getModId().toLowerCase().equals("miscutils")) { + String S = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; + writeToFile(S); + dumpItemsAndBlocksForModContainer(modcontainer); + } + } + return true; + } + + public static boolean dumpItemsAndBlocksForModContainer(ModContainer mod) { + writeToFile("Dumping Items from "+mod.getModId()+"."); + for (Object C : GameData.getItemRegistry()) { + + try { + + if (C != null) { + if (C instanceof Item) { + Item R = (Item) C; + ItemStack IS = ItemUtils.getSimpleStack(R); + String modid = ItemUtils.getModId(IS); + if (modid.equals("miscutils") || modid.equals("ToxicEverglades")) { + String S = "["+modid+"] "+IS.getUnlocalizedName()+".name="; + writeToFile(S); + } + } + } + + } + catch (Throwable T) {} + + } + writeToFile("Dumping Blocks from "+mod.getModId()+"."); + for (Object B : GameData.getBlockRegistry()) { + + try { + + if (B != null) { + if (B instanceof Block) { + Block R = (Block) B; + ItemStack IS = ItemUtils.getSimpleStack(R); + String modid = ItemUtils.getModId(IS); + if (modid.equals("miscutils") || modid.equals("ToxicEverglades")) { + String S = "["+modid+"] "+IS.getUnlocalizedName()+".name="; + writeToFile(S); + } + } + } + + } + catch (Throwable T) {} + + } + + + return true; + } + + public static void writeToFile(String S) { + try { + File F = new File(Utils.getMcDir(), "config/GTplusplus/en_US.lang"); + BufferedWriter writer; + writer = new BufferedWriter(new FileWriter(F, true)); + writer.write(S); + writer.newLine(); + writer.close(); + } + catch (IOException e) {} + } + + +} diff --git a/src/Java/gtPlusPlus/core/util/math/MathUtils.java b/src/Java/gtPlusPlus/core/util/math/MathUtils.java index 313d1059ca..6d61335fe8 100644 --- a/src/Java/gtPlusPlus/core/util/math/MathUtils.java +++ b/src/Java/gtPlusPlus/core/util/math/MathUtils.java @@ -4,8 +4,8 @@ import java.util.Map; import java.util.Random; import gregtech.api.enums.GT_Values; -import gtPlusPlus.api.objects.CSPRNG_DO_NOT_USE; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.random.CSPRNG_DO_NOT_USE; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; diff --git a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java index 2e8e29c372..c9ac557fee 100644 --- a/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java +++ b/src/Java/gtPlusPlus/core/util/nbt/ModularArmourUtils.java @@ -3,7 +3,7 @@ package gtPlusPlus.core.util.nbt; import baubles.api.BaubleType; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.array.Pair; +import gtPlusPlus.api.objects.data.Pair; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java b/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java index 04a59e7f7d..cabd1f086c 100644 --- a/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java +++ b/src/Java/gtPlusPlus/core/util/reflect/AddGregtechRecipe.java @@ -78,7 +78,7 @@ public final class AddGregtechRecipe { FluidStack[] aFluidInputs, ItemStack aOutput, int aDuration, int aEUt){ -/* + /* try { IGT_RecipeAdder IGT_RecipeAdder = GT_Values.RA; if (IGT_RecipeAdder != null){ @@ -95,7 +95,7 @@ public final class AddGregtechRecipe { } //Utils.LOG_INFO("==============================================="); } - + try { Method testRA = GT_Values.RA.getClass().getMethod("addAssemblylineRecipe", GT_Values.RA.getClass(), aResearchItem.getClass(), int.class, aInputs.getClass(), aFluidInputs.getClass(), aOutput.getClass(), int.class, int.class); testRA.invoke(aResearchItem, aResearchTime, aInputs, aFluidInputs, aOutput, aDuration, aEUt); @@ -103,7 +103,7 @@ public final class AddGregtechRecipe { catch (Throwable masndj){ masndj.printStackTrace(); } - + Method addRecipe = classRA.getDeclaredMethod( "addAssemblylineRecipe", @@ -125,7 +125,7 @@ public final class AddGregtechRecipe { return false; } Utils.LOG_INFO("[Assembly Line] - Failed to add recipe. Research: "+aResearchItem.getDisplayName()+" | Result: "+aOutput.getDisplayName()); - */return false; + */return false; } public static boolean addCircuitAssemblerRecipe( @@ -203,4 +203,39 @@ public final class AddGregtechRecipe { return false; } + + public static boolean addChemicalRecipeForBasicMachineOnly(final ItemStack p0, final ItemStack p1, final FluidStack p2, final FluidStack p3, final ItemStack p4, final ItemStack p5, final int p6, final int p7){ + + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { + try { + IGT_RecipeAdder IGT_RecipeAdder = GT_Values.RA; + if (IGT_RecipeAdder != null){ + Class<? extends IGT_RecipeAdder> classRA = IGT_RecipeAdder.getClass(); + //final ItemStack p0, final ItemStack p1, final FluidStack p2, final FluidStack p3, final ItemStack p4, final ItemStack p5, final int p6, final int p7 + Method addRecipe = classRA.getMethod("addChemicalRecipeForBasicMachineOnly", ItemStack.class, ItemStack.class, FluidStack.class, FluidStack.class, ItemStack.class, ItemStack.class, int.class, int.class); + if (addRecipe != null){ + return (boolean) addRecipe.invoke(IGT_RecipeAdder, p0, p1, p2, p3, p4, p5, p6, p7); + } + } + } + catch (SecurityException | NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + + } + } + + return GT_Values.RA.addChemicalRecipe( + p0, + p1, + p2, + p3, + p4, + p5, + p6, + p7); + + } + + + + }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/util/uuid/UUIDGenerator.java b/src/Java/gtPlusPlus/core/util/uuid/UUIDGenerator.java index 0fd2d8c6a5..bf0ac3d1f5 100644 --- a/src/Java/gtPlusPlus/core/util/uuid/UUIDGenerator.java +++ b/src/Java/gtPlusPlus/core/util/uuid/UUIDGenerator.java @@ -5,7 +5,7 @@ import java.net.InetAddress; import java.util.Random; import java.util.UUID; -import gtPlusPlus.api.objects.CSPRNG_DO_NOT_USE; +import gtPlusPlus.api.objects.random.CSPRNG_DO_NOT_USE; /** * diff --git a/src/Java/gtPlusPlus/api/damage/BaseCustomDamageSource.java b/src/Java/gtPlusPlus/core/world/damage/BaseCustomDamageSource.java index 24348988d6..3778beacfb 100644 --- a/src/Java/gtPlusPlus/api/damage/BaseCustomDamageSource.java +++ b/src/Java/gtPlusPlus/core/world/damage/BaseCustomDamageSource.java @@ -1,4 +1,4 @@ -package gtPlusPlus.api.damage; +package gtPlusPlus.core.world.damage; import net.minecraft.entity.Entity; import net.minecraft.util.EntityDamageSourceIndirect; diff --git a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java index 6be899e5de..301a2154c2 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_GT_Base.java @@ -6,7 +6,7 @@ import cpw.mods.fml.common.IWorldGenerator; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.util.GT_Log; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.world.darkworld.Dimension_DarkWorld; import gtPlusPlus.xmod.gregtech.HANDLER_GT; diff --git a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_Ores.java b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_Ores.java index 4b099ee4cf..8b28e2d4e8 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_Ores.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/gen/gt/WorldGen_Ores.java @@ -4,12 +4,12 @@ import java.util.Hashtable; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; -import gtPlusPlus.api.objects.MaterialHelper; +import gtPlusPlus.api.helpers.MaterialHelper; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.ORES; import gtPlusPlus.core.material.nuclear.FLUORIDES; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.world.darkworld.object.BoxedQuad; import net.minecraft.block.Block; diff --git a/src/Java/gtPlusPlus/core/world/darkworld/object/BoxedQuad.java b/src/Java/gtPlusPlus/core/world/darkworld/object/BoxedQuad.java index d3c400896b..fd3d734e08 100644 --- a/src/Java/gtPlusPlus/core/world/darkworld/object/BoxedQuad.java +++ b/src/Java/gtPlusPlus/core/world/darkworld/object/BoxedQuad.java @@ -1,6 +1,6 @@ package gtPlusPlus.core.world.darkworld.object; -import gtPlusPlus.core.util.array.Pair; +import gtPlusPlus.api.objects.data.Pair; import net.minecraft.block.Block; public class BoxedQuad<K,V,C,R> { diff --git a/src/Java/gtPlusPlus/core/world/explosions/MiningExplosion.java b/src/Java/gtPlusPlus/core/world/explosions/MiningExplosion.java index 50fa08f55f..bcbb16a3b6 100644 --- a/src/Java/gtPlusPlus/core/world/explosions/MiningExplosion.java +++ b/src/Java/gtPlusPlus/core/world/explosions/MiningExplosion.java @@ -2,7 +2,7 @@ package gtPlusPlus.core.world.explosions; import java.util.*; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.entity.EntityPrimedMiningExplosive; import gtPlusPlus.core.util.math.MathUtils; import net.minecraft.block.Block; diff --git a/src/Java/gtPlusPlus/plugin/manager/Core_Manager.java b/src/Java/gtPlusPlus/plugin/manager/Core_Manager.java index 2fc6102779..2fd6096d32 100644 --- a/src/Java/gtPlusPlus/plugin/manager/Core_Manager.java +++ b/src/Java/gtPlusPlus/plugin/manager/Core_Manager.java @@ -2,7 +2,7 @@ package gtPlusPlus.plugin.manager; import gtPlusPlus.api.interfaces.IPlugin; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.array.AutoMap; +import gtPlusPlus.api.objects.data.AutoMap; public class Core_Manager { diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java index c6edd94238..4a8a0a1e3c 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_ClassTransformer2.java @@ -19,8 +19,8 @@ import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.common.blocks.GT_Block_Machines; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.XSTR; -import gtPlusPlus.core.util.array.BlockPos; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.api.objects.random.XSTR; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.nbt.NBTUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; diff --git a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java b/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java deleted file mode 100644 index 155feae83c..0000000000 --- a/src/Java/gtPlusPlus/xmod/forestry/trees/TreefarmManager.java +++ /dev/null @@ -1,140 +0,0 @@ -package gtPlusPlus.xmod.forestry.trees; - -import cpw.mods.fml.common.Optional; -import gregtech.api.enums.OrePrefixes; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.LoadedMods; -import gtPlusPlus.core.util.item.ItemUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; -import net.minecraft.block.Block; -import net.minecraft.block.BlockAir; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; - -public class TreefarmManager { - - public static boolean isHumusLoaded = false; - public static boolean isForestryLogsLoaded = false; - public static boolean isForestryFenceLoaded = false; - public static boolean isForestrySaplingsLoaded = false; - public static boolean isForestryLeavesLoaded = false; - public static Block blockHumus; - - public static boolean isForestryValid(){ - if (!LoadedMods.Forestry){ - return false; - } - if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){ - isHumusLoaded = true; - } - if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockLog")){ - isForestryLogsLoaded = true; - } - if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockArbFence")){ - isForestryFenceLoaded = true; - } - if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockSapling")){ - isForestrySaplingsLoaded = true; - } - if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockForestryLeaves")){ - isForestryLeavesLoaded = true; - } - return true; - } - - @Optional.Method(modid = "Forestry") - public static Block getHumus(){ - if(blockHumus != null){ - return blockHumus; - } - else if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){ - try { - final Class<?> humusClass = Class.forName("forestry.core.blocks.BlockSoil"); - final ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1); - if (humusClass != null){ - blockHumus = Block.getBlockFromItem(humusStack.getItem()); - return Block.getBlockFromItem(humusStack.getItem()); - } - } catch (final ClassNotFoundException e) {} - } - return null; - } - - public static boolean isWoodLog(final Block log){ - final String tTool = log.getHarvestTool(0); - - if ((log == Blocks.log) || (log == Blocks.log2)){ - return true; - } - - //Forestry/General Compat - if (log.getClass().getName().toLowerCase().contains("blocklog")){ - return true; - } - - //IC2 Rubber Tree Compat - if (log.getClass().getName().toLowerCase().contains("rubwood") || log.getClass().getName().toLowerCase().contains("rubleaves")){ - return true; - } - - return (OrePrefixes.log.contains(new ItemStack(log, 1))&& ((tTool != null) && (tTool.equals("axe")))) || (log.getMaterial() != Material.wood) ? false : (OrePrefixes.fence.contains(new ItemStack(log, 1)) ? false : true); - } - - public static boolean isLeaves(final Block log){ - if (log.getUnlocalizedName().toLowerCase().contains("leaf")){ - return true; - } - if (log.getUnlocalizedName().toLowerCase().contains("leaves")){ - return true; - } - if (log.getLocalizedName().toLowerCase().contains("leaf")){ - return true; - } - if (log.getLocalizedName().toLowerCase().contains("leaves")){ - return true; - } - return OrePrefixes.leaves.contains(new ItemStack(log, 1)) || (log.getMaterial() == Material.leaves); - } - - public static boolean isSapling(final Block log){ - if (log != null){ - if (OrePrefixes.sapling.contains(new ItemStack(log, 1))){ - Logger.WARNING(""+log.getLocalizedName()); - } - if (log.getLocalizedName().toLowerCase().contains("sapling")){ - Logger.WARNING(""+log.getLocalizedName()); - return true; - } - } - return OrePrefixes.sapling.contains(new ItemStack(log, 1)); - } - - public static boolean isDirtBlock(final Block dirt){ - return (dirt == Blocks.dirt ? true : (dirt == Blocks.grass ? true : (getHumus() == null ? false : (dirt == blockHumus ? true : false)))); - } - - public static boolean isFenceBlock(final Block fence){ - return (fence == Blocks.fence ? true : (fence == Blocks.fence_gate ? true : (fence == Blocks.nether_brick_fence ? true : (OrePrefixes.fence.contains(new ItemStack(fence, 1)) ? true : false)))); - } - - public static boolean isAirBlock(final Block air){ - - if (air.getLocalizedName().toLowerCase().contains("air")){ - return true; - } - - if (air.getClass().getName().toLowerCase().contains("residual") || air.getClass().getName().toLowerCase().contains("heat")){ - return true; - } - - //Utils.LOG_INFO("Found "+air.getLocalizedName()); - - return (air == Blocks.air ? true : (air instanceof BlockAir ? true : false)); - } - - /*public static boolean isSaplingBlock(Block sapling){ - return (sapling == Blocks.sapling ? true : (sapling == Blocks.)) - }*/ - -} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java index 82bc38aa9a..240ca6cfe8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/CONTAINER_TreeFarmer.java @@ -58,7 +58,7 @@ public class CONTAINER_TreeFarmer extends GT_ContainerMetaTile_Machine { super.detectAndSendChanges(); for(final ICrafting crafting : (List<ICrafting>)this.crafters) { crafting.sendProgressBarUpdate(this, 100, (int) ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).maxEUStore()); - crafting.sendProgressBarUpdate(this, 101, (int) ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).getStoredInternalPower()); + crafting.sendProgressBarUpdate(this, 101, (int) ((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).getEUVar()); if (((GregtechMetaTileEntityTreeFarm) this.mTileEntity.getMetaTileEntity()).isCorrectMachinePart(this.mTileEntity.getStackInSlot(1))){ this.mTileEntity.markDirty(); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java index 565c378179..3a60a3e93e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/gui/GUI_TreeFarmer.java @@ -24,9 +24,9 @@ public class GUI_TreeFarmer extends GT_GUIContainerMetaTile_Machine { this.maxPower = ((CONTAINER_TreeFarmer)this.mContainer).maxEU; this.storedPower = ((CONTAINER_TreeFarmer)this.mContainer).storedEU; if (((CONTAINER_TreeFarmer) this.mContainer).mDisplayErrorCode == 0) { - this.fontRendererObj.drawString("Current Power Stored: "+this.storedPower+"EU", 10, 52, 16448255); - this.fontRendererObj.drawString("Max Power Storage: "+this.maxPower+"EU", 10, 60, 16448255); - this.fontRendererObj.drawString("Current operations left: "+(this.storedPower/32), 10, 68, 16448255); + this.fontRendererObj.drawString("Current Power: "+this.storedPower+"EU", 8, 52, 16448255); + this.fontRendererObj.drawString("Max Power: "+this.maxPower+"EU", 8, 60, 16448255); + this.fontRendererObj.drawString("Current operations left: "+(this.storedPower/32), 8, 68, 16448255); } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java index df886220c2..14586a91f8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_DeluxeMachine.java @@ -15,7 +15,7 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.XSTR; +import gtPlusPlus.api.objects.random.XSTR; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; 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 22248814ce..0eec457d66 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 @@ -4,6 +4,7 @@ import java.lang.reflect.*; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.concurrent.TimeUnit; import gregtech.api.util.GT_Utility; import net.minecraftforge.fluids.FluidStack; @@ -30,6 +31,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import static gtPlusPlus.core.util.array.ArrayUtils.removeNulls; @@ -39,6 +41,7 @@ GT_MetaTileEntity_MultiBlockBase { public GT_Recipe mLastRecipe; private boolean mInternalCircuit = false; + protected long mTotalRunTime = 0; public ArrayList<GT_MetaTileEntity_Hatch_InputBattery> mChargeHatches = new ArrayList<GT_MetaTileEntity_Hatch_InputBattery>(); public ArrayList<GT_MetaTileEntity_Hatch_OutputBattery> mDischargeHatches = new ArrayList<GT_MetaTileEntity_Hatch_OutputBattery>(); @@ -59,7 +62,7 @@ GT_MetaTileEntity_MultiBlockBase { .getMetaTileEntity() == aMetaTileEntity) && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); } - + public abstract boolean hasSlotInGUI(); @Override @@ -83,11 +86,27 @@ GT_MetaTileEntity_MultiBlockBase { } @Override - public String[] getInfoData() { - return new String[]{"Progress:", (this.mProgresstime / 20) + "secs", - (this.mMaxProgresstime / 20) + "secs", "Efficiency:", - (this.mEfficiency / 100.0F) + "%", "Problems:", - "" + (this.getIdealStatus() - this.getRepairStatus())}; + public String[] getInfoData() { + + long seconds = (this.mTotalRunTime/20); + int weeks = (int) (TimeUnit.SECONDS.toDays(seconds) / 7); + int days = (int) (TimeUnit.SECONDS.toDays(seconds) - 7 * weeks); + long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(days) - TimeUnit.DAYS.toHours(7*weeks); + long minutes = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60); + long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) *60); + + String[] g = { + "Progress: " + (this.mProgresstime / 20) +" / "+ (this.mMaxProgresstime / 20) + " secs", + "Efficiency: "+(this.mEfficiency / 100.0F) + "%", + "Problems: " + "" + (this.getIdealStatus() - this.getRepairStatus()), + "Total Time Since Built: " + ""+weeks+" Weeks, " + ""+days+" Days, ", + ""+hours+" Hours, " + ""+minutes+" Minutes, " + ""+second+" Seconds.", + "Total Time in ticks: "+this.mTotalRunTime}; + + return g; + + + } @Override @@ -128,7 +147,7 @@ GT_MetaTileEntity_MultiBlockBase { // Gendustry custom comb with a billion centrifuge outputs? Do it anyway. return true; } - + // Count slots available in output buses ArrayList<ItemStack> tBusStacks = new ArrayList<>(); @@ -353,16 +372,16 @@ GT_MetaTileEntity_MultiBlockBase { GT_Recipe cloneRecipe = null; baseRecipe = tRecipe.copy(); - if ((cloneRecipe != baseRecipe) || (cloneRecipe == null)) { + if ((baseRecipe != null) && ((cloneRecipe != baseRecipe) || (cloneRecipe == null))) { cloneRecipe = baseRecipe.copy(); Logger.WARNING("Setting Recipe"); } - if ((cloneTime != baseRecipe.mDuration) || (cloneTime == 0)) { + if ((baseRecipe != null) && ((cloneTime != baseRecipe.mDuration) || (cloneTime == 0))) { cloneTime = baseRecipe.mDuration; Logger.WARNING("Setting Time"); } - if (cloneRecipe.mDuration > 0) { + if ((cloneRecipe != null) && cloneRecipe.mDuration > 0) { final int originalTime = cloneRecipe.mDuration; final int tempTime = MathUtils.findPercentageOfInt(cloneRecipe.mDuration, (100 - percentage)); @@ -385,6 +404,12 @@ GT_MetaTileEntity_MultiBlockBase { @Override public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { + + //Time Counter + if (aBaseMetaTileEntity.isServerSide()){ + this.mTotalRunTime++; + } + super.onPostTick(aBaseMetaTileEntity, aTick); //this.mChargeHatches.clear(); //this.mDischargeHatches.clear(); @@ -408,7 +433,7 @@ GT_MetaTileEntity_MultiBlockBase { } super.explodeMultiblock(); } - + protected int getGUICircuit(ItemStack[] t) { Item g = CI.getNumberedCircuit(0).getItem(); ItemStack guiSlot = this.mInventory[1]; @@ -420,12 +445,12 @@ GT_MetaTileEntity_MultiBlockBase { else { this.mInternalCircuit = false; } - + if (!this.mInternalCircuit) { for (ItemStack j : t) { if (j.getItem() == g) { - mMode = j.getItemDamage(); - break; + mMode = j.getItemDamage(); + break; } } } @@ -593,7 +618,7 @@ GT_MetaTileEntity_MultiBlockBase { * This is the array Used to Store the Tectech Multi-Amp hatches. */ - public ArrayList<GT_MetaTileEntity_Hatch> mMultiDynamoHatches = new ArrayList(); + public ArrayList<GT_MetaTileEntity_Hatch> mMultiDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch>(); /** * TecTech Multi-Amp Dynamo Support @@ -652,4 +677,16 @@ GT_MetaTileEntity_MultiBlockBase { return 0; } + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setLong("mTotalRunTime", this.mTotalRunTime); + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mTotalRunTime = aNBT.getLong("mTotalRunTime"); + super.loadNBTData(aNBT); + } + } 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 d3bf4dfe51..148e92b7fa 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/textures/CasingTextureHandler2.java @@ -8,61 +8,68 @@ public class CasingTextureHandler2 { public static IIcon getIcon(final int aSide, final int aMeta) { //Texture ID's. case 0 == ID[57] if ((aMeta >= 0) && (aMeta < 16)) { switch (aMeta) { - //Centrifuge - case 0: - return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); - //Coke Oven Frame - case 1: - return TexturesGtBlock.Casing_Material_HastelloyX.getIcon(); - //Coke Oven Casing Tier 1 - case 2: - return TexturesGtBlock.Casing_Material_HastelloyN.getIcon(); - //Coke Oven Casing Tier 2 - case 3: - return TexturesGtBlock.Casing_Material_Fluid_IncoloyDS.getIcon(); - //Material Press Casings - case 4: - return TexturesGtBlock.Casing_Material_Grisium.getIcon(); - //Sifter Structural - case 5: - return TexturesGtBlock.Casing_Machine_Metal_Panel_A.getIcon(); - //Sifter Sieve - case 6: - return TexturesGtBlock.Casing_Machine_Metal_Grate_A.getIcon(); - - //Vanadium Radox Battery - case 7: - return TexturesGtBlock.Overlay_Machine_Cyber_B.getIcon(); - //Power Sub-Station Casing - case 8: - return TexturesGtBlock.Casing_Machine_Metal_Sheet_A.getIcon(); - //Cyclotron Coil - case 9: - return TexturesGtBlock.Overlay_Machine_Cyber_A.getIcon(); - //Cyclotron External Casing - case 10: - return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); - //Multitank Exterior Casing - case 11: - return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon(); - //Reactor Casing I - case 12: - return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); - //Reactor Casing II - case 13: - if (aSide <2) { - return TexturesGtBlock.TEXTURE_TECH_A.getIcon(); - } - else { - return TexturesGtBlock.TEXTURE_TECH_B.getIcon(); - } - case 14: - return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); - case 15: - return TexturesGtBlock.Casing_Machine_Farm_Manager.getIcon(); //Tree Farmer Textures + //Centrifuge + case 0: + return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); + //Coke Oven Frame + case 1: + return TexturesGtBlock.Casing_Material_HastelloyX.getIcon(); + //Coke Oven Casing Tier 1 + case 2: + return TexturesGtBlock.Casing_Material_HastelloyN.getIcon(); + //Coke Oven Casing Tier 2 + case 3: + return TexturesGtBlock.Casing_Material_Fluid_IncoloyDS.getIcon(); + //Material Press Casings + case 4: + return TexturesGtBlock.Casing_Material_Grisium.getIcon(); + //Sifter Structural + case 5: + return TexturesGtBlock.Casing_Machine_Metal_Panel_A.getIcon(); + //Sifter Sieve + case 6: + return TexturesGtBlock.Casing_Machine_Metal_Grate_A.getIcon(); - default: - return TexturesGtBlock.Overlay_UU_Matter.getIcon(); + //Vanadium Radox Battery + case 7: + return TexturesGtBlock.Overlay_Machine_Cyber_B.getIcon(); + //Power Sub-Station Casing + case 8: + return TexturesGtBlock.Casing_Machine_Metal_Sheet_A.getIcon(); + //Cyclotron Coil + case 9: + return TexturesGtBlock.Overlay_Machine_Cyber_A.getIcon(); + //Cyclotron External Casing + case 10: + return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); + //Multitank Exterior Casing + case 11: + return TexturesGtBlock.Casing_Material_Tantalloy61.getIcon(); + //Reactor Casing I + case 12: + return TexturesGtBlock.Casing_Machine_Simple_Top.getIcon(); + //Reactor Casing II + case 13: + if (aSide <2) { + return TexturesGtBlock.TEXTURE_TECH_A.getIcon(); + } + else { + return TexturesGtBlock.TEXTURE_TECH_B.getIcon(); + } + case 14: + return TexturesGtBlock.Casing_Material_RedSteel.getIcon(); + case 15: + if (aSide <2) { + if (aSide == 1) { + return TexturesGtBlock.Casing_Machine_Podzol.getIcon(); + } + return TexturesGtBlock.Casing_Machine_Acacia_Log.getIcon(); + } + 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/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index 210603ec0d..7aaabe6ef1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -8,9 +8,9 @@ import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_ModHandler; import gregtech.common.items.*; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.BlockPos; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.nbt.NBTUtils; import gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic.GregtechMetaWirelessCharger; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java index d023307820..7b1da9738b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java @@ -2,28 +2,63 @@ package gtPlusPlus.xmod.gregtech.common.helpers; import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableTreeFarmerParticles; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Queue; +import java.util.Set; +import java.util.Stack; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +import com.google.common.collect.Lists; + +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Optional; import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import gnu.trove.set.hash.THashSet; import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.TAE; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.common.items.GT_MetaGenerated_Item_02; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.players.FakeFarmer; import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.fluid.FluidUtils; +import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.particles.BlockBreakParticles; -import gtPlusPlus.xmod.forestry.trees.TreefarmManager; +import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.block.Block; +import net.minecraft.block.BlockAir; import net.minecraft.block.IGrowable; +import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.play.server.S23PacketBlockChange; +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.ChunkPosition; import net.minecraft.world.World; +import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.BonemealEvent; +import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.fluids.FluidStack; public class TreeFarmHelper { @@ -199,7 +234,7 @@ public class TreeFarmHelper { } - if (TreefarmManager.isLeaves(testBlock) || TreefarmManager.isWoodLog(testBlock)){ + if (isLeaves(testBlock) || isWoodLog(testBlock)){ Logger.WARNING("1:"+testBlock.getUnlocalizedName()); int posiX, posiY, posiZ; posiX = aBaseMetaTileEntity.getXCoord()+xDir+i; @@ -232,7 +267,7 @@ public class TreeFarmHelper { //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.10")){ + if (aStack.getDisplayName().toLowerCase().contains("saw") || aStack.getDisplayName().toLowerCase().contains("gt.metatool.01")){ if (aStack.getItemDamage() == 10){ return SAWTOOL.SAW; } @@ -258,4 +293,730 @@ public class TreeFarmHelper { return SAWTOOL.NONE; } + public static boolean isHumusLoaded = false; + public static boolean isForestryLogsLoaded = false; + public static boolean isForestryFenceLoaded = false; + public static boolean isForestrySaplingsLoaded = false; + public static boolean isForestryLeavesLoaded = false; + public static Block blockHumus; + + public static boolean isForestryValid(){ + if (!LoadedMods.Forestry){ + return false; + } + if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){ + isHumusLoaded = true; + } + if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockLog")){ + isForestryLogsLoaded = true; + } + if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockArbFence")){ + isForestryFenceLoaded = true; + } + if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockSapling")){ + isForestrySaplingsLoaded = true; + } + if (ReflectionUtils.doesClassExist("forestry.arboriculture.blocks.BlockForestryLeaves")){ + isForestryLeavesLoaded = true; + } + return true; + } + + @Optional.Method(modid = "Forestry") + public static Block getHumus(){ + if(blockHumus != null){ + return blockHumus; + } + else if (ReflectionUtils.doesClassExist("forestry.core.blocks.BlockSoil")){ + try { + final Class<?> humusClass = Class.forName("forestry.core.blocks.BlockSoil"); + final ItemStack humusStack = ItemUtils.getCorrectStacktype("Forestry:soil", 1); + if (humusClass != null){ + blockHumus = Block.getBlockFromItem(humusStack.getItem()); + return Block.getBlockFromItem(humusStack.getItem()); + } + } catch (final ClassNotFoundException e) {} + } + return null; + } + + public static boolean isWoodLog(final Block log){ + final String tTool = log.getHarvestTool(0); + + if ((log == Blocks.log) || (log == Blocks.log2)){ + return true; + } + + //Forestry/General Compat + if (log.getClass().getName().toLowerCase().contains("blocklog")){ + return true; + } + + //IC2 Rubber Tree Compat + if (log.getClass().getName().toLowerCase().contains("rubwood") || log.getClass().getName().toLowerCase().contains("rubleaves")){ + return true; + } + + return (OrePrefixes.log.contains(new ItemStack(log, 1))&& ((tTool != null) && (tTool.equals("axe")))) || (log.getMaterial() != Material.wood) ? false : (OrePrefixes.fence.contains(new ItemStack(log, 1)) ? false : true); + } + + public static boolean isLeaves(final Block log){ + if (log.getUnlocalizedName().toLowerCase().contains("leaf")){ + return true; + } + if (log.getUnlocalizedName().toLowerCase().contains("leaves")){ + return true; + } + if (log.getLocalizedName().toLowerCase().contains("leaf")){ + return true; + } + if (log.getLocalizedName().toLowerCase().contains("leaves")){ + return true; + } + return OrePrefixes.leaves.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.leaves || OrePrefixes.treeLeaves.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.vine || OrePrefixes.mushroom.contains(new ItemStack(log, 1)) || log.getMaterial() == Material.cactus; + } + + public static boolean isSapling(final Block log){ + if (log != null){ + if (OrePrefixes.sapling.contains(new ItemStack(log, 1))){ + Logger.WARNING(""+log.getLocalizedName()); + } + if (log.getLocalizedName().toLowerCase().contains("sapling")){ + Logger.WARNING(""+log.getLocalizedName()); + return true; + } + } + return OrePrefixes.sapling.contains(new ItemStack(log, 1)); + } + + public static boolean isDirtBlock(final Block dirt){ + return (dirt == Blocks.dirt ? true : (dirt == Blocks.grass ? true : (getHumus() == null ? false : (dirt == blockHumus ? true : false)))); + } + + public static boolean isFenceBlock(final Block fence){ + return (fence == Blocks.fence ? true : (fence == Blocks.fence_gate ? true : (fence == Blocks.nether_brick_fence ? true : (OrePrefixes.fence.contains(new ItemStack(fence, 1)) ? true : false)))); + } + + public static boolean isAirBlock(final Block air){ + if (air.getLocalizedName().toLowerCase().contains("air")){ + return true; + } + if (air.getClass().getName().toLowerCase().contains("residual") || air.getClass().getName().toLowerCase().contains("heat")){ + return true; + } + return (air == Blocks.air ? true : (air instanceof BlockAir ? true : false)); + } + + /*public static boolean isSaplingBlock(Block sapling){ + return (sapling == Blocks.sapling ? true : (sapling == Blocks.)) + }*/ + + public static BlockPos checkForLogsInGrowArea(final IGregTechTileEntity aBaseMetaTileEntity) { + 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++) { + for (int j = -7; j <= 7; j++) { + for (int h = 0; h <= 1; h++) { + //Farm Floor inner 14x14 + if (((i != -7) && (i != 7)) && ((j != -7) && (j != 7))) { + if (h == 1) { + if (TreeFarmHelper.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) { + Logger.INFO("Found a Log"); + return new BlockPos(aBaseMetaTileEntity.getXCoord()+xDir + i, aBaseMetaTileEntity.getYCoord()+h, aBaseMetaTileEntity.getZCoord()+zDir + j); + } + } + } + } + } + } + return null; + } + + public static ItemStack[] findTreeFromBase(World world, BlockPos h) { + int HARD_LIMIT = 10000; + int mCount = 0; + Logger.INFO("Finding Rest of Tree."); + BlockPos mFirstSpot = h; + Set<BlockPos> mSearchedSpaces = new HashSet<BlockPos>(); + Set<BlockPos> mTreeSet = getConnectedBlocks(world, mFirstSpot, mSearchedSpaces); + Set<Set<BlockPos>> mTreeSet2 = new HashSet<Set<BlockPos>>(); + Set<BlockPos> mFinalTree = new HashSet<BlockPos>(); + Iterator<BlockPos> it = mTreeSet.iterator(); + + + Logger.INFO("Running first iteration."); + while(it.hasNext()){ + BlockPos G = it.next(); + mSearchedSpaces.add(G); + mTreeSet2.add(getConnectedBlocks(world, G, mSearchedSpaces)); + mCount++; + Logger.INFO("First Search: "+G.getLocationString()); + if (mCount > HARD_LIMIT) { + break; + } + } + + mCount = 0; + Iterator<Set<BlockPos>> it2 = mTreeSet2.iterator(); + Iterator<BlockPos> it3; + Logger.INFO("Running second iteration."); + while(it2.hasNext()){ + Set<BlockPos> G = it2.next(); + it3 = G.iterator(); + while(it3.hasNext()){ + BlockPos G2 = it3.next(); + mSearchedSpaces.add(G2); + mFinalTree.add(G2); + mCount++; + Logger.INFO("Second Search: "+G2.getLocationString()); + if (mCount > HARD_LIMIT) { + break; + } + } + if (mCount > HARD_LIMIT) { + break; + } + } + + + if (mFinalTree.size() > 0) { + Logger.INFO("Queuing "+mFinalTree.size()+" to Harvest Manager."); + TreeCutter harvestManager = new TreeCutter(world); + + Iterator<BlockPos> ith = mFinalTree.iterator(); + while(ith.hasNext()){ + BlockPos G = ith.next(); + harvestManager.queue(G); + mCount++; + Logger.INFO("Queued: "+G.getLocationString()); + if (mCount > HARD_LIMIT) { + break; + } + } + + if (harvestManager.isValid) { + ItemStack[] loot = harvestManager.getDrops(); + if (loot.length > 0) { + //Logger.INFO("Returning Drops from harvestManager Queue."); + return loot; + } + } + } + return new ItemStack[] {}; + } + + + public static Set<BlockPos> getConnectedBlocks(World W, BlockPos P, Set<BlockPos> checkedSpaces) { + int HARD_LIMIT = 1000; + int mCount = 0; + Logger.INFO("Finding blocks connected to "+P.getLocationString()+"."); + Set<BlockPos> mCheckedSpaces = checkedSpaces; + Set<BlockPos> mStartSearch = searchSixFaces(W, P, mCheckedSpaces, false); + Set<BlockPos> mSecondSearch = new HashSet<BlockPos>(); + Set<BlockPos> mThirdSearch = new HashSet<BlockPos>(); + Iterator<BlockPos> it = mStartSearch.iterator(); + while(it.hasNext()){ + Logger.INFO("Running first iteration. [II]"); + BlockPos G = it.next(); + mCheckedSpaces.add(G); + Set<BlockPos> mBranchSearch = searchSixFaces(W, G, mCheckedSpaces, true); + Iterator<BlockPos> it2 = mBranchSearch.iterator(); + while(it2.hasNext()){ + Logger.INFO("Running second iteration. [II]"); + BlockPos G2 = it2.next(); + mCheckedSpaces.add(G2); + mSecondSearch.add(G2); + mCount++; + if (mCount > HARD_LIMIT) { + break; + } + } + if (mCount > HARD_LIMIT) { + break; + } + } + mCount = 0; + Iterator<BlockPos> itx = mSecondSearch.iterator(); + while(itx.hasNext()){ + BlockPos G = itx.next(); + mCheckedSpaces.add(G); + Set<BlockPos> mBranchSearch = searchSixFaces(W, G, mCheckedSpaces, true); + Iterator<BlockPos> it2 = mBranchSearch.iterator(); + while(it2.hasNext()){ + BlockPos G2 = it2.next(); + mCheckedSpaces.add(G2); + mThirdSearch.add(G2); + mCount++; + if (mCount > HARD_LIMIT) { + break; + } + } + if (mCount > HARD_LIMIT) { + break; + } + } + return mThirdSearch; + } + + public static Set<BlockPos> searchSixFaces(World W, BlockPos P, Set<BlockPos> checkedSpaces, boolean checkLeaves) { + Set<BlockPos> mConnected = new HashSet<BlockPos>(); + int x = P.xPos; + int y = P.yPos; + int z = P.zPos; + if (checkLeaves) { + if (isWoodLog(W.getBlock(x-1, y, z)) || isLeaves(W.getBlock(x-1, y, z))) { + BlockPos L = new BlockPos(x-1, y, z); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x+1, y, z)) || isLeaves(W.getBlock(x+1, y, z))) { + BlockPos L = new BlockPos(x+1, y, z); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y-1, z)) || isLeaves(W.getBlock(x, y-1, z))) { + BlockPos L = new BlockPos(x, y-1, z); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y+1, z)) || isLeaves(W.getBlock(x, y+1, z))) { + BlockPos L = new BlockPos(x, y+1, z); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y, z-1)) || isLeaves(W.getBlock(x, y, z-1))) { + BlockPos L = new BlockPos(x, y, z-1); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + if (isWoodLog(W.getBlock(x, y, z+1)) || isLeaves(W.getBlock(x, y, z+1))) { + BlockPos L = new BlockPos(x, y, z+1); + if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + } + } + } + else { + if (isWoodLog(W.getBlock(x-1, y, z))) { + BlockPos L = new BlockPos(x-1, y, z); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x+1, y, z))) { + BlockPos L = new BlockPos(x+1, y, z); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x, y-1, z))) { + BlockPos L = new BlockPos(x, y-1, z); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x, y+1, z))) { + BlockPos L = new BlockPos(x, y+1, z); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x, y, z-1))) { + BlockPos L = new BlockPos(x, y, z-1); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + if (isWoodLog(W.getBlock(x, y, z+1))) { + BlockPos L = new BlockPos(x, y, z+1); + //if (!checkedSpaces.contains(L)) { + mConnected.add(L); + Logger.INFO("Found Connected. [III]"); + //} + } + } + return mConnected; + } + + public static <T> Set<T> combineSetData(Set<T> S, Set<T> J) { + Set<T> mData = new HashSet<T>(); + T[] array1 = (T[]) S.toArray(); + Collections.addAll(mData, array1); + T[] array2 = (T[]) J.toArray(); + Collections.addAll(mData, array2); + return mData; + } + + + + /** + * Tree Cutting + */ + + public static class TreeCutter { + + private final World mWorld; + private Map<String, BlockPos> mQueue = new ConcurrentHashMap<String, BlockPos>(); + private AutoMap<ItemStack[]> mDrops = new AutoMap<ItemStack[]>(); + private boolean isValid = true; + + public TreeCutter(World world) { + this.mWorld = world; + } + + public boolean queue(BlockPos pos) { + if (isValid && pos != null) { + //Logger.INFO("Queued: "+pos.getLocationString()); + String hash = Utils.calculateChecksumMD5(pos); + if (hash != null && !mQueue.containsKey(hash)) { + mQueue.put(hash, pos); + return true; + } + } + return false; + } + + private boolean emptyQueue() { + if (isValid) { + Logger.INFO("Emptying Queue."); + if (this.mQueue.size() > 0) { + int totalRemoved = 0; + for (BlockPos h : mQueue.values()) { + final Block block = mWorld.getBlock(h.xPos, h.yPos, h.zPos); + if (block != null) { + final int dropMeta = mWorld.getBlockMetadata(h.xPos, h.yPos, h.zPos); + final ArrayList<ItemStack> blockDrops = block.getDrops(mWorld, h.xPos, h.yPos, h.zPos, dropMeta, 0); + final ItemStack[] drops = ItemUtils.getBlockDrops(blockDrops); + mDrops.put(drops); + //Remove drop that was added to the bus. + mWorld.setBlockToAir(h.xPos, h.yPos, h.zPos); + //new BlockBreakParticles(mWorld, h.xPos, h.yPos, h.zPos, block); + totalRemoved++; + } + } + if (totalRemoved > 0 && mDrops.size() > 0) { + return true; + } + } + } + return false; + } + + public ItemStack[] getDrops() { + //If Queue is successfully cleared and drops are created, let us continue. + if (isValid && emptyQueue()) { + AutoMap<ItemStack> mCollective = new AutoMap<ItemStack>(); + //Iterate ALL of the arrays, add output to a collective. + for (ItemStack[] i : this.mDrops) { + //Array is not null. + if (i != null) { + //Iterate this array. + for (int d=0;d<i.length;d++) { + //Put Output into collective if valid + if (i[d] != null && i[d].stackSize > 0) { + mCollective.put(i[d]); + } + } + } + } + //Build an ItemStack array. + ItemStack[] drops = new ItemStack[mCollective.size()]; + for (int m=0;m<drops.length;m++) { + drops[m] = mCollective.get(m); + } + //Return drops array if it's valid. + if (drops.length > 0) { + isValid = false; + return drops; + } + } + //Invalid or no drops, return empty array. + isValid = false; + return new ItemStack[] {}; + } + + } + + + /** + * Farm AI + */ + private static EntityPlayerMP farmerAI; + public EntityPlayerMP getFakePlayer(World world) { + return farmerAI = checkFakePlayer(world); + } + + public static EntityPlayerMP checkFakePlayer(World world) { + if (farmerAI == null) { + return new FakeFarmer(MinecraftServer.getServer().worldServerForDimension(world.provider.dimensionId)); + } + return farmerAI; + } + + public static boolean onBlockStartBreak (int x, int y, int z, World world){ + final Block wood = world.getBlock(x, y, z); + if (wood == null){ + return false; + } + if (wood.isWood(world, x, y, z) || wood.getMaterial() == Material.sponge) + if(detectTree(world, x,y,z)) { + TreeChopTask chopper = new TreeChopTask(new ChunkPosition(x, y, z), checkFakePlayer(world), 128); + FMLCommonHandler.instance().bus().register(chopper); + // custom block breaking code, don't call vanilla code + return true; + } + //return onBlockStartBreak(stack, x, y, z, player); + return false; + } + + public static boolean detectTree(World world, int pX, int pY, int pZ) { + ChunkPosition pos = null; + Stack<ChunkPosition> candidates = new Stack<>(); + candidates.add(new ChunkPosition(pX, pY, pZ)); + + while (!candidates.isEmpty()) { + ChunkPosition candidate = candidates.pop(); + int curX = candidate.chunkPosX, curY = candidate.chunkPosY, curZ = candidate.chunkPosZ; + + Block block = world.getBlock(curX, curY, curZ); + if ((pos == null || candidate.chunkPosY > pos.chunkPosY) && block.isWood(world, curX, curY, curZ)) { + pos = new ChunkPosition(curX, candidate.chunkPosY + 1, curZ); + // go up + while (world.getBlock(curX, pos.chunkPosY, curZ).isWood(world, curX, pos.chunkPosY, curZ)) { + pos = new ChunkPosition(curX, pos.chunkPosY + 1, curZ); + } + // check if we still have a way diagonally up + candidates.add(new ChunkPosition(curX + 1, pos.chunkPosY + 1, curZ )); + candidates.add(new ChunkPosition(curX , pos.chunkPosY + 1, curZ + 1)); + candidates.add(new ChunkPosition(curX - 1, pos.chunkPosY + 1, curZ )); + candidates.add(new ChunkPosition(curX , pos.chunkPosY + 1, curZ - 1)); + } + } + + // not even one match, so there were no logs. + if (pos == null) { + return false; + } + + // check if there were enough leaves around the last position + // pos now contains the block above the topmost log + // we want at least 5 leaves in the surrounding 26 blocks + int d = 3; + int leaves = 0; + for (int offX = 0; offX < d; offX++) { + for (int offY = 0; offY < d; offY++) { + for (int offZ = 0; offZ < d; offZ++) { + int xPos = pos.chunkPosX -1 + offX, yPos = pos.chunkPosY - 1 + offY, zPos = pos.chunkPosZ - 1 + offZ; + Block leaf = world.getBlock(xPos, yPos, zPos); + if (leaf != null && leaf.isLeaves(world, xPos, yPos, zPos)) { + if (++leaves >= 5) { + return true; + } + } + } + } + } + + // not enough leaves. sorreh + return false; + } + + public static class TreeChopTask { + + public final World world; + public final EntityPlayer player; + public final int blocksPerTick; + + public Queue<ChunkPosition> blocks = Lists.newLinkedList(); + public Set<ChunkPosition> visited = new THashSet<>(); + + public TreeChopTask(ChunkPosition start, EntityPlayer player, int blocksPerTick) { + this.world = player.getEntityWorld(); + this.player = player; + this.blocksPerTick = blocksPerTick; + + this.blocks.add(start); + } + + private void queueCoordinate(int x, int y, int z) { + ChunkPosition pos = new ChunkPosition(x, y, z); + if (!visited.contains(pos)) { + blocks.add(pos); + } + } + + @SubscribeEvent + public void onWorldTick(TickEvent.WorldTickEvent event) { + if (event.side.isClient()) { + finish(); + return; + } + // only if same dimension + if (event.world.provider.dimensionId != world.provider.dimensionId) { + return; + } + + // setup + int left = blocksPerTick; + //NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool"); + + // continue running + ChunkPosition pos; + while (left > 0) { + // completely done or can't do our job anymore?! + if (blocks.isEmpty()/* || tags.getBoolean("Broken")*/) { + finish(); + return; + } + + pos = blocks.remove(); + if (!visited.add(pos)) { + continue; + } + int x = pos.chunkPosX, y = pos.chunkPosY, z = pos.chunkPosZ; + + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + // can we harvest the block and is effective? + if (!block.isWood(world, x, y, z) || !isWoodLog(block)) { + continue; + } + + // save its neighbors + queueCoordinate(x + 1, y, z ); + queueCoordinate(x, y, z + 1); + queueCoordinate(x - 1, y, z ); + queueCoordinate(x, y, z - 1); + + // also add the layer above.. stupid acacia trees + for (int offX = 0; offX < 3; offX++) { + for (int offZ = 0; offZ < 3; offZ++) { + queueCoordinate(x - 1 + offX, y + 1, z - 1 + offZ); + } + } + + // break it, wooo! + breakExtraBlock(player.worldObj, x, y, z, 0, player, x, y, z); + left--; + } + } + + private void finish() { + // goodbye cruel world + FMLCommonHandler.instance().bus().unregister(this); + } + } + + + public static void breakExtraBlock(World world, int x, int y, int z, int sidehit, EntityPlayer playerEntity, int refX, int refY, int refZ) { + // prevent calling that stuff for air blocks, could lead to unexpected behaviour since it fires events + if (world.isAirBlock(x, y, z)) + return; + + // what? + if(!(playerEntity instanceof EntityPlayerMP)) + return; + EntityPlayerMP player = (EntityPlayerMP) playerEntity; + + // check if the block can be broken, since extra block breaks shouldn't instantly break stuff like obsidian + // or precious ores you can't harvest while mining stone + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + // only effective materials + if (!isWoodLog(block)) + return; + + Block refBlock = world.getBlock(refX, refY, refZ); + float refStrength = ForgeHooks.blockStrength(refBlock, player, world, refX, refY, refZ); + float strength = ForgeHooks.blockStrength(block, player, world, x,y,z); + + // only harvestable blocks that aren't impossibly slow to harvest + if (!ForgeHooks.canHarvestBlock(block, player, meta) || refStrength/strength > 10f) + return; + + // send the blockbreak event + BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x,y,z); + if(event.isCanceled()) + return; + + if (player.capabilities.isCreativeMode) { + block.onBlockHarvested(world, x, y, z, meta, player); + if (block.removedByPlayer(world, player, x, y, z, false)) + block.onBlockDestroyedByPlayer(world, x, y, z, meta); + + // send update to client + if (!world.isRemote) { + player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + } + return; + } + + // callback to the tool the player uses. Called on both sides. This damages the tool n stuff. + player.getCurrentEquippedItem().func_150999_a(world, block, x, y, z, player); + + // server sided handling + if (!world.isRemote) { + // serverside we reproduce ItemInWorldManager.tryHarvestBlock + + // ItemInWorldManager.removeBlock + block.onBlockHarvested(world, x,y,z, meta, player); + + if(block.removedByPlayer(world, player, x,y,z, true)) // boolean is if block can be harvested, checked above + { + block.onBlockDestroyedByPlayer( world, x,y,z, meta); + block.harvestBlock(world, player, x,y,z, meta); + block.dropXpOnBlockBreak(world, x,y,z, event.getExpToDrop()); + } + + // always send block update to client + player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); + } + // client sided handling + else { + //PlayerControllerMP pcmp = Minecraft.getMinecraft().playerController; + // clientside we do a "this clock has been clicked on long enough to be broken" call. This should not send any new packets + // the code above, executed on the server, sends a block-updates that give us the correct state of the block we destroy. + + // following code can be found in PlayerControllerMP.onPlayerDestroyBlock + world.playAuxSFX(2001, x, y, z, Block.getIdFromBlock(block) + (meta << 12)); + if(block.removedByPlayer(world, player, x,y,z, true)) + { + block.onBlockDestroyedByPlayer(world, x,y,z, meta); + } + // callback to the tool + ItemStack itemstack = player.getCurrentEquippedItem(); + if (itemstack != null) + { + itemstack.func_150999_a(world, block, x, y, z, player); + + if (itemstack.stackSize == 0) + { + player.destroyCurrentEquippedItem(); + } + } + + // send an update to the server, so we get an update back + //if(PHConstruct.extraBlockUpdates) + //Minecraft.getMinecraft().getNetHandler().addToSendQueue(new C07PacketPlayerDigging(2, x,y,z, Minecraft.getMinecraft().objectMouseOver.sideHit)); + } + } + } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java index 7bdc5ae2f2..297db1d7a0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaTileEntityChunkLoader.java @@ -1,7 +1,8 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; import static gregtech.api.enums.GT_Values.V; -import static gtPlusPlus.api.objects.ChunkManager.mChunkLoaderManagerMap; +import static gtPlusPlus.api.objects.minecraft.ChunkManager.mChunkLoaderManagerMap; + import java.io.File; import java.io.IOException; import java.util.Map; @@ -17,11 +18,11 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachi import gregtech.api.objects.GT_RenderedTexture; import gtPlusPlus.GTplusplus; import gtPlusPlus.api.interfaces.IChunkLoader; -import gtPlusPlus.api.objects.ChunkManager; -import gtPlusPlus.api.objects.DimChunkPos; import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.array.BlockPos; -import gtPlusPlus.core.util.array.Triplet; +import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.api.objects.minecraft.ChunkManager; +import gtPlusPlus.api.objects.minecraft.DimChunkPos; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java index 7f70712ee9..e88840573d 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java @@ -11,8 +11,8 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.minecraft.BlockPos; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.array.BlockPos; import gtPlusPlus.core.util.entity.EntityUtils; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java index b2b6b83d0b..4540c41bd5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_TeslaTower.java @@ -19,10 +19,10 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.entity.EntityTeslaTowerLightning; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.util.player.PlayerUtils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java index da83b3c3d1..7b7e4414b3 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntityAnimalFarm.java @@ -1,397 +1,82 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; -import java.lang.reflect.Field; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; 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_MultiBlockBase; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; -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.core.lib.LoadedMods; -import gtPlusPlus.xmod.forestry.trees.TreefarmManager; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -public class GregtechMetaTileEntityAnimalFarm extends GT_MetaTileEntity_MultiBlockBase { - - - private static final ITexture[] FACING_SIDE = {new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Tumbaga)}; - private static final ITexture[] FACING_FRONT = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBLASTFURNACE)}; - private static final ITexture[] FACING_ACTIVE = {new GT_RenderedTexture(Textures.BlockIcons.MACHINE_BRONZEBLASTFURNACE_ACTIVE)}; - - - //public ArrayList<GT_MetaTileEntity_TieredMachineBlock> mCasings = new ArrayList(); +public abstract class GregtechMetaTileEntityAnimalFarm extends GT_MetaTileEntity_MultiBlockBase { - private final boolean running = false; - private boolean p1, p2, p3, p4, p5, p6; - public ItemStack mOutputItem1; - public ItemStack mOutputItem2; - private Block Humus; - private final boolean isForestryLoaded = TreefarmManager.isForestryValid(); - - public GregtechMetaTileEntityAnimalFarm(final int aID, final String aName, final String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GregtechMetaTileEntityAnimalFarm(final String aName) { + public GregtechMetaTileEntityAnimalFarm(String aName) { super(aName); + // TODO Auto-generated constructor stub } - - @Override - public String[] getDescription() { - return new String[]{ - "Controller Block for the Animal Farmer", - "How to get your first logs without an axe.", - "Max Size(WxHxD): 9x1x9 (Controller, with upto 4 dirt out each direction on a flat plane.)", - "Dirt for the rest! [D = Dirt, X = Controller]" - }; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, final byte aColorIndex, final boolean aActive, final boolean aRedstone) { - if (aSide == 1) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log), new GT_RenderedTexture(aActive ? TexturesGtBlock.Overlay_Machine_Vent_Fast : TexturesGtBlock.Overlay_Machine_Vent)}; - } - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Farm_Manager)}; + + public GregtechMetaTileEntityAnimalFarm(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + // TODO Auto-generated constructor stub } @Override - public GT_Recipe.GT_Recipe_Map getRecipeMap() { + public IMetaTileEntity newMetaEntity(IGregTechTileEntity p0) { + // TODO Auto-generated method stub return null; } @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public boolean isFacingValid(final byte aFacing) { - return aFacing > 1; - } - - @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 GregtechMetaTileEntityAnimalFarm(this.mName); + public String[] getDescription() { + // TODO Auto-generated method stub + return null; } @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - - return true; + public ITexture[] getTexture(IGregTechTileEntity p0, byte p1, byte p2, byte p3, boolean p4, boolean p5) { + // TODO Auto-generated method stub + return null; } @Override - public boolean isCorrectMachinePart(final ItemStack aStack) { - return true; + public boolean isCorrectMachinePart(ItemStack p0) { + // TODO Auto-generated method stub + return false; } @Override - public boolean checkRecipe(final ItemStack aStack) { - Logger.INFO("Working"); - /*if (!checkRecursiveBlocks()) { - this.mEfficiency = 0; - this.mEfficiencyIncrease = 0; - this.mMaxProgresstime = 0; - running = false; - return false; - } - - if (mEfficiency == 0) { - this.mEfficiency = 10000; - this.mEfficiencyIncrease = 10000; - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); - //GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), mMaxProgresstime*5); - return true; - }*/ - this.mEfficiency = 0; - this.mEfficiencyIncrease = 0; - this.mMaxProgresstime = 0; + public boolean checkRecipe(ItemStack p0) { + // TODO Auto-generated method stub return false; } - - private Block getHumus(){ - if (!LoadedMods.Forestry){ - return null; - } - return TreefarmManager.getHumus(); - } - @Override - public boolean checkMachine(final IGregTechTileEntity aBaseMetaTileEntity, final ItemStack aStack) { - - //this.mCasings.clear(); - Logger.INFO("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.INFO("Step 2"); - for (int j = -7; j <= 7; j++) { - Logger.INFO("Step 3"); - for (int h = 0; h <= 1; h++) { - Logger.INFO("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.INFO("Step 5 - H:"+h); - // Farm Dirt Floor and Inner Air/Log space. - if (h == 0) { - //Dirt Floor - if (!TreefarmManager.isDirtBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) { - Logger.INFO("Dirt like block missing from inner 14x14."); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); - aBaseMetaTileEntity.getWorld().setBlock( - (aBaseMetaTileEntity.getXCoord()+(xDir+i)), - (aBaseMetaTileEntity.getYCoord()+(h)), - (aBaseMetaTileEntity.getZCoord()+(zDir+j)), - Blocks.melon_block); - return false; - } - } - // Inside fenced area, mostly air or trees or saplings - else if (h == 1){ - //Farm Inner 14x14 - /*if (!TreefarmManager.isWoodLog(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)) || !TreefarmManager.isAirBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)) || !aBaseMetaTileEntity.getAirOffset(xDir+i, h, zDir+j)) { - Utils.LOG_INFO("Wood like block missing from inner 14x14, layer 2."); //TODO - Utils.LOG_INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); - Utils.LOG_INFO("Found at x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j)); - //return false; - }*/ - } - - } - //Dealt with inner 5x5, now deal with the exterior. - else { - Logger.INFO("Step 6 - H:"+h); - //Deal with all 4 sides (Fenced area) - if (h == 1) { - if (!TreefarmManager.isFenceBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j))) { - Logger.INFO("Fence/Gate missing from outside the second layer."); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); - 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) { - - try { - this.addCasingToCasingList(tTileEntity); - } catch (final Throwable t){} - - if ((!this.addMaintenanceToMachineList(tTileEntity, 77)) && (!this.addInputToMachineList(tTileEntity, 77)) && (!this.addOutputToMachineList(tTileEntity, 77)) && (!this.addEnergyInputToMachineList(tTileEntity, 77))) { - if (((xDir + i) != 0) || ((zDir + j) != 0)) {//no controller - - if (!(aBaseMetaTileEntity.getMetaTileID() != 752)) { - Logger.INFO("Fark Keeper Casings Missing from one of the edges on the bottom edge. x:"+(xDir+i)+" y:"+h+" z:"+(zDir+j)+" | "+aBaseMetaTileEntity.getClass()); - Logger.INFO("Instead, found "+aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j).getLocalizedName()); - return false; - } - Logger.INFO("Found a farm keeper."); - } - } - } - Logger.INFO("Step a"); - - } - Logger.INFO("Step b"); - } - Logger.INFO("Step c"); - } - Logger.INFO("Step d"); - } - Logger.INFO("Step 7"); - - //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 < 2){ - Logger.INFO("You require at LEAST MV tier Energy Hatches."); - Logger.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 < 2) && (this.mOutputHatches.get(i).getBaseMetaTileEntity() instanceof GregtechMTE_NuclearReactor)){ - Logger.INFO("You require at LEAST MV tier Output Hatches."); - Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord()); - Logger.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 < 2){ - Logger.INFO("You require at LEAST MV tier Input Hatches."); - Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getXCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getYCoord()+","+this.mOutputHatches.get(i).getBaseMetaTileEntity().getZCoord()); - Logger.INFO(this.mOutputHatches.get(i).getBaseMetaTileEntity().getInventoryName()); - return false; - } - } - } - this.mSolderingTool = true; - //turnCasingActive(true); - Logger.INFO("Multiblock Formed."); - return true; + public boolean checkMachine(IGregTechTileEntity p0, ItemStack p1) { + // TODO Auto-generated method stub + return false; } @Override - public int getMaxEfficiency(final ItemStack aStack) { - return 10000; + public int getMaxEfficiency(ItemStack p0) { + // TODO Auto-generated method stub + return 0; } @Override - public int getPollutionPerTick(final ItemStack aStack) { + public int getPollutionPerTick(ItemStack p0) { + // TODO Auto-generated method stub return 0; } @Override - public int getDamageToComponent(final ItemStack aStack) { + public int getDamageToComponent(ItemStack p0) { + // TODO Auto-generated method stub return 0; } - public int getAmountOfOutputs() { - return 1; - } - @Override - public boolean explodesOnComponentBreak(final ItemStack aStack) { - return false; - } - - public boolean addCasingToCasingList(final IGregTechTileEntity aTileEntity) { - if (aTileEntity == null) { - return false; - } - final IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return false; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_TieredMachineBlock) { - //return this.mCasings.add((GT_MetaTileEntity_TieredMachineBlock) aMetaTileEntity); - } + public boolean explodesOnComponentBreak(ItemStack p0) { + // TODO Auto-generated method stub return false; } - private GT_MetaTileEntity_TieredMachineBlock changeTextureswithReflection(final GT_MetaTileEntity_TieredMachineBlock casing, final ITexture[][][] textureSet){ - final GT_MetaTileEntity_TieredMachineBlock cv = casing; - //System.out.println("Before: "+cv.mTextures.hashCode()); - //Get declared field from class - Field f; - try { - final Field[] x = cv.getClass().getFields(); - for (int i =0; i<x.length;i++){ - //Utils.LOG_INFO(x[i].getName()); - } - try { - //Try get the field variable - f = cv.getClass().getField("mTextures"); - // set the accessiblity of the field to true, this will enable you to change the value - f.setAccessible(true); - //change the field value - f.set(cv, textureSet); - //Verify change in texture set - //System.out.println("After: "+cv.mTextures.hashCode()); - return cv; - } catch (final NoSuchFieldException e) { - Logger.INFO("Could not find mTextures."); - return casing; - } - } catch (SecurityException | IllegalArgumentException | IllegalAccessException e) { - // TODO Auto-generated catch block - //e.printStackTrace(); - return casing; - } - } - - - public ITexture[][][] getTextureSet() { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[2][aColor + 1]}; - } - - public ITexture[] getFrontActive(final byte aColor) { - return this.getFront(aColor); - } - - public ITexture[] getBackActive(final byte aColor) { - return this.getBack(aColor); - } - - public ITexture[] getBottomActive(final byte aColor) { - return this.getBottom(aColor); - } - - public ITexture[] getTopActive(final byte aColor) { - return this.getTop(aColor); - } - - public ITexture[] getSidesActive(final byte aColor) { - return this.getSides(aColor); - } }
\ No newline at end of file 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 a6323726c3..f0123c2a08 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 @@ -1,37 +1,39 @@ package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi; import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.TAE; import gregtech.api.interfaces.ITexture; 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.*; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.minecraft.BlockPos; +import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.players.FakeFarmer; +import gtPlusPlus.core.slots.SlotBuzzSaw.SAWTOOL; import gtPlusPlus.xmod.gregtech.api.gui.CONTAINER_TreeFarmer; import gtPlusPlus.xmod.gregtech.api.gui.GUI_TreeFarmer; 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 net.minecraft.block.Block; import net.minecraft.entity.player.*; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase { public final static int TEX_INDEX = 31; - - /** - * Farm AI - */ - - private EntityPlayerMP farmerAI; + protected boolean mIsCurrentlyWorking = false; + + - public EntityPlayerMP getFakePlayer() { - return this.farmerAI; - } - public GregtechMetaTileEntityTreeFarm(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); @@ -41,6 +43,10 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase super(aName); } + public boolean isCurrentlyWorking() { + return this.mIsCurrentlyWorking; + } + @Override public String[] getDescription() { return new String[]{ @@ -66,9 +72,33 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase } @Override + public boolean drainEnergyInput(final long aEU) { + if (aEU <= 0L) { + return true; + } + + //Special Override, so that this function uses internally stored power first. + if (this.getEUVar() >= aEU) { + this.setEUVar(this.getEUVar()-aEU); + return true; + } + + for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { + if (isValidMetaTileEntity((MetaTileEntity) tHatch) + && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)) { + return true; + } + } + return false; + } + + @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)}; + } if (aSide == 1) { - return new ITexture[]{new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log), new GT_RenderedTexture(true ? TexturesGtBlock.Overlay_Machine_Vent_Fast : TexturesGtBlock.Overlay_Machine_Vent)}; + 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)}; } @@ -78,6 +108,18 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase 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; @@ -118,9 +160,18 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase return true; } - @Override - public boolean onRunningTick(final ItemStack aStack) { - return super.onRunningTick(aStack); + public Block getCasingBlock() { + return ModBlocks.blockCasings2Misc; + } + + + public byte getCasingMeta() { + return 15; + } + + + public byte getCasingTextureIndex() { + return (byte) TAE.GTPP_INDEX(31); } @Override @@ -130,34 +181,201 @@ public class GregtechMetaTileEntityTreeFarm extends GregtechMeta_MultiBlockBase @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + String[] mSuper = super.getInfoData(); + 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) { - //super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide()) { - //Set Forestry Fake player Sapling Planter - if (this.farmerAI == null) { - this.farmerAI = new FakeFarmer(MinecraftServer.getServer().worldServerForDimension(this.getBaseMetaTileEntity().getWorld().provider.dimensionId)); + //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; + } + + if (this.getBaseMetaTileEntity().isServerSide()) { + if (this.mEnergyHatches.size() > 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); + } + } + } } - + + + //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); + } + } + } - //Client Side - do nothing } @Override - public boolean checkRecipe(ItemStack p0) { + public boolean checkRecipe(ItemStack p0) { + mIsCurrentlyWorking = (isCorrectMachinePart(p0) && this.getEUVar() > 0); + if (isCurrentlyWorking()) { + return true; + } return false; } @Override - public boolean checkMachine(IGregTechTileEntity p0, ItemStack p1) { - return false; + 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 checkMachine(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()); + 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 + + 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."); + } + } + } + } + } + } + } + + //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; + } + + + @Override + public int getPollutionPerTick(ItemStack arg0) { + return 0; + } + + + @Override + public void onServerStart() { + super.onServerStart(); } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java index 76c6490480..4b93adad37 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialCuttingMachine.java @@ -137,7 +137,7 @@ extends GregtechMeta_MultiBlockBase { } } } - if ((this.mOutputHatches.size() != 0) || (this.mInputHatches.size() < 0)) { + if ((this.mOutputHatches.size() != 0) || (this.mInputHatches.size() != 0)) { Logger.INFO("Use Busses, Not Hatches for Input/Output."); return false; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java index 98dc3140bb..62279f0461 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_IndustrialFishingPond.java @@ -17,10 +17,10 @@ import gregtech.api.util.FishPondFakeRecipe; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.array.AutoMap; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java index a64057f3cc..f5cf674578 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java @@ -24,15 +24,15 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.api.util.Recipe_GT; -import gtPlusPlus.api.objects.GenericStack; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.api.objects.minecraft.GenericStack; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.AutoMap; -import gtPlusPlus.core.util.array.Pair; -import gtPlusPlus.core.util.array.Triplet; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.math.MathUtils; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java index 7176db5d97..db6b1d9e6a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MultiTank.java @@ -14,9 +14,9 @@ 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.data.Pair; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.fluid.FluidUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java index c57ad71fc7..b36ba2f69e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/GT_Material_Loader.java @@ -7,9 +7,9 @@ import java.util.Map; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.AutoMap; import gtPlusPlus.core.util.materials.MaterialUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java index 32fa282b0c..590296eee9 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_MaterialProcessing.java @@ -4,12 +4,12 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_Recipe; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.material.state.MaterialState; -import gtPlusPlus.core.util.array.AutoMap; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java index bdcb30f930..d7fb58366b 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Ore.java @@ -5,14 +5,14 @@ import gregtech.api.enums.GT_Values; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Recipe; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.MaterialStack; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.recipe.common.CI; -import gtPlusPlus.core.util.array.AutoMap; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.recipe.RecipeUtils; import net.minecraft.item.ItemStack; diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java index 98fb6050d4..00feb26ca5 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Recycling.java @@ -11,10 +11,11 @@ import gregtech.api.enums.GT_Values; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.*; import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.material.state.MaterialState; import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.array.Pair; import gtPlusPlus.core.util.item.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import net.minecraft.item.ItemStack; @@ -22,6 +23,16 @@ import net.minecraftforge.oredict.OreDictionary; public class RecipeGen_Recycling implements Runnable { + public static AutoMap<Runnable> mQueuedRecyclingGenerators = new AutoMap<Runnable>(); + + public static void executeGenerators() { + if (mQueuedRecyclingGenerators.size() > 0) { + for (Runnable R : mQueuedRecyclingGenerators.values()) { + R.run(); + } + } + } + final Material toGenerate; public static Map<String, ItemStack> mNameMap; @@ -30,14 +41,14 @@ public class RecipeGen_Recycling implements Runnable { if (mNameMap == null){ mNameMap = this.getNameMap(); } - if (mNameMap != null){ - generateRecipes(this.toGenerate); - } + mQueuedRecyclingGenerators.put(this); } @Override public void run() { - + if (mNameMap != null){ + generateRecipes(this.toGenerate); + } } public static void generateRecipes(final Material material) { |