diff options
| author | Alkalus <draknyte1@hotmail.com> | 2017-09-09 21:10:23 +1000 |
|---|---|---|
| committer | Alkalus <draknyte1@hotmail.com> | 2017-09-09 21:10:23 +1000 |
| commit | 3b15de7e6090b0b60dd77311d8e599c7dccd9326 (patch) | |
| tree | cd72c71d0f57f2733285a44b8d46659b239967c5 /src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base | |
| parent | db713aab91e567051de587dcb9aeebf7d0b0b308 (diff) | |
| download | GT5-Unofficial-3b15de7e6090b0b60dd77311d8e599c7dccd9326.tar.gz GT5-Unofficial-3b15de7e6090b0b60dd77311d8e599c7dccd9326.tar.bz2 GT5-Unofficial-3b15de7e6090b0b60dd77311d8e599c7dccd9326.zip | |
- Removed Superconductors and Conduction Nodes.
Diffstat (limited to 'src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base')
6 files changed, 0 insertions, 4072 deletions
diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechBaseMetaTileEntityLossless.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechBaseMetaTileEntityLossless.java deleted file mode 100644 index 3343750c09..0000000000 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/lossless/GregtechBaseMetaTileEntityLossless.java +++ /dev/null @@ -1,2113 +0,0 @@ -package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.lossless; - -import static gregtech.api.enums.GT_Values.NW; -import static gregtech.api.enums.GT_Values.V; - -import java.util.*; - -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IEnergyConnected; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.BaseTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.net.GT_Packet_TileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; -import ic2.api.Direction; -import net.minecraft.block.Block; -import net.minecraft.block.BlockFire; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.network.Packet; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.EnumSkyBlock; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.*; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * <p/> - * This is the main TileEntity for EVERYTHING. - */ -public class GregtechBaseMetaTileEntityLossless extends BaseTileEntity implements IGregTechTileEntity { - private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior}; - protected MetaTileEntity mMetaTileEntity; - protected long mStoredEnergy = 0, mStoredSteam = 0; - protected int mAverageEUInputIndex = 0, mAverageEUOutputIndex = 0; - protected boolean mReleaseEnergy = false; - protected int[] mAverageEUInput = new int[]{0, 0, 0, 0, 0}, mAverageEUOutput = new int[]{0, 0, 0, 0, 0}; - private final boolean[] mActiveEUInputs = new boolean[]{false, false, false, false, false, false}, mActiveEUOutputs = new boolean[]{false, false, false, false, false, false}; - private byte[] mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; - private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}; - private final int[] mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; - private boolean mHasEnoughEnergy = true, mRunningThroughTick = false, mInputDisabled = false, mOutputDisabled = false, mMuffler = false, mLockUpgrade = false, mActive = false, mRedstone = false, mWorkUpdate = false, mSteamConverter = false, mInventoryChanged = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false, oRedstone = false; - private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, 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 short mID = 0; - private long mTickTimer = 0, oOutput = 0, mAcceptedAmperes = Long.MAX_VALUE; - private String mOwnerName = ""; - private NBTTagCompound mRecipeStuff = new NBTTagCompound(); - - public GregtechBaseMetaTileEntityLossless() { - } - - @Override - public void writeToNBT(final NBTTagCompound aNBT) { - try { - super.writeToNBT(aNBT); - } catch (final Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - try { - aNBT.setInteger("mID", this.mID); - aNBT.setLong("mStoredSteam", this.mStoredSteam); - aNBT.setLong("mStoredEnergy", this.mStoredEnergy); - aNBT.setIntArray("mCoverData", this.mCoverData); - aNBT.setIntArray("mCoverSides", this.mCoverSides); - aNBT.setByteArray("mRedstoneSided", this.mSidedRedstone); - aNBT.setByte("mColor", this.mColor); - aNBT.setByte("mLightValue", this.mLightValue); - aNBT.setByte("mOtherUpgrades", this.mOtherUpgrades); - aNBT.setByte("mWorkData", this.mWorkData); - aNBT.setByte("mStrongRedstone", this.mStrongRedstone); - aNBT.setShort("mFacing", this.mFacing); - aNBT.setString("mOwnerName", this.mOwnerName); - aNBT.setBoolean("mLockUpgrade", this.mLockUpgrade); - aNBT.setBoolean("mMuffler", this.mMuffler); - aNBT.setBoolean("mSteamConverter", this.mSteamConverter); - aNBT.setBoolean("mActive", this.mActive); - aNBT.setBoolean("mRedstone", this.mRedstone); - aNBT.setBoolean("mWorks", !this.mWorks); - aNBT.setBoolean("mInputDisabled", this.mInputDisabled); - aNBT.setBoolean("mOutputDisabled", this.mOutputDisabled); - aNBT.setTag("GT.CraftingComponents", this.mRecipeStuff); - } catch (final Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - try { - if (this.hasValidMetaTileEntity()) { - final NBTTagList tItemList = new NBTTagList(); - for (int i = 0; i < this.mMetaTileEntity.getRealInventory().length; i++) { - final ItemStack tStack = this.mMetaTileEntity.getRealInventory()[i]; - if (tStack != null) { - final NBTTagCompound tTag = new NBTTagCompound(); - tTag.setInteger("IntSlot", i); - tStack.writeToNBT(tTag); - tItemList.appendTag(tTag); - } - } - aNBT.setTag("Inventory", tItemList); - - try { - this.mMetaTileEntity.saveNBTData(aNBT); - } catch (final Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - } catch (final Throwable e) { - GT_Log.err.println("Encountered CRITICAL ERROR while saving MetaTileEntity, the Chunk whould've been corrupted by now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - @Override - public void readFromNBT(final NBTTagCompound aNBT) { - super.readFromNBT(aNBT); - this.setInitialValuesAsNBT(aNBT, (short) 0); - } - - @Override - public void setInitialValuesAsNBT(final NBTTagCompound aNBT, final short aID) { - if (aNBT == null) { - if (aID > 0) { - this.mID = aID; - } else { - this.mID = this.mID > 0 ? this.mID : 0; - } - if (this.mID != 0) { - this.createNewMetatileEntity(this.mID); - } - this.mSidedRedstone = (this.hasValidMetaTileEntity() && this.mMetaTileEntity.hasSidedRedstoneOutputBehavior() ? new byte[]{0, 0, 0, 0, 0, 0} : new byte[]{15, 15, 15, 15, 15, 15}); - } else { - if (aID <= 0) { - this.mID = (short) aNBT.getInteger("mID"); - } else { - this.mID = aID; - } - this.mStoredSteam = aNBT.getInteger("mStoredSteam"); - this.mStoredEnergy = aNBT.getInteger("mStoredEnergy"); - this.mColor = aNBT.getByte("mColor"); - this.mLightValue = aNBT.getByte("mLightValue"); - this.mWorkData = aNBT.getByte("mWorkData"); - this.mStrongRedstone = aNBT.getByte("mStrongRedstone"); - this.mFacing = this.oFacing = (byte) aNBT.getShort("mFacing"); - this.mOwnerName = aNBT.getString("mOwnerName"); - this.mLockUpgrade = aNBT.getBoolean("mLockUpgrade"); - this.mMuffler = aNBT.getBoolean("mMuffler"); - this.mSteamConverter = aNBT.getBoolean("mSteamConverter"); - this.mActive = aNBT.getBoolean("mActive"); - this.mRedstone = aNBT.getBoolean("mRedstone"); - this.mWorks = !aNBT.getBoolean("mWorks"); - this.mInputDisabled = aNBT.getBoolean("mInputDisabled"); - this.mOutputDisabled = aNBT.getBoolean("mOutputDisabled"); - this.mOtherUpgrades = (byte) (aNBT.getByte("mOtherUpgrades") + aNBT.getByte("mBatteries") + aNBT.getByte("mLiBatteries")); - this.mCoverSides = aNBT.getIntArray("mCoverSides"); - this.mCoverData = aNBT.getIntArray("mCoverData"); - this.mSidedRedstone = aNBT.getByteArray("mRedstoneSided"); - this.mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); - - if (this.mCoverData.length != 6) { - this.mCoverData = new int[]{0, 0, 0, 0, 0, 0}; - } - if (this.mCoverSides.length != 6) { - this.mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; - } - if (this.mSidedRedstone.length != 6) { - if (this.hasValidMetaTileEntity() && this.mMetaTileEntity.hasSidedRedstoneOutputBehavior()) { - this.mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0}; - } else { - this.mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; - } - } - - for (byte i = 0; i < 6; i++) { - this.mCoverBehaviors[i] = GregTech_API.getCoverBehavior(this.mCoverSides[i]); - } - - if ((this.mID != 0) && this.createNewMetatileEntity(this.mID)) { - final NBTTagList tItemList = aNBT.getTagList("Inventory", 10); - for (int i = 0; i < tItemList.tagCount(); i++) { - final NBTTagCompound tTag = tItemList.getCompoundTagAt(i); - final int tSlot = tTag.getInteger("IntSlot"); - if ((tSlot >= 0) && (tSlot < this.mMetaTileEntity.getRealInventory().length)) { - this.mMetaTileEntity.getRealInventory()[tSlot] = GT_Utility.loadItem(tTag); - } - } - - try { - this.mMetaTileEntity.loadNBTData(aNBT); - } catch (final Throwable e) { - GT_Log.err.println("Encountered Exception while loading MetaTileEntity, the Server should've crashed now, but I prevented that. Please report immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - } - - if (this.mCoverData.length != 6) { - this.mCoverData = new int[]{0, 0, 0, 0, 0, 0}; - } - if (this.mCoverSides.length != 6) { - this.mCoverSides = new int[]{0, 0, 0, 0, 0, 0}; - } - if (this.mSidedRedstone.length != 6) { - if (this.hasValidMetaTileEntity() && this.mMetaTileEntity.hasSidedRedstoneOutputBehavior()) { - this.mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0}; - } else { - this.mSidedRedstone = new byte[]{15, 15, 15, 15, 15, 15}; - } - } - - for (byte i = 0; i < 6; i++) { - this.mCoverBehaviors[i] = GregTech_API.getCoverBehavior(this.mCoverSides[i]); - } - } - - private boolean createNewMetatileEntity(final short aID) { - if ((aID <= 0) || (aID >= GregTech_API.METATILEENTITIES.length) || (GregTech_API.METATILEENTITIES[aID] == null)) { - GT_Log.err.println("MetaID " + aID + " not loadable => locking TileEntity!"); - } else { - if (aID != 0) { - if (this.hasValidMetaTileEntity()) { - this.mMetaTileEntity.setBaseMetaTileEntity(null); - } - GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); - this.mTickTimer = 0; - this.mID = aID; - return true; - } - } - return false; - } - - /** - * Used for ticking special BaseMetaTileEntities, which need that for Energy Conversion - * It's called right before onPostTick() - */ - public void updateStatus() { - // - } - - /** - * Called when trying to charge Items - */ - public void chargeItem(final ItemStack aStack) { - this.decreaseStoredEU(GT_ModHandler.chargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, this.getStoredEU()), (int) Math.min(Integer.MAX_VALUE, this.mMetaTileEntity.getOutputTier()), false, false), true); - } - - /** - * Called when trying to discharge Items - */ - public void dischargeItem(final ItemStack aStack) { - this.increaseStoredEnergyUnits(GT_ModHandler.dischargeElectricItem(aStack, (int) Math.min(Integer.MAX_VALUE, this.getEUCapacity() - this.getStoredEU()), (int) Math.min(Integer.MAX_VALUE, this.mMetaTileEntity.getInputTier()), false, false, false), true); - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if (!this.hasValidMetaTileEntity()) { - if (this.mMetaTileEntity == null) { - return; - } - this.mMetaTileEntity.setBaseMetaTileEntity(this); - } - - this.mRunningThroughTick = true; - long tTime = System.currentTimeMillis(); - - for (int tCode = 0; this.hasValidMetaTileEntity() && (tCode >= 0); ) { - try { - switch (tCode) { - case 0: - tCode++; - if (this.mTickTimer++ == 0) { - this.oX = this.xCoord; - this.oY = this.yCoord; - this.oZ = this.zCoord; - if (this.isServerSide()) { - for (byte i = 0; i < 6; i++) { - if (this.getCoverIDAtSide(i) != 0) { - if (!this.mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(this.getCoverIDAtSide(i)))) { - this.dropCover(i, i, true); - } - } - } - } - - this.worldObj.markTileEntityChunkModified(this.xCoord, this.yCoord, this.zCoord, this); - - this.mMetaTileEntity.onFirstTick(this); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - } - case 1: - tCode++; - if (this.isClientSide()) { - if (this.mColor != this.oColor) { - this.mMetaTileEntity.onColorChangeClient(this.oColor = this.mColor); - this.issueTextureUpdate(); - } - - if (this.mLightValue != this.oLightValueClient) { - this.worldObj.setLightValue(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord, this.mLightValue); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord + 1, this.yCoord, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord - 1, this.yCoord, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord + 1, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord - 1, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord + 1); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord - 1); - this.oLightValueClient = this.mLightValue; - this.issueTextureUpdate(); - } - - if (this.mNeedsUpdate) { - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - //worldObj.func_147479_m(xCoord, yCoord, zCoord); - this.mNeedsUpdate = false; - } - } - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - if (this.isServerSide() && (this.mTickTimer > 10)) { - for (byte i = (byte) (tCode - 2); i < 6; i++) { - if (this.getCoverIDAtSide(i) != 0) { - tCode++; - final GT_CoverBehavior tCover = this.getCoverBehaviorAtSide(i); - final int tCoverTickRate = tCover.getTickRate(i, this.getCoverIDAtSide(i), this.mCoverData[i], this); - if ((tCoverTickRate > 0) && ((this.mTickTimer % tCoverTickRate) == 0)) { - this.mCoverData[i] = tCover.doCoverThings(i, this.getInputRedstoneSignal(i), this.getCoverIDAtSide(i), this.mCoverData[i], this, this.mTickTimer); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - } - } - } - - } - case 8: - tCode = 9; - if (this.isServerSide()) { - if (++this.mAverageEUInputIndex >= this.mAverageEUInput.length) { - this.mAverageEUInputIndex = 0; - } - if (++this.mAverageEUOutputIndex >= this.mAverageEUOutput.length) { - this.mAverageEUOutputIndex = 0; - } - - this.mAverageEUInput[this.mAverageEUInputIndex] = 0; - this.mAverageEUOutput[this.mAverageEUOutputIndex] = 0; - } - case 9: - tCode++; - this.mMetaTileEntity.onPreTick(this, this.mTickTimer); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - case 10: - tCode++; - if (this.isServerSide()) { - if ((this.mRedstone != this.oRedstone) || (this.mTickTimer == 10)) { - for (byte i = 0; i < 6; i++) { - this.mCoverBehaviors[i] = GregTech_API.getCoverBehavior(this.mCoverSides[i]); - } - this.oRedstone = this.mRedstone; - this.issueBlockUpdate(); - } - - if ((this.xCoord != this.oX) || (this.yCoord != this.oY) || (this.zCoord != this.oZ)) { - this.oX = this.xCoord; - this.oY = this.yCoord; - this.oZ = this.zCoord; - this.issueClientUpdate(); - this.clearTileEntityBuffer(); - } - - if (this.mFacing != this.oFacing) { - this.oFacing = this.mFacing; - for (byte i = 0; i < 6; i++) { - if (this.getCoverIDAtSide(i) != 0) { - if (!this.mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(this.getCoverIDAtSide(i)))) { - this.dropCover(i, i, true); - } - } - } - this.issueBlockUpdate(); - } - - if ((this.mTickTimer > 20) && this.mMetaTileEntity.isElectric()) { - this.mAcceptedAmperes = 0; - - if (this.getOutputVoltage() != this.oOutput) { - this.oOutput = this.getOutputVoltage(); - } - - if (this.mMetaTileEntity.isEnetOutput() || this.mMetaTileEntity.isEnetInput()) { - for (byte i = 0; i < 6; i++) { - boolean - temp = this.isEnergyInputSide(i); - if (temp != this.mActiveEUInputs[i]) { - this.mActiveEUInputs[i] = temp; - } - temp = this.isEnergyOutputSide(i); - if (temp != this.mActiveEUOutputs[i]) { - this.mActiveEUOutputs[i] = temp; - } - } - } - - - - if (this.mMetaTileEntity.isEnetOutput() && (this.oOutput > 0)) { - final long tOutputVoltage = this.oOutput, tUsableAmperage = Math.min(this.getOutputAmperage(), (this.getStoredEU() - this.mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); - if (tUsableAmperage > 0) { - final long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork(this.oOutput, tUsableAmperage, this); - this.mAverageEUOutput[this.mAverageEUOutputIndex] += tEU; - this.decreaseStoredEU(tEU, true); - } - } - - - if (this.getEUCapacity() > 0) { - if (GregTech_API.sMachineFireExplosions && (this.getRandomNumber(1000) == 0)) { - final Block tBlock = this.getBlockAtSide((byte) this.getRandomNumber(6)); - if ((tBlock != null) && (tBlock instanceof BlockFire)) { - this.doEnergyExplosion(); - } - } - - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - - if (this.getRandomNumber(1000) == 0) { - if (((this.getCoverIDAtSide((byte) 1) == 0) && ((this.worldObj.getPrecipitationHeight(this.xCoord, this.zCoord) - 2) < this.yCoord)) - || ((this.getCoverIDAtSide((byte) 2) == 0) && ((this.worldObj.getPrecipitationHeight(this.xCoord, this.zCoord - 1) - 1) < this.yCoord)) - || ((this.getCoverIDAtSide((byte) 3) == 0) && ((this.worldObj.getPrecipitationHeight(this.xCoord, this.zCoord + 1) - 1) < this.yCoord)) - || ((this.getCoverIDAtSide((byte) 4) == 0) && ((this.worldObj.getPrecipitationHeight(this.xCoord - 1, this.zCoord) - 1) < this.yCoord)) - || ((this.getCoverIDAtSide((byte) 5) == 0) && ((this.worldObj.getPrecipitationHeight(this.xCoord + 1, this.zCoord) - 1) < this.yCoord))) { - if (GregTech_API.sMachineRainExplosions && this.worldObj.isRaining() && (this.getBiome().rainfall > 0)) { - if (this.getRandomNumber(10) == 0) { - try { - GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(this.mOwnerName), "badweather"); - } catch (final Exception e) { - } - this.doEnergyExplosion(); - } else { - this.setOnFire(); - } - } - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - if (GregTech_API.sMachineThunderExplosions && this.worldObj.isThundering() && (this.getBiome().rainfall > 0) && (this.getRandomNumber(3) == 0)) { - try { - GT_Mod.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(this.mOwnerName), "badweather"); - } catch (final Exception e) { - } - this.doEnergyExplosion(); - } - } - } - } - } - - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - } - case 11: - tCode++; - if (this.isServerSide()) { - if ((this.mMetaTileEntity.dechargerSlotCount() > 0) && (this.getStoredEU() < this.getEUCapacity())) { - for (int i = this.mMetaTileEntity.dechargerSlotStartIndex(), k = this.mMetaTileEntity.dechargerSlotCount() + i; i < k; i++) { - if ((this.mMetaTileEntity.mInventory[i] != null) && (this.getStoredEU() < this.getEUCapacity())) { - this.dischargeItem(this.mMetaTileEntity.mInventory[i]); - if (this.mMetaTileEntity.mInventory[i].stackSize <= 0) { - this.mMetaTileEntity.mInventory[i] = null; - } - this.mInventoryChanged = true; - } - } - } - } - case 12: - tCode++; - if (this.isServerSide()) { - if ((this.mMetaTileEntity.rechargerSlotCount() > 0) && (this.getStoredEU() > 0)) { - for (int i = this.mMetaTileEntity.rechargerSlotStartIndex(), k = this.mMetaTileEntity.rechargerSlotCount() + i; i < k; i++) { - if ((this.getStoredEU() > 0) && (this.mMetaTileEntity.mInventory[i] != null)) { - this.chargeItem(this.mMetaTileEntity.mInventory[i]); - if (this.mMetaTileEntity.mInventory[i].stackSize <= 0) { - this.mMetaTileEntity.mInventory[i] = null; - } - this.mInventoryChanged = true; - } - } - } - } - case 13: - tCode++; - this.updateStatus(); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - case 14: - tCode++; - this.mMetaTileEntity.onPostTick(this, this.mTickTimer); - if (!this.hasValidMetaTileEntity()) { - this.mRunningThroughTick = false; - return; - } - case 15: - tCode++; - if (this.isServerSide()) { - if ((this.mTickTimer % 10) == 0) { - if (this.mSendClientData) { - NW.sendPacketToAllPlayersInRange(this.worldObj, new GT_Packet_TileEntity(this.xCoord, (short) this.yCoord, this.zCoord, this.mID, this.mCoverSides[0], this.mCoverSides[1], this.mCoverSides[2], this.mCoverSides[3], this.mCoverSides[4], this.mCoverSides[5], this.oTextureData = (byte) ((this.mFacing & 7) | (this.mActive ? 8 : 0) | (this.mRedstone ? 16 : 0) | (this.mLockUpgrade ? 32 : 0)), this.oUpdateData = this.hasValidMetaTileEntity() ? this.mMetaTileEntity.getUpdateData() : 0, this.oRedstoneData = (byte) (((this.mSidedRedstone[0] > 0) ? 1 : 0) | ((this.mSidedRedstone[1] > 0) ? 2 : 0) | ((this.mSidedRedstone[2] > 0) ? 4 : 0) | ((this.mSidedRedstone[3] > 0) ? 8 : 0) | ((this.mSidedRedstone[4] > 0) ? 16 : 0) | ((this.mSidedRedstone[5] > 0) ? 32 : 0)), this.oColor = this.mColor), this.xCoord, this.zCoord); - this.mSendClientData = false; - } - } - - if (this.mTickTimer > 10) { - byte tData = (byte) ((this.mFacing & 7) | (this.mActive ? 8 : 0) | (this.mRedstone ? 16 : 0) | (this.mLockUpgrade ? 32 : 0)); - if (tData != this.oTextureData) { - this.sendBlockEvent((byte) 0, this.oTextureData = tData); - } - tData = this.mMetaTileEntity.getUpdateData(); - if (tData != this.oUpdateData) { - this.sendBlockEvent((byte) 1, this.oUpdateData = tData); - } - if (this.mColor != this.oColor) { - this.sendBlockEvent((byte) 2, this.oColor = this.mColor); - } - tData = (byte) (((this.mSidedRedstone[0] > 0) ? 1 : 0) | ((this.mSidedRedstone[1] > 0) ? 2 : 0) | ((this.mSidedRedstone[2] > 0) ? 4 : 0) | ((this.mSidedRedstone[3] > 0) ? 8 : 0) | ((this.mSidedRedstone[4] > 0) ? 16 : 0) | ((this.mSidedRedstone[5] > 0) ? 32 : 0)); - if (tData != this.oRedstoneData) { - this.sendBlockEvent((byte) 3, this.oRedstoneData = tData); - } - if (this.mLightValue != this.oLightValue) { - this.worldObj.setLightValue(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord, this.mLightValue); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord + 1, this.yCoord, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord - 1, this.yCoord, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord + 1, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord - 1, this.zCoord); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord + 1); - this.worldObj.updateLightByType(EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord - 1); - this.issueTextureUpdate(); - this.sendBlockEvent((byte) 7, this.oLightValue = this.mLightValue); - } - } - - if (this.mNeedsBlockUpdate) { - this.worldObj.notifyBlocksOfNeighborChange(this.xCoord, this.yCoord, this.zCoord, this.getBlockOffset(0, 0, 0)); - this.mNeedsBlockUpdate = false; - } - } - default: - tCode = -1; - break; - } - } catch (final Throwable e) { - 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); - } - } - - if (this.isServerSide() && this.hasValidMetaTileEntity()) { - tTime = System.currentTimeMillis() - tTime; - if (this.mTimeStatistics.length > 0) { - this.mTimeStatistics[this.mTimeStatisticsIndex = (this.mTimeStatisticsIndex + 1) % this.mTimeStatistics.length] = (int) tTime; - } - if ((tTime > 0) && (tTime > GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING) && (this.mTickTimer > 1000) && this.getMetaTileEntity().doTickProfilingMessageDuringThisTick() && (this.mLagWarningCount++ < 10)) { - System.out.println("WARNING: Possible Lag Source at [" + this.xCoord + ", " + this.yCoord + ", " + this.zCoord + "] in Dimension " + this.worldObj.provider.dimensionId + " with " + tTime + "ms caused by an instance of " + this.getMetaTileEntity().getClass()); - } - } - - this.mWorkUpdate = this.mInventoryChanged = this.mRunningThroughTick = false; - } - - @Override - public Packet getDescriptionPacket() { - this.issueClientUpdate(); - return null; - } - - public final void receiveMetaTileEntityData(final short aID, final int aCover0, final int aCover1, final int aCover2, final int aCover3, final int aCover4, final int aCover5, final byte aTextureData, final byte aUpdateData, final byte aRedstoneData, final byte aColorData) { - this.issueTextureUpdate(); - if ((this.mID != aID) && (aID > 0)) { - this.mID = aID; - this.createNewMetatileEntity(this.mID); - } - - this.mCoverSides[0] = aCover0; - this.mCoverSides[1] = aCover1; - this.mCoverSides[2] = aCover2; - this.mCoverSides[3] = aCover3; - this.mCoverSides[4] = aCover4; - this.mCoverSides[5] = aCover5; - - for (byte i = 0; i < 6; i++) { - this.mCoverBehaviors[i] = GregTech_API.getCoverBehavior(this.mCoverSides[i]); - } - - this.receiveClientEvent(0, aTextureData); - this.receiveClientEvent(1, aUpdateData); - this.receiveClientEvent(2, aColorData); - this.receiveClientEvent(3, aRedstoneData); - } - - @Override - public boolean receiveClientEvent(final int aEventID, int aValue) { - super.receiveClientEvent(aEventID, aValue); - - if (this.hasValidMetaTileEntity()) { - try { - this.mMetaTileEntity.receiveClientEvent((byte) aEventID, (byte) aValue); - } catch (final 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 immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - if (this.isClientSide()) { - this.issueTextureUpdate(); - switch (aEventID) { - case 0: - this.mFacing = (byte) (aValue & 7); - this.mActive = ((aValue & 8) != 0); - this.mRedstone = ((aValue & 16) != 0); - //mLockUpgrade = ((aValue&32) != 0); - break; - case 1: - if (this.hasValidMetaTileEntity()) { - this.mMetaTileEntity.onValueUpdate((byte) aValue); - } - break; - case 2: - if ((aValue > 16) || (aValue < 0)) { - aValue = 0; - } - this.mColor = (byte) aValue; - break; - case 3: - this.mSidedRedstone[0] = (byte) ((aValue & 1) > 0 ? 15 : 0); - this.mSidedRedstone[1] = (byte) ((aValue & 2) > 0 ? 15 : 0); - this.mSidedRedstone[2] = (byte) ((aValue & 4) > 0 ? 15 : 0); - this.mSidedRedstone[3] = (byte) ((aValue & 8) > 0 ? 15 : 0); - this.mSidedRedstone[4] = (byte) ((aValue & 16) > 0 ? 15 : 0); - this.mSidedRedstone[5] = (byte) ((aValue & 32) > 0 ? 15 : 0); - break; - case 4: - if (this.hasValidMetaTileEntity() && (this.mTickTimer > 20)) { - this.mMetaTileEntity.doSound((byte) aValue, this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5); - } - break; - case 5: - if (this.hasValidMetaTileEntity() && (this.mTickTimer > 20)) { - this.mMetaTileEntity.startSoundLoop((byte) aValue, this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5); - } - break; - case 6: - if (this.hasValidMetaTileEntity() && (this.mTickTimer > 20)) { - this.mMetaTileEntity.stopSoundLoop((byte) aValue, this.xCoord + 0.5, this.yCoord + 0.5, this.zCoord + 0.5); - } - break; - case 7: - this.mLightValue = (byte) aValue; - break; - } - } - return true; - } - - public ArrayList<String> getDebugInfo(final EntityPlayer aPlayer, final int aLogLevel) { - final ArrayList<String> tList = new ArrayList<>(); - if (aLogLevel > 2) { - tList.add("Meta-ID: " + this.mID + (this.canAccessData() ? " valid" : " invalid") + (this.mMetaTileEntity == null ? " MetaTileEntity == null!" : " ")); - } - if (aLogLevel > 1) { - if (this.mTimeStatistics.length > 0) { - double tAverageTime = 0; - for (final int tTime : this.mTimeStatistics) { - tAverageTime += tTime; - } - tList.add("This particular TileEntity has caused an average CPU-load of ~" + (tAverageTime / this.mTimeStatistics.length) + "ms over the last " + this.mTimeStatistics.length + " ticks."); - } - if (this.mLagWarningCount > 0) { - tList.add("This TileEntity has also caused " + (this.mLagWarningCount >= 10 ? "more than 10" : this.mLagWarningCount) + " Lag Spike Warnings (anything taking longer than " + GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING + "ms) on the Server."); - } - tList.add("Is" + (this.mMetaTileEntity.isAccessAllowed(aPlayer) ? " " : " not ") + "accessible for you"); - } - if (aLogLevel > 0) { - if ((this.getSteamCapacity() > 0) && this.hasSteamEngineUpgrade()) { - tList.add(this.getStoredSteam() + " of " + this.getSteamCapacity() + " Steam"); - } - tList.add("Machine is " + (this.mActive ? "active" : "inactive")); - if (!this.mHasEnoughEnergy) { - tList.add("ATTENTION: This Device consumes Energy at a higher Rate than you input. You could insert more to speed up the process."); - } - } - return this.mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); - } - - @Override - public void issueTextureUpdate() { - this.mNeedsUpdate = true; - } - - @Override - public void issueBlockUpdate() { - this.mNeedsBlockUpdate = true; - } - - @Override - public void issueClientUpdate() { - this.mSendClientData = true; - } - - @Override - public void issueCoverUpdate(final byte aSide) { - this.issueClientUpdate(); - } - - @Override - public byte getStrongestRedstone() { - return (byte) Math.max(this.getInternalInputRedstoneSignal((byte) 0), Math.max(this.getInternalInputRedstoneSignal((byte) 1), Math.max(this.getInternalInputRedstoneSignal((byte) 2), Math.max(this.getInternalInputRedstoneSignal((byte) 3), Math.max(this.getInternalInputRedstoneSignal((byte) 4), this.getInternalInputRedstoneSignal((byte) 5)))))); - } - - @Override - public boolean getRedstone() { - return this.getRedstone((byte) 0) || this.getRedstone((byte) 1) || this.getRedstone((byte) 2) || this.getRedstone((byte) 3) || this.getRedstone((byte) 4) || this.getRedstone((byte) 5); - } - - @Override - public boolean getRedstone(final byte aSide) { - return this.getInternalInputRedstoneSignal(aSide) > 0; - } - - public ITexture getCoverTexture(final byte aSide) { - return GregTech_API.sCovers.get(new GT_ItemStack(this.getCoverIDAtSide(aSide))); - } - - @Override - public boolean isGivingInformation() { - if (this.canAccessData()) { - return this.mMetaTileEntity.isGivingInformation(); - } - return false; - } - - @Override - public boolean isValidFacing(final byte aSide) { - if (this.canAccessData()) { - return this.mMetaTileEntity.isFacingValid(aSide); - } - return false; - } - - @Override - public byte getBackFacing() { - return GT_Utility.getOppositeSide(this.mFacing); - } - - @Override - public byte getFrontFacing() { - return this.mFacing; - } - - @Override - public void setFrontFacing(final byte aFacing) { - if (this.isValidFacing(aFacing)) { - this.mFacing = aFacing; - this.mMetaTileEntity.onFacingChange(); - this.onMachineBlockUpdate(); - } - } - - @Override - public int getSizeInventory() { - if (this.canAccessData()) { - return this.mMetaTileEntity.getSizeInventory(); |
