aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/metatileentity/BaseTileEntity.java')
-rw-r--r--src/main/java/gregtech/api/metatileentity/BaseTileEntity.java57
1 files changed, 31 insertions, 26 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java
index 8e6206f612..1f6fb0c68d 100644
--- a/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java
+++ b/src/main/java/gregtech/api/metatileentity/BaseTileEntity.java
@@ -1,14 +1,22 @@
package gregtech.api.metatileentity;
+import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES;
+import static gregtech.api.enums.GT_Values.COMPASS_DIRECTIONS;
+import static gregtech.api.enums.GT_Values.GT;
+import static gregtech.api.enums.GT_Values.NW;
+import static gregtech.api.enums.GT_Values.SIDE_DOWN;
+import static gregtech.api.enums.GT_Values.SIDE_UP;
+
import gregtech.api.interfaces.tileentity.IGTEnet;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords;
import gregtech.api.interfaces.tileentity.IIC2Enet;
import gregtech.api.net.GT_Packet_Block_Event;
-import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_Utility;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
+import java.util.Arrays;
+import java.util.concurrent.ThreadLocalRandom;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@@ -25,16 +33,6 @@ import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.IFluidHandler;
-import java.util.Arrays;
-import java.util.concurrent.ThreadLocalRandom;
-
-import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES;
-import static gregtech.api.enums.GT_Values.COMPASS_DIRECTIONS;
-import static gregtech.api.enums.GT_Values.GT;
-import static gregtech.api.enums.GT_Values.NW;
-import static gregtech.api.enums.GT_Values.SIDE_DOWN;
-import static gregtech.api.enums.GT_Values.SIDE_UP;
-
/**
* The Functions my old TileEntities and my BaseMetaTileEntities have in common.
* <p/>
@@ -63,17 +61,17 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje
private final ChunkCoordinates mReturnedCoordinates = new ChunkCoordinates();
public static byte getSideForPlayerPlacing(Entity aPlayer, byte aDefaultFacing, boolean[] aAllowedFacings) {
- if(aPlayer != null) {
+ if (aPlayer != null) {
if (aPlayer.rotationPitch >= 65 && aAllowedFacings[SIDE_UP]) return SIDE_UP;
if (aPlayer.rotationPitch <= -65 && aAllowedFacings[SIDE_DOWN]) return SIDE_DOWN;
- final byte rFacing = COMPASS_DIRECTIONS[MathHelper.floor_double(0.5D + 4.0F * aPlayer.rotationYaw / 360.0F) & 0x3];
+ final byte rFacing =
+ COMPASS_DIRECTIONS[MathHelper.floor_double(0.5D + 4.0F * aPlayer.rotationYaw / 360.0F) & 0x3];
if (aAllowedFacings[rFacing]) return rFacing;
}
for (final byte tSide : ALL_VALID_SIDES) if (aAllowedFacings[tSide]) return tSide;
return aDefaultFacing;
}
-
private void clearNullMarkersFromTileEntityBuffer() {
for (int i = 0; i < mBufferedTileEntities.length; i++)
if (mBufferedTileEntities[i] == this) mBufferedTileEntities[i] = null;
@@ -364,7 +362,9 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje
public Block getBlock(ChunkCoordinates aCoords) {
if (worldObj == null) return Blocks.air;
- if (ignoreUnloadedChunks && crossedChunkBorder(aCoords) && !worldObj.blockExists(aCoords.posX, aCoords.posY, aCoords.posZ)) return Blocks.air;
+ if (ignoreUnloadedChunks
+ && crossedChunkBorder(aCoords)
+ && !worldObj.blockExists(aCoords.posX, aCoords.posY, aCoords.posZ)) return Blocks.air;
return worldObj.getBlock(aCoords.posX, aCoords.posY, aCoords.posZ);
}
@@ -426,7 +426,9 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje
mBufferedTileEntities[aSide] = null;
return getTileEntityAtSide(aSide);
}
- if (mBufferedTileEntities[aSide].xCoord == tX && mBufferedTileEntities[aSide].yCoord == tY && mBufferedTileEntities[aSide].zCoord == tZ) {
+ if (mBufferedTileEntities[aSide].xCoord == tX
+ && mBufferedTileEntities[aSide].yCoord == tY
+ && mBufferedTileEntities[aSide].zCoord == tZ) {
return mBufferedTileEntities[aSide];
}
return null;
@@ -482,8 +484,11 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje
worldObj.notifyBlockOfNeighborChange(x1, y1, z1, thisBlock);
// update if it was / is strong powered.
- if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0 ) && getBlock(x1, y1, z1).isNormalCube()) {
- final int skipUpdateSide = dir.getOpposite().ordinal(); //Don't update this block. Still updates diagonal blocks twice if conditions meet.
+ if (((((mStrongRedstone | oStrongRedstone) >>> dir.ordinal()) & 1) != 0)
+ && getBlock(x1, y1, z1).isNormalCube()) {
+ final int skipUpdateSide = dir.getOpposite()
+ .ordinal(); // Don't update this block. Still updates diagonal blocks twice if conditions
+ // meet.
for (final ForgeDirection dir2 : ForgeDirection.VALID_DIRECTIONS) {
final int x2 = x1 + dir2.offsetX, y2 = y1 + dir2.offsetY, z2 = z1 + dir2.offsetZ;
@@ -497,7 +502,8 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje
@Override
public final void sendBlockEvent(byte aID, byte aValue) {
- NW.sendPacketToAllPlayersInRange(worldObj, new GT_Packet_Block_Event(xCoord, (short) yCoord, zCoord, aID, aValue), xCoord, zCoord);
+ NW.sendPacketToAllPlayersInRange(
+ worldObj, new GT_Packet_Block_Event(xCoord, (short) yCoord, zCoord, aID, aValue), xCoord, zCoord);
}
protected boolean crossedChunkBorder(int aX, int aZ) {
@@ -520,14 +526,14 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje
public void markDirty() {
// Avoid sending neighbor updates, just mark the chunk as dirty to make sure it gets saved
final Chunk chunk = worldObj.getChunkFromBlockCoords(xCoord, zCoord);
- if(chunk != null) {
+ if (chunk != null) {
chunk.setChunkModified();
}
}
@Deprecated
- public String trans(String aKey, String aEnglish){
- return GT_Utility.trans(aKey, aEnglish);
+ public String trans(String aKey, String aEnglish) {
+ return GT_Utility.trans(aKey, aEnglish);
}
/*
@@ -537,8 +543,8 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje
protected boolean joinedIc2Enet = false;
protected void createIc2Sink() {
- if(ic2EnergySink == null && isServerSide() && shouldJoinIc2Enet()) {
- ic2EnergySink = new TileIC2EnergySink((IGregTechTileEntity)this);
+ if (ic2EnergySink == null && isServerSide() && shouldJoinIc2Enet()) {
+ ic2EnergySink = new TileIC2EnergySink((IGregTechTileEntity) this);
}
}
@@ -551,7 +557,7 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje
protected void joinEnet() {
if (joinedIc2Enet || !shouldJoinIc2Enet()) return;
- if(ic2EnergySink == null) createIc2Sink();
+ if (ic2EnergySink == null) createIc2Sink();
if (ic2EnergySink != null) {
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(ic2EnergySink));
@@ -565,5 +571,4 @@ public abstract class BaseTileEntity extends TileEntity implements IHasWorldObje
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(ic2EnergySink));
}
}
-
}