aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus
diff options
context:
space:
mode:
authorJordan Byrne <draknyte1@hotmail.com>2018-02-19 17:06:10 +1000
committerJordan Byrne <draknyte1@hotmail.com>2018-02-19 17:06:10 +1000
commitb87b64a28c9e0b8520a1447c7f1996a6ff71acc2 (patch)
treefc2204b2a8b881a33b20d2311038d3d777bb8523 /src/Java/gtPlusPlus
parent941add7ddac9c6db5dce5d05507b5ed69893f9fc (diff)
downloadGT5-Unofficial-b87b64a28c9e0b8520a1447c7f1996a6ff71acc2.tar.gz
GT5-Unofficial-b87b64a28c9e0b8520a1447c7f1996a6ff71acc2.tar.bz2
GT5-Unofficial-b87b64a28c9e0b8520a1447c7f1996a6ff71acc2.zip
$ Tree farmer work.
+ Things.
Diffstat (limited to 'src/Java/gtPlusPlus')
-rw-r--r--src/Java/gtPlusPlus/api/interfaces/IGregtechPower.java149
-rw-r--r--src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java29
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/base/TileEntityBase.java6
-rw-r--r--src/Java/gtPlusPlus/core/tileentities/base/TilePoweredGT.java1171
-rw-r--r--src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java203
5 files changed, 1503 insertions, 55 deletions
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/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/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..72153964e9
--- /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.core.lib.CORE;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.array.AutoMap;
+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/xmod/gregtech/common/helpers/TreeFarmHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java
index 22fd7f9092..2166e80640 100644
--- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java
+++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/TreeFarmHelper.java
@@ -4,7 +4,11 @@ import static gtPlusPlus.core.lib.CORE.ConfigSwitches.enableTreeFarmerParticles;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import cpw.mods.fml.common.Optional;
@@ -403,8 +407,8 @@ public class TreeFarmHelper {
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))) {
+ if (h == 1) {
+ if (!isFenceBlock(aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j)) && 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);
}
@@ -419,28 +423,143 @@ public class TreeFarmHelper {
public static ItemStack[] findTreeFromBase(World world, BlockPos h) {
- Map<String, BlockPos> mResultsAroundBaseLayer = findTreeViaBranching(world, h);
- Map<String, Map<String, BlockPos>> mOtherResults = new ConcurrentHashMap<String, Map<String, BlockPos>>();
- String hash = Utils.calculateChecksumMD5(mResultsAroundBaseLayer);
- mOtherResults.put(hash, mResultsAroundBaseLayer);
- Logger.INFO("Initial Search found "+mResultsAroundBaseLayer.size()+" blocks to search around.");
- for (BlockPos j : mResultsAroundBaseLayer.values()) {
- Map<String, BlockPos> x = findTreeViaBranching(world, j);
- hash = Utils.calculateChecksumMD5(x);
- if (hash != null && !mOtherResults.containsKey(hash)) {
+
+ BlockPos mFirstSpot = h;
+ Set<BlockPos> mFirstSearch = new HashSet<BlockPos>();
+ Set<BlockPos> mSecondSearch = new HashSet<BlockPos>();
+ Set<BlockPos> mThirdSearch = new HashSet<BlockPos>();
+ Set<BlockPos> mAllSearched = new HashSet<BlockPos>();
+
+ Set<BlockPos> mTempSearch = new HashSet<BlockPos>();
+
+ mAllSearched.add(mFirstSpot);
+
+ mFirstSearch = findTreeViaBranching(world, h);
+
+ if (mFirstSearch.size() > 0) {
+ Iterator<BlockPos> j = mFirstSearch.iterator();
+ while (j.hasNext()){
+ BlockPos M = j.next();
+ if (!mAllSearched.contains(M)) {
+ mAllSearched.add(M);
+ mTempSearch = findTreeViaBranching(world, M);
+ if (mTempSearch.size() > 0) {
+ Iterator<BlockPos> D = mTempSearch.iterator();
+ while (D.hasNext()){
+ BlockPos F = D.next();
+ if (!mAllSearched.contains(F))
+ mAllSearched.add(F);
+ }
+ }
+ if (!mSecondSearch.contains(M)) {
+ mSecondSearch.add(M);
+ }
+ }
+ }
+ }
+
+
+ /*if (mFirstSearch.size() > 0) {
+ Iterator<BlockPos> j = mFirstSearch.iterator();
+ while (j.hasNext()){
+ BlockPos M = j.next();
+ if (!mAllSearched.contains(M))
+ mAllSearched.add(M);
+ if (!mSecondSearch.contains(M))
+ mSecondSearch.add(M);
+ }
+ }*/
+ /*if (mSecondSearch.size() > 0) {
+ Iterator<BlockPos> j = mSecondSearch.iterator();
+ while (j.hasNext()){
+ BlockPos M = j.next();
+ if (!mAllSearched.contains(M))
+ mAllSearched.add(M);
+ if (!mThirdSearch.contains(M))
+ mThirdSearch.add(M);
+ }
+ }*/
+
+ if (mSecondSearch.size() > 0) {
+ Iterator<BlockPos> j = mSecondSearch.iterator();
+ while (j.hasNext()){
+ BlockPos M = j.next();
+ if (!mAllSearched.contains(M)) {
+ mAllSearched.add(M);
+ mTempSearch = findTreeViaBranching(world, M);
+ if (mTempSearch.size() > 0) {
+ Iterator<BlockPos> D = mTempSearch.iterator();
+ while (D.hasNext()){
+ BlockPos F = D.next();
+ if (!mAllSearched.contains(F))
+ mAllSearched.add(F);
+ }
+ }
+ if (!mThirdSearch.contains(M)) {
+ mThirdSearch.add(M);
+ }
+ }
+ }
+ }
+
+
+ if (mThirdSearch.size() > 0) {
+ Iterator<BlockPos> j = mThirdSearch.iterator();
+ while (j.hasNext()){
+ BlockPos M = j.next();
+ if (!mAllSearched.contains(M)) {
+ mAllSearched.add(M);
+ mTempSearch = findTreeViaBranching(world, M);
+ if (mTempSearch.size() > 0) {
+ Iterator<BlockPos> D = mTempSearch.iterator();
+ while (D.hasNext()){
+ BlockPos F = D.next();
+ if (!mAllSearched.contains(F))
+ mAllSearched.add(F);
+ }
+ }
+ }
+ }
+ }
+
+
+ /*Set<BlockPos> mBaseLayer = new HashSet<BlockPos>();
+ Set<Set<BlockPos>> mAllLayers = new HashSet<Set<BlockPos>>();
+ Set<BlockPos> mFinalSet = new HashSet<BlockPos>();
+
+ mBaseLayer = findTreeViaBranching(world, h);
+ mAllLayers.add(mBaseLayer);
+ Logger.INFO("Initial Search found "+mBaseLayer.size()+" blocks to search around.");
+ for (Iterator<BlockPos> flavoursIter = mBaseLayer.iterator(); flavoursIter.hasNext();){
+ Set<BlockPos> x = findTreeViaBranching(world, flavoursIter.next());
+ if (!mAllLayers.contains(x)) {
Logger.INFO("Branching.");
- mOtherResults.put(hash, x);
+ mAllLayers.add(x);
}
- }
-
- if (mOtherResults.size() > 0) {
- Logger.INFO("Queuing "+mOtherResults.size()+" to Harvest Manager.");
- TreeCutter harvestManager = new TreeCutter(world);
- for (Map<String, BlockPos> a : mOtherResults.values()) {
- for (BlockPos p : a.values()) {
- harvestManager.queue(p);
+ }*/
+
+
+ /*if (mAllLayers.size() > 0) {
+ for (Iterator<Set<BlockPos>> flavoursIter = mAllLayers.iterator(); flavoursIter.hasNext();){
+ for (Iterator<BlockPos> flavoursIter2 = flavoursIter.next().iterator(); flavoursIter2.hasNext();){
+ Set<BlockPos> x = findTreeViaBranching(world, flavoursIter2.next());
+ for (Iterator<BlockPos> flavoursIter3 = x.iterator(); flavoursIter3.hasNext();){
+ if (!mFinalSet.contains(flavoursIter3.next())) {
+ Logger.INFO("Branching II.");
+ mFinalSet.add(flavoursIter3.next());
+ }
+ }
}
}
+ }*/
+
+
+ if (mAllSearched.size() > 0) {
+ Logger.INFO("Queuing "+mAllSearched.size()+" to Harvest Manager.");
+ TreeCutter harvestManager = new TreeCutter(world);
+ for (Iterator<BlockPos> flavoursIter = mAllSearched.iterator(); flavoursIter.hasNext();){
+ harvestManager.queue(flavoursIter.next());
+ }
if (harvestManager.isValid) {
ItemStack[] loot = harvestManager.getDrops();
if (loot.length > 0) {
@@ -452,49 +571,45 @@ public class TreeFarmHelper {
return new ItemStack[] {};
}
- public static Map<String, BlockPos> findTreeViaBranching(World world, BlockPos h) {
- Map<String, BlockPos> results = new ConcurrentHashMap<String, BlockPos>();
- final Block block = world.getBlock(h.xPos, h.yPos, h.zPos);
+ public static Set<BlockPos> findTreeViaBranching(World world, BlockPos h) {
+
+ Set<BlockPos> results = new HashSet<BlockPos>();
+
+ //Map<String, BlockPos> results = new ConcurrentHashMap<String, BlockPos>();
+ final Block block = world.getBlock(h.xPos, h.yPos, h.zPos);
+
Logger.INFO("--------------------------" + "Searching around "+h.getLocationString() + "--------------------------");
int xRel = h.xPos, yRel = h.yPos, zRel = h.zPos;
//if (TreeFarmHelper.isWoodLog(block)) {
- for (int a=-2;a<3;a++) {
- for (int b=-2;b<3;b++) {
- for (int c=-2;c<3;c++) {
+ for (int a=-4;a<5;a++) {
+ for (int b=-4;b<5;b++) {
+ for (int c=-4;c<5;c++) {
//Check block
Logger.INFO("Looking at X: "+(xRel+a)+" | Y: "+(yRel+b)+" | Z: "+(zRel+c));
Block log = world.getBlock(xRel+a, yRel+b, zRel+c);
BlockPos P = new BlockPos(xRel+a, yRel+b, zRel+c);
- String hash = Utils.calculateChecksumMD5(P);
- if (TreeFarmHelper.isWoodLog(log) || TreeFarmHelper.isLeaves(log)) {
+ if ((!isFenceBlock(log)) && (isWoodLog(log) || isLeaves(log))) {
Logger.INFO("Was Logs/leaves. "+P.getLocationString());
- if (hash != null && !results.containsKey(hash)) {
+ if (!results.contains(P)) {
Logger.INFO("Caching result.");
- results.put(hash, P);
+ results.add(P);
}
else {
- if (hash == null) {
- Logger.INFO("Hash was invalid.");
-
- }
- if (results == null) {
- Logger.INFO("Results were invalid.");
- }
- if (results.containsKey(hash)) {
- Logger.INFO("Results were already cached. HASH: "+hash);
+ if (P != null && results.contains(P)) {
+ Logger.INFO("Results were already cached.");
}
}
}
}
}
}
-
+
Logger.INFO("----------------------------------------------------------");
-
+
//}
if (results.isEmpty()) {
- //Logger.INFO("Returning Empty Branch Iteration.");
- return new HashMap<String, BlockPos>();
+ Logger.INFO("Returning Empty Branch Iteration.");
+ return new HashSet<BlockPos>();
}
else {
Logger.INFO("Returning Valid Branch Iteration. "+results.size());
@@ -521,7 +636,7 @@ public class TreeFarmHelper {
public boolean queue(BlockPos pos) {
if (isValid && pos != null) {
- Logger.INFO("Queued: "+pos.getLocationString());
+ //Logger.INFO("Queued: "+pos.getLocationString());
String hash = Utils.calculateChecksumMD5(pos);
if (hash != null && !mQueue.containsKey(hash)) {
mQueue.put(hash, pos);