aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
diff options
context:
space:
mode:
authorRaven Szewczyk <git@eigenraven.me>2022-08-27 10:19:57 +0100
committerGitHub <noreply@github.com>2022-08-27 11:19:57 +0200
commit6f31720697bcc351421a4d86ba3bf749375dd12c (patch)
tree3adf8f318f22c892d74cd7c9d30b6dd3f11f11bd /src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
parentc3eac50decd33ee2be8703dfb2ecf9cdc31c2b67 (diff)
downloadGT5-Unofficial-6f31720697bcc351421a4d86ba3bf749375dd12c.tar.gz
GT5-Unofficial-6f31720697bcc351421a4d86ba3bf749375dd12c.tar.bz2
GT5-Unofficial-6f31720697bcc351421a4d86ba3bf749375dd12c.zip
Update buildscript & apply spotless (#1306)
* Update dependencies * Update buildscript, apply spotless
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java')
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java879
1 files changed, 608 insertions, 271 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
index b68715770c..911c1cabcb 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java
@@ -1,5 +1,10 @@
package gregtech.api.metatileentity;
+import static gregtech.GT_Mod.GT_FML_LOGGER;
+import static gregtech.api.enums.GT_Values.NW;
+import static gregtech.api.enums.GT_Values.V;
+import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
+
import appeng.api.networking.IGridNode;
import appeng.api.networking.security.IActionHost;
import appeng.api.util.AECableType;
@@ -9,11 +14,9 @@ import appeng.me.helpers.IGridProxyable;
import appeng.tile.TileEvent;
import appeng.tile.events.TileEventType;
import com.gtnewhorizon.structurelib.alignment.IAlignment;
-import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits;
import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider;
import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable;
import com.gtnewhorizon.structurelib.alignment.constructable.IConstructableProvider;
-import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.ReflectionHelper;
import gregtech.GT_Mod;
@@ -38,6 +41,9 @@ import gregtech.api.objects.GT_ItemStack;
import gregtech.api.util.*;
import gregtech.common.GT_Pollution;
import ic2.api.Direction;
+import java.lang.reflect.Field;
+import java.util.*;
+import javax.annotation.Nullable;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import net.minecraft.block.Block;
@@ -61,27 +67,34 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
-import javax.annotation.Nullable;
-import java.lang.reflect.Field;
-import java.util.*;
-
-import static gregtech.GT_Mod.GT_FML_LOGGER;
-import static gregtech.api.enums.GT_Values.NW;
-import static gregtech.api.enums.GT_Values.V;
-import static gregtech.api.objects.XSTR.XSTR_INSTANCE;
-
/**
* NEVER INCLUDE THIS FILE IN YOUR MOD!!!
* <p/>
* This is the main TileEntity for EVERYTHING.
*/
-@Optional.InterfaceList(value = {
- @Optional.Interface(iface = "appeng.api.networking.security.IActionHost", modid = "appliedenergistics2", striprefs = true),
- @Optional.Interface(iface = "appeng.me.helpers.IGridProxyable", modid = "appliedenergistics2", striprefs = true)})
-public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTechTileEntity, IActionHost, IGridProxyable, IAlignmentProvider, IConstructableProvider, IDebugableTileEntity, IGregtechWailaProvider {
- private static final Field ENTITY_ITEM_HEALTH_FIELD = ReflectionHelper.findField(EntityItem.class, "health", "field_70291_e");
- private final boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false};
- private final boolean[] mActiveEUOutputs = new boolean[]{false, false, false, false, false, false};
+@Optional.InterfaceList(
+ value = {
+ @Optional.Interface(
+ iface = "appeng.api.networking.security.IActionHost",
+ modid = "appliedenergistics2",
+ striprefs = true),
+ @Optional.Interface(
+ iface = "appeng.me.helpers.IGridProxyable",
+ modid = "appliedenergistics2",
+ striprefs = true)
+ })
+public class BaseMetaTileEntity extends CommonMetaTileEntity
+ implements IGregTechTileEntity,
+ IActionHost,
+ IGridProxyable,
+ IAlignmentProvider,
+ IConstructableProvider,
+ IDebugableTileEntity,
+ IGregtechWailaProvider {
+ private static final Field ENTITY_ITEM_HEALTH_FIELD =
+ ReflectionHelper.findField(EntityItem.class, "health", "field_70291_e");
+ private final boolean[] mActiveEUInputs = new boolean[] {false, false, false, false, false, false};
+ private final boolean[] mActiveEUOutputs = new boolean[] {false, false, false, false, false, false};
private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING];
public long mLastSoundTick = 0;
public boolean mWasShutdown = false;
@@ -89,12 +102,29 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
protected long mStoredEnergy = 0, mStoredSteam = 0;
protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0;
protected boolean mReleaseEnergy = false;
- protected long[] mAverageEUInput = new long[]{0, 0, 0, 0, 0}, mAverageEUOutput = new long[]{0, 0, 0, 0, 0};
- private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false;
+ protected long[] mAverageEUInput = new long[] {0, 0, 0, 0, 0}, mAverageEUOutput = new long[] {0, 0, 0, 0, 0};
+ private boolean mHasEnoughEnergy = true,
+ mRunningThroughTick = false,
+ mInputDisabled = false,
+ mOutputDisabled = false,
+ mMuffler = false,
+ mLockUpgrade = false;
private boolean mActive = false, mWorkUpdate = false, mSteamConverter = false, mWorks = true;
private boolean oRedstone = false;
- private byte mColor = 0, oColor = 0, oStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, oTexturePage = 0;
- private byte oLightValueClient = -1, oLightValue = -1, mLightValue = 0, mOtherUpgrades = 0, mFacing = 0, oFacing = 0, mWorkData = 0;
+ private byte mColor = 0,
+ oColor = 0,
+ oStrongRedstone = 0,
+ oRedstoneData = 63,
+ oTextureData = 0,
+ oUpdateData = 0,
+ oTexturePage = 0;
+ private byte oLightValueClient = -1,
+ oLightValue = -1,
+ mLightValue = 0,
+ mOtherUpgrades = 0,
+ mFacing = 0,
+ oFacing = 0,
+ mWorkData = 0;
private int mDisplayErrorCode = 0, oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0, mLagWarningCount = 0;
private long oOutput = 0, mAcceptedAmperes = Long.MAX_VALUE;
private long mLastCheckTick = 0;
@@ -103,8 +133,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
private NBTTagCompound mRecipeStuff = new NBTTagCompound();
private int cableUpdateDelay = 30;
- public BaseMetaTileEntity() {
- }
+ public BaseMetaTileEntity() {}
@Override
public void writeToNBT(NBTTagCompound aNBT) {
@@ -152,7 +181,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
if (aID > 0) mID = aID;
else mID = mID > 0 ? mID : 0;
if (mID != 0) createNewMetatileEntity(mID);
- mSidedRedstone = (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior() ? new byte[]{0, 0, 0, 0, 0, 0} : new byte[]{15, 15, 15, 15, 15, 15});
+ mSidedRedstone = (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior()
+ ? new byte[] {0, 0, 0, 0, 0, 0}
+ : new byte[] {15, 15, 15, 15, 15, 15});
} else {
if (aID <= 0) mID = (short) aNBT.getInteger("mID");
else mID = aID;
@@ -175,7 +206,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
mWorks = !aNBT.getBoolean("mWorks");
mInputDisabled = aNBT.getBoolean("mInputDisabled");
mOutputDisabled = aNBT.getBoolean("mOutputDisabled");
- mOtherUpgrades = (byte) (aNBT.getByte("mOtherUpgrades") + aNBT.getByte("mBatteries") + aNBT.getByte("mLiBatteries"));
+ mOtherUpgrades =
+ (byte) (aNBT.getByte("mOtherUpgrades") + aNBT.getByte("mBatteries") + aNBT.getByte("mLiBatteries"));
mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents");
final int nbtVersion = aNBT.getInteger("nbtVersion");
@@ -184,11 +216,11 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
}
if (mCoverData == null || mCoverData.length != 6) mCoverData = new ISerializableObject[6];
- if (mCoverSides.length != 6) mCoverSides = new int[]{0, 0, 0, 0, 0, 0};
+ if (mCoverSides.length != 6) mCoverSides = new int[] {0, 0, 0, 0, 0, 0};
if (mSidedRedstone.length != 6)
if (hasValidMetaTileEntity() && mMetaTileEntity.hasSidedRedstoneOutputBehavior())
- mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0};
- else mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15};
+ mSidedRedstone = new byte[] {0, 0, 0, 0, 0, 0};
+ else mSidedRedstone = new byte[] {15, 15, 15, 15, 15, 15};
updateCoverBehavior();
}
@@ -205,14 +237,29 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
* Called when trying to charge Items
*/
public void chargeItem(ItemStack aStack) {
- decreaseStoredEU(GT_ModHandler.chargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getOutputTier()), false, false), true);
+ decreaseStoredEU(
+ GT_ModHandler.chargeElectricItem(
+ aStack,
+ (int) Math.min(Integer.MAX_VALUE, getStoredEU()),
+ (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getOutputTier()),
+ false,
+ false),
+ true);
}
/**
* Called when trying to discharge Items
*/
public void dischargeItem(ItemStack aStack) {
- increaseStoredEnergyUnits(GT_ModHandler.dischargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, getEUCapacity() - getStoredEU()), (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()), false, false, false), true);
+ increaseStoredEnergyUnits(
+ GT_ModHandler.dischargeElectricItem(
+ aStack,
+ (int) Math.min(Integer.MAX_VALUE, getEUCapacity() - getStoredEU()),
+ (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getInputTier()),
+ false,
+ false,
+ false),
+ true);
}
protected boolean isRainPossible() {
@@ -274,7 +321,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
if (mNeedsUpdate) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
- //worldObj.func_147479_m(xCoord, yCoord, zCoord);
+ // worldObj.func_147479_m(xCoord, yCoord, zCoord);
mNeedsUpdate = false;
}
}
@@ -340,12 +387,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
}
}
-
if (mMetaTileEntity.isEnetOutput() && oOutput > 0) {
- final long tOutputVoltage = Math.max(oOutput, oOutput + (1L << Math.max(0, GT_Utility.getTier(oOutput) - 1)));
- final long tUsableAmperage = Math.min(getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage);
+ final long tOutputVoltage =
+ Math.max(oOutput, oOutput + (1L << Math.max(0, GT_Utility.getTier(oOutput) - 1)));
+ final long tUsableAmperage = Math.min(
+ getOutputAmperage(),
+ (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage);
if (tUsableAmperage > 0) {
- final long tEU = tOutputVoltage * Util.emitEnergyToNetwork(oOutput, tUsableAmperage, this);
+ final long tEU =
+ tOutputVoltage * Util.emitEnergyToNetwork(oOutput, tUsableAmperage, this);
mAverageEUOutput[mAverageEUOutputIndex] += tEU;
decreaseStoredEU(tEU, true);
}
@@ -362,26 +412,46 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
}
if (getRandomNumber(1000) == 0 && isRainPossible()) {
- final int precipitationHeightAtSide2 = worldObj.getPrecipitationHeight(xCoord, zCoord - 1);
- final int precipitationHeightAtSide3 = worldObj.getPrecipitationHeight(xCoord, zCoord + 1);
- final int precipitationHeightAtSide4 = worldObj.getPrecipitationHeight(xCoord - 1, zCoord);
- final int precipitationHeightAtSide5 = worldObj.getPrecipitationHeight(xCoord + 1, zCoord);
-
- if ((getCoverIDAtSide((byte) 1) == 0 && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord)
- || (getCoverIDAtSide((byte) 2) == 0 && precipitationHeightAtSide2 - 1 < yCoord && precipitationHeightAtSide2 > -1)
- || (getCoverIDAtSide((byte) 3) == 0 && precipitationHeightAtSide3 - 1 < yCoord && precipitationHeightAtSide3 > -1)
- || (getCoverIDAtSide((byte) 4) == 0 && precipitationHeightAtSide4 - 1 < yCoord && precipitationHeightAtSide4 > -1)
- || (getCoverIDAtSide((byte) 5) == 0 && precipitationHeightAtSide5 - 1 < yCoord && precipitationHeightAtSide5 > -1)) {
+ final int precipitationHeightAtSide2 =
+ worldObj.getPrecipitationHeight(xCoord, zCoord - 1);
+ final int precipitationHeightAtSide3 =
+ worldObj.getPrecipitationHeight(xCoord, zCoord + 1);
+ final int precipitationHeightAtSide4 =
+ worldObj.getPrecipitationHeight(xCoord - 1, zCoord);
+ final int precipitationHeightAtSide5 =
+ worldObj.getPrecipitationHeight(xCoord + 1, zCoord);
+
+ if ((getCoverIDAtSide((byte) 1) == 0
+ && worldObj.getPrecipitationHeight(xCoord, zCoord) - 2 < yCoord)
+ || (getCoverIDAtSide((byte) 2) == 0
+ && precipitationHeightAtSide2 - 1 < yCoord
+ && precipitationHeightAtSide2 > -1)
+ || (getCoverIDAtSide((byte) 3) == 0
+ && precipitationHeightAtSide3 - 1 < yCoord
+ && precipitationHeightAtSide3 > -1)
+ || (getCoverIDAtSide((byte) 4) == 0
+ && precipitationHeightAtSide4 - 1 < yCoord
+ && precipitationHeightAtSide4 > -1)
+ || (getCoverIDAtSide((byte) 5) == 0
+ && precipitationHeightAtSide5 - 1 < yCoord
+ && precipitationHeightAtSide5 > -1)) {
if (GregTech_API.sMachineRainExplosions && worldObj.isRaining()) {
if (getRandomNumber(10) == 0) {
try {
- GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");
+ GT_Mod.achievements.issueAchievement(
+ this.getWorldObj().getPlayerEntityByName(mOwnerName),
+ "badweather");
} catch (Exception ignored) {
}
- GT_Log.exp.println("Machine at: " + this.getXCoord() + " | " + this.getYCoord() + " | " + this.getZCoord() + " DIMID: " + this.worldObj.provider.dimensionId + " explosion due to rain!");
+ GT_Log.exp.println("Machine at: " + this.getXCoord() + " | "
+ + this.getYCoord() + " | " + this.getZCoord() + " DIMID: "
+ + this.worldObj.provider.dimensionId + " explosion due to rain!");
doEnergyExplosion();
} else {
- GT_Log.exp.println("Machine at: " + this.getXCoord() + " | " + this.getYCoord() + " | " + this.getZCoord() + " DIMID: " + this.worldObj.provider.dimensionId + " set to Fire due to rain!");
+ GT_Log.exp.println("Machine at: " + this.getXCoord() + " | "
+ + this.getYCoord() + " | " + this.getZCoord() + " DIMID: "
+ + this.worldObj.provider.dimensionId
+ + " set to Fire due to rain!");
setOnFire();
}
}
@@ -389,12 +459,18 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
mRunningThroughTick = false;
return;
}
- if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getRandomNumber(3) == 0) {
+ if (GregTech_API.sMachineThunderExplosions
+ && worldObj.isThundering()
+ && getRandomNumber(3) == 0) {
try {
- GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");
+ GT_Mod.achievements.issueAchievement(
+ this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");
} catch (Exception ignored) {
}
- GT_Log.exp.println("Machine at: " + this.getXCoord() + " | " + this.getYCoord() + " | " + this.getZCoord() + " DIMID: " + this.worldObj.provider.dimensionId + " explosion due to Thunderstorm!");
+ GT_Log.exp.println("Machine at: " + this.getXCoord() + " | " + this.getYCoord()
+ + " | " + this.getZCoord() + " DIMID: "
+ + this.worldObj.provider.dimensionId
+ + " explosion due to Thunderstorm!");
doEnergyExplosion();
}
}
@@ -409,12 +485,21 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
}
if (aSideServer) {
if (mMetaTileEntity.dechargerSlotCount() > 0 && getStoredEU() < getEUCapacity()) {
- for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) {
+ for (int i = mMetaTileEntity.dechargerSlotStartIndex(),
+ k = mMetaTileEntity.dechargerSlotCount() + i;
+ i < k;
+ i++) {
if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) {
dischargeItem(mMetaTileEntity.mInventory[i]);
if (ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i]) > 0) {
- if ((getStoredEU() + ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i])) < getEUCapacity()) {
- increaseStoredEnergyUnits((long) ic2.api.info.Info.itemEnergy.getEnergyValue(mMetaTileEntity.mInventory[i]), false);
+ if ((getStoredEU()
+ + ic2.api.info.Info.itemEnergy.getEnergyValue(
+ mMetaTileEntity.mInventory[i]))
+ < getEUCapacity()) {
+ increaseStoredEnergyUnits(
+ (long) ic2.api.info.Info.itemEnergy.getEnergyValue(
+ mMetaTileEntity.mInventory[i]),
+ false);
mMetaTileEntity.mInventory[i].stackSize--;
mInventoryChanged = true;
}
@@ -429,7 +514,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
}
if (aSideServer) {
if (mMetaTileEntity.rechargerSlotCount() > 0 && getStoredEU() > 0) {
- for (int i = mMetaTileEntity.rechargerSlotStartIndex(), k = mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) {
+ for (int i = mMetaTileEntity.rechargerSlotStartIndex(),
+ k = mMetaTileEntity.rechargerSlotCount() + i;
+ i < k;
+ i++) {
if (getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) {
chargeItem(mMetaTileEntity.mInventory[i]);
if (mMetaTileEntity.mInventory[i].stackSize <= 0) {
@@ -460,7 +548,11 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
}
if (mTickTimer > 10) {
- byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0) | (mWorks ? 64 : 0));
+ byte tData = (byte) ((mFacing & 7)
+ | (mActive ? 8 : 0)
+ | (mRedstone ? 16 : 0)
+ | (mLockUpgrade ? 32 : 0)
+ | (mWorks ? 64 : 0));
if (tData != oTextureData)
sendBlockEvent(GregTechTileClientEvents.CHANGE_COMMON_DATA, oTextureData = tData);
@@ -470,10 +562,16 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
if (mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) {
tData = ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage();
if (tData != oTexturePage)
- sendBlockEvent(GregTechTileClientEvents.CHANGE_CUSTOM_DATA, (byte) ((oTexturePage = tData) | 0x80));//set last bit as a flag for page
+ sendBlockEvent(GregTechTileClientEvents.CHANGE_CUSTOM_DATA, (byte)
+ ((oTexturePage = tData) | 0x80)); // set last bit as a flag for page
}
if (mColor != oColor) sendBlockEvent(GregTechTileClientEvents.CHANGE_COLOR, oColor = mColor);
- tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0));
+ tData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0)
+ | ((mSidedRedstone[1] > 0) ? 2 : 0)
+ | ((mSidedRedstone[2] > 0) ? 4 : 0)
+ | ((mSidedRedstone[3] > 0) ? 8 : 0)
+ | ((mSidedRedstone[4] > 0) ? 16 : 0)
+ | ((mSidedRedstone[5] > 0) ? 32 : 0));
if (tData != oRedstoneData)
sendBlockEvent(GregTechTileClientEvents.CHANGE_REDSTONE_OUTPUT, oRedstoneData = tData);
if (mLightValue != oLightValue) {
@@ -505,16 +603,24 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
if (aSideServer && hasValidMetaTileEntity()) {
tTime = System.nanoTime() - tTime;
if (mTimeStatistics.length > 0)
- mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = (int) tTime;
- if (tTime > 0 && tTime > (GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING * 1000000L) && mTickTimer > 1000 && getMetaTileEntity().doTickProfilingMessageDuringThisTick() && mLagWarningCount++ < 10)
- GT_FML_LOGGER.warn("WARNING: Possible Lag Source at [" + xCoord + ", " + yCoord + ", " + zCoord + "] in Dimension " + worldObj.provider.dimensionId + " with " + tTime + "ns caused by an instance of " + getMetaTileEntity().getClass());
+ mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] =
+ (int) tTime;
+ if (tTime > 0
+ && tTime > (GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING * 1000000L)
+ && mTickTimer > 1000
+ && getMetaTileEntity().doTickProfilingMessageDuringThisTick()
+ && mLagWarningCount++ < 10)
+ GT_FML_LOGGER.warn("WARNING: Possible Lag Source at [" + xCoord + ", " + yCoord + ", " + zCoord
+ + "] in Dimension " + worldObj.provider.dimensionId + " with " + tTime
+ + "ns caused by an instance of " + getMetaTileEntity().getClass());
}
mWorkUpdate = mInventoryChanged = mRunningThroughTick = false;
}
@Override
- public void getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
+ public void getWailaBody(
+ ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
if (hasValidMetaTileEntity() && getMetaTileEntity() != null) {
getMetaTileEntity().getWailaBody(itemStack, currenttip, accessor, config);
}
@@ -522,7 +628,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
}
@Override
- public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, int z) {
+ public void getWailaNBTData(
+ EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, int z) {
super.getWailaNBTData(player, tile, tag, world, x, y, z);
if (hasValidMetaTileEntity() && getMetaTileEntity() != null) {
getMetaTileEntity().getWailaNBTData(player, tile, tag, world, x, y, z);
@@ -532,22 +639,55 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
private void sendClientData() {
if (mSendClientData) {
NW.sendPacketToAllPlayersInRange(
- worldObj,
- new GT_Packet_TileEntity(
- xCoord, (short) yCoord, zCoord, mID, mCoverSides[0], mCoverSides[1], mCoverSides[2], mCoverSides[3], mCoverSides[4], mCoverSides[5],
- oTextureData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0) | (mWorks ? 64 : 0)),
- oTexturePage = (hasValidMetaTileEntity() && mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) ? ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage() : 0,
- oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0,
- oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0) | ((mSidedRedstone[1] > 0) ? 2 : 0) | ((mSidedRedstone[2] > 0) ? 4 : 0) | ((mSidedRedstone[3] > 0) ? 8 : 0) | ((mSidedRedstone[4] > 0) ? 16 : 0) | ((mSidedRedstone[5] > 0) ? 32 : 0)),
- oColor = mColor),
- xCoord, zCoord
- );
+ worldObj,
+ new GT_Packet_TileEntity(
+ xCoord,
+ (short) yCoord,
+ zCoord,
+ mID,
+ mCoverSides[0],
+ mCoverSides[1],
+ mCoverSides[2],
+ mCoverSides[3],
+ mCoverSides[4],
+ mCoverSides[5],
+ oTextureData = (byte) ((mFacing & 7)
+ | (mActive ? 8 : 0)
+ | (mRedstone ? 16 : 0)
+ | (mLockUpgrade ? 32 : 0)
+ | (mWorks ? 64 : 0)),
+ oTexturePage =
+ (hasValidMetaTileEntity() && mMetaTileEntity instanceof GT_MetaTileEntity_Hatch)
+ ? ((GT_MetaTileEntity_Hatch) mMetaTileEntity).getTexturePage()
+ : 0,
+ oUpdateData = hasValidMetaTileEntity() ? mMetaTileEntity.getUpdateData() : 0,
+ oRedstoneData = (byte) (((mSidedRedstone[0] > 0) ? 1 : 0)
+ | ((mSidedRedstone[1] > 0) ? 2 : 0)
+ | ((mSidedRedstone[2] > 0) ? 4 : 0)
+ | ((mSidedRedstone[3] > 0) ? 8 : 0)
+ | ((mSidedRedstone[4] > 0) ? 16 : 0)
+ | ((mSidedRedstone[5] > 0) ? 32 : 0)),
+ oColor = mColor),
+ xCoord,
+ zCoord);
mSendClientData = false;
}
sendCoverDataIfNeeded();
}
- public final void receiveMetaTileEntityData(short aID, int aCover0, int aCover1, int aCover2, int aCover3, int aCover4, int aCover5, byte aTextureData, byte aTexturePage, byte aUpdateData, byte aRedstoneData, byte aColorData) {
+ public final void receiveMetaTileEntityData(
+ short aID,
+ int aCover0,
+ int aCover1,
+ int aCover2,
+ int aCover3,
+ int aCover4,
+ int aCover5,
+ byte aTextureData,
+ byte aTexturePage,
+ byte aUpdateData,
+ byte aRedstoneData,
+ byte aColorData) {
issueTextureUpdate();
if (mID != aID && aID > 0) {
mID = aID;
@@ -569,11 +709,33 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
}
@Deprecated
- public final void receiveMetaTileEntityData(short aID, int aCover0, int aCover1, int aCover2, int aCover3, int aCover4, int aCover5, byte aTextureData, byte aUpdateData, byte aRedstoneData, byte aColorData) {
- receiveMetaTileEntityData(aID, aCover0, aCover1, aCover2, aCover3, aCover4, aCover5, aTextureData, (byte) 0, aUpdateData, aRedstoneData, aColorData);
+ public final void receiveMetaTileEntityData(
+ short aID,
+ int aCover0,
+ int aCover1,
+ int aCover2,
+ int aCover3,
+ int aCover4,
+ int aCover5,
+ byte aTextureData,
+ byte aUpdateData,
+ byte aRedstoneData,
+ byte aColorData) {
+ receiveMetaTileEntityData(
+ aID,
+ aCover0,
+ aCover1,
+ aCover2,
+ aCover3,
+ aCover4,
+ aCover5,
+ aTextureData,
+ (byte) 0,
+ aUpdateData,
+ aRedstoneData,
+ aColorData);
}
-
@Override
public boolean receiveClientEvent(int aEventID, int aValue) {
super.receiveClientEvent(aEventID, aValue);
@@ -582,7 +744,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
try {
mMetaTileEntity.receiveClientEvent((byte) aEventID, (byte) aValue);
} catch (Throwable e) {
- GT_Log.err.println("Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!");
+ GT_Log.err.println(
+ "Encountered Exception while receiving Data from the Server, the Client should've been crashed by now, but I prevented that. Please report immediately to GregTech Intergalactical!!!");
e.printStackTrace(GT_Log.err);
}
}
@@ -594,15 +757,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
mFacing = (byte) (aValue & 7);
mActive = ((aValue & 8) != 0);
mRedstone = ((aValue & 16) != 0);
- //mLockUpgrade = ((aValue&32) != 0);
+ // mLockUpgrade = ((aValue&32) != 0);
mWorks = ((aValue & 64) != 0);
break;
case GregTechTileClientEvents.CHANGE_CUSTOM_DATA:
if (hasValidMetaTileEntity()) {
- if ((aValue & 0x80) == 0) //Is texture index
- mMetaTileEntity.onValueUpdate((byte) (aValue & 0x7F));
- else if (mMetaTileEntity instanceof GT_MetaTileEntity_Hatch)//is texture page and hatch
- ((GT_MetaTileEntity_Hatch) mMetaTileEntity).onTexturePageUpdate((byte) (aValue & 0x7F));
+ if ((aValue & 0x80) == 0) // Is texture index
+ mMetaTileEntity.onValueUpdate((byte) (aValue & 0x7F));
+ else if (mMetaTileEntity instanceof GT_MetaTileEntity_Hatch) // is texture page and hatch
+ ((GT_MetaTileEntity_Hatch) mMetaTileEntity).onTexturePageUpdate((byte) (aValue & 0x7F));
}
break;
case GregTechTileClientEvents.CHANGE_COLOR:
@@ -641,7 +804,13 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aLogLevel) {
final ArrayList<String> tList = new ArrayList<>();
if (aLogLevel > 2) {
- tList.add("Meta-ID: " + EnumChatFormatting.BLUE + mID + EnumChatFormatting.RESET + (canAccessData() ? EnumChatFormatting.GREEN + " valid" + EnumChatFormatting.RESET : EnumChatFormatting.RED + " invalid" + EnumChatFormatting.RESET) + (mMetaTileEntity == null ? EnumChatFormatting.RED + " MetaTileEntity == null!" + EnumChatFormatting.RESET : " "));
+ tList.add("Meta-ID: " + EnumChatFormatting.BLUE + mID + EnumChatFormatting.RESET
+ + (canAccessData()
+ ? EnumChatFormatting.GREEN + " valid" + EnumChatFormatting.RESET
+ : EnumChatFormatting.RED + " invalid" + EnumChatFormatting.RESET)
+ + (mMetaTileEntity == null
+ ? EnumChatFormatting.RED + " MetaTileEntity == null!" + EnumChatFormatting.RESET
+ : " "));
}
if (aLogLevel > 1) {
if (mTimeStatistics.length > 0) {
@@ -653,27 +822,40 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
tWorstTime = tTime;
}
// Uncomment this line to print out tick-by-tick times.
- //tList.add("tTime " + tTime);
+ // tList.add("tTime " + tTime);
}
- tList.add("Average CPU load of ~" + GT_Utility.formatNumbers(tAverageTime / mTimeStatistics.length) + "ns over " + GT_Utility.formatNumbers(mTimeStatistics.length) + " ticks with worst time of " + GT_Utility.formatNumbers(tWorstTime) + "ns.");
- tList.add("Recorded " + GT_Utility.formatNumbers(mMetaTileEntity.mSoundRequests) + " sound requests in " + GT_Utility.formatNumbers(mTickTimer - mLastCheckTick) + " ticks.");
+ tList.add("Average CPU load of ~" + GT_Utility.formatNumbers(tAverageTime / mTimeStatistics.length)
+ + "ns over " + GT_Utility.formatNumbers(mTimeStatistics.length) + " ticks with worst time of "
+ + GT_Utility.formatNumbers(tWorstTime) + "ns.");
+ tList.add("Recorded " + GT_Utility.formatNumbers(mMetaTileEntity.mSoundRequests) + " sound requests in "
+ + GT_Utility.formatNumbers(mTickTimer - mLastCheckTick) + " ticks.");
mLastCheckTick = mTickTimer;
mMetaTileEntity.mSoundRequests = 0;
}
if (mLagWarningCount > 0) {
- tList.add("Caused " + (mLagWarningCount >= 10 ? "more than 10" : mLagWarningCount) + " Lag Spike Warnings (anything taking longer than " + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server.");
+ tList.add("Caused " + (mLagWarningCount >= 10 ? "more than 10" : mLagWarningCount)
+ + " Lag Spike Warnings (anything taking longer than "
+ + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server.");
}
- tList.add("Is" + (mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : EnumChatFormatting.RED + " not " + EnumChatFormatting.RESET) + "accessible for you");
+ tList.add("Is"
+ + (mMetaTileEntity.isAccessAllowed(aPlayer)
+ ? " "
+ : EnumChatFormatting.RED + " not " + EnumChatFormatting.RESET)
+ + "accessible for you");
}
if (aLogLevel > 0) {
if (getSteamCapacity() > 0 && hasSteamEngineUpgrade())
- tList.add(GT_Utility.formatNumbers(getStoredSteam()) + " of " + GT_Utility.formatNumbers(getSteamCapacity()) + " Steam");
- tList.add("Machine is " + (mActive ? EnumChatFormatting.GREEN + "active" + EnumChatFormatting.RESET : EnumChatFormatting.RED + "inactive" + EnumChatFormatting.RESET));
+ tList.add(GT_Utility.formatNumbers(getStoredSteam()) + " of "
+ + GT_Utility.formatNumbers(getSteamCapacity()) + " Steam");
+ tList.add("Machine is "
+ + (mActive
+ ? EnumChatFormatting.GREEN + "active" + EnumChatFormatting.RESET
+ : EnumChatFormatting.RED + "inactive" + EnumChatFormatting.RESET));
if (!mHasEnoughEnergy)
- tList.add(EnumChatFormatting.RED + "ATTENTION: This Device needs more power." + EnumChatFormatting.RESET);
+ tList.add(
+ EnumChatFormatting.RED + "ATTENTION: This Device needs more power." + EnumChatFormatting.RESET);
}
- if (joinedIc2Enet)
- tList.add("Joined IC2 ENet");
+ if (joinedIc2Enet) tList.add("Joined IC2 ENet");
return mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList);
}
@@ -729,7 +911,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
mInventoryChanged = true;
if (canAccessData()) {
markDirty();
- mMetaTileEntity.setInventorySlotContents(aIndex, worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack));
+ mMetaTileEntity.setInventorySlotContents(
+ aIndex, worldObj.isRemote ? aStack : GT_OreDictUnificator.setStack(true, aStack));
}
}
@@ -758,9 +941,12 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
public boolean isUseableByPlayer(EntityPlayer aPlayer) {
- return canAccessData() && playerOwnsThis(aPlayer, false) && mTickTimer > 40 &&
- getTileEntityOffset(0, 0, 0) == this &&
- aPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64 && mMetaTileEntity.isAccessAllowed(aPlayer);
+ return canAccessData()
+ && playerOwnsThis(aPlayer, false)
+ && mTickTimer > 40
+ && getTileEntityOffset(0, 0, 0) == this
+ && aPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64
+ && mMetaTileEntity.isAccessAllowed(aPlayer);
}
@Override
@@ -774,8 +960,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
tileEntityInvalid = false;
leaveEnet();
if (canAccessData()) {
- if (GregTech_API.mAE2)
- invalidateAE();
+ if (GregTech_API.mAE2) invalidateAE();
mMetaTileEntity.onRemoval();
mMetaTileEntity.setBaseMetaTileEntity(null);
}
@@ -785,8 +970,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
public void onChunkUnload() {
super.onChunkUnload();
- if (GregTech_API.mAE2)
- onChunkUnloadAE();
+ if (GregTech_API.mAE2) onChunkUnloadAE();
}
@Override
@@ -898,7 +1082,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) {
if (!canAccessData()) return false;
- return mHasEnoughEnergy = decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) || decreaseStoredSteam(aEnergy, false) || (aIgnoreTooLessEnergy && (decreaseStoredSteam(aEnergy, true)));
+ return mHasEnoughEnergy = decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy)
+ || decreaseStoredSteam(aEnergy, false)
+ || (aIgnoreTooLessEnergy && (decreaseStoredSteam(aEnergy, true)));
}
@Override
@@ -1039,9 +1225,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
public ITexture[] getTexture(Block aBlock, byte aSide) {
final ITexture coverTexture = getCoverTexture(aSide);
- final ITexture[] textureUncovered = hasValidMetaTileEntity() ?
- mMetaTileEntity.getTexture(this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0) :
- Textures.BlockIcons.ERROR_RENDERING;
+ final ITexture[] textureUncovered = hasValidMetaTileEntity()
+ ? mMetaTileEntity.getTexture(
+ this, aSide, mFacing, (byte) (mColor - 1), mActive, getOutputRedstoneSignal(aSide) > 0)
+ : Textures.BlockIcons.ERROR_RENDERING;
final ITexture[] textureCovered;
if (coverTexture != null) {
textureCovered = Arrays.copyOf(textureUncovered, textureUncovered.length + 1);
@@ -1054,8 +1241,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
private boolean isEnergyInputSide(byte aSide) {
if (aSide >= 0 && aSide < 6) {
- if (!getCoverBehaviorAtSideNew(aSide).letsEnergyIn(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
- return false;
+ if (!getCoverBehaviorAtSideNew(aSide)
+ .letsEnergyIn(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this)) return false;
if (isInvalid() || mReleaseEnergy) return false;
if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetInput())
return mMetaTileEntity.isInputFacing(aSide);
@@ -1065,7 +1252,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
private boolean isEnergyOutputSide(byte aSide) {
if (aSide >= 0 && aSide < 6) {
- if (!getCoverBehaviorAtSideNew(aSide).letsEnergyOut(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
+ if (!getCoverBehaviorAtSideNew(aSide)
+ .letsEnergyOut(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
return false;
if (isInvalid() || mReleaseEnergy) return mReleaseEnergy;
if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput())
@@ -1133,7 +1321,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
setOwnerName(aPlayer.getDisplayName());
setOwnerUuid(aPlayer.getUniqueID());
} else
- return !privateAccess() || aPlayer.getDisplayName().equals("Player") || mOwnerName.equals("Player") || mOwnerName.equals(aPlayer.getDisplayName());
+ return !privateAccess()
+ || aPlayer.getDisplayName().equals("Player")
+ || mOwnerName.equals("Player")
+ || mOwnerName.equals(aPlayer.getDisplayName());
return true;
}
@@ -1144,10 +1335,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
public void doEnergyExplosion() {
if (getUniversalEnergyCapacity() > 0 && getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 5) {
- GT_Log.exp.println("Energy Explosion, injected " + getUniversalEnergyStored() + "EU >= " + getUniversalEnergyCapacity() / 5D + "Capacity of the Machine!");
-
- doExplosion(oOutput * (getUniversalEnergyStored() >= getUniversalEnergyCapacity() ? 4 : getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 2 ? 2 : 1));
- GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "electricproblems");
+ GT_Log.exp.println("Energy Explosion, injected " + getUniversalEnergyStored() + "EU >= "
+ + getUniversalEnergyCapacity() / 5D + "Capacity of the Machine!");
+
+ doExplosion(oOutput
+ * (getUniversalEnergyStored() >= getUniversalEnergyCapacity()
+ ? 4
+ : getUniversalEnergyStored() >= getUniversalEnergyCapacity() / 2 ? 2 : 1));
+ GT_Mod.achievements.issueAchievement(
+ this.getWorldObj().getPlayerEntityByName(mOwnerName), "electricproblems");
}
}
@@ -1189,9 +1385,15 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
public void dropItems(ItemStack tItem) {
if (tItem == null) return;
- final EntityItem tItemEntity = new EntityItem(this.worldObj, this.xCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, this.yCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, this.zCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage()));
+ final EntityItem tItemEntity = new EntityItem(
+ this.worldObj,
+ this.xCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F,
+ this.yCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F,
+ this.zCoord + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F,
+ new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage()));
if (tItem.hasTagCompound()) {
- tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy());
+ tItemEntity.getEntityItem().setTagCompound((NBTTagCompound)
+ tItem.getTagCompound().copy());
}
tItemEntity.motionX = (XSTR_INSTANCE.nextGaussian() * 0.0500000007450581D);
tItemEntity.motionY = (XSTR_INSTANCE.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D);
@@ -1199,8 +1401,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
tItemEntity.hurtResistantTime = 999999;
tItemEntity.lifespan = 60000;
try {
- if (ENTITY_ITEM_HEALTH_FIELD != null)
- ENTITY_ITEM_HEALTH_FIELD.setInt(tItemEntity, 99999999);
+ if (ENTITY_ITEM_HEALTH_FIELD != null) ENTITY_ITEM_HEALTH_FIELD.setInt(tItemEntity, 99999999);
} catch (Exception ignored) {
}
this.worldObj.spawnEntityInWorld(tItemEntity);
@@ -1232,34 +1433,43 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) {
if (isClientSide()) {
- //Configure Cover, sneak can also be: screwdriver, wrench, side cutter, soldering iron
+ // Configure Cover, sneak can also be: screwdriver, wrench, side cutter, soldering iron
if (aPlayer.isSneaking()) {
- final byte tSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) : aSide;
+ final byte tSide =
+ (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) : aSide;
return (getCoverBehaviorAtSideNew(tSide).hasCoverGUI());
} else if (getCoverBehaviorAtSideNew(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) {
return true;
}
- if (!getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
+ if (!getCoverBehaviorAtSideNew(aSide)
+ .isGUIClickable(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
return false;
}
if (isServerSide()) {
if (!privateAccess() || aPlayer.getDisplayName().equalsIgnoreCase(getOwnerName())) {
final ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem();
if (tCurrentItem != null) {
- if (getColorization() >= 0 && GT_Utility.areStacksEqual(new ItemStack(Items.water_bucket, 1), tCurrentItem)) {
+ if (getColorization() >= 0
+ && GT_Utility.areStacksEqual(new ItemStack(Items.water_bucket, 1), tCurrentItem)) {
tCurrentItem.func_150996_a(Items.bucket);
setColorization((byte) (getColorization() >= 16 ? -2 : -1));
return true;
}
if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) {
- if (aPlayer.isSneaking() && mMetaTileEntity instanceof GT_MetaTileEntity_BasicMachine && ((GT_MetaTileEntity_BasicMachine) mMetaTileEntity).setMainFacing(GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ))) {
+ if (aPlayer.isSneaking()
+ && mMetaTileEntity instanceof GT_MetaTileEntity_BasicMachine
+ && ((GT_MetaTileEntity_BasicMachine) mMetaTileEntity)
+ .setMainFacing(GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ))) {
GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer);
- GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord);
+ GT_Utility.sendSoundToPlayers(
+ worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord);
cableUpdateDelay = 10;
- } else if (mMetaTileEntity.onWrenchRightClick(aSide, GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ), aPlayer, aX, aY, aZ)) {
+ } else if (mMetaTileEntity.onWrenchRightClick(
+ aSide, GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ), aPlayer, aX, aY, aZ)) {
GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer);
- GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord);
+ GT_Utility.sendSoundToPlayers(
+ worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord);
cableUpdateDelay = 10;
}
return true;
@@ -1267,9 +1477,21 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) {
if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) {
- setCoverDataAtSide(aSide, getCoverBehaviorAtSideNew(aSide).onCoverScrewdriverClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ));
+ setCoverDataAtSide(
+ aSide,
+ getCoverBehaviorAtSideNew(aSide)
+ .onCoverScrewdriverClick(
+ aSide,
+ getCoverIDAtSide(aSide),
+ getComplexCoverDataAtSide(aSide),
+ this,
+ aPlayer,
+ aX,
+ aY,
+ aZ));
mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ);
- GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord);
+ GT_Utility.sendSoundToPlayers(
+ worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord);
}
return true;
}
@@ -1278,8 +1500,18 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) {
mInputDisabled = !mInputDisabled;
if (mInputDisabled) mOutputDisabled = !mOutputDisabled;
- GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("086", "Auto-Input: ") + (mInputDisabled ? GT_Utility.trans("087", "Disabled") : GT_Utility.trans("088", "Enabled") + GT_Utility.trans("089", " Auto-Output: ") + (mOutputDisabled ? GT_Utility.trans("087", "Disabled") : GT_Utility.trans("088", "Enabled"))));
- GT_Utility.sendSoundToPlayers(worldObj, SoundResource.RANDOM_ANVIL_USE, 1.0F, -1, xCoord, yCoord, zCoord);
+ GT_Utility.sendChatToPlayer(
+ aPlayer,
+ GT_Utility.trans("086", "Auto-Input: ")
+ + (mInputDisabled
+ ? GT_Utility.trans("087", "Disabled")
+ : GT_Utility.trans("088", "Enabled")
+ + GT_Utility.trans("089", " Auto-Output: ")
+ + (mOutputDisabled
+ ? GT_Utility.trans("087", "Disabled")
+ : GT_Utility.trans("088", "Enabled"))));
+ GT_Utility.sendSoundToPlayers(
+ worldObj, SoundResource.RANDOM_ANVIL_USE, 1.0F, -1, xCoord, yCoord, zCoord);
}
return true;
}
@@ -1289,12 +1521,23 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
if (mWorks) disableWorking();
else enableWorking();
{
- String tChat = GT_Utility.trans("090", "Machine Processing: ") + (isAllowedToWork() ? GT_Utility.trans("088", "Enabled") : GT_Utility.trans("087", "Disabled"));
- if (getMetaTileEntity() != null && getMetaTileEntity().hasAlternativeModeText())
+ String tChat = GT_Utility.trans("090", "Machine Processing: ")
+ + (isAllowedToWork()
+ ? GT_Utility.trans("088", "Enabled")
+ : GT_Utility.trans("087", "Disabled"));
+ if (getMetaTileEntity() != null
+ && getMetaTileEntity().hasAlternativeModeText())
tChat = getMetaTileEntity().getAlternativeModeText();
GT_Utility.sendChatToPlayer(aPlayer, tChat);
}
- GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_RUBBER_TRAMPOLINE, 1.0F, -1, xCoord, yCoord, zCoord);
+ GT_Utility.sendSoundToPlayers(
+ worldObj,
+ SoundResource.IC2_TOOLS_RUBBER_TRAMPOLINE,
+ 1.0F,
+ -1,
+ xCoord,
+ yCoord,
+ zCoord);
}
return true;
}
@@ -1302,12 +1545,21 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) {
final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ);
if (mMetaTileEntity.onSolderingToolRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) {
- //logic handled internally
- GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_BATTERY_USE, 1.0F, -1, xCoord, yCoord, zCoord);
+ // logic handled internally
+ GT_Utility.sendSoundToPlayers(
+ worldObj, SoundResource.IC2_TOOLS_BATTERY_USE, 1.0F, -1, xCoord, yCoord, zCoord);
} else if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) {
mStrongRedstone ^= (1 << tSide);
- GT_Utility.sendChatToPlayer(aPlayer, GT_Utility.trans("091", "Redstone Output at Side ") + tSide + GT_Utility.trans("092", " set to: ") + ((mStrongRedstone & (1 << tSide)) != 0 ? GT_Utility.trans("093", "Strong") : GT_Utility.trans("094", "Weak")));
- GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_BATTERY_USE, 3.0F, -1, xCoord, yCoord, zCoord);
+ GT_Utility.sendChatToPlayer(
+ aPlayer,
+ GT_Utility.trans("091", "Redstone Output at Side ")
+ + tSide
+ + GT_Utility.trans("092", " set to: ")
+ + ((mStrongRedstone & (1 << tSide)) != 0
+ ? GT_Utility.trans("093", "Strong")
+ : GT_Utility.trans("094", "Weak")));
+ GT_Utility.sendSoundToPlayers(
+ worldObj, SoundResource.IC2_TOOLS_BATTERY_USE, 3.0F, -1, xCoord, yCoord, zCoord);
issueBlockUpdate();
}
doEnetUpdate();
@@ -1318,8 +1570,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList)) {
final byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ);
if (mMetaTileEntity.onWireCutterRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) {
- //logic handled internally
- GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord);
+ // logic handled internally
+ GT_Utility.sendSoundToPlayers(
+ worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord);
}
doEnetUpdate();
cableUpdateDelay = 10;
@@ -1331,38 +1584,60 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
if (getCoverIDAtSide(coverSide) == 0) {
if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCovers.keySet())) {
- if (GregTech_API.getCoverBehaviorNew(tCurrentItem).isCoverPlaceable(coverSide, tCurrentItem, this) &&
- mMetaTileEntity.allowCoverOnSide(coverSide, new GT_ItemStack(tCurrentItem))) {
+ if (GregTech_API.getCoverBehaviorNew(tCurrentItem)
+ .isCoverPlaceable(coverSide, tCurrentItem, this)
+ && mMetaTileEntity.allowCoverOnSide(coverSide, new GT_ItemStack(tCurrentItem))) {
setCoverItemAtSide(coverSide, tCurrentItem);
if (!aPlayer.capabilities.isCreativeMode) tCurrentItem.stackSize--;
- GT_Utility.sendSoundToPlayers(worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord);
+ GT_Utility.sendSoundToPlayers(
+ worldObj, SoundResource.IC2_TOOLS_WRENCH, 1.0F, -1, xCoord, yCoord, zCoord);
}
return true;
}
} else {
if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList)) {
if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) {
- GT_Utility.sendSoundToPlayers(worldObj, SoundResource.RANDOM_BREAK, 1.0F, -1, xCoord, yCoord, zCoord);
+ GT_Utility.sendSoundToPlayers(
+ worldObj, SoundResource.RANDOM_BREAK, 1.0F, -1, xCoord, yCoord, zCoord);
dropCover(coverSide, aSide, false);
}
return true;
}
}
- } else if (aPlayer.isSneaking()) { //Sneak click, no tool -> open cover config if possible.
- aSide = (getCoverIDAtSide(aSide) == 0) ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ) : aSide;
- return getCoverIDAtSide(aSide) > 0 && getCoverBehaviorAtSideNew(aSide).onCoverShiftRightClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer);
+ } else if (aPlayer.isSneaking()) { // Sneak click, no tool -> open cover config if possible.
+ aSide = (getCoverIDAtSide(aSide) == 0)
+ ? GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ)
+ : aSide;
+ return getCoverIDAtSide(aSide) > 0
+ && getCoverBehaviorAtSideNew(aSide)
+ .onCoverShiftRightClick(
+ aSide,
+ getCoverIDAtSide(aSide),
+ getComplexCoverDataAtSide(aSide),
+ this,
+ aPlayer);
}
- if (getCoverBehaviorAtSideNew(aSide).onCoverRightClick(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ))
- return true;
-
- if (!getCoverBehaviorAtSideNew(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
+ if (getCoverBehaviorAtSideNew(aSide)
+ .onCoverRightClick(
+ aSide,
+ getCoverIDAtSide(aSide),
+ getComplexCoverDataAtSide(aSide),
+ this,
+ aPlayer,
+ aX,
+ aY,
+ aZ)) return true;
+
+ if (!getCoverBehaviorAtSideNew(aSide)
+ .isGUIClickable(aSide, getCoverIDAtSide(aSide), getComplexCoverDataAtSide(aSide), this))
return false;
if (isUpgradable() && tCurrentItem != null) {
if (ItemList.Upgrade_Muffler.isStackEqual(aPlayer.inventory.getCurrentItem())) {
if (addMufflerUpgrade()) {
- GT_Utility.sendSoundToPlayers(worldObj, SoundResource.RANDOM_CLICK, 1.0F, -1, xCoord, yCoord, zCoord);
+ GT_Utility.sendSoundToPlayers(
+ worldObj, SoundResource.RANDOM_CLICK, 1.0F, -1, xCoord, yCoord, zCoord);
if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--;
}
return true;
@@ -1372,7 +1647,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
mLockUpgrade = true;
setOwnerName(aPlayer.getDisplayName());
setOwnerUuid(aPlayer.getUniqueID());
- GT_Utility.sendSoundToPlayers(worldObj, SoundResource.RANDOM_CLICK, 1.0F, -1, xCoord, yCoord, zCoord);
+ GT_Utility.sendSoundToPlayers(
+ worldObj, SoundResource.RANDOM_CLICK, 1.0F, -1, xCoord, yCoord, zCoord);
if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--;
}
return true;
@@ -1385,7 +1661,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
if (!aPlayer.isSneaking() && hasValidMetaTileEntity())
return mMetaTileEntity.onRightclick(this, aPlayer, aSide, aX, aY, aZ);
} catch (Throwable e) {
- GT_Log.err.println("Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!");
+ GT_Log.err.println(
+ "Encountered Exception while rightclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!");
e.printStackTrace(GT_Log.err);
}
@@ -1397,7 +1674,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
try {
if (aPlayer != null && hasValidMetaTileEntity()) mMetaTileEntity.onLeftclick(this, aPlayer);
} catch (Throwable e) {
- GT_Log.err.println("Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!");
+ GT_Log.err.println(
+ "Encountered Exception while leftclicking TileEntity, the Game should've crashed now, but I prevented that. Please report immediately to GregTech Intergalactical!!!");
e.printStackTrace(GT_Log.err);
}
}
@@ -1439,8 +1717,21 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
*/
@Override
public int[] getAccessibleSlotsFromSide(int aSide) {
- if (canAccessData() && (getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), -1, this) || getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), -1, this)))
- return mMetaTileEntity.getAccessibleSlotsFromSide(aSide);
+ if (canAccessData()
+ && (getCoverBehaviorAtSideNew((byte) aSide)
+ .letsItemsOut(
+ (byte) aSide,
+ getCoverIDAtSide((byte) aSide),
+ getComplexCoverDataAtSide((byte) aSide),
+ -1,
+ this)
+ || getCoverBehaviorAtSideNew((byte) aSide)
+ .letsItemsIn(
+ (byte) aSide,
+ getCoverIDAtSide((byte) aSide),
+ getComplexCoverDataAtSide((byte) aSide),
+ -1,
+ this))) return mMetaTileEntity.getAccessibleSlotsFromSide(aSide);
return GT_Values.emptyIntArray;
}
@@ -1449,7 +1740,16 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
*/
@Override
public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) {
- return canAccessData() && (mRunningThroughTick || !mInputDisabled) && getCoverBehaviorAtSideNew((byte) aSide).letsItemsIn((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide);
+ return canAccessData()
+ && (mRunningThroughTick || !mInputDisabled)
+ && getCoverBehaviorAtSideNew((byte) aSide)
+ .letsItemsIn(
+ (byte) aSide,
+ getCoverIDAtSide((byte) aSide),
+ getComplexCoverDataAtSide((byte) aSide),
+ aIndex,
+ this)
+ && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide);
}
/**
@@ -1457,7 +1757,16 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
*/
@Override
public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) {
- return canAccessData() && (mRunningThroughTick || !mOutputDisabled) && getCoverBehaviorAtSideNew((byte) aSide).letsItemsOut((byte) aSide, getCoverIDAtSide((byte) aSide), getComplexCoverDataAtSide((byte) aSide), aIndex, this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide);
+ return canAccessData()
+ && (mRunningThroughTick || !mOutputDisabled)
+ && getCoverBehaviorAtSideNew((byte) aSide)
+ .letsItemsOut(
+ (byte) aSide,
+ getCoverIDAtSide((byte) aSide),
+ getComplexCoverDataAtSide((byte) aSide),
+ aIndex,
+ this)
+ && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide);
}
@Override
@@ -1471,7 +1780,6 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
return mMetaTileEntity.allowGeneralRedstoneOutput() ? mSidedRedstone[aSide] : 0;
}
-
@Override
public boolean isSteamEngineUpgradable() {
return isUpgradable() && !hasSteamEngineUpgrade() && getSteamCapacity() > 0;
@@ -1546,22 +1854,17 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
public long getAverageElectricInput() {
long rEU = 0;
- for (int i = 0; i < mAverageEUInput.length; ++i)
- if (i != mAverageEUInputIndex)
- rEU += mAverageEUInput[i];
+ for (int i = 0; i < mAverageEUInput.length; ++i) if (i != mAverageEUInputIndex) rEU += mAverageEUInput[i];
return rEU / (mAverageEUInput.length - 1);
}
@Override
public long getAverageElectricOutput() {
long rEU = 0;
- for (int i = 0; i < mAverageEUOutput.length; ++i)
- if (i != mAverageEUOutputIndex)
- rEU += mAverageEUOutput[i];
+ for (int i = 0; i < mAverageEUOutput.length; ++i) if (i != mAverageEUOutputIndex) rEU += mAverageEUOutput[i];
return rEU / (mAverageEUOutput.length - 1);
}
-
@Override
protected void updateOutputRedstoneSignal(byte aSide) {
if (mMetaTileEntity.hasSidedRedstoneOutputBehavior()) {
@@ -1598,7 +1901,6 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
return canAccessData() ? mMetaTileEntity.getComparatorValue(aSide) : 0;
}
-
@Override
public ItemStack decrStackSize(int aIndex, int aAmount) {
if (canAccessData()) {
@@ -1610,14 +1912,27 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
- if (!canAccessData() || !mMetaTileEntity.isElectric() || !inputEnergyFrom(aSide) || aAmperage <= 0 || aVoltage <= 0 || getStoredEU() >= getEUCapacity() || mMetaTileEntity.maxAmperesIn() <= mAcceptedAmperes)
- return 0;
+ if (!canAccessData()
+ || !mMetaTileEntity.isElectric()
+ || !inputEnergyFrom(aSide)
+ || aAmperage <= 0
+ || aVoltage <= 0
+ || getStoredEU() >= getEUCapacity()
+ || mMetaTileEntity.maxAmperesIn() <= mAcceptedAmperes) return 0;
if (aVoltage > getInputVoltage()) {
- GT_Log.exp.println("Energy Explosion, injected " + aVoltage + "EU/t in a " + getInputVoltage() + "EU/t Machine!");
+ GT_Log.exp.println(
+ "Energy Explosion, injected " + aVoltage + "EU/t in a " + getInputVoltage() + "EU/t Machine!");
doExplosion(aVoltage);
return 0;
}
- if (increaseStoredEnergyUnits(aVoltage * (aAmperage = Math.min(aAmperage, Math.min(mMetaTileEntity.maxAmperesIn() - mAcceptedAmperes, 1 + ((getEUCapacity() - getStoredEU()) / aVoltage)))), true)) {
+ if (increaseStoredEnergyUnits(
+ aVoltage
+ * (aAmperage = Math.min(
+ aAmperage,
+ Math.min(
+ mMetaTileEntity.maxAmperesIn() - mAcceptedAmperes,
+ 1 + ((getEUCapacity() - getStoredEU()) / aVoltage)))),
+ true)) {
mAverageEUInput[mAverageEUInputIndex] += aVoltage * aAmperage;
mAcceptedAmperes += aAmperage;
return aAmperage;
@@ -1627,8 +1942,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) {
- if (!canAccessData() || !mMetaTileEntity.isElectric() || !outputsEnergyTo(aSide) || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU())
- return false;
+ if (!canAccessData()
+ || !mMetaTileEntity.isElectric()
+ || !outputsEnergyTo(aSide)
+ || getStoredEU() - (aVoltage * aAmperage) < mMetaTileEntity.getMinimumStoredEU()) return false;
if (decreaseStoredEU(aVoltage * aAmperage, false)) {
mAverageEUOutput[mAverageEUOutputIndex] += aVoltage * aAmperage;
return true;
@@ -1650,81 +1967,90 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) {
- if (mTickTimer > 5 && canAccessData() &&
- (mRunningThroughTick || !mInputDisabled) &&
- (
- aSide == ForgeDirection.UNKNOWN ||
- (
- mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) &&
- getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)
- )
- )
- )
- return mMetaTileEntity.fill(aSide, aFluid, doFill);
+ if (mTickTimer > 5
+ && canAccessData()
+ && (mRunningThroughTick || !mInputDisabled)
+ && (aSide == ForgeDirection.UNKNOWN
+ || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal())
+ && getCoverBehaviorAtSideNew((byte) aSide.ordinal())
+ .letsFluidIn(
+ (byte) aSide.ordinal(),
+ getCoverIDAtSide((byte) aSide.ordinal()),
+ getComplexCoverDataAtSide((byte) aSide.ordinal()),
+ aFluid == null ? null : aFluid.getFluid(),
+ this)))) return mMetaTileEntity.fill(aSide, aFluid, doFill);
return 0;
}
@Override
public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) {
- if (mTickTimer > 5 && canAccessData() &&
- (mRunningThroughTick || !mOutputDisabled) &&
- (
- aSide == ForgeDirection.UNKNOWN ||
- (
- mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) &&
- getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), mMetaTileEntity.getFluid() == null ? null : mMetaTileEntity.getFluid().getFluid(), this)
- )
- )
- )
- return mMetaTileEntity.drain(aSide, maxDrain, doDrain);
+ if (mTickTimer > 5
+ && canAccessData()
+ && (mRunningThroughTick || !mOutputDisabled)
+ && (aSide == ForgeDirection.UNKNOWN
+ || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal())
+ && getCoverBehaviorAtSideNew((byte) aSide.ordinal())
+ .letsFluidOut(
+ (byte) aSide.ordinal(),
+ getCoverIDAtSide((byte) aSide.ordinal()),
+ getComplexCoverDataAtSide((byte) aSide.ordinal()),
+ mMetaTileEntity.getFluid() == null
+ ? null
+ : mMetaTileEntity
+ .getFluid()
+ .getFluid(),
+ this)))) return mMetaTileEntity.drain(aSide, maxDrain, doDrain);
return null;
}
@Override
public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) {
- if (mTickTimer > 5 && canAccessData() &&
- (mRunningThroughTick || !mOutputDisabled) &&
- (
- aSide == ForgeDirection.UNKNOWN ||
- (
- mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) &&
- getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid == null ? null : aFluid.getFluid(), this)
- )
- )
- )
- return mMetaTileEntity.drain(aSide, aFluid, doDrain);
+ if (mTickTimer > 5
+ && canAccessData()
+ && (mRunningThroughTick || !mOutputDisabled)
+ && (aSide == ForgeDirection.UNKNOWN
+ || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal())
+ && getCoverBehaviorAtSideNew((byte) aSide.ordinal())
+ .letsFluidOut(
+ (byte) aSide.ordinal(),
+ getCoverIDAtSide((byte) aSide.ordinal()),
+ getComplexCoverDataAtSide((byte) aSide.ordinal()),
+ aFluid == null ? null : aFluid.getFluid(),
+ this)))) return mMetaTileEntity.drain(aSide, aFluid, doDrain);
return null;
}
@Override
public boolean canFill(ForgeDirection aSide, Fluid aFluid) {
- if (mTickTimer > 5 && canAccessData() &&
- (mRunningThroughTick || !mInputDisabled) &&
- (
- aSide == ForgeDirection.UNKNOWN ||
- (
- mMetaTileEntity.isLiquidInput((byte) aSide.ordinal()) &&
- getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidIn((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)
- )
- )
- )
- return mMetaTileEntity.canFill(aSide, aFluid);
+ if (mTickTimer > 5
+ && canAccessData()
+ && (mRunningThroughTick || !mInputDisabled)
+ && (aSide == ForgeDirection.UNKNOWN
+ || (mMetaTileEntity.isLiquidInput((byte) aSide.ordinal())
+ && getCoverBehaviorAtSideNew((byte) aSide.ordinal())
+ .letsFluidIn(
+ (byte) aSide.ordinal(),
+ getCoverIDAtSide((byte) aSide.ordinal()),
+ getComplexCoverDataAtSide((byte) aSide.ordinal()),
+ aFluid,
+ this)))) return mMetaTileEntity.canFill(aSide, aFluid);
return false;
}
@Override
public boolean canDrain(ForgeDirection aSide, Fluid aFluid) {
- if (mTickTimer > 5 && canAccessData() &&
- (mRunningThroughTick || !mOutputDisabled) &&
- (
- aSide == ForgeDirection.UNKNOWN ||
- (
- mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal()) &&
- getCoverBehaviorAtSideNew((byte) aSide.ordinal()).letsFluidOut((byte) aSide.ordinal(), getCoverIDAtSide((byte) aSide.ordinal()), getComplexCoverDataAtSide((byte) aSide.ordinal()), aFluid, this)
- )
- )
- )
- return mMetaTileEntity.canDrain(aSide, aFluid);
+ if (mTickTimer > 5
+ && canAccessData()
+ && (mRunningThroughTick || !mOutputDisabled)
+ && (aSide == ForgeDirection.UNKNOWN
+ || (mMetaTileEntity.isLiquidOutput((byte) aSide.ordinal())
+ && getCoverBehaviorAtSideNew((byte) aSide.ordinal())
+ .letsFluidOut(
+ (byte) aSide.ordinal(),
+ getCoverIDAtSide((byte) aSide.ordinal()),
+ getComplexCoverDataAtSide((byte) aSide.ordinal()),
+ aFluid,
+ this)))) return mMetaTileEntity.canDrain(aSide, aFluid);
return false;
}
@@ -1732,17 +2058,25 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
public FluidTankInfo[] getTankInfo(ForgeDirection aSide) {
final byte tSide = (byte) aSide.ordinal();
- if (canAccessData() &&
- (
- aSide == ForgeDirection.UNKNOWN ||
- (
- mMetaTileEntity.isLiquidInput(tSide) && getCoverBehaviorAtSideNew(tSide).letsFluidIn(tSide, getCoverIDAtSide(tSide), getComplexCoverDataAtSide(tSide), null, this)) ||
- (mMetaTileEntity.isLiquidOutput(tSide) && getCoverBehaviorAtSideNew(tSide).letsFluidOut(tSide, getCoverIDAtSide(tSide), getComplexCoverDataAtSide(tSide), null, this)
- )
- )
- )
- return mMetaTileEntity.getTankInfo(aSide);
- return new FluidTankInfo[]{};
+ if (canAccessData()
+ && (aSide == ForgeDirection.UNKNOWN
+ || (mMetaTileEntity.isLiquidInput(tSide)
+ && getCoverBehaviorAtSideNew(tSide)
+ .letsFluidIn(
+ tSide,
+ getCoverIDAtSide(tSide),
+ getComplexCoverDataAtSide(tSide),
+ null,
+ this))
+ || (mMetaTileEntity.isLiquidOutput(tSide)
+ && getCoverBehaviorAtSideNew(tSide)
+ .letsFluidOut(
+ tSide,
+ getCoverIDAtSide(tSide),
+ getComplexCoverDataAtSide(tSide),
+ null,
+ this)))) return mMetaTileEntity.getTankInfo(aSide);
+ return new FluidTankInfo[] {};
}
public double getOutputEnergyUnitsPerTick() {
@@ -1771,7 +2105,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
}
public double getOfferedEnergy() {
- return (canAccessData() && getStoredEU() - mMetaTileEntity.getMinimumStoredEU() >= oOutput) ? Math.max(0, oOutput) : 0;
+ return (canAccessData() && getStoredEU() - mMetaTileEntity.getMinimumStoredEU() >= oOutput)
+ ? Math.max(0, oOutput)
+ : 0;
}
public void drawEnergy(double amount) {
@@ -1785,10 +2121,8 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
public int addEnergy(int aEnergy) {
if (!canAccessData()) return 0;
- if (aEnergy > 0)
- increaseStoredEnergyUnits(aEnergy, true);
- else
- decreaseStoredEU(-aEnergy, true);
+ if (aEnergy > 0) increaseStoredEnergyUnits(aEnergy, true);
+ else decreaseStoredEU(-aEnergy, true);
return (int) Math.min(Integer.MAX_VALUE, mMetaTileEntity.getEUVar());
}
@@ -1852,7 +2186,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
return true;
}
aStack = GT_OreDictUnificator.get(aStack);
- if (GT_Utility.areStacksEqual(tStack, aStack) && tStack.stackSize + aStack.stackSize <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) {
+ if (GT_Utility.areStacksEqual(tStack, aStack)
+ && tStack.stackSize + aStack.stackSize
+ <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) {
tStack.stackSize += aStack.stackSize;
markDirty();
return true;
@@ -1894,7 +2230,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
public String[] getInfoData() {
{
if (canAccessData()) return getMetaTileEntity().getInfoData();
- return new String[]{};
+ return new String[] {};
}
}
@@ -1904,7 +2240,14 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
}
@Override
- public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) {
+ public void addCollisionBoxesToList(
+ World aWorld,
+ int aX,
+ int aY,
+ int aZ,
+ AxisAlignedBB inputAABB,
+ List<AxisAlignedBB> outputAABB,
+ Entity collider) {
mMetaTileEntity.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider);
}
@@ -1935,9 +2278,10 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
final int chemistryUpdateVersion = GT_Mod.calculateTotalGTVersion(509, 31);
final int configCircuitAdditionVersion = GT_Mod.calculateTotalGTVersion(509, 40);
// 4 is old GT_MetaTileEntity_BasicMachine.OTHER_SLOT_COUNT
- if (nbtVersion < configCircuitAdditionVersion && getMetaTileEntity() instanceof GT_MetaTileEntity_BasicMachine && slotIndex >= 4)
- slotIndex += 1;
- if (mID >= 211 && mID <= 218) {//Assembler
+ if (nbtVersion < configCircuitAdditionVersion
+ && getMetaTileEntity() instanceof GT_MetaTileEntity_BasicMachine
+ && slotIndex >= 4) slotIndex += 1;
+ if (mID >= 211 && mID <= 218) { // Assembler
if (nbtVersion < chemistryUpdateVersion) {
oldInputSize = 2;
oldOutputSize = 1;
@@ -1947,8 +2291,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
newInputSize = 6;
newOutputSize = 1;
-
- } else if (mID >= 421 && mID <= 428) {//Chemical Reactor
+ } else if (mID >= 421 && mID <= 428) { // Chemical Reactor
if (nbtVersion < chemistryUpdateVersion) {
oldInputSize = 2;
oldOutputSize = 1;
@@ -1958,7 +2301,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
newInputSize = 2;
newOutputSize = 2;
- } else if (mID >= 531 && mID <= 538) {//Distillery
+ } else if (mID >= 531 && mID <= 538) { // Distillery
if (nbtVersion < chemistryUpdateVersion) {
oldInputSize = 1;
oldOutputSize = 0;
@@ -1967,7 +2310,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
}
newInputSize = 1;
newOutputSize = 1;
- } else if (mID >= 581 && mID <= 588) {//Mixer
+ } else if (mID >= 581 && mID <= 588) { // Mixer
if (nbtVersion < chemistryUpdateVersion) {
oldInputSize = 4;
oldOutputSize = 1;
@@ -1994,8 +2337,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
@Optional.Method(modid = "appliedenergistics2")
public IGridNode getGridNode(ForgeDirection forgeDirection) {
- if (mFacing != forgeDirection.ordinal())
- return null;
+ if (mFacing != forgeDirection.ordinal()) return null;
final AENetworkProxy gp = getProxy();
return gp != null ? gp.getNode() : null;
}
@@ -2008,8 +2350,7 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
@Optional.Method(modid = "appliedenergistics2")
- public void securityBreak() {
- }
+ public void securityBreak() {}
@Override
@Optional.Method(modid = "appliedenergistics2")
@@ -2033,38 +2374,33 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
@Optional.Method(modid = "appliedenergistics2")
public void gridChanged() {
- if (mMetaTileEntity != null)
- mMetaTileEntity.gridChanged();
+ if (mMetaTileEntity != null) mMetaTileEntity.gridChanged();
}
@TileEvent(TileEventType.WORLD_NBT_READ)
@Optional.Method(modid = "appliedenergistics2")
public void readFromNBT_AENetwork(final NBTTagCompound data) {
final AENetworkProxy gp = getProxy();
- if (gp != null)
- getProxy().readFromNBT(data);
+ if (gp != null) getProxy().readFromNBT(data);
}
@TileEvent(TileEventType.WORLD_NBT_WRITE)
@Optional.Method(modid = "appliedenergistics2")
public void writeToNBT_AENetwork(final NBTTagCompound data) {
final AENetworkProxy gp = getProxy();
- if (gp != null)
- gp.writeToNBT(data);
+ if (gp != null) gp.writeToNBT(data);
}
@Optional.Method(modid = "appliedenergistics2")
void onChunkUnloadAE() {
final AENetworkProxy gp = getProxy();
- if (gp != null)
- gp.onChunkUnload();
+ if (gp != null) gp.onChunkUnload();
}
@Optional.Method(modid = "appliedenergistics2")
void invalidateAE() {
final AENetworkProxy gp = getProxy();
- if (gp != null)
- gp.invalidate();
+ if (gp != null) gp.invalidate();
}
@Override
@@ -2079,8 +2415,9 @@ public class BaseMetaTileEntity extends CommonMetaTileEntity implements IGregTec
@Override
public IAlignment getAlignment() {
- return getMetaTileEntity() instanceof IAlignmentProvider ? ((IAlignmentProvider) getMetaTileEntity()).getAlignment() :
- getMetaTileEntity() instanceof IAlignment ? (IAlignment) getMetaTileEntity() : null;
+ return getMetaTileEntity() instanceof IAlignmentProvider
+ ? ((IAlignmentProvider) getMetaTileEntity()).getAlignment()
+ : getMetaTileEntity() instanceof IAlignment ? (IAlignment) getMetaTileEntity() : null;
}
@Nullable