Revert switch change

This commit is contained in:
Muramasa 2016-08-14 08:12:25 +01:00
parent 7874d1c91f
commit 5e5fa8cf38
2 changed files with 101 additions and 114 deletions

View file

@ -180,9 +180,9 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
long tTime = System.currentTimeMillis(); long tTime = System.currentTimeMillis();
int tCode = 0; int tCode = 0;
try { try { for (tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) {
for (tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { switch (tCode) {
if (tCode == 0) { case 0:
tCode++; tCode++;
if (mTickTimer++ == 0) { if (mTickTimer++ == 0) {
oX = xCoord; oX = xCoord;
@ -196,8 +196,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
mMetaTileEntity.onFirstTick(this); mMetaTileEntity.onFirstTick(this);
if (!hasValidMetaTileEntity()) return; if (!hasValidMetaTileEntity()) return;
} }
} case 1:
if (tCode == 1) {
tCode++; tCode++;
if (isClientSide()) { if (isClientSide()) {
if (mColor != oColor) { if (mColor != oColor) {
@ -211,8 +210,12 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
mNeedsUpdate = false; mNeedsUpdate = false;
} }
} }
} case 2:
if (tCode >= 2 && tCode <= 7) { case 3:
case 4:
case 5:
case 6:
case 7:
if (isServerSide() && mTickTimer > 10) { if (isServerSide() && mTickTimer > 10) {
for (byte i = (byte) (tCode - 2); i < 6; i++) for (byte i = (byte) (tCode - 2); i < 6; i++)
if (getCoverIDAtSide(i) != 0) { if (getCoverIDAtSide(i) != 0) {
@ -229,12 +232,11 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
mConnections = (byte) ((mConnections & ~64) | -128); mConnections = (byte) ((mConnections & ~64) | -128);
} }
} }
} case 8:
if (tCode == 8) {
tCode = 9; tCode = 9;
mMetaTileEntity.onPreTick(this, mTickTimer); mMetaTileEntity.onPreTick(this, mTickTimer);
if (!hasValidMetaTileEntity()) return;} if (!hasValidMetaTileEntity()) return;
if (tCode == 9) { case 9:
tCode++; tCode++;
if (isServerSide()) { if (isServerSide()) {
if (mTickTimer == 10) { if (mTickTimer == 10) {
@ -251,12 +253,11 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
clearTileEntityBuffer(); clearTileEntityBuffer();
} }
} }
} case 10:
if (tCode == 10) {
tCode++; tCode++;
mMetaTileEntity.onPostTick(this, mTickTimer); mMetaTileEntity.onPostTick(this, mTickTimer);
if (!hasValidMetaTileEntity()) return;} if (!hasValidMetaTileEntity()) return;
if (tCode == 11) { case 11:
tCode++; tCode++;
if (isServerSide()) { if (isServerSide()) {
if (mTickTimer % 10 == 0) { if (mTickTimer % 10 == 0) {
@ -280,15 +281,13 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE
mNeedsBlockUpdate = false; mNeedsBlockUpdate = false;
} }
} }
} default:
if (tCode > 11) {
tCode = -1; tCode = -1;
break;
}
} }
}
} catch (Throwable e) { } catch (Throwable e) {
gregtech.api.util.GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); gregtech.api.util.GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
e.printStackTrace(GT_Log.err); e.printStackTrace(gregtech.api.util.GT_Log.err);
} }
if (isServerSide() && hasValidMetaTileEntity()) { if (isServerSide() && hasValidMetaTileEntity()) {

View file

@ -250,9 +250,9 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
long tTime = System.currentTimeMillis(); long tTime = System.currentTimeMillis();
int tCode = 0; int tCode = 0;
try { try { for (tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) {
for (tCode = 0; hasValidMetaTileEntity() && tCode >= 0; ) { switch (tCode) {
if (tCode == 0) { case 0:
tCode++; tCode++;
if (mTickTimer++ == 0) { if (mTickTimer++ == 0) {
oX = xCoord; oX = xCoord;
@ -262,17 +262,14 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
if (getCoverIDAtSide(i) != 0) if (getCoverIDAtSide(i) != 0)
if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i))))
dropCover(i, i, true); dropCover(i, i, true);
worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this); worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this);
mMetaTileEntity.onFirstTick(this); mMetaTileEntity.onFirstTick(this);
if (!hasValidMetaTileEntity()) { if (!hasValidMetaTileEntity()) {
mRunningThroughTick = false; mRunningThroughTick = false;
return; return;
} }
} }
} case 1:
if (tCode == 1) {
tCode++; tCode++;
if (isClientSide()) { if (isClientSide()) {
if (mColor != oColor) { if (mColor != oColor) {
@ -299,8 +296,12 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mNeedsUpdate = false; mNeedsUpdate = false;
} }
} }
} case 2:
if (tCode >= 2 && tCode <= 7) { case 3:
case 4:
case 5:
case 6:
case 7:
if (isServerSide() && mTickTimer > 10) { if (isServerSide() && mTickTimer > 10) {
for (byte i = (byte) (tCode - 2); i < 6; i++) for (byte i = (byte) (tCode - 2); i < 6; i++)
if (getCoverIDAtSide(i) != 0) { if (getCoverIDAtSide(i) != 0) {
@ -317,8 +318,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
} }
} }
} case 8:
if (tCode == 8) {
tCode = 9; tCode = 9;
if (isServerSide()) { if (isServerSide()) {
if (++mAverageEUInputIndex >= mAverageEUInput.length) mAverageEUInputIndex = 0; if (++mAverageEUInputIndex >= mAverageEUInput.length) mAverageEUInputIndex = 0;
@ -327,16 +327,14 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
mAverageEUInput[mAverageEUInputIndex] = 0; mAverageEUInput[mAverageEUInputIndex] = 0;
mAverageEUOutput[mAverageEUOutputIndex] = 0; mAverageEUOutput[mAverageEUOutputIndex] = 0;
} }
} case 9:
if (tCode == 9) {
tCode++; tCode++;
mMetaTileEntity.onPreTick(this, mTickTimer); mMetaTileEntity.onPreTick(this, mTickTimer);
if (!hasValidMetaTileEntity()) { if (!hasValidMetaTileEntity()) {
mRunningThroughTick = false; mRunningThroughTick = false;
return; return;
} }
} case 10:
if (tCode == 10) {
tCode++; tCode++;
if (isServerSide()) { if (isServerSide()) {
if (mRedstone != oRedstone || mTickTimer == 10) { if (mRedstone != oRedstone || mTickTimer == 10) {
@ -420,10 +418,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
return; return;
} }
if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getBiome().rainfall > 0 && getRandomNumber(3) == 0) { if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getBiome().rainfall > 0 && getRandomNumber(3) == 0) {
try { GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");
GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");
} catch (Exception e) {
}
doEnergyExplosion(); doEnergyExplosion();
} }
} }
@ -436,99 +431,92 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE
return; return;
} }
} }
if (tCode == 11) { case 11:
tCode++; tCode++;
if (isServerSide()) { if (isServerSide()) {
if (mMetaTileEntity.dechargerSlotCount() > 0 && getStoredEU() < getEUCapacity()) { 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()) { if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) {
dischargeItem(mMetaTileEntity.mInventory[i]); dischargeItem(mMetaTileEntity.mInventory[i]);
if (mMetaTileEntity.mInventory[i].stackSize <= 0) if (mMetaTileEntity.mInventory[i].stackSize <= 0)
mMetaTileEntity.mInventory[i] = null; mMetaTileEntity.mInventory[i] = null;
mInventoryChanged = true; mInventoryChanged = true;
}
} }
} }
} }
} }
if (tCode == 12) { case 12:
tCode++; tCode++;
if (isServerSide()) { if (isServerSide()) {
if (mMetaTileEntity.rechargerSlotCount() > 0 && getStoredEU() > 0) { 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) { if (getStoredEU() > 0 && mMetaTileEntity.mInventory[i] != null) {
chargeItem(mMetaTileEntity.mInventory[i]); chargeItem(mMetaTileEntity.mInventory[i]);
if (mMetaTileEntity.mInventory[i].stackSize <= 0) if (mMetaTileEntity.mInventory[i].stackSize <= 0)
mMetaTileEntity.mInventory[i] = null; mMetaTileEntity.mInventory[i] = null;
mInventoryChanged = true; mInventoryChanged = true;
}
} }
} }
} }
} }
if (tCode == 13) { case 13:
tCode++; tCode++;
updateStatus(); updateStatus();
if (!hasValidMetaTileEntity()) { if (!hasValidMetaTileEntity()) {
mRunningThroughTick = false; mRunningThroughTick = false;
return; return;
}
} }
if (tCode == 14) { case 14:
tCode++; tCode++;
mMetaTileEntity.onPostTick(this, mTickTimer); mMetaTileEntity.onPostTick(this, mTickTimer);
if (!hasValidMetaTileEntity()) { if (!hasValidMetaTileEntity()) {
mRunningThroughTick = false; mRunningThroughTick = false;
return; return;
}
} }
if (tCode == 15) { case 15:
tCode++; tCode++;
if (isServerSide()) { if (isServerSide()) {
if (mTickTimer % 10 == 0) { if (mTickTimer % 10 == 0) {
if (mSendClientData) { 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)), 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); 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)), 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; mSendClientData = false;
}
} }
}
if (mTickTimer > 10) { if (mTickTimer > 10) {
byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0)); byte tData = (byte) ((mFacing & 7) | (mActive ? 8 : 0) | (mRedstone ? 16 : 0) | (mLockUpgrade ? 32 : 0));
if (tData != oTextureData) sendBlockEvent((byte) 0, oTextureData = tData); if (tData != oTextureData) sendBlockEvent((byte) 0, oTextureData = tData);
tData = mMetaTileEntity.getUpdateData(); tData = mMetaTileEntity.getUpdateData();
if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData); if (tData != oUpdateData) sendBlockEvent((byte) 1, oUpdateData = tData);
if (mColor != oColor) sendBlockEvent((byte) 2, oColor = mColor); if (mColor != oColor) sendBlockEvent((byte) 2, 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((byte) 3, oRedstoneData = tData); if (tData != oRedstoneData) sendBlockEvent((byte) 3, oRedstoneData = tData);
if (mLightValue != oLightValue) { if (mLightValue != oLightValue) {
worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue); worldObj.setLightValue(EnumSkyBlock.Block, xCoord, yCoord, zCoord, mLightValue);
worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord);
worldObj.updateLightByType(EnumSkyBlock.Block, xCoord + 1, yCoord, zCoord); worldObj.updateLightByType(EnumSkyBlock.Block, xCoord + 1, yCoord, zCoord);
worldObj.updateLightByType(EnumSkyBlock.Block, xCoord - 1, yCoord, zCoord); worldObj.updateLightByType(EnumSkyBlock.Block, xCoord - 1, yCoord, zCoord);
worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord + 1, zCoord); worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord + 1, zCoord);
worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord - 1, zCoord); worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord - 1, zCoord);
worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1); worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord + 1);
worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1); worldObj.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord - 1);
issueTextureUpdate(); issueTextureUpdate();
sendBlockEvent((byte) 7, oLightValue = mLightValue); sendBlockEvent((byte) 7, oLightValue = mLightValue);
}
}
if (mNeedsBlockUpdate) {
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0));
mNeedsBlockUpdate = false;
} }
} }
if (mNeedsBlockUpdate) {
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0));
mNeedsBlockUpdate = false;
}
} }
if (tCode > 15) { default:
tCode = -1; tCode = -1;
break;
}
}
} }
}
} catch (Throwable e) { } catch (Throwable e) {
gregtech.api.util.GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); gregtech.api.util.GT_Log.err.println("Encountered Exception while ticking MetaTileEntity in Step " + (tCode - 1) + ". The Game should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!");
e.printStackTrace(GT_Log.err); e.printStackTrace(gregtech.api.util.GT_Log.err);
} }
if (isServerSide() && hasValidMetaTileEntity()) { if (isServerSide() && hasValidMetaTileEntity()) {