diff options
Diffstat (limited to 'main/java/gregtech/api/metatileentity')
33 files changed, 0 insertions, 8738 deletions
diff --git a/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java deleted file mode 100644 index 4244753ba7..0000000000 --- a/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ /dev/null @@ -1,1016 +0,0 @@ -package gregtech.api.metatileentity; - -import static gregtech.api.enums.GT_Values.NW; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity; -import gregtech.api.net.GT_Packet_TileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -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.util.AxisAlignedBB; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * - * This is the main TileEntity for EVERYTHING. - */ -public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileEntity, IPipeRenderedTileEntity { - public byte mConnections = 0; - - protected MetaPipeEntity mMetaTileEntity; - - private byte[] mSidedRedstone = new byte[] {0,0,0,0,0,0}; - private int[] mCoverSides = new int[] {0,0,0,0,0,0}, mCoverData = new int[] {0,0,0,0,0,0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; - private boolean mInventoryChanged = false, mWorkUpdate = false, mWorks = true, mNeedsUpdate = true, mNeedsBlockUpdate = true, mSendClientData = false; - private byte mColor = 0, oColor = 0, mStrongRedstone = 0, oRedstoneData = 63, oTextureData = 0, oUpdateData = 0, mLagWarningCount = 0; - private int oX = 0, oY = 0, oZ = 0, mTimeStatisticsIndex = 0; - private short mID = 0; - private long mTickTimer = 0; - - public BaseMetaPipeEntity() {} - - @Override - public void writeToNBT(NBTTagCompound aNBT) { - try { - super.writeToNBT(aNBT); - } catch(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" , mID); - aNBT.setIntArray ("mCoverData" , mCoverData); - aNBT.setIntArray ("mCoverSides" , mCoverSides); - aNBT.setByteArray ("mRedstoneSided" , mSidedRedstone); - aNBT.setByte ("mConnections" , mConnections); - aNBT.setByte ("mColor" , mColor); - aNBT.setByte ("mStrongRedstone" , mStrongRedstone); - aNBT.setBoolean ("mWorks" , !mWorks); - } catch(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 (hasValidMetaTileEntity()) { - NBTTagList tItemList = new NBTTagList(); - for (int i = 0; i < mMetaTileEntity.getRealInventory().length; i++) { - ItemStack tStack = mMetaTileEntity.getRealInventory()[i]; - if (tStack != null) { - NBTTagCompound tTag = new NBTTagCompound(); - tTag.setInteger("IntSlot", i); - tStack.writeToNBT(tTag); - tItemList.appendTag(tTag); - } - } - aNBT.setTag("Inventory", tItemList); - - try { - mMetaTileEntity.saveNBTData(aNBT); - } catch(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(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(NBTTagCompound aNBT) { - super.readFromNBT(aNBT); - setInitialValuesAsNBT(aNBT, (short)0); - } - - @Override - public void setInitialValuesAsNBT(NBTTagCompound aNBT, short aID) { - if (aNBT == null) { - if (aID>0) mID=aID; else mID=mID>0?mID:0; - if (mID!=0) createNewMetatileEntity(mID); - } else { - if (aID<=0) mID = (short)aNBT.getInteger ("mID"); else mID = aID; - mCoverSides = aNBT.getIntArray ("mCoverSides"); - mCoverData = aNBT.getIntArray ("mCoverData"); - mSidedRedstone = aNBT.getByteArray ("mRedstoneSided"); - mConnections = aNBT.getByte ("mConnections"); - mColor = aNBT.getByte ("mColor"); - mStrongRedstone = aNBT.getByte ("mStrongRedstone"); - mWorks =!aNBT.getBoolean ("mWorks"); - - if (mCoverData.length != 6) mCoverData = 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) mSidedRedstone = new byte[] { 0, 0, 0, 0, 0, 0}; - - for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - - if (mID!=0 && createNewMetatileEntity(mID)) { - NBTTagList tItemList = aNBT.getTagList("Inventory", 10); - for (int i = 0; i < tItemList.tagCount(); i++) { - NBTTagCompound tTag = tItemList.getCompoundTagAt(i); - int tSlot = tTag.getInteger("IntSlot"); - if (tSlot >= 0 && tSlot < mMetaTileEntity.getRealInventory().length) { - mMetaTileEntity.getRealInventory()[tSlot] = GT_Utility.loadItem(tTag); - } - } - - try { - mMetaTileEntity.loadNBTData(aNBT); - } catch(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 (mCoverData.length != 6) mCoverData = 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) mSidedRedstone = new byte[] { 0, 0, 0, 0, 0, 0}; - - for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - } - - private boolean createNewMetatileEntity(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 (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null); - GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); - mTickTimer = 0; - mID = aID; - return true; - } - } - return false; - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if (!hasValidMetaTileEntity()) { - if (mMetaTileEntity == null) return; - mMetaTileEntity.setBaseMetaTileEntity(this); - } - - long tTime = System.currentTimeMillis(); - - for (int tCode = 0; hasValidMetaTileEntity() && tCode >= 0;) {try {switch (tCode) { - case 0: - tCode++; - if (mTickTimer++==0) { - oX = xCoord; - oY = yCoord; - oZ = zCoord; - if (isServerSide()) for (byte i = 0; i < 6; i++) if (getCoverIDAtSide(i)!=0) if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) dropCover(i, i, true); - worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this); - mMetaTileEntity.onFirstTick(this); - if (!hasValidMetaTileEntity()) return; - } - case 1: - tCode++; - if (isClientSide()) { - if (mColor != oColor) { - mMetaTileEntity.onColorChangeClient(oColor = mColor); - issueTextureUpdate(); - } - - if (mNeedsUpdate) { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - //worldObj.func_147479_m(xCoord, yCoord, zCoord); - mNeedsUpdate = false; - } - } - case 2: case 3: case 4: case 5: case 6: case 7: - if (isServerSide() && mTickTimer > 10) { - for (byte i = (byte)(tCode-2); i < 6; i++) if (getCoverIDAtSide(i) != 0) { - tCode++; - GT_CoverBehavior tCover = getCoverBehaviorAtSide(i); - int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this); - if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) { - mCoverData[i] = tCover.doCoverThings(i, getInputRedstoneSignal(i), getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); - if (!hasValidMetaTileEntity()) return; - } - } - mConnections = (byte)(mMetaTileEntity.mConnections | (mConnections & ~63)); - if ((mConnections & -64) == 64 && getRandomNumber(1000) == 0) { - mConnections = (byte)((mConnections & ~64) | -128); - } - } - case 8: - tCode=9; - mMetaTileEntity.onPreTick(this, mTickTimer); - if (!hasValidMetaTileEntity()) return; - case 9: - tCode++; - if (isServerSide()) { - if (mTickTimer == 10) { - for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - issueBlockUpdate(); - } - - if (xCoord != oX || yCoord != oY || zCoord != oZ) { - oX = xCoord; - oY = yCoord; - oZ = zCoord; - issueClientUpdate(); - clearTileEntityBuffer(); - } - } - case 10: - tCode++; - mMetaTileEntity.onPostTick(this, mTickTimer); - if (!hasValidMetaTileEntity()) return; - case 11: - tCode++; - if (isServerSide()) { - if (mTickTimer % 10 == 0) { - 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 = mConnections, 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; - } - } - - if (mTickTimer > 10) { - if (mConnections != oTextureData) sendBlockEvent((byte)0, oTextureData = mConnections); - byte tData = mMetaTileEntity.getUpdateData(); - if (tData != oUpdateData) sendBlockEvent((byte)1, oUpdateData = tData); - 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)); - if (tData != oRedstoneData) sendBlockEvent((byte)3, oRedstoneData = tData); - } - - if (mNeedsBlockUpdate) { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0)); - mNeedsBlockUpdate = false; - } - } - default: - tCode = -1; - break; - }} catch (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 (isServerSide() && hasValidMetaTileEntity()) { - tTime = System.currentTimeMillis() - tTime; - if (mTimeStatistics.length > 0) mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = (int)tTime; - if (tTime > 0 && tTime > GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING && mTickTimer > 1000 && getMetaTileEntity().doTickProfilingMessageDuringThisTick() && mLagWarningCount++<10) System.out.println("WARNING: Possible Lag Source at [" + xCoord + ", " + yCoord + ", " + zCoord + "] in Dimension " + worldObj.provider.dimensionId + " with " + tTime + "ms caused by an instance of " + getMetaTileEntity().getClass()); - } - - mWorkUpdate = mInventoryChanged = false; - } - - @Override - public Packet getDescriptionPacket() { - issueClientUpdate(); - return null; - } - - 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) { - issueTextureUpdate(); - if (mID != aID && aID > 0) { - mID = aID; - createNewMetatileEntity(mID); - } - - mCoverSides[0] = aCover0; - mCoverSides[1] = aCover1; - mCoverSides[2] = aCover2; - mCoverSides[3] = aCover3; - mCoverSides[4] = aCover4; - mCoverSides[5] = aCover5; - - for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - - receiveClientEvent(0, aTextureData); - receiveClientEvent(1, aUpdateData); - receiveClientEvent(2, aColorData); - receiveClientEvent(3, aRedstoneData); - } - - @Override - public boolean receiveClientEvent(int aEventID, int aValue) { - super.receiveClientEvent(aEventID, aValue); - - if (hasValidMetaTileEntity()) { - 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 immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - if (isClientSide()) { - issueTextureUpdate(); - switch(aEventID) { - case 0: - mConnections = (byte)aValue; - break; - case 1: - if (hasValidMetaTileEntity()) mMetaTileEntity.onValueUpdate((byte)aValue); - break; - case 2: - if (aValue > 16 || aValue < 0) aValue = 0; - mColor = (byte)aValue; - break; - case 3: - mSidedRedstone[0] = (byte)((aValue& 1)>0?15:0); - mSidedRedstone[1] = (byte)((aValue& 2)>0?15:0); - mSidedRedstone[2] = (byte)((aValue& 4)>0?15:0); - mSidedRedstone[3] = (byte)((aValue& 8)>0?15:0); - mSidedRedstone[4] = (byte)((aValue&16)>0?15:0); - mSidedRedstone[5] = (byte)((aValue&32)>0?15:0); - break; - case 4: - if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.doSound((byte)aValue, xCoord+0.5, yCoord+0.5, zCoord+0.5); - break; - case 5: - if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.startSoundLoop((byte)aValue, xCoord+0.5, yCoord+0.5, zCoord+0.5); - break; - case 6: - if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.stopSoundLoop((byte)aValue, xCoord+0.5, yCoord+0.5, zCoord+0.5); - break; - } - } - return true; - } - - public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aLogLevel) { - ArrayList<String> tList = new ArrayList<String>(); - if (aLogLevel > 2) { - tList.add("Meta-ID: " + mID + (hasValidMetaTileEntity()?" valid":" invalid") + (mMetaTileEntity==null?" MetaTileEntity == null!":" ")); - } - if (aLogLevel > 1) { - if (mTimeStatistics.length > 0) { - double tAverageTime = 0; for (int tTime : mTimeStatistics) tAverageTime += tTime; - tList.add("This particular TileEntity has caused an average CPU-load of ~" + (tAverageTime/mTimeStatistics.length) + "ms over the last " + mTimeStatistics.length + " ticks."); - } - if (mLagWarningCount > 0) { - tList.add("This TileEntity has also 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)?" ":" not ") + "accessible for you"); - } - return mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); - } - - @Override public void issueTextureUpdate() {mNeedsUpdate = true;} - @Override public void issueBlockUpdate() {mNeedsBlockUpdate = true;} - @Override public void issueClientUpdate() {mSendClientData = true;} - @Override public void issueCoverUpdate(byte aSide) {issueClientUpdate();} - - @Override public byte getStrongestRedstone() {return (byte)Math.max(getInternalInputRedstoneSignal((byte)0), Math.max(getInternalInputRedstoneSignal((byte)1), Math.max(getInternalInputRedstoneSignal((byte)2), Math.max(getInternalInputRedstoneSignal((byte)3), Math.max(getInternalInputRedstoneSignal((byte)4), getInternalInputRedstoneSignal((byte)5))))));} - - @Override public boolean getRedstone() {return getRedstone((byte)0)||getRedstone((byte)1)||getRedstone((byte)2)||getRedstone((byte)3)||getRedstone((byte)4)||getRedstone((byte)5);} - @Override public boolean getRedstone(byte aSide) {return getInternalInputRedstoneSignal(aSide) > 0;} - - public ITexture getCoverTexture(byte aSide) {return GregTech_API.sCovers.get(new GT_ItemStack(getCoverIDAtSide(aSide)));} - - @Override public boolean isGivingInformation() {if (canAccessData()) return mMetaTileEntity.isGivingInformation(); return false;} - @Override public boolean isValidFacing(byte aSide) {if (canAccessData()) return mMetaTileEntity.isFacingValid(aSide); return false;} - @Override public byte getBackFacing() {return GT_Utility.getOppositeSide(getFrontFacing());} - @Override public byte getFrontFacing() {return 6;} - @Override public void setFrontFacing(byte aFacing) {/*Do nothing*/} - @Override public int getSizeInventory() {if (canAccessData()) return mMetaTileEntity.getSizeInventory(); return 0;} - @Override public ItemStack getStackInSlot(int aIndex) {if (canAccessData()) return mMetaTileEntity.getStackInSlot(aIndex); return null;} - @Override public void setInventorySlotContents(int aIndex, ItemStack aStack) {mInventoryChanged = true; if (canAccessData()) mMetaTileEntity.setInventorySlotContents(aIndex, worldObj.isRemote?aStack:GT_OreDictUnificator.setStack(true, aStack));} - @Override public String getInventoryName() {if (canAccessData()) return mMetaTileEntity.getInventoryName(); if (GregTech_API.METATILEENTITIES[mID] != null) return GregTech_API.METATILEENTITIES[mID].getInventoryName(); return "";} - @Override public int getInventoryStackLimit() {if (canAccessData()) return mMetaTileEntity.getInventoryStackLimit(); return 64;} - @Override public void openInventory() {/*Do nothing*/} - @Override public void closeInventory() {/*Do nothing*/} - @Override public boolean isUseableByPlayer(EntityPlayer aPlayer) {return hasValidMetaTileEntity() && mTickTimer>40 && getTileEntityOffset(0, 0, 0) == this && aPlayer.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64 && mMetaTileEntity.isAccessAllowed(aPlayer);} - @Override public void validate() {super.validate(); mTickTimer = 0;} - @Override public void invalidate() {tileEntityInvalid = false; if (hasValidMetaTileEntity()) {mMetaTileEntity.onRemoval(); mMetaTileEntity.setBaseMetaTileEntity(null);} super.invalidate();} - @Override public void onChunkUnload() {super.onChunkUnload();} - @Override public boolean hasCustomInventoryName() {return false;} - @Override public ItemStack getStackInSlotOnClosing(int slot) {ItemStack stack = getStackInSlot(slot); if (stack != null) setInventorySlotContents(slot, null); return stack;} - @Override public void onMachineBlockUpdate() {if (canAccessData()) mMetaTileEntity.onMachineBlockUpdate();} - @Override public int getProgress() {return canAccessData()?mMetaTileEntity.getProgresstime():0;} - @Override public int getMaxProgress() {return canAccessData()?mMetaTileEntity.maxProgresstime():0;} - @Override public boolean increaseProgress(int aProgressAmountInTicks) {return canAccessData()?mMetaTileEntity.increaseProgress(aProgressAmountInTicks)!=aProgressAmountInTicks:false;} - @Override public boolean hasThingsToDo() {return getMaxProgress()>0;} - @Override public void enableWorking() {if (!mWorks) mWorkUpdate = true; mWorks = true;} - @Override public void disableWorking() {mWorks = false;} - @Override public boolean isAllowedToWork() {return mWorks;} - @Override public boolean hasWorkJustBeenEnabled() {return mWorkUpdate;} - @Override public void setWorkDataValue(byte aValue) {/*Do nothing*/} - @Override public byte getWorkDataValue() {return 0;} - @Override public int getMetaTileID() {return mID;} - @Override public int setMetaTileID(short aID) {return mID = aID;} - @Override public boolean isActive() {return false;} - @Override public void setActive(boolean aActive) {/*Do nothing*/} - @Override public long getTimer() {return mTickTimer;} - @Override public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) {return false;} - @Override public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) {return false;} - @Override public boolean inputEnergyFrom(byte aSide) {return false;} - @Override public boolean outputsEnergyTo(byte aSide) {return false;} - @Override public long getOutputAmperage() {return 0;} - @Override public long getOutputVoltage() {return 0;} - @Override public long getInputAmperage() {return 0;} - @Override public long getInputVoltage() {return 0;} - @Override public boolean increaseStoredSteam(long aEnergy, boolean aIgnoreTooMuchEnergy) {return false;} - @Override public String[] getDescription() {if (canAccessData()) return mMetaTileEntity.getDescription(); return new String[0];} - @Override public boolean isValidSlot(int aIndex) {if (canAccessData()) return mMetaTileEntity.isValidSlot(aIndex); return false;} - @Override public long getUniversalEnergyStored() {return Math.max(getStoredEU(), getStoredSteam());} - @Override public long getUniversalEnergyCapacity() {return Math.max(getEUCapacity(), getSteamCapacity());} - @Override public long getStoredEU() {return 0;} - @Override public long getEUCapacity() {return 0;} - @Override public long getStoredSteam() {return 0;} - @Override public long getSteamCapacity() {return 0;} - @Override public ITexture[] getTexture(byte aSide) {ITexture rIcon = getCoverTexture(aSide); if (rIcon != null) return new ITexture[] {rIcon}; return getTextureUncovered(aSide);} - @Override public ITexture[] getTextureUncovered(byte aSide) {if ((mConnections & 64) != 0) return Textures.BlockIcons.FRESHFOAM; if ((mConnections & -128) != 0) return Textures.BlockIcons.HARDENEDFOAMS[mColor]; if ((mConnections & -64) != 0) return Textures.BlockIcons.ERROR_RENDERING; byte tConnections = mConnections; if (tConnections == 1 || tConnections == 2) tConnections = 3; else if (tConnections == 4 || tConnections == 8) tConnections = 12; else if (tConnections == 16 || tConnections == 32) tConnections = 48; if (hasValidMetaTileEntity()) return mMetaTileEntity.getTexture(this, aSide, tConnections, (byte)(mColor-1), tConnections == 0 || (tConnections & (1<<aSide)) != 0, getOutputRedstoneSignal(aSide)>0); return Textures.BlockIcons.ERROR_RENDERING;} - - protected boolean hasValidMetaTileEntity() {return mMetaTileEntity != null && mMetaTileEntity.getBaseMetaTileEntity() == this;} - protected boolean canAccessData() {return !isDead && hasValidMetaTileEntity();} - - @Override - public void doExplosion(long aAmount) { - if (canAccessData()) { - mMetaTileEntity.onExplosion(); - mMetaTileEntity.doExplosion(aAmount); - } - } - - @Override - public ArrayList<ItemStack> getDrops() { - ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, mID); - NBTTagCompound tNBT = new NBTTagCompound(); - if (mStrongRedstone > 0) tNBT.setByte ("mStrongRedstone" , mStrongRedstone); - for (byte i = 0; i < mCoverSides.length; i++) { - if (mCoverSides[i] != 0) { - tNBT.setIntArray("mCoverData" , mCoverData); - tNBT.setIntArray("mCoverSides" , mCoverSides); - break; - } - } - if (hasValidMetaTileEntity()) mMetaTileEntity.setItemNBT(tNBT); - if (!tNBT.hasNoTags()) rStack.setTagCompound(tNBT); - return new ArrayList<ItemStack>(Arrays.asList(rStack)); - } - - @Override - public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - if (isClientSide()) { - if (getCoverBehaviorAtSide(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) return true; - } - if (isServerSide()) { - ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if (tCurrentItem != null) { - if (getColorization() >= 0 && GT_Utility.areStacksEqual(new ItemStack(Items.water_bucket, 1), tCurrentItem)) { - tCurrentItem.func_150996_a(Items.bucket); - setColorization((byte)-1); - return true; - } - byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)) { - if (mMetaTileEntity.onWrenchRightClick(aSide, tSide, aPlayer, aX, aY, aZ)) { - GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) { - if (getCoverIDAtSide(aSide) == 0 && getCoverIDAtSide(tSide) != 0) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) { - setCoverDataAtSide(tSide, getCoverBehaviorAtSide(tSide).onCoverScrewdriverclick(tSide, getCoverIDAtSide(tSide), getCoverDataAtSide(tSide), this, aPlayer, 0.5F, 0.5F, 0.5F)); - mMetaTileEntity.onScrewdriverRightClick(tSide, aPlayer, aX, aY, aZ); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); - } - } else { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - setCoverDataAtSide(aSide, getCoverBehaviorAtSide(aSide).onCoverScrewdriverclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)); - mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); - } - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList)) { - //if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - // GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(1), 1.0F, -1, xCoord, yCoord, zCoord); - //} - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList)) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - if (mWorks) disableWorking(); else enableWorking(); - GT_Utility.sendChatToPlayer(aPlayer, "Machine Processing: " + (isAllowedToWork()?"Enabled":"Disabled")); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(101), 1.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) { - if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) { - mStrongRedstone ^= (1 << tSide); - GT_Utility.sendChatToPlayer(aPlayer, "Redstone Output at Side " + tSide + " set to: " + ((mStrongRedstone & (1 << tSide))!=0?"Strong":"Weak")); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - - byte cSide = tSide; - if (getCoverIDAtSide(aSide) != 0) cSide = aSide; - - if (getCoverIDAtSide(cSide) == 0) { - if (GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) { - if (GregTech_API.getCoverBehavior(tCurrentItem).isCoverPlaceable(cSide, new GT_ItemStack(tCurrentItem), this) && mMetaTileEntity.allowCoverOnSide(cSide, new GT_ItemStack(tCurrentItem))) { - setCoverItemAtSide(cSide, tCurrentItem); - if (!aPlayer.capabilities.isCreativeMode) tCurrentItem.stackSize--; - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 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, GregTech_API.sSoundList.get(0), 1.0F, -1, xCoord, yCoord, zCoord); - dropCover(cSide, aSide, false); - } - return true; - } - } - } - - if (getCoverBehaviorAtSide(aSide).onCoverRightclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)) return true; - } - - if (!getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) return false; - - try { - if (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 immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - - return false; - } - - @Override - public void onLeftclick(EntityPlayer aPlayer) { - 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 immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - @Override - public boolean isDigitalChest() { - return false; - } - - @Override - public ItemStack[] getStoredItemData() { - return null; - } - - @Override - public void setItemCount(int aCount) { - // - } - - @Override - public int getMaxItemCount() { - return 0; - } - - /** - * Can put aStack into Slot - */ - @Override - public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { - return canAccessData() && mMetaTileEntity.isItemValidForSlot(aIndex, aStack); - } - - /** - * returns all valid Inventory Slots, no matter which Side (Unless it's covered). - * The Side Stuff is done in the following two Functions. - */ - @Override - public int[] getAccessibleSlotsFromSide(int aSide) { - if (canAccessData() && (getCoverBehaviorAtSide((byte)aSide).letsItemsOut((byte)aSide, getCoverIDAtSide((byte)aSide), getCoverDataAtSide((byte)aSide), -1, this) || getCoverBehaviorAtSide((byte)aSide).letsItemsIn((byte)aSide, getCoverIDAtSide((byte)aSide), getCoverDataAtSide((byte)aSide), -1, this))) return mMetaTileEntity.getAccessibleSlotsFromSide(aSide); - return new int[0]; - } - - /** - * Can put aStack into Slot at Side - */ - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && getCoverBehaviorAtSide((byte)aSide).letsItemsIn ((byte)aSide, getCoverIDAtSide((byte)aSide), getCoverDataAtSide((byte)aSide), aIndex, this) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide); - } - - /** - * Can pull aStack out of Slot from Side - */ - @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && getCoverBehaviorAtSide((byte)aSide).letsItemsOut((byte)aSide, getCoverIDAtSide((byte)aSide), getCoverDataAtSide((byte)aSide), aIndex, this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide); - } - - @Override - public boolean isUpgradable() { - return false; - } - - @Override - public byte getInternalInputRedstoneSignal(byte aSide) { - return (byte)(getCoverBehaviorAtSide(aSide).getRedstoneInput(aSide, getInputRedstoneSignal(aSide), getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)&15); - } - - @Override - public byte getInputRedstoneSignal(byte aSide) { - return (byte)(worldObj.getIndirectPowerLevelTo(getOffsetX(aSide, 1), getOffsetY(aSide, 1), getOffsetZ(aSide, 1), aSide)&15); - } - - @Override - public byte getOutputRedstoneSignal(byte aSide) { - return (byte)(getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) || (getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))?mSidedRedstone[aSide]&15:0); - } - - @Override - public void setInternalOutputRedstoneSignal(byte aSide, byte aStrength) { - if (!getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) setOutputRedstoneSignal(aSide, aStrength); - } - - @Override - public void setOutputRedstoneSignal(byte aSide, byte aStrength) { - aStrength = (byte)Math.min(Math.max(0, aStrength), 15); - if (aSide >= 0 && aSide < 6 && mSidedRedstone[aSide] != aStrength) { - mSidedRedstone[aSide] = aStrength; - issueBlockUpdate(); - } - } - - @Override - public boolean isSteamEngineUpgradable() { - return isUpgradable()&&!hasSteamEngineUpgrade()&&getSteamCapacity()>0; - } - - @Override - public boolean addSteamEngineUpgrade() { - if (isSteamEngineUpgradable()) { - issueBlockUpdate(); - return true; - } - return false; - } - - @Override - public boolean hasSteamEngineUpgrade() { - return false; - } - - @Override - public boolean hasInventoryBeenModified() { - return mInventoryChanged; - } - - @Override - public void setGenericRedstoneOutput(boolean aOnOff) { - // - } - - @Override - public int getErrorDisplayID() { - return 0; - } - - @Override - public void setErrorDisplayID(int aErrorID) { - // - } - - @Override - public IMetaTileEntity getMetaTileEntity() { - return hasValidMetaTileEntity()?mMetaTileEntity:null; - } - - 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}; - - @Override - public GT_CoverBehavior getCoverBehaviorAtSide(byte aSide) { - return aSide >= 0 && aSide < mCoverBehaviors.length ? mCoverBehaviors[aSide] : GregTech_API.sNoBehavior; - } - - @Override - public void setCoverIDAtSide(byte aSide, int aID) { - if (aSide >= 0 && aSide < 6) { - mCoverSides[aSide] = aID; - mCoverData[aSide] = 0; - mCoverBehaviors[aSide] = GregTech_API.getCoverBehavior(aID); - issueCoverUpdate(aSide); - issueBlockUpdate(); - } - } - - @Override - public void setCoverItemAtSide(byte aSide, ItemStack aCover) { - GregTech_API.getCoverBehavior(aCover).placeCover(aSide, aCover, this); - } - - @Override - public int getCoverIDAtSide(byte aSide) { - if (aSide >= 0 && aSide < 6) return mCoverSides[aSide]; return 0; - } - - @Override - public ItemStack getCoverItemAtSide(byte aSide) { - return GT_Utility.intToStack(getCoverIDAtSide(aSide)); - } - - @Override - public boolean canPlaceCoverIDAtSide(byte aSide, int aID) { - return getCoverIDAtSide(aSide) == 0; - } - - @Override - public boolean canPlaceCoverItemAtSide(byte aSide, ItemStack aCover) { - return getCoverIDAtSide(aSide) == 0; - } - - @Override - public void setCoverDataAtSide(byte aSide, int aData) { - if (aSide >= 0 && aSide < 6) mCoverData[aSide] = aData; - } - - @Override - public int getCoverDataAtSide(byte aSide) { - if (aSide >= 0 && aSide < 6) return mCoverData[aSide]; - return 0; - } - - @Override - public void setLightValue(byte aLightValue) { - // - } - - @Override - public long getAverageElectricInput() { - return 0; - } - - @Override - public long getAverageElectricOutput() { - return 0; - } - - @Override - public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) { - if (getCoverBehaviorAtSide(aSide).onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) { - ItemStack tStack = getCoverBehaviorAtSide(aSide).getDrop(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this); - if (tStack != null) { - tStack.setTagCompound(null); - EntityItem tEntity = new EntityItem(worldObj, getOffsetX(aDroppedSide, 1) + 0.5, getOffsetY(aDroppedSide, 1) + 0.5, getOffsetZ(aDroppedSide, 1) + 0.5, tStack); - tEntity.motionX = 0; - tEntity.motionY = 0; - tEntity.motionZ = 0; - worldObj.spawnEntityInWorld(tEntity); - } - - setCoverIDAtSide(aSide, 0); - setOutputRedstoneSignal(aSide, (byte) 0); - return true; - } - return false; - } - - @Override - public String getOwnerName() { - return "Player"; - } - - @Override - public String setOwnerName(String aName) { - return "Player"; - } - - @Override - public byte getComparatorValue(byte aSide) { - return canAccessData()?mMetaTileEntity.getComparatorValue(aSide):0; - } - - @Override - public byte getStrongOutputRedstoneSignal(byte aSide) { - return aSide>=0&&aSide<6&&(mStrongRedstone & (1 << aSide))!=0?(byte)(mSidedRedstone[aSide]&15):0; - } - - @Override - public void setStrongOutputRedstoneSignal(byte aSide, byte aStrength) { - mStrongRedstone |= (1 << aSide); - setOutputRedstoneSignal(aSide, aStrength); - } - - @Override - public ItemStack decrStackSize(int aIndex, int aAmount) { - if (canAccessData()) { - mInventoryChanged = true; - return mMetaTileEntity.decrStackSize(aIndex, aAmount); - } - return null; - } - - @Override - public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (canAccessData()) return mMetaTileEntity.injectEnergyUnits(aSide, aVoltage, aAmperage); - return 0; - } - - @Override - public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - return false; - } - - @Override - public boolean acceptsRotationalEnergy(byte aSide) { - if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false; - return mMetaTileEntity.acceptsRotationalEnergy(aSide); - } - - @Override - public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { - if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false; - return mMetaTileEntity.injectRotationalEnergy(aSide, aSpeed, aEnergy); - } - - @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (mTickTimer > 5 && canAccessData() && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput ((byte)aSide.ordinal()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidIn ((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((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() && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte)aSide.ordinal()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidOut((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((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() && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte)aSide.ordinal()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidOut((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((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() && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput ((byte)aSide.ordinal()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidIn ((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((byte)aSide.ordinal()), aFluid, this)))) return mMetaTileEntity.canFill(aSide, aFluid); - return false; - } - - @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - if (mTickTimer > 5 && canAccessData() && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidOutput((byte)aSide.ordinal()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidOut((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((byte)aSide.ordinal()), aFluid, this)))) return mMetaTileEntity.canDrain(aSide, aFluid); - return false; - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (canAccessData() && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte)aSide.ordinal()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidIn ((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((byte)aSide.ordinal()), null, this)) || (mMetaTileEntity.isLiquidOutput((byte)aSide.ordinal()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidOut((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((byte)aSide.ordinal()), null, this)))) return mMetaTileEntity.getTankInfo(aSide); - return new FluidTankInfo[] {}; - } - - @Override - public boolean isInvalidTileEntity() { - return isInvalid(); - } - - @Override - public boolean addStackToSlot(int aIndex, ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) return true; - if (aIndex < 0 || aIndex >= getSizeInventory()) return false; - ItemStack tStack = getStackInSlot(aIndex); - if (GT_Utility.isStackInvalid(tStack)) { - setInventorySlotContents(aIndex, aStack); - return true; - } - aStack = GT_OreDictUnificator.get(aStack); - if (GT_Utility.areStacksEqual(tStack, aStack) && tStack.stackSize + aStack.stackSize <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) { - tStack.stackSize+=aStack.stackSize; - return true; - } - return false; - } - - @Override - public boolean addStackToSlot(int aIndex, ItemStack aStack, int aAmount) { - return addStackToSlot(aIndex, GT_Utility.copyAmount(aAmount, aStack)); - } - - @Override - public void setMetaTileEntity(IMetaTileEntity aMetaTileEntity) { - mMetaTileEntity = (MetaPipeEntity)aMetaTileEntity; - } - - @Override - public byte getColorization() { - return (byte)(mColor-1); - } - - @Override - public byte setColorization(byte aColor) { - if (aColor > 15 || aColor < -1) aColor = -1; - if (canAccessData()) mMetaTileEntity.onColorChangeServer(aColor); - return mColor = (byte)(aColor+1); - } - - @Override - public float getThickNess() { - if (canAccessData()) return mMetaTileEntity.getThickNess(); - return 1.0F; - } - - public boolean renderInside(byte aSide) { - if (canAccessData()) return mMetaTileEntity.renderInside(aSide); - return false; - } - - @Override - public float getBlastResistance(byte aSide) { - return (mConnections & 192) != 0 ? 50.0F : 5.0F; - } - - @Override - public boolean isMufflerUpgradable() { - return false; - } - - @Override - public boolean addMufflerUpgrade() { - return false; - } - - @Override - public boolean hasMufflerUpgrade() { - return false; - } - - @Override - public boolean isUniversalEnergyStored(long aEnergyAmount) { - return getUniversalEnergyStored() >= aEnergyAmount; - } - - @Override - public String[] getInfoData() { - {if (canAccessData()) return getMetaTileEntity().getInfoData(); return new String[]{};} - } - - @Override - public byte getConnections() { - return mConnections; - } - - @Override - public void markDirty() { - super.markDirty(); - mInventoryChanged = true; - } - - @Override - public int getLightOpacity() { - return mMetaTileEntity == null ? 0 : mMetaTileEntity.getLightOpacity(); - } - - @Override - 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); - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - return mMetaTileEntity.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - @Override - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { - mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java deleted file mode 100644 index 9870ba9bec..0000000000 --- a/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ /dev/null @@ -1,1353 +0,0 @@ -package gregtech.api.metatileentity; - -import static gregtech.api.enums.GT_Values.NW; -import static gregtech.api.enums.GT_Values.V; -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.net.GT_Packet_TileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; -import ic2.api.Direction; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -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.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * - * This is the main TileEntity for EVERYTHING. - */ -public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileEntity { - 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 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}, 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 BaseMetaTileEntity() {} - - @Override - public void writeToNBT(NBTTagCompound aNBT) { - try { - super.writeToNBT(aNBT); - } catch(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" , mID); - aNBT.setLong ("mStoredSteam" , mStoredSteam); - aNBT.setLong ("mStoredEnergy" , mStoredEnergy); - aNBT.setIntArray ("mCoverData" , mCoverData); - aNBT.setIntArray ("mCoverSides" , mCoverSides); - aNBT.setByteArray ("mRedstoneSided" , mSidedRedstone); - aNBT.setByte ("mColor" , mColor); - aNBT.setByte ("mLightValue" , mLightValue); - aNBT.setByte ("mOtherUpgrades" , mOtherUpgrades); - aNBT.setByte ("mWorkData" , mWorkData); - aNBT.setByte ("mStrongRedstone" , mStrongRedstone); - aNBT.setShort ("mFacing" , mFacing); - aNBT.setString ("mOwnerName" , mOwnerName); - aNBT.setBoolean ("mLockUpgrade" , mLockUpgrade); - aNBT.setBoolean ("mMuffler" , mMuffler); - aNBT.setBoolean ("mSteamConverter" , mSteamConverter); - aNBT.setBoolean ("mActive" , mActive); - aNBT.setBoolean ("mRedstone" , mRedstone); - aNBT.setBoolean ("mWorks" , !mWorks); - aNBT.setBoolean ("mInputDisabled" , mInputDisabled); - aNBT.setBoolean ("mOutputDisabled" , mOutputDisabled); - aNBT.setTag ("GT.CraftingComponents", mRecipeStuff); - } catch(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 (hasValidMetaTileEntity()) { - NBTTagList tItemList = new NBTTagList(); - for (int i = 0; i < mMetaTileEntity.getRealInventory().length; i++) { - ItemStack tStack = mMetaTileEntity.getRealInventory()[i]; - if (tStack != null) { - NBTTagCompound tTag = new NBTTagCompound(); - tTag.setInteger("IntSlot", i); - tStack.writeToNBT(tTag); - tItemList.appendTag(tTag); - } - } - aNBT.setTag("Inventory", tItemList); - - try { - mMetaTileEntity.saveNBTData(aNBT); - } catch(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(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(NBTTagCompound aNBT) { - super.readFromNBT(aNBT); - setInitialValuesAsNBT(aNBT, (short)0); - } - - @Override - public void setInitialValuesAsNBT(NBTTagCompound aNBT, short aID) { - if (aNBT == null) { - 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}); - } else { - if (aID<=0) mID = (short)aNBT.getInteger ("mID"); else mID = aID; - mStoredSteam = aNBT.getInteger ("mStoredSteam"); - mStoredEnergy = aNBT.getInteger ("mStoredEnergy"); - mColor = aNBT.getByte ("mColor"); - mLightValue = aNBT.getByte ("mLightValue"); - mWorkData = aNBT.getByte ("mWorkData"); - mStrongRedstone = aNBT.getByte ("mStrongRedstone"); - mFacing = oFacing = (byte)aNBT.getShort("mFacing"); - mOwnerName = aNBT.getString ("mOwnerName"); - mLockUpgrade = aNBT.getBoolean ("mLockUpgrade"); - mMuffler = aNBT.getBoolean ("mMuffler"); - mSteamConverter = aNBT.getBoolean ("mSteamConverter"); - mActive = aNBT.getBoolean ("mActive"); - mRedstone = aNBT.getBoolean ("mRedstone"); - mWorks =!aNBT.getBoolean ("mWorks"); - mInputDisabled = aNBT.getBoolean ("mInputDisabled"); - mOutputDisabled = aNBT.getBoolean ("mOutputDisabled"); - mOtherUpgrades = (byte)(aNBT.getByte("mOtherUpgrades")+aNBT.getByte("mBatteries")+aNBT.getByte("mLiBatteries")); - mCoverSides = aNBT.getIntArray ("mCoverSides"); - mCoverData = aNBT.getIntArray ("mCoverData"); - mSidedRedstone = aNBT.getByteArray ("mRedstoneSided"); - mRecipeStuff = aNBT.getCompoundTag("GT.CraftingComponents"); - - if (mCoverData.length != 6) mCoverData = 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}; - - for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - - if (mID!=0 && createNewMetatileEntity(mID)) { - NBTTagList tItemList = aNBT.getTagList("Inventory", 10); - for (int i = 0; i < tItemList.tagCount(); i++) { - NBTTagCompound tTag = tItemList.getCompoundTagAt(i); - int tSlot = tTag.getInteger("IntSlot"); - if (tSlot >= 0 && tSlot < mMetaTileEntity.getRealInventory().length) { - mMetaTileEntity.getRealInventory()[tSlot] = GT_Utility.loadItem(tTag); - } - } - - try { - mMetaTileEntity.loadNBTData(aNBT); - } catch(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 (mCoverData.length != 6) mCoverData = 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}; - - for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - } - - private boolean createNewMetatileEntity(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 (hasValidMetaTileEntity()) mMetaTileEntity.setBaseMetaTileEntity(null); - GregTech_API.METATILEENTITIES[aID].newMetaEntity(this).setBaseMetaTileEntity(this); - mTickTimer = 0; - 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(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); - } - - /** - * 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); - } - - @Override - public void updateEntity() { - super.updateEntity(); - - if (!hasValidMetaTileEntity()) { - if (mMetaTileEntity == null) return; - mMetaTileEntity.setBaseMetaTileEntity(this); - } - - mRunningThroughTick = true; - long tTime = System.currentTimeMillis(); - - for (int tCode = 0; hasValidMetaTileEntity() && tCode >= 0;) {try {switch (tCode) { - case 0: - tCode++; - if (mTickTimer++==0) { - oX = xCoord; - oY = yCoord; - oZ = zCoord; - if (isServerSide()) for (byte i = 0; i < 6; i++) if (getCoverIDAtSide(i)!=0) if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) dropCover(i, i, true); - - worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this); - - mMetaTileEntity.onFirstTick(this); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - } - case 1: - tCode++; - if (isClientSide()) { - if (mColor != oColor) { - mMetaTileEntity.onColorChangeClient(oColor = mColor); - issueTextureUpdate(); - } - - if (mLightValue != oLightValueClient) { - worldObj.setLightValue (EnumSkyBlock.Block, xCoord , yCoord , zCoord , mLightValue); - 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 , 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); - oLightValueClient = mLightValue; - issueTextureUpdate(); - } - - if (mNeedsUpdate) { - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); - //worldObj.func_147479_m(xCoord, yCoord, zCoord); - mNeedsUpdate = false; - } - } - case 2: case 3: case 4: case 5: case 6: case 7: - if (isServerSide() && mTickTimer > 10) { - for (byte i = (byte)(tCode-2); i < 6; i++) if (getCoverIDAtSide(i) != 0) { - tCode++; - GT_CoverBehavior tCover = getCoverBehaviorAtSide(i); - int tCoverTickRate = tCover.getTickRate(i, getCoverIDAtSide(i), mCoverData[i], this); - if (tCoverTickRate > 0 && mTickTimer % tCoverTickRate == 0) { - mCoverData[i] = tCover.doCoverThings(i, getInputRedstoneSignal(i), getCoverIDAtSide(i), mCoverData[i], this, mTickTimer); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - } - } - - } - case 8: - tCode=9; - if (isServerSide()) { - if (++mAverageEUInputIndex >= mAverageEUInput.length ) mAverageEUInputIndex = 0; - if (++mAverageEUOutputIndex >= mAverageEUOutput.length) mAverageEUOutputIndex = 0; - - mAverageEUInput [mAverageEUInputIndex ] = 0; - mAverageEUOutput[mAverageEUOutputIndex] = 0; - } - case 9: - tCode++; - mMetaTileEntity.onPreTick(this, mTickTimer); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - case 10: - tCode++; - if (isServerSide()) { - if (mRedstone != oRedstone || mTickTimer == 10) { - for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - oRedstone = mRedstone; - issueBlockUpdate(); - } - - if (xCoord != oX || yCoord != oY || zCoord != oZ) { - oX = xCoord; - oY = yCoord; - oZ = zCoord; - issueClientUpdate(); - clearTileEntityBuffer(); - } - - if (mFacing != oFacing) { - oFacing = mFacing; - for (byte i = 0; i < 6; i++) if (getCoverIDAtSide(i)!=0) if (!mMetaTileEntity.allowCoverOnSide(i, new GT_ItemStack(getCoverIDAtSide(i)))) dropCover(i, i, true); - issueBlockUpdate(); - } - - if (mTickTimer > 20 && mMetaTileEntity.isElectric()) { - mAcceptedAmperes = 0; - - if (getOutputVoltage() != oOutput) { - oOutput = getOutputVoltage(); - } - - if (mMetaTileEntity.isEnetOutput() || mMetaTileEntity.isEnetInput()) { - for (byte i = 0; i < 6; i++) { - boolean - temp = isEnergyInputSide(i); - if (temp != mActiveEUInputs[i]) { - mActiveEUInputs[i] = temp; - } - temp = isEnergyOutputSide(i); - if (temp != mActiveEUOutputs[i]) { - mActiveEUOutputs[i] = temp; - } - } - } - - if (mMetaTileEntity.isEnetOutput() && oOutput > 0) { - long tOutputVoltage = Math.max(oOutput, oOutput + (1 << GT_Utility.getTier(oOutput))), tUsableAmperage = Math.min(getOutputAmperage(), (getStoredEU() - mMetaTileEntity.getMinimumStoredEU()) / tOutputVoltage); - if (tUsableAmperage > 0) { - long tEU = tOutputVoltage * IEnergyConnected.Util.emitEnergyToNetwork(oOutput, tUsableAmperage, this); - mAverageEUOutput[mAverageEUOutputIndex] += tEU; - decreaseStoredEU(tEU, true); - } - } - if (getEUCapacity() > 0) { - if (GregTech_API.sMachineFireExplosions && getRandomNumber(1000) == 0) { - Block tBlock = getBlockAtSide((byte)getRandomNumber(6)); - if (tBlock != null && tBlock instanceof BlockFire) doEnergyExplosion(); - } - - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - - if (getRandomNumber(1000) == 0) { - if((getCoverIDAtSide((byte)1) == 0 && worldObj.getPrecipitationHeight(xCoord , zCoord ) - 2 < yCoord) - || (getCoverIDAtSide((byte)2) == 0 && worldObj.getPrecipitationHeight(xCoord , zCoord-1) - 1 < yCoord) - || (getCoverIDAtSide((byte)3) == 0 && worldObj.getPrecipitationHeight(xCoord , zCoord+1) - 1 < yCoord) - || (getCoverIDAtSide((byte)4) == 0 && worldObj.getPrecipitationHeight(xCoord-1, zCoord ) - 1 < yCoord) - || (getCoverIDAtSide((byte)5) == 0 && worldObj.getPrecipitationHeight(xCoord+1, zCoord ) - 1 < yCoord)) { - if (GregTech_API.sMachineRainExplosions && worldObj.isRaining() && getBiome().rainfall > 0) { - if (getRandomNumber(10)==0) { - try{GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");}catch(Exception e){} - doEnergyExplosion(); - }else setOnFire(); - } - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - if (GregTech_API.sMachineThunderExplosions && worldObj.isThundering() && getBiome().rainfall > 0 && getRandomNumber(3) == 0) { - try{GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "badweather");}catch(Exception e){} - doEnergyExplosion(); - } - } - } - } - } - - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - } - case 11: - tCode++; - if (isServerSide()) { - if (mMetaTileEntity.dechargerSlotCount() > 0 && getStoredEU() < getEUCapacity()) { - for (int i = mMetaTileEntity.dechargerSlotStartIndex(), k = mMetaTileEntity.dechargerSlotCount()+i; i < k; i++) { - if (mMetaTileEntity.mInventory[i] != null && getStoredEU() < getEUCapacity()) { - dischargeItem(mMetaTileEntity.mInventory[i]); - if (mMetaTileEntity.mInventory[i].stackSize <= 0) mMetaTileEntity.mInventory[i] = null; - mInventoryChanged = true; - } - } - } - } - case 12: - tCode++; - if (isServerSide()) { - if (mMetaTileEntity.rechargerSlotCount() > 0 && getStoredEU() > 0) { - 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) mMetaTileEntity.mInventory[i] = null; - mInventoryChanged = true; - } - } - } - } - case 13: - tCode++; - updateStatus(); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - case 14: - tCode++; - mMetaTileEntity.onPostTick(this, mTickTimer); - if (!hasValidMetaTileEntity()) { - mRunningThroughTick = false; - return; - } - case 15: - tCode++; - if (isServerSide()) { - if (mTickTimer % 10 == 0) { - 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); - mSendClientData = false; - } - } - - if (mTickTimer > 10) { - byte tData = (byte)((mFacing&7)|(mActive?8:0)|(mRedstone?16:0)|(mLockUpgrade?32:0)); - if (tData != oTextureData) sendBlockEvent((byte)0, oTextureData = tData); - tData = mMetaTileEntity.getUpdateData(); - if (tData != oUpdateData) sendBlockEvent((byte)1, oUpdateData = tData); - 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)); - if (tData != oRedstoneData) sendBlockEvent((byte)3, oRedstoneData = tData); - if (mLightValue != oLightValue) { - worldObj.setLightValue (EnumSkyBlock.Block, xCoord , yCoord , zCoord , mLightValue); - 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 , 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); - issueTextureUpdate(); - sendBlockEvent((byte)7, oLightValue = mLightValue); - } - } - - if (mNeedsBlockUpdate) { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockOffset(0, 0, 0)); - mNeedsBlockUpdate = false; - } - } - default: - tCode = -1; - break; - }} catch (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 (isServerSide() && hasValidMetaTileEntity()) { - tTime = System.currentTimeMillis() - tTime; - if (mTimeStatistics.length > 0) mTimeStatistics[mTimeStatisticsIndex = (mTimeStatisticsIndex + 1) % mTimeStatistics.length] = (int)tTime; - if (tTime > 0 && tTime > GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING && mTickTimer > 1000 && getMetaTileEntity().doTickProfilingMessageDuringThisTick() && mLagWarningCount++<10) System.out.println("WARNING: Possible Lag Source at [" + xCoord + ", " + yCoord + ", " + zCoord + "] in Dimension " + worldObj.provider.dimensionId + " with " + tTime + "ms caused by an instance of " + getMetaTileEntity().getClass()); - } - - mWorkUpdate = mInventoryChanged = mRunningThroughTick = false; - } - - @Override - public Packet getDescriptionPacket() { - issueClientUpdate(); - return null; - } - - 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) { - issueTextureUpdate(); - if (mID != aID && aID > 0) { - mID = aID; - createNewMetatileEntity(mID); - } - - mCoverSides[0] = aCover0; - mCoverSides[1] = aCover1; - mCoverSides[2] = aCover2; - mCoverSides[3] = aCover3; - mCoverSides[4] = aCover4; - mCoverSides[5] = aCover5; - - for (byte i = 0; i < 6; i++) mCoverBehaviors[i] = GregTech_API.getCoverBehavior(mCoverSides[i]); - - receiveClientEvent(0, aTextureData); - receiveClientEvent(1, aUpdateData); - receiveClientEvent(2, aColorData); - receiveClientEvent(3, aRedstoneData); - } - - @Override - public boolean receiveClientEvent(int aEventID, int aValue) { - super.receiveClientEvent(aEventID, aValue); - - if (hasValidMetaTileEntity()) { - 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 immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - if (isClientSide()) { - issueTextureUpdate(); - switch(aEventID) { - case 0: - mFacing = (byte)(aValue& 7); - mActive = ((aValue& 8) != 0); - mRedstone = ((aValue&16) != 0); - //mLockUpgrade = ((aValue&32) != 0); - break; - case 1: - if (hasValidMetaTileEntity()) mMetaTileEntity.onValueUpdate((byte)aValue); - break; - case 2: - if (aValue > 16 || aValue < 0) aValue = 0; - mColor = (byte)aValue; - break; - case 3: - mSidedRedstone[0] = (byte)((aValue& 1)>0?15:0); - mSidedRedstone[1] = (byte)((aValue& 2)>0?15:0); - mSidedRedstone[2] = (byte)((aValue& 4)>0?15:0); - mSidedRedstone[3] = (byte)((aValue& 8)>0?15:0); - mSidedRedstone[4] = (byte)((aValue&16)>0?15:0); - mSidedRedstone[5] = (byte)((aValue&32)>0?15:0); - break; - case 4: - if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.doSound((byte)aValue, xCoord+0.5, yCoord+0.5, zCoord+0.5); - break; - case 5: - if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.startSoundLoop((byte)aValue, xCoord+0.5, yCoord+0.5, zCoord+0.5); - break; - case 6: - if (hasValidMetaTileEntity() && mTickTimer > 20) mMetaTileEntity.stopSoundLoop((byte)aValue, xCoord+0.5, yCoord+0.5, zCoord+0.5); - break; - case 7: - mLightValue = (byte)aValue; - break; - } - } - return true; - } - - public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aLogLevel) { - ArrayList<String> tList = new ArrayList<String>(); - if (aLogLevel > 2) { - tList.add("Meta-ID: " + mID + (canAccessData()?" valid":" invalid") + (mMetaTileEntity==null?" MetaTileEntity == null!":" ")); - } - if (aLogLevel > 1) { - if (mTimeStatistics.length > 0) { - double tAverageTime = 0; for (int tTime : mTimeStatistics) tAverageTime += tTime; - tList.add("This particular TileEntity has caused an average CPU-load of ~" + (tAverageTime/mTimeStatistics.length) + "ms over the last " + mTimeStatistics.length + " ticks."); - } - if (mLagWarningCount > 0) { - tList.add("This TileEntity has also 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)?" ":" not ") + "accessible for you"); - } - if (aLogLevel > 0) { - if (getSteamCapacity() > 0 && hasSteamEngineUpgrade()) tList.add(getStoredSteam() + " of " + getSteamCapacity() + " Steam"); - tList.add("Machine is " + (mActive?"active":"inactive")); - if (!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 mMetaTileEntity.getSpecialDebugInfo(this, aPlayer, aLogLevel, tList); - } - - @Override public void issueTextureUpdate() {mNeedsUpdate = true;} - @Override public void issueBlockUpdate() {mNeedsBlockUpdate = true;} - @Override public void issueClientUpdate() {mSendClientData = true;} - @Override public void issueCoverUpdate(byte aSide) {issueClientUpdate();} - - @Override public byte getStrongestRedstone() {return (byte)Math.max(getInternalInputRedstoneSignal((byte)0), Math.max(getInternalInputRedstoneSignal((byte)1), Math.max(getInternalInputRedstoneSignal((byte)2), Math.max(getInternalInputRedstoneSignal((byte)3), Math.max(getInternalInputRedstoneSignal((byte)4), getInternalInputRedstoneSignal((byte)5))))));} - - @Override public boolean getRedstone() {return getRedstone((byte)0)||getRedstone((byte)1)||getRedstone((byte)2)||getRedstone((byte)3)||getRedstone((byte)4)||getRedstone((byte)5);} - @Override public boolean getRedstone(byte aSide) {return getInternalInputRedstoneSignal(aSide) > 0;} - - public ITexture getCoverTexture(byte aSide) {return GregTech_API.sCovers.get(new GT_ItemStack(getCoverIDAtSide(aSide)));} - - @Override public boolean isGivingInformation() {if (canAccessData()) return mMetaTileEntity.isGivingInformation(); return false;} - @Override public boolean isValidFacing(byte aSide) {if (canAccessData()) return mMetaTileEntity.isFacingValid(aSide); return false;} - @Override public byte getBackFacing() {return GT_Utility.getOppositeSide(mFacing);} - @Override public byte getFrontFacing() {return mFacing;} - @Override public void setFrontFacing(byte aFacing) {if (isValidFacing(aFacing)) {mFacing = aFacing; mMetaTileEntity.onFacingChange(); onMachineBlockUpdate();}} - @Override public int getSizeInventory() {if (canAccessData()) return mMetaTileEntity.getSizeInventory(); return 0;} - @Override public ItemStack getStackInSlot(int aIndex) {if (canAccessData()) return mMetaTileEntity.getStackInSlot(aIndex); return null;} - @Override public void setInventorySlotContents(int aIndex, ItemStack aStack) {mInventoryChanged = true; if (canAccessData()) mMetaTileEntity.setInventorySlotContents(aIndex, worldObj.isRemote?aStack:GT_OreDictUnificator.setStack(true, aStack));} - @Override public String getInventoryName() {if (canAccessData()) return mMetaTileEntity.getInventoryName(); if (GregTech_API.METATILEENTITIES[mID] != null) return GregTech_API.METATILEENTITIES[mID].getInventoryName(); return "";} - @Override public int getInventoryStackLimit() {if (canAccessData()) return mMetaTileEntity.getInventoryStackLimit(); return 64;} - @Override public void openInventory() {if (canAccessData()) mMetaTileEntity.onOpenGUI();} - @Override public void closeInventory() {if (canAccessData()) mMetaTileEntity.onCloseGUI();} - @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);} - @Override public void validate() {super.validate(); mTickTimer = 0;} - @Override public void invalidate() {tileEntityInvalid = false; if (canAccessData()) {mMetaTileEntity.onRemoval(); mMetaTileEntity.setBaseMetaTileEntity(null);} super.invalidate();} - @Override public void onChunkUnload() {super.onChunkUnload();} - @Override public boolean hasCustomInventoryName() {return false;} - @Override public ItemStack getStackInSlotOnClosing(int slot) {ItemStack stack = getStackInSlot(slot); if (stack != null) setInventorySlotContents(slot, null); return stack;} - @Override public void onMachineBlockUpdate() {if (canAccessData()) mMetaTileEntity.onMachineBlockUpdate();} - @Override public int getProgress() {return canAccessData()?mMetaTileEntity.getProgresstime():0;} - @Override public int getMaxProgress() {return canAccessData()?mMetaTileEntity.maxProgresstime():0;} - @Override public boolean increaseProgress(int aProgressAmountInTicks) {return canAccessData()?mMetaTileEntity.increaseProgress(aProgressAmountInTicks)!=aProgressAmountInTicks:false;} - @Override public boolean hasThingsToDo() {return getMaxProgress()>0;} - @Override public void enableWorking() {if (!mWorks) mWorkUpdate = true; mWorks = true;} - @Override public void disableWorking() {mWorks = false;} - @Override public boolean isAllowedToWork() {return mWorks;} - @Override public boolean hasWorkJustBeenEnabled() {return mWorkUpdate;} - @Override public void setWorkDataValue(byte aValue) {mWorkData = aValue;} - @Override public byte getWorkDataValue() {return mWorkData;} - @Override public int getMetaTileID() {return mID;} - @Override public int setMetaTileID(short aID) {return mID = aID;} - @Override public boolean isActive() {return mActive;} - @Override public void setActive(boolean aActive) {mActive = aActive;} - @Override public long getTimer() {return mTickTimer;} - @Override public boolean decreaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooLessEnergy) {if (!canAccessData()) return false; return mHasEnoughEnergy = decreaseStoredEU(aEnergy, aIgnoreTooLessEnergy) || decreaseStoredSteam(aEnergy, false) || (aIgnoreTooLessEnergy && (decreaseStoredSteam(aEnergy, true)));} - @Override public boolean increaseStoredEnergyUnits(long aEnergy, boolean aIgnoreTooMuchEnergy) {if (!canAccessData()) return false; if (getStoredEU() < getEUCapacity() || aIgnoreTooMuchEnergy) {setStoredEU(mMetaTileEntity.getEUVar() + aEnergy); return true;} return false;} - @Override public boolean inputEnergyFrom(byte aSide) {if (aSide == 6) return true; if (isServerSide()) return (aSide>=0&&aSide<6?mActiveEUInputs [aSide]:false)&&!mReleaseEnergy; return isEnergyInputSide (aSide);} - @Override public boolean outputsEnergyTo(byte aSide) {if (aSide == 6) return true; if (isServerSide()) return (aSide>=0&&aSide<6?mActiveEUOutputs[aSide]:false)|| mReleaseEnergy; return isEnergyOutputSide(aSide);} - @Override public long getOutputAmperage() {if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxAmperesOut(); return 0;} - @Override public long getOutputVoltage() {if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput()) return mMetaTileEntity.maxEUOutput(); return 0;} - @Override public long getInputAmperage() {if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxAmperesIn(); return 0;} - @Override public long getInputVoltage() {if (canAccessData() && mMetaTileEntity.isElectric()) return mMetaTileEntity.maxEUInput(); return Integer.MAX_VALUE;} - @Override public boolean increaseStoredSteam(long aEnergy, boolean aIgnoreTooMuchEnergy) {if (!canAccessData()) return false; if (mMetaTileEntity.getSteamVar() < getSteamCapacity() || aIgnoreTooMuchEnergy) {setStoredSteam(mMetaTileEntity.getSteamVar() + aEnergy); return true;} return false;} - @Override public String[] getDescription() {if (canAccessData()) return mMetaTileEntity.getDescription(); return new String[0];} - @Override public boolean isValidSlot(int aIndex) {if (canAccessData()) return mMetaTileEntity.isValidSlot(aIndex); return false;} - @Override public long getUniversalEnergyStored() {return Math.max(getStoredEU(), getStoredSteam());} - @Override public long getUniversalEnergyCapacity() {return Math.max(getEUCapacity(), getSteamCapacity());} - @Override public long getStoredEU() {if (canAccessData()) return Math.min(mMetaTileEntity.getEUVar(), getEUCapacity()); return 0;} - @Override public long getEUCapacity() {if (canAccessData()) return mMetaTileEntity.maxEUStore(); return 0;} - @Override public long getStoredSteam() {if (canAccessData()) return Math.min(mMetaTileEntity.getSteamVar(), getSteamCapacity()); return 0;} - @Override public long getSteamCapacity() {if (canAccessData()) return mMetaTileEntity.maxSteamStore(); return 0;} - @Override public ITexture[] getTexture(byte aSide) {ITexture rIcon = getCoverTexture(aSide); if (rIcon != null) return new ITexture[] {rIcon}; if (hasValidMetaTileEntity()) return mMetaTileEntity.getTexture(this, aSide, mFacing, (byte)(mColor-1), mActive, getOutputRedstoneSignal(aSide)>0); return Textures.BlockIcons.ERROR_RENDERING;} - - private boolean isEnergyInputSide(byte aSide) {if (aSide >= 0 && aSide < 6) {if (!getCoverBehaviorAtSide(aSide).letsEnergyIn (aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) return false; if (isInvalid()||mReleaseEnergy) return false; if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetInput ()) return mMetaTileEntity.isInputFacing (aSide);} return false;} - private boolean isEnergyOutputSide(byte aSide) {if (aSide >= 0 && aSide < 6) {if (!getCoverBehaviorAtSide(aSide).letsEnergyOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) return false; if (isInvalid()||mReleaseEnergy) return mReleaseEnergy; if (canAccessData() && mMetaTileEntity.isElectric() && mMetaTileEntity.isEnetOutput()) return mMetaTileEntity.isOutputFacing(aSide);} return false;} - - protected boolean hasValidMetaTileEntity() {return mMetaTileEntity != null && mMetaTileEntity.getBaseMetaTileEntity() == this;} - protected boolean canAccessData() {return !isDead && hasValidMetaTileEntity();} - - public boolean setStoredEU (long aEnergy) {if (!canAccessData()) return false; if (aEnergy < 0) aEnergy = 0; mMetaTileEntity.setEUVar (aEnergy); return true;} - public boolean setStoredSteam (long aEnergy) {if (!canAccessData()) return false; if (aEnergy < 0) aEnergy = 0; mMetaTileEntity.setSteamVar (aEnergy); return true;} - public boolean decreaseStoredEU (long aEnergy, boolean aIgnoreTooLessEnergy) {if (!canAccessData()) {return false;} if (mMetaTileEntity.getEUVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) {setStoredEU(mMetaTileEntity.getEUVar() - aEnergy); if (mMetaTileEntity.getEUVar() < 0) {setStoredEU (0); return false;} return true;} return false;} - public boolean decreaseStoredSteam (long aEnergy, boolean aIgnoreTooLessEnergy) {if (!canAccessData()) return false; if (mMetaTileEntity.getSteamVar() - aEnergy >= 0 || aIgnoreTooLessEnergy) {setStoredSteam(mMetaTileEntity.getSteamVar() - aEnergy); if (mMetaTileEntity.getSteamVar() < 0) {setStoredSteam(0); return false;} return true;} return false;} - - public boolean playerOwnsThis(EntityPlayer aPlayer, boolean aCheckPrecicely) {if (!canAccessData()) return false; if (aCheckPrecicely || privateAccess() || mOwnerName.equals("")) if (mOwnerName.equals("")&&isServerSide()) setOwnerName(aPlayer.getDisplayName()); else if (privateAccess() && !aPlayer.getDisplayName().equals("Player") && !mOwnerName.equals("Player") && !mOwnerName.equals(aPlayer.getDisplayName())) return false; return true;} - public boolean privateAccess() {if (!canAccessData()) return mLockUpgrade; return mLockUpgrade || mMetaTileEntity.ownerControl();} - public void doEnergyExplosion() {if (getUniversalEnergyCapacity() > 0 && getUniversalEnergyStored() >= getUniversalEnergyCapacity()/5) {doExplosion(oOutput*(getUniversalEnergyStored() >= getUniversalEnergyCapacity()?4:getUniversalEnergyStored() >= getUniversalEnergyCapacity()/2?2:1)); GT_Mod.instance.achievements.issueAchievement(this.getWorldObj().getPlayerEntityByName(mOwnerName), "electricproblems");}} - - @Override - public void doExplosion(long aAmount) { - if (canAccessData()) { - // This is only for Electric Machines - if (GregTech_API.sMachineWireFire && mMetaTileEntity.isElectric()) { - try { - mReleaseEnergy = true; - IEnergyConnected.Util.emitEnergyToNetwork(V[5], Math.max(1, getStoredEU() / V[5]), this); - } catch(Exception e) {/* Fun Fact: all these "do nothing" Comments you see in my Code, are just there to let Eclipse shut up about the intended empty Brackets, but I need eclipse to yell at me in some of the regular Cases where I forget to add Code */} - } - mReleaseEnergy = false; - // Normal Explosion Code - mMetaTileEntity.onExplosion(); - mMetaTileEntity.doExplosion(aAmount); - } - } - - @Override - public ArrayList<ItemStack> getDrops() { - ItemStack rStack = new ItemStack(GregTech_API.sBlockMachines, 1, mID); - NBTTagCompound tNBT = new NBTTagCompound(); - if (mRecipeStuff != null && !mRecipeStuff.hasNoTags()) tNBT.setTag("GT.CraftingComponents", mRecipeStuff); - if (mMuffler ) tNBT.setBoolean ("mMuffler" , mMuffler); - if (mLockUpgrade ) tNBT.setBoolean ("mLockUpgrade" , mLockUpgrade); - if (mSteamConverter ) tNBT.setBoolean ("mSteamConverter" , mSteamConverter); - if (mColor > 0) tNBT.setByte ("mColor" , mColor); - if (mOtherUpgrades > 0) tNBT.setByte ("mOtherUpgrades" , mOtherUpgrades); - if (mStrongRedstone > 0) tNBT.setByte ("mStrongRedstone" , mStrongRedstone); - for (byte i = 0; i < mCoverSides.length; i++) { - if (mCoverSides[i] != 0) { - tNBT.setIntArray("mCoverData" , mCoverData); - tNBT.setIntArray("mCoverSides" , mCoverSides); - break; - } - } - if (hasValidMetaTileEntity()) mMetaTileEntity.setItemNBT(tNBT); - if (!tNBT.hasNoTags()) rStack.setTagCompound(tNBT); - return new ArrayList<ItemStack>(Arrays.asList(rStack)); - } - - public int getUpgradeCount() { - return (mMuffler?1:0)+(mLockUpgrade?1:0)+(mSteamConverter?1:0)+mOtherUpgrades; - } - - @Override - public boolean onRightclick(EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - if (isClientSide()) { - if (getCoverBehaviorAtSide(aSide).onCoverRightclickClient(aSide, this, aPlayer, aX, aY, aZ)) return true; - if (!getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) return false; - } - if (isServerSide()) { - if (!privateAccess() || aPlayer.getDisplayName().equalsIgnoreCase(getOwnerName())) { - ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if (tCurrentItem != null) { - 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 (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, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList)) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 200, aPlayer)) { - setCoverDataAtSide(aSide, getCoverBehaviorAtSide(aSide).onCoverScrewdriverclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)); - mMetaTileEntity.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 1.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList)) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - mInputDisabled = !mInputDisabled; - if (mInputDisabled) mOutputDisabled = !mOutputDisabled; - GT_Utility.sendChatToPlayer(aPlayer, "Auto-Input: " + (mInputDisabled?"Disabled":"Enabled") + " Auto-Output: " + (mOutputDisabled?"Disabled":"Enabled")); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(1), 1.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList)) { - if (GT_ModHandler.damageOrDechargeItem(tCurrentItem, 1, 1000, aPlayer)) { - if (mWorks) disableWorking(); else enableWorking(); - GT_Utility.sendChatToPlayer(aPlayer, "Machine Processing: " + (isAllowedToWork()?"Enabled":"Disabled")); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(101), 1.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - - if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) { - byte tSide = GT_Utility.determineWrenchingSide(aSide, aX, aY, aZ); - if (GT_ModHandler.useSolderingIron(tCurrentItem, aPlayer)) { - mStrongRedstone ^= (1 << tSide); - GT_Utility.sendChatToPlayer(aPlayer, "Redstone Output at Side " + tSide + " set to: " + ((mStrongRedstone & (1 << tSide))!=0?"Strong":"Weak")); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(103), 3.0F, -1, xCoord, yCoord, zCoord); - } - return true; - } - - if (getCoverIDAtSide(aSide) == 0) { - if (GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) { - if (GregTech_API.getCoverBehavior(tCurrentItem).isCoverPlaceable(aSide, new GT_ItemStack(tCurrentItem), this) && mMetaTileEntity.allowCoverOnSide(aSide, new GT_ItemStack(tCurrentItem))) { - setCoverItemAtSide(aSide, tCurrentItem); - if (!aPlayer.capabilities.isCreativeMode) tCurrentItem.stackSize--; - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(100), 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, GregTech_API.sSoundList.get(0), 1.0F, -1, xCoord, yCoord, zCoord); - dropCover(aSide, aSide, false); - } - return true; - } - } - } - - if (getCoverBehaviorAtSide(aSide).onCoverRightclick(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this, aPlayer, aX, aY, aZ)) return true; - - if (!getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) return false; - - if (isUpgradable() && aPlayer.inventory.getCurrentItem() != null) {/* - if (ItemList.Upgrade_SteamEngine.isStackEqual(aPlayer.inventory.getCurrentItem())) { - if (addSteamEngineUpgrade()) { - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord); - if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; - } - return true; - }*/ - if (ItemList.Upgrade_Muffler.isStackEqual(aPlayer.inventory.getCurrentItem())) { - if (addMufflerUpgrade()) { - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord); - if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; - } - return true; - } - if (ItemList.Upgrade_Lock.isStackEqual(aPlayer.inventory.getCurrentItem())) { - if (isUpgradable() && !mLockUpgrade) { - mLockUpgrade = true; - setOwnerName(aPlayer.getDisplayName()); - GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(3), 1.0F, -1, xCoord, yCoord, zCoord); - if (!aPlayer.capabilities.isCreativeMode) aPlayer.inventory.getCurrentItem().stackSize--; - } - return true; - } - } - } - } - - try { - if (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 immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - - return true; - } - - @Override - public void onLeftclick(EntityPlayer aPlayer) { - 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 immidietly to GregTech Intergalactical!!!"); - e.printStackTrace(GT_Log.err); - } - } - - @Override - public boolean isDigitalChest() { - if (canAccessData()) return mMetaTileEntity.isDigitalChest(); - return false; - } - - @Override - public ItemStack[] getStoredItemData() { - if (canAccessData()) return mMetaTileEntity.getStoredItemData(); - return null; - } - - @Override - public void setItemCount(int aCount) { - if (canAccessData()) mMetaTileEntity.setItemCount(aCount); - } - - @Override - public int getMaxItemCount() { - if (canAccessData()) return mMetaTileEntity.getMaxItemCount(); - return 0; - } - - /** - * Can put aStack into Slot - */ - @Override - public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { - return canAccessData() && mMetaTileEntity.isItemValidForSlot(aIndex, aStack); - } - - /** - * returns all valid Inventory Slots, no matter which Side (Unless it's covered). - * The Side Stuff is done in the following two Functions. - */ - @Override - public int[] getAccessibleSlotsFromSide(int aSide) { - if (canAccessData() && (getCoverBehaviorAtSide((byte)aSide).letsItemsOut((byte)aSide, getCoverIDAtSide((byte)aSide), getCoverDataAtSide((byte)aSide), -1, this) || getCoverBehaviorAtSide((byte)aSide).letsItemsIn((byte)aSide, getCoverIDAtSide((byte)aSide), getCoverDataAtSide((byte)aSide), -1, this))) return mMetaTileEntity.getAccessibleSlotsFromSide(aSide); - return new int[0]; - } - - /** - * Can put aStack into Slot at Side - */ - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && (mRunningThroughTick || !mInputDisabled ) && getCoverBehaviorAtSide((byte)aSide).letsItemsIn ((byte)aSide, getCoverIDAtSide((byte)aSide), getCoverDataAtSide((byte)aSide), aIndex, this) && mMetaTileEntity.canInsertItem(aIndex, aStack, aSide); - } - - /** - * Can pull aStack out of Slot from Side - */ - @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return canAccessData() && (mRunningThroughTick || !mOutputDisabled) && getCoverBehaviorAtSide((byte)aSide).letsItemsOut((byte)aSide, getCoverIDAtSide((byte)aSide), getCoverDataAtSide((byte)aSide), aIndex, this) && mMetaTileEntity.canExtractItem(aIndex, aStack, aSide); - } - - @Override - public boolean isUpgradable() { - return canAccessData() && getUpgradeCount() < 8; - } - - @Override - public byte getInternalInputRedstoneSignal(byte aSide) { - return (byte)(getCoverBehaviorAtSide(aSide).getRedstoneInput(aSide, getInputRedstoneSignal(aSide), getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)&15); - } - - @Override - public byte getInputRedstoneSignal(byte aSide) { - return (byte)(worldObj.getIndirectPowerLevelTo(getOffsetX(aSide, 1), getOffsetY(aSide, 1), getOffsetZ(aSide, 1), aSide)&15); - } - - @Override - public byte getOutputRedstoneSignal(byte aSide) { - return getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) ? mSidedRedstone[aSide]: 0; -// return (byte)(getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this) || (mRedstone && getCoverBehaviorAtSide(aSide).letsRedstoneGoOut(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this))?mSidedRedstone[aSide]&15:0); - } - - @Override - public void setInternalOutputRedstoneSignal(byte aSide, byte aStrength) { - if (!getCoverBehaviorAtSide(aSide).manipulatesSidedRedstoneOutput(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this)) setOutputRedstoneSignal(aSide, aStrength); - } - - @Override - public void setOutputRedstoneSignal(byte aSide, byte aStrength) { - aStrength = (byte)Math.min(Math.max(0, aStrength), 15); - if (aSide >= 0 && aSide < 6 && mSidedRedstone[aSide] != aStrength) { - mSidedRedstone[aSide] = aStrength; - issueBlockUpdate(); - } - } - - @Override - public boolean isSteamEngineUpgradable() { - return isUpgradable()&&!hasSteamEngineUpgrade()&&getSteamCapacity()>0; - } - - @Override - public boolean addSteamEngineUpgrade() { - if (isSteamEngineUpgradable()) { - issueBlockUpdate(); - mSteamConverter = true; - return true; - } - return false; - } - - @Override - public boolean hasSteamEngineUpgrade() { - if (canAccessData() && mMetaTileEntity.isSteampowered()) return true; - return mSteamConverter; - } - - @Override - public boolean hasMufflerUpgrade() { - return mMuffler; - } - - @Override - public boolean isMufflerUpgradable() { - return isUpgradable()&&!hasMufflerUpgrade(); - } - - @Override - public boolean addMufflerUpgrade() { - if (isMufflerUpgradable()) return mMuffler = true; - return false; - } - - @Override - public boolean hasInventoryBeenModified() { - return mInventoryChanged; - } - - @Override - public void setGenericRedstoneOutput(boolean aOnOff) { - mRedstone = aOnOff; - } - - @Override - public int getErrorDisplayID() { - return mDisplayErrorCode; - } - - @Override - public void setErrorDisplayID(int aErrorID) { - mDisplayErrorCode = aErrorID; - } - - @Override - public IMetaTileEntity getMetaTileEntity() { - return hasValidMetaTileEntity()?mMetaTileEntity:null; - } - - 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}; - - @Override - public GT_CoverBehavior getCoverBehaviorAtSide(byte aSide) { - return aSide >= 0 && aSide < mCoverBehaviors.length ? mCoverBehaviors[aSide] : GregTech_API.sNoBehavior; - } - - @Override - public void setCoverIDAtSide(byte aSide, int aID) { - if (aSide >= 0 && aSide < 6) { - mCoverSides[aSide] = aID; - mCoverData[aSide] = 0; - mCoverBehaviors[aSide] = GregTech_API.getCoverBehavior(aID); - issueCoverUpdate(aSide); - issueBlockUpdate(); - } - } - - @Override - public void setCoverItemAtSide(byte aSide, ItemStack aCover) { - GregTech_API.getCoverBehavior(aCover).placeCover(aSide, aCover, this); - } - - @Override - public int getCoverIDAtSide(byte aSide) { - if (aSide >= 0 && aSide < 6) return mCoverSides[aSide]; return 0; - } - - @Override - public ItemStack getCoverItemAtSide(byte aSide) { - return GT_Utility.intToStack(getCoverIDAtSide(aSide)); - } - - @Override - public boolean canPlaceCoverIDAtSide(byte aSide, int aID) { - return getCoverIDAtSide(aSide) == 0; - } - - @Override - public boolean canPlaceCoverItemAtSide(byte aSide, ItemStack aCover) { - return getCoverIDAtSide(aSide) == 0; - } - - @Override - public void setCoverDataAtSide(byte aSide, int aData) { - if (aSide >= 0 && aSide < 6) mCoverData[aSide] = aData; - } - - @Override - public int getCoverDataAtSide(byte aSide) { - if (aSide >= 0 && aSide < 6) return mCoverData[aSide]; - return 0; - } - - @Override - public void setLightValue(byte aLightValue) { - mLightValue = (byte)(aLightValue & 15); - } - - public byte getLightValue() { - return mLightValue; - } - - - @Override - public long getAverageElectricInput() { - int rEU = 0; - for (int tEU : mAverageEUInput) rEU += tEU; - return rEU / mAverageEUInput.length; - } - - @Override - public long getAverageElectricOutput() { - int rEU = 0; - for (int tEU : mAverageEUOutput) rEU += tEU; - return rEU / mAverageEUOutput.length; - } - - @Override - public boolean dropCover(byte aSide, byte aDroppedSide, boolean aForced) { - if (getCoverBehaviorAtSide(aSide).onCoverRemoval(aSide, getCoverIDAtSide(aSide), mCoverData[aSide], this, aForced) || aForced) { - ItemStack tStack = getCoverBehaviorAtSide(aSide).getDrop(aSide, getCoverIDAtSide(aSide), getCoverDataAtSide(aSide), this); - if (tStack != null) { - tStack.setTagCompound(null); - EntityItem tEntity = new EntityItem(worldObj, getOffsetX(aDroppedSide, 1) + 0.5, getOffsetY(aDroppedSide, 1) + 0.5, getOffsetZ(aDroppedSide, 1) + 0.5, tStack); - tEntity.motionX = 0; - tEntity.motionY = 0; - tEntity.motionZ = 0; - worldObj.spawnEntityInWorld(tEntity); - } - setCoverIDAtSide(aSide, 0); - if (mMetaTileEntity.hasSidedRedstoneOutputBehavior()) { - setOutputRedstoneSignal(aSide, (byte) 0); - } else { - setOutputRedstoneSignal(aSide, (byte)15); - } - return true; - } - return false; - } - - @Override - public String getOwnerName() { - if (GT_Utility.isStringInvalid(mOwnerName)) return "Player"; - return mOwnerName; - } - - @Override - public String setOwnerName(String aName) { - if (GT_Utility.isStringInvalid(aName)) return mOwnerName = "Player"; - return mOwnerName = aName; - } - - @Override - public byte getComparatorValue(byte aSide) { - return canAccessData()?mMetaTileEntity.getComparatorValue(aSide):0; - } - - @Override - public byte getStrongOutputRedstoneSignal(byte aSide) { - return aSide>=0&&aSide<6&&(mStrongRedstone & (1 << aSide))!=0?(byte)(mSidedRedstone[aSide]&15):0; - } - - @Override - public void setStrongOutputRedstoneSignal(byte aSide, byte aStrength) { - mStrongRedstone |= (1 << aSide); - setOutputRedstoneSignal(aSide, aStrength); - } - - @Override - public ItemStack decrStackSize(int aIndex, int aAmount) { - if (canAccessData()) { - mInventoryChanged = true; - return mMetaTileEntity.decrStackSize(aIndex, aAmount); - } - return null; - } - - @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 (aVoltage > getInputVoltage()) { - doExplosion(aVoltage); - return 0; - } - 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; - } - return 0; - } - - @Override - public boolean drainEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!canAccessData() || !mMetaTileEntity.isElectric() || !outputsEnergyTo(aSide) || getStoredEU() - (aVoltage*aAmperage) < mMetaTileEntity.getMinimumStoredEU()) return false; - if (decreaseStoredEU(aVoltage*aAmperage, false)) { - mAverageEUOutput[mAverageEUOutputIndex] += aVoltage*aAmperage; - return true; - } - return false; - } - - @Override - public boolean acceptsRotationalEnergy(byte aSide) { - if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false; - return mMetaTileEntity.acceptsRotationalEnergy(aSide); - } - - @Override - public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { - if (!canAccessData() || getCoverIDAtSide(aSide) != 0) return false; - return mMetaTileEntity.injectRotationalEnergy(aSide, aSpeed, aEnergy); - } - - @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (mTickTimer > 5 && canAccessData() && (mRunningThroughTick || !mInputDisabled ) && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput ((byte)aSide.ordinal()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidIn ((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((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()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidOut((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((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()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidOut((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((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()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidIn ((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((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()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidOut((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((byte)aSide.ordinal()), aFluid, this)))) return mMetaTileEntity.canDrain(aSide, aFluid); - return false; - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (canAccessData() && (aSide == ForgeDirection.UNKNOWN || (mMetaTileEntity.isLiquidInput((byte)aSide.ordinal()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidIn ((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((byte)aSide.ordinal()), null, this)) || (mMetaTileEntity.isLiquidOutput((byte)aSide.ordinal()) && getCoverBehaviorAtSide((byte)aSide.ordinal()).letsFluidOut((byte)aSide.ordinal(), getCoverIDAtSide((byte)aSide.ordinal()), getCoverDataAtSide((byte)aSide.ordinal()), null, this)))) return mMetaTileEntity.getTankInfo(aSide); - return new FluidTankInfo[] {}; - } - - public double getOutputEnergyUnitsPerTick() { return oOutput;} - public boolean isTeleporterCompatible(ForgeDirection aSide) {return canAccessData() && mMetaTileEntity.isTeleporterCompatible();} - public double demandedEnergyUnits() {if (mReleaseEnergy || !canAccessData() || !mMetaTileEntity.isEnetInput()) return 0; return getEUCapacity() - getStoredEU();} - public double injectEnergyUnits(ForgeDirection aDirection, double aAmount) {return injectEnergyUnits((byte)aDirection.ordinal(), (int)aAmount, 1)>0?0:aAmount;} - public boolean acceptsEnergyFrom(TileEntity aEmitter, ForgeDirection aDirection) {return inputEnergyFrom((byte)aDirection.ordinal());} - public boolean emitsEnergyTo(TileEntity aReceiver, ForgeDirection aDirection) {return outputsEnergyTo((byte)aDirection.ordinal());} - public double getOfferedEnergy() {return (canAccessData() && getStoredEU() - mMetaTileEntity.getMinimumStoredEU() >= oOutput)?Math.max(0, oOutput):0;} - public void drawEnergy(double amount) {mAverageEUOutput[mAverageEUOutputIndex] += amount; decreaseStoredEU((int)amount, true);} - public int injectEnergy(ForgeDirection aForgeDirection, int aAmount) {return injectEnergyUnits((byte)aForgeDirection.ordinal(), aAmount, 1)>0?0:aAmount;} - - public int addEnergy(int aEnergy) { - if (!canAccessData()) return 0; - if (aEnergy > 0) - increaseStoredEnergyUnits( aEnergy, true); - else - decreaseStoredEU(-aEnergy, true); - return (int)Math.min(Integer.MAX_VALUE, mMetaTileEntity.getEUVar()); - } - - public boolean isAddedToEnergyNet() {return false;} - public void setStored(int aEU) {if (canAccessData()) setStoredEU(aEU);} - public int demandsEnergy() {if (mReleaseEnergy || !canAccessData() || !mMetaTileEntity.isEnetInput()) return 0; return getCapacity() - getStored();} - public int getCapacity() {return (int)Math.min(Integer.MAX_VALUE, getEUCapacity());} - public int getStored() {return (int)Math.min(Integer.MAX_VALUE, Math.min(getStoredEU(), getCapacity()));} - public int getMaxSafeInput() {return (int)Math.min(Integer.MAX_VALUE, getInputVoltage());} - public int getMaxEnergyOutput() {if (mReleaseEnergy) return Integer.MAX_VALUE; return getOutput();} - public int getOutput() {return (int)Math.min(Integer.MAX_VALUE, oOutput);} - public int injectEnergy(Direction aDirection, int aAmount) {return injectEnergyUnits((byte)aDirection.toSideValue(), aAmount, 1)>0?0:aAmount;} - public boolean isTeleporterCompatible(Direction aSide) {return canAccessData() && mMetaTileEntity.isTeleporterCompatible();} - public boolean acceptsEnergyFrom(TileEntity aReceiver, Direction aDirection) {return inputEnergyFrom((byte)aDirection.toSideValue());} - public boolean emitsEnergyTo(TileEntity aReceiver, Direction aDirection) {return outputsEnergyTo((byte)aDirection.toSideValue());} - - @Override - public boolean isInvalidTileEntity() { - return isInvalid(); - } - - @Override - public boolean addStackToSlot(int aIndex, ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) return true; - if (aIndex < 0 || aIndex >= getSizeInventory()) return false; - ItemStack tStack = getStackInSlot(aIndex); - if (GT_Utility.isStackInvalid(tStack)) { - setInventorySlotContents(aIndex, aStack); - return true; - } - aStack = GT_OreDictUnificator.get(aStack); - if (GT_Utility.areStacksEqual(tStack, aStack) && tStack.stackSize + aStack.stackSize <= Math.min(aStack.getMaxStackSize(), getInventoryStackLimit())) { - tStack.stackSize+=aStack.stackSize; - return true; - } - return false; - } - - @Override - public boolean addStackToSlot(int aIndex, ItemStack aStack, int aAmount) { - return addStackToSlot(aIndex, GT_Utility.copyAmount(aAmount, aStack)); - } - - @Override - public void setMetaTileEntity(IMetaTileEntity aMetaTileEntity) { - mMetaTileEntity = (MetaTileEntity)aMetaTileEntity; - } - - @Override - public byte getColorization() { - return (byte)(mColor-1); - } - - @Override - public byte setColorization(byte aColor) { - if (aColor > 15 || aColor < -1) aColor = -1; - if (canAccessData()) mMetaTileEntity.onColorChangeServer(aColor); - return mColor = (byte)(aColor+1); - } - - @Override - public float getBlastResistance(byte aSide) { - return canAccessData()?Math.max(0, getMetaTileEntity().getExplosionResistance(aSide)):10.0F; - } - - @Override - public boolean isUniversalEnergyStored(long aEnergyAmount) { - if (getUniversalEnergyStored() >= aEnergyAmount) return true; - mHasEnoughEnergy = false; - return false; - } - - @Override - public String[] getInfoData() { - {if (canAccessData()) return getMetaTileEntity().getInfoData(); return new String[]{};} - } - - @Override - public void markDirty() { - super.markDirty(); - mInventoryChanged = true; - } - - @Override - public int getLightOpacity() { - return mMetaTileEntity == null ? getLightValue() > 0 ? 0 : 255 : mMetaTileEntity.getLightOpacity(); - } - - @Override - 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); - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - return mMetaTileEntity.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - @Override - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { - mMetaTileEntity.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/BaseMetaTileEntityUE.java b/main/java/gregtech/api/metatileentity/BaseMetaTileEntityUE.java deleted file mode 100644 index d18ddeb204..0000000000 --- a/main/java/gregtech/api/metatileentity/BaseMetaTileEntityUE.java +++ /dev/null @@ -1,98 +0,0 @@ -package gregtech.api.metatileentity; - - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * - * This file contains all the needed 'implements' of the Interfaces for the Universal Electricity Stuff. - * - * I am using the BC3 Ratio, since that is a constant in comparison to IC² Energy (1 MJ is always 2,5 EU). - */ -public class BaseMetaTileEntityUE extends BaseMetaTileEntity /*implements IUETileEntity*/ { - public BaseMetaTileEntityUE() { - super(); - } - /* - @Override - public void updateStatus() { - super.updateStatus(); - } - - @Override - public void chargeItem(ItemStack aStack) { - super.chargeItem(aStack); - float tEnergy = ElectricItemHelper.chargeItem(aStack, (float)(getOfferedEnergy() * (Compatibility.BC3_RATIO * 0.4F))); - if (tEnergy > 0) decreaseStoredEU((int)(tEnergy / (Compatibility.BC3_RATIO * 0.4F)) + 1, true); - } - - @Override - public void dischargeItem(ItemStack aStack) { - super.dischargeItem(aStack); - float tEnergy = ElectricItemHelper.dischargeItem(aStack, (float)(demandedEnergyUnits() * (Compatibility.BC3_RATIO * 0.4F))); - if (tEnergy > 0) increaseStoredEnergyUnits((int)(tEnergy / (Compatibility.BC3_RATIO * 0.4F)), true); - } - - @Override - public float receiveElectricity(ForgeDirection aSide, ElectricityPack aPacket, boolean doReceive) { - if (!getUEConsumingSides().contains(aSide)) return 0; - int aInserted = (int)(aPacket.getWatts()/(Compatibility.BC3_RATIO * 0.4F)); - if (doReceive) return injectEnergyUnits((byte)aSide.ordinal(), aInserted, 1) ? aInserted : 0; - return getEUCapacity() - getStoredEU() >= aInserted ? aInserted : 0; - } - - @Override - public ElectricityPack provideElectricity(ForgeDirection aSide, ElectricityPack aRequested, boolean doProvide) { - if (!getUEProducingSides().contains(aSide)) return null; - int aExtracted = (int)getOfferedEnergy(); - if (doProvide) return aRequested.getWatts()/(Compatibility.BC3_RATIO * 0.4F) >= getOfferedEnergy() ? decreaseStoredEU(aExtracted, false) ? new ElectricityPack(aExtracted * (Compatibility.BC3_RATIO * 0.4F), 1) : null : decreaseStoredEU((int)(aRequested.getWatts()/(Compatibility.BC3_RATIO * 0.4F)), false) ? new ElectricityPack((int)(aRequested.getWatts()/(Compatibility.BC3_RATIO * 0.4F)) * (Compatibility.BC3_RATIO * 0.4F), 1) : null; - return aRequested.getWatts()/(Compatibility.BC3_RATIO * 0.4F) >= getOfferedEnergy() ? new ElectricityPack(aExtracted * (Compatibility.BC3_RATIO * 0.4F), 1) : new ElectricityPack((int)(aRequested.getWatts()/(Compatibility.BC3_RATIO * 0.4F)) * (Compatibility.BC3_RATIO * 0.4F), 1); - } - - @Override - public float getRequest(ForgeDirection aSide) { - if (!getUEConsumingSides().contains(aSide)) return 0; - return (float)(demandedEnergyUnits() * (Compatibility.BC3_RATIO * 0.4F)); - } - - @Override - public float getProvide(ForgeDirection aSide) { - if (!getUEProducingSides().contains(aSide)) return 0; - return (float)(getOfferedEnergy() * (Compatibility.BC3_RATIO * 0.4F)); - } - - @Override - public float getVoltage() { - return (float)(getOfferedEnergy() * (Compatibility.BC3_RATIO * 0.4F)); - } - - @Override - public boolean canConnect(ForgeDirection aSide) { - return getUEProducingSides().contains(aSide) || getUEConsumingSides().contains(aSide); - } - - private EnumSet<ForgeDirection> getUEConsumingSides() { - EnumSet<ForgeDirection> rSides = EnumSet.noneOf(ForgeDirection.class); - for (byte i = 0; i < 6; i++) { - if (inputEnergyFrom(i)) { - Object tTileEntity = getTileEntityAtSide(i); - if (tTileEntity != null && tTileEntity instanceof IConductor) { - rSides.add(ForgeDirection.getOrientation(i)); - } - } - } - return rSides; - } - - private EnumSet<ForgeDirection> getUEProducingSides() { - EnumSet<ForgeDirection> rSides = EnumSet.noneOf(ForgeDirection.class); - for (byte i = 0; i < 6; i++) { - if (outputsEnergyTo(i)) { - Object tTileEntity = getTileEntityAtSide(i); - if (tTileEntity != null && tTileEntity instanceof IConductor) { - rSides.add(ForgeDirection.getOrientation(i)); - } - } - } - return rSides; - }*/ -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/BaseTileEntity.java b/main/java/gregtech/api/metatileentity/BaseTileEntity.java deleted file mode 100644 index d8a798d19e..0000000000 --- a/main/java/gregtech/api/metatileentity/BaseTileEntity.java +++ /dev/null @@ -1,227 +0,0 @@ -package gregtech.api.metatileentity; - -import static gregtech.api.enums.GT_Values.GT; -import static gregtech.api.enums.GT_Values.NW; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; -import gregtech.api.net.GT_Packet_Block_Event; -import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.inventory.IInventory; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.IFluidHandler; - -/** - * The Functions my old TileEntities and my BaseMetaTileEntities have in common. - * - * Basically everything a TileEntity should have. - */ -public abstract class BaseTileEntity extends TileEntity implements IHasWorldObjectAndCoords { - /** - * If this TileEntity checks for the Chunk to be loaded before returning World based values. - * The AdvPump hacks this to false to ensure everything runs properly even when far Chunks are not actively loaded. - * But anything else should not cause worfin' Chunks, uhh I mean orphan Chunks. - */ - public boolean ignoreUnloadedChunks = true; - - /** - * This Variable checks if this TileEntity is dead, because Minecraft is too stupid to have proper TileEntity unloading. - */ - public boolean isDead = false; - - /** - * Buffers adjacent TileEntities for faster access - * - * "this" means that there is no TileEntity, while "null" means that it doesn't know if there is even a TileEntity and still needs to check that if needed. - */ - private final TileEntity[] mBufferedTileEntities = new TileEntity[6]; - - private final void clearNullMarkersFromTileEntityBuffer() { - for (int i = 0; i < mBufferedTileEntities.length; i++) if (mBufferedTileEntities[i] == this) mBufferedTileEntities[i] = null; - } - - /** - * Called automatically when the Coordinates of this TileEntity have been changed - */ - protected final void clearTileEntityBuffer() { - for (int i = 0; i < mBufferedTileEntities.length; i++) mBufferedTileEntities[i] = null; - } - - @Override public final World getWorld () {return worldObj;} - @Override public final int getXCoord() {return xCoord;} - @Override public final short getYCoord() {return (short)yCoord;} - @Override public final int getZCoord() {return zCoord;} - @Override public final int getOffsetX(byte aSide, int aMultiplier) {return xCoord + ForgeDirection.getOrientation(aSide).offsetX * aMultiplier ;} - @Override public final short getOffsetY(byte aSide, int aMultiplier) {return (short)(yCoord + ForgeDirection.getOrientation(aSide).offsetY * aMultiplier);} - @Override public final int getOffsetZ(byte aSide, int aMultiplier) {return zCoord + ForgeDirection.getOrientation(aSide).offsetZ * aMultiplier ;} - @Override public final boolean isServerSide() {return !worldObj.isRemote;} - @Override public final boolean isClientSide() {return worldObj.isRemote;} - @Override public final boolean openGUI(EntityPlayer aPlayer) {return openGUI(aPlayer, 0);} - @Override public final boolean openGUI(EntityPlayer aPlayer, int aID) {if (aPlayer == null) return false; aPlayer.openGui(GT, aID, worldObj, xCoord, yCoord, zCoord); return true;} - @Override public final int getRandomNumber(int aRange) {return worldObj.rand.nextInt(aRange);} - @Override public final BiomeGenBase getBiome(int aX, int aZ) {return worldObj.getBiomeGenForCoords(aX, aZ);} - @Override public final BiomeGenBase getBiome() {return getBiome(xCoord, zCoord);} - @Override public final Block getBlockOffset(int aX, int aY, int aZ) {return getBlock(xCoord+aX, yCoord+aY, zCoord+aZ);} - @Override public final Block getBlockAtSide(byte aSide) {return getBlockAtSideAndDistance(aSide, 1);} - @Override public final Block getBlockAtSideAndDistance(byte aSide, int aDistance) {return getBlock(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance));} - @Override public final byte getMetaIDOffset(int aX, int aY, int aZ) {return getMetaID(xCoord+aX, yCoord+aY, zCoord+aZ);} - @Override public final byte getMetaIDAtSide(byte aSide) {return getMetaIDAtSideAndDistance(aSide, 1);} - @Override public final byte getMetaIDAtSideAndDistance(byte aSide, int aDistance) {return getMetaID(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance));} - @Override public final byte getLightLevelOffset(int aX, int aY, int aZ) {return getLightLevel(xCoord+aX, yCoord+aY, zCoord+aZ);} - @Override public final byte getLightLevelAtSide(byte aSide) {return getLightLevelAtSideAndDistance(aSide, 1);} - @Override public final byte getLightLevelAtSideAndDistance(byte aSide, int aDistance) {return getLightLevel(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance));} - @Override public final boolean getOpacityOffset(int aX, int aY, int aZ) {return getOpacity(xCoord+aX, yCoord+aY, zCoord+aZ);} - @Override public final boolean getOpacityAtSide(byte aSide) {return getOpacityAtSideAndDistance(aSide, 1);} - @Override public final boolean getOpacityAtSideAndDistance(byte aSide, int aDistance) {return getOpacity(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance));} - @Override public final boolean getSkyOffset(int aX, int aY, int aZ) {return getSky(xCoord+aX, yCoord+aY, zCoord+aZ);} - @Override public final boolean getSkyAtSide(byte aSide) {return getSkyAtSideAndDistance(aSide, 1);} - @Override public final boolean getSkyAtSideAndDistance(byte aSide, int aDistance) {return getSky(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance));} - @Override public final boolean getAirOffset(int aX, int aY, int aZ) {return getAir(xCoord+aX, yCoord+aY, zCoord+aZ);} - @Override public final boolean getAirAtSide(byte aSide) {return getAirAtSideAndDistance(aSide, 1);} - @Override public final boolean getAirAtSideAndDistance(byte aSide, int aDistance) {return getAir(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance));} - @Override public final TileEntity getTileEntityOffset(int aX, int aY, int aZ) {return getTileEntity(xCoord+aX, yCoord+aY, zCoord+aZ);} - @Override public final TileEntity getTileEntityAtSideAndDistance(byte aSide, int aDistance) {if (aDistance == 1) return getTileEntityAtSide(aSide); return getTileEntity(getOffsetX(aSide, aDistance), getOffsetY(aSide, aDistance), getOffsetZ(aSide, aDistance));} - @Override public final IInventory getIInventory(int aX, int aY, int aZ) {TileEntity tTileEntity = getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IInventory) return (IInventory)tTileEntity; return null;} - @Override public final IInventory getIInventoryOffset(int aX, int aY, int aZ) {TileEntity tTileEntity = getTileEntityOffset(aX, aY, aZ); if (tTileEntity instanceof IInventory) return (IInventory)tTileEntity; return null;} - @Override public final IInventory getIInventoryAtSide(byte aSide) {TileEntity tTileEntity = getTileEntityAtSide(aSide); if (tTileEntity instanceof IInventory) return (IInventory)tTileEntity; return null;} - @Override public final IInventory getIInventoryAtSideAndDistance(byte aSide, int aDistance) {TileEntity tTileEntity = getTileEntityAtSideAndDistance(aSide, aDistance); if (tTileEntity instanceof IInventory) return (IInventory)tTileEntity; return null;} - @Override public final IFluidHandler getITankContainer(int aX, int aY, int aZ) {TileEntity tTileEntity = getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IFluidHandler) return (IFluidHandler)tTileEntity; return null;} - @Override public final IFluidHandler getITankContainerOffset(int aX, int aY, int aZ) {TileEntity tTileEntity = getTileEntityOffset(aX, aY, aZ); if (tTileEntity instanceof IFluidHandler) return (IFluidHandler)tTileEntity; return null;} - @Override public final IFluidHandler getITankContainerAtSide(byte aSide) {TileEntity tTileEntity = getTileEntityAtSide(aSide); if (tTileEntity instanceof IFluidHandler) return (IFluidHandler)tTileEntity; return null;} - @Override public final IFluidHandler getITankContainerAtSideAndDistance(byte aSide, int aDistance) {TileEntity tTileEntity = getTileEntityAtSideAndDistance(aSide, aDistance); if (tTileEntity instanceof IFluidHandler) return (IFluidHandler)tTileEntity; return null;} - @Override public final IGregTechTileEntity getIGregTechTileEntity(int aX, int aY, int aZ) {TileEntity tTileEntity = getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity) return (IGregTechTileEntity)tTileEntity; return null;} - @Override public final IGregTechTileEntity getIGregTechTileEntityOffset(int aX, int aY, int aZ) {TileEntity tTileEntity = getTileEntityOffset(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity) return (IGregTechTileEntity)tTileEntity; return null;} - @Override public final IGregTechTileEntity getIGregTechTileEntityAtSide(byte aSide) {TileEntity tTileEntity = getTileEntityAtSide(aSide); if (tTileEntity instanceof IGregTechTileEntity) return (IGregTechTileEntity)tTileEntity; return null;} - @Override public final IGregTechTileEntity getIGregTechTileEntityAtSideAndDistance(byte aSide, int aDistance) {TileEntity tTileEntity = getTileEntityAtSideAndDistance(aSide, aDistance); if (tTileEntity instanceof IGregTechTileEntity) return (IGregTechTileEntity)tTileEntity; return null;} - - @Override - public final Block getBlock(int aX, int aY, int aZ) { - if (ignoreUnloadedChunks && crossedChunkBorder(aX, aZ) && !worldObj.blockExists(aX, aY, aZ)) return Blocks.air; - return worldObj.getBlock(aX, aY, aZ); - } - - @Override - public final byte getMetaID(int aX, int aY, int aZ) { - if (ignoreUnloadedChunks && crossedChunkBorder(aX, aZ) && !worldObj.blockExists(aX, aY, aZ)) return 0; - return (byte)worldObj.getBlockMetadata(aX, aY, aZ); - } - - @Override - public final byte getLightLevel(int aX, int aY, int aZ) { - if (ignoreUnloadedChunks && crossedChunkBorder(aX, aZ) && !worldObj.blockExists(aX, aY, aZ)) return 0; - return (byte)(worldObj.getLightBrightness(aX, aY, aZ)*15); - } - - @Override - public final boolean getSky(int aX, int aY, int aZ) { - if (ignoreUnloadedChunks && crossedChunkBorder(aX, aZ) && !worldObj.blockExists(aX, aY, aZ)) return true; - return worldObj.canBlockSeeTheSky(aX, aY, aZ); - } - - @Override - public final boolean getOpacity(int aX, int aY, int aZ) { - if (ignoreUnloadedChunks && crossedChunkBorder(aX, aZ) && !worldObj.blockExists(aX, aY, aZ)) return false; - return GT_Utility.isOpaqueBlock(worldObj, aX, aY, aZ); - } - - @Override - public final boolean getAir(int aX, int aY, int aZ) { - if (ignoreUnloadedChunks && crossedChunkBorder(aX, aZ) && !worldObj.blockExists(aX, aY, aZ)) return true; - return GT_Utility.isBlockAir(worldObj, aX, aY, aZ); - } - - @Override - public final TileEntity getTileEntity(int aX, int aY, int aZ) { - if (ignoreUnloadedChunks && crossedChunkBorder(aX, aZ) && !worldObj.blockExists(aX, aY, aZ)) return null; - return worldObj.getTileEntity(aX, aY, aZ); - } - - @Override - public final TileEntity getTileEntityAtSide(byte aSide) { - if (aSide < 0 || aSide >= 6 || mBufferedTileEntities[aSide] == this) return null; - int tX = getOffsetX(aSide, 1), tY = getOffsetY(aSide, 1), tZ = getOffsetZ(aSide, 1); - if (crossedChunkBorder(tX, tZ)) { - mBufferedTileEntities[aSide] = null; - if (ignoreUnloadedChunks && !worldObj.blockExists(tX, tY, tZ)) return null; - } - if (mBufferedTileEntities[aSide] == null) { - mBufferedTileEntities[aSide] = worldObj.getTileEntity(tX, tY, tZ); - if (mBufferedTileEntities[aSide] == null) { - mBufferedTileEntities[aSide] = this; - return null; - } - return mBufferedTileEntities[aSide]; - } - if (mBufferedTileEntities[aSide].isInvalid()) { - mBufferedTileEntities[aSide] = null; - return getTileEntityAtSide(aSide); - } - if (mBufferedTileEntities[aSide].xCoord == tX && mBufferedTileEntities[aSide].yCoord == tY && mBufferedTileEntities[aSide].zCoord == tZ) { - return mBufferedTileEntities[aSide]; - } - return null; - } - - @Override - public void writeToNBT(NBTTagCompound aNBT) { - super.writeToNBT(aNBT); - //isDead = true; - } - - @Override - public boolean isDead() { - return isDead || isInvalidTileEntity(); - } - - @Override - public void validate() { - clearNullMarkersFromTileEntityBuffer(); - super.validate(); - } - - @Override - public void invalidate() { - clearNullMarkersFromTileEntityBuffer(); - super.invalidate(); - } - - @Override - public void onChunkUnload() { - clearNullMarkersFromTileEntityBuffer(); - super.onChunkUnload(); - isDead = true; - } - - @Override - public void updateEntity() { - // Well if the TileEntity gets ticked it is alive. - isDead = false; - } - - public final void onAdjacentBlockChange(int aX, int aY, int aZ) { - clearNullMarkersFromTileEntityBuffer(); - } - - @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); - } - - private boolean crossedChunkBorder(int aX, int aZ) { - return aX >> 4 != xCoord >> 4 || aZ >> 4 != zCoord >> 4; - } - - public final void setOnFire() { - GT_Utility.setCoordsOnFire(worldObj, xCoord, yCoord, zCoord, false); - } - - public final void setToFire() { - worldObj.setBlock(xCoord, yCoord, zCoord, Blocks.fire); - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/main/java/gregtech/api/metatileentity/MetaPipeEntity.java deleted file mode 100644 index d82a23b6d7..0000000000 --- a/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ /dev/null @@ -1,534 +0,0 @@ -package gregtech.api.metatileentity; - -import static gregtech.api.enums.GT_Values.GT; -import static gregtech.api.enums.GT_Values.V; -import gregtech.api.GregTech_API; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_Config; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Utility; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * - * Extend this Class to add a new MetaPipe - * Call the Constructor with the desired ID at the load-phase (not preload and also not postload!) - * Implement the newMetaEntity-Method to return a new ready instance of your MetaTileEntity - * - * Call the Constructor like the following example inside the Load Phase, to register it. - * "new GT_MetaTileEntity_E_Furnace(54, "GT_E_Furnace", "Automatic E-Furnace");" - */ -public abstract class MetaPipeEntity implements IMetaTileEntity { - /** - * This variable tells, which directions the Block is connected to. It is a Bitmask. - */ - public byte mConnections = 0; - - /** - * For Pipe Rendering - */ - public abstract float getThickNess(); - - /** - * For Pipe Rendering - */ - public abstract boolean renderInside(byte aSide); - - /** - * Only assigned for the MetaTileEntity in the List! Also only used to get the localized Name for the ItemStack and for getInvName. - */ - public String mName; - - public boolean doTickProfilingInThisTick = true; - - /** - * accessibility to this Field is no longer given, see below - */ - private IGregTechTileEntity mBaseMetaTileEntity; - - @Override - public IGregTechTileEntity getBaseMetaTileEntity() { - return mBaseMetaTileEntity; - } - - @Override - public ItemStack getStackForm(long aAmount) { - return new ItemStack(GregTech_API.sBlockMachines, (int)aAmount, getBaseMetaTileEntity().getMetaTileID()); - } - - /** - * The Inventory of the MetaTileEntity. Amount of Slots can be larger than 256. HAYO! - */ - public final ItemStack[] mInventory; - - /** - * This registers your Machine at the List. - * Use only ID's larger than 2048, because i reserved these ones. - * See also the List in the API, as it has a Description containing all the reservations. - * @param aID the ID - * @example for Constructor overload. - * - * public GT_MetaTileEntity_EBench(int aID, String mName, String mNameRegional) { - * super(aID, mName, mNameRegional); - * } - */ - public MetaPipeEntity(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { - if (GregTech_API.sPostloadStarted || !GregTech_API.sPreloadStarted) throw new IllegalAccessError("This Constructor has to be called in the load Phase"); - if (GregTech_API.METATILEENTITIES[aID] == null) { - GregTech_API.METATILEENTITIES[aID] = this; - } else { - throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!"); - } - mName = aBasicName.replaceAll(" ", "_").toLowerCase(); - setBaseMetaTileEntity(new BaseMetaPipeEntity()); - getBaseMetaTileEntity().setMetaTileID((short)aID); - GT_LanguageManager.addStringLocalization("gt.blockmachines." + mName + ".name", aRegionalName); - mInventory = new ItemStack[aInvSlotCount]; - - if (GT.isClientSide()) { - ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID); - tStack.getItem().addInformation(tStack, null, new ArrayList<String>(), true); - } - } - - @Override - public void setBaseMetaTileEntity(IGregTechTileEntity aBaseMetaTileEntity) { - if (mBaseMetaTileEntity != null && aBaseMetaTileEntity == null) { - mBaseMetaTileEntity.getMetaTileEntity().inValidate(); - mBaseMetaTileEntity.setMetaTileEntity(null); - } - mBaseMetaTileEntity = aBaseMetaTileEntity; - if (mBaseMetaTileEntity != null) { - mBaseMetaTileEntity.setMetaTileEntity(this); - } - } - - /** - * This is the normal Constructor. - */ - public MetaPipeEntity(String aName, int aInvSlotCount) { - mInventory = new ItemStack[aInvSlotCount]; - mName = aName; - } - - @Override - public void onServerStart() {/*Do nothing*/} - @Override - public void onWorldSave(File aSaveDirectory) {/*Do nothing*/} - @Override - public void onWorldLoad(File aSaveDirectory) {/*Do nothing*/} - @Override - public void onConfigLoad(GT_Config aConfig) {/*Do nothing*/} - @Override - public void setItemNBT(NBTTagCompound aNBT) {/*Do nothing*/} - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister aBlockIconRegister) {/*Do nothing*/} - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) {return true;} - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {/*Do nothing*/} - @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {return false;} - @Override - public void onExplosion() {/*Do nothing*/} - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {/*Do nothing*/} - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} - @Override - public void inValidate() {/*Do nothing*/} - @Override - public void onRemoval() {/*Do nothing*/} - @Override - public void initDefaultModes(NBTTagCompound aNBT) {/*Do nothing*/} - - /** - * When a GUI is opened - */ - public void onOpenGUI() {/*Do nothing*/} - - /** - * When a GUI is closed - */ - public void onCloseGUI() {/*Do nothing*/} - - /** - * a Player rightclicks the Machine - * Sneaky rightclicks are not getting passed to this! - */ - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) {return false;} - @Override - public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {/*Do nothing*/} - @Override - public void onValueUpdate(byte aValue) {/*Do nothing*/} - @Override - public byte getUpdateData() {return 0;} - - @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/} - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/} - @Override - public void stopSoundLoop(byte aValue, double aX, double aY, double aZ) {/*Do nothing*/} - - @Override - public final void sendSound(byte aIndex) {if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte)4, aIndex);} - @Override - public final void sendLoopStart(byte aIndex) {if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte)5, aIndex);} - @Override - public final void sendLoopEnd(byte aIndex) {if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte)6, aIndex);} - - @Override - public boolean isFacingValid(byte aFacing) {return false;} - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override - public boolean isValidSlot(int aIndex) {return true;} - @Override - public boolean setStackToZeroInsteadOfNull(int aIndex) {return false;} - - @Override - public ArrayList<String> getSpecialDebugInfo(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, int aLogLevel, ArrayList<String> aList) { - return aList; - } - - @Override - public boolean isLiquidInput(byte aSide) { - return true; - } - - @Override - public boolean isLiquidOutput(byte aSide) { - return true; - } - - /** - * gets the contained Liquid - */ - @Override - public FluidStack getFluid() {return null;} - - /** - * tries to fill this Tank - */ - @Override - public int fill(FluidStack resource, boolean doFill) {return 0;} - - /** - * tries to empty this Tank - */ - @Override - public FluidStack drain(int maxDrain, boolean doDrain) {return null;} - - /** - * Tank pressure - */ - public int getTankPressure() {return 0;} - - /** - * Liquid Capacity - */ - @Override - public int getCapacity() {return 0;} - - /** - * Progress this machine has already made - */ - public int getProgresstime() {return 0;} - - /** - * Progress this Machine has to do to produce something - */ - public int maxProgresstime() {return 0;} - - /** - * Increases the Progress, returns the overflown Progress. - */ - public int increaseProgress(int aProgress) {return 0;} - - @Override - public void onMachineBlockUpdate() {/*Do nothing*/} - @Override - public void receiveClientEvent(byte aEventID, byte aValue) {/*Do nothing*/} - @Override - public boolean isSimpleMachine() {return false;} - - @Override - public byte getComparatorValue(byte aSide) { - return 0; - } - - @Override - public boolean acceptsRotationalEnergy(byte aSide) { - return false; - } - - @Override - public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { - return false; - } - - @Override - public String getSpecialVoltageToolTip() {return null;} - - @Override - public boolean isGivingInformation() {return false;} - @Override - public String[] getInfoData() {return new String[]{};} - - public boolean isDigitalChest() {return false;} - public ItemStack[] getStoredItemData() {return null;} - public void setItemCount(int aCount) {/*Do nothing*/} - public int getMaxItemCount() {return 0;} - - @Override - public int getSizeInventory() {return mInventory.length;} - @Override - public ItemStack getStackInSlot(int aIndex) {if (aIndex >= 0 && aIndex < mInventory.length) return mInventory[aIndex]; return null;} - @Override - public void setInventorySlotContents(int aIndex, ItemStack aStack) {if (aIndex >= 0 && aIndex < mInventory.length) mInventory[aIndex] = aStack;} - @Override - public String getInventoryName() {if (GregTech_API.METATILEENTITIES[getBaseMetaTileEntity().getMetaTileID()] != null) return GregTech_API.METATILEENTITIES[getBaseMetaTileEntity().getMetaTileID()].getMetaName(); return "";} - @Override - public int getInventoryStackLimit() {return 64;} - @Override - public boolean isItemValidForSlot(int aIndex, ItemStack aStack) {return getBaseMetaTileEntity().isValidSlot(aIndex);} - - @Override - public ItemStack decrStackSize(int aIndex, int aAmount) { - ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copy(tStack); - if (tStack != null) { - if (tStack.stackSize <= aAmount) { - if (setStackToZeroInsteadOfNull(aIndex)) tStack.stackSize = 0; else setInventorySlotContents(aIndex, null); - } else { - rStack = tStack.splitStack(aAmount); - if (tStack.stackSize == 0 && !setStackToZeroInsteadOfNull(aIndex)) setInventorySlotContents(aIndex, null); - } - } - return rStack; - } - - @Override - public int[] getAccessibleSlotsFromSide(int aSide) { - ArrayList<Integer> tList = new ArrayList<Integer>(); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity(); - boolean tSkip = tTileEntity.getCoverBehaviorAtSide((byte)aSide).letsItemsIn((byte)aSide, tTileEntity.getCoverIDAtSide((byte)aSide), tTileEntity.getCoverDataAtSide((byte)aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte)aSide).letsItemsOut((byte)aSide, tTileEntity.getCoverIDAtSide((byte)aSide), tTileEntity.getCoverDataAtSide((byte)aSide), -2, tTileEntity); - for (int i = 0; i < getSizeInventory(); i++) if (isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSide((byte)aSide).letsItemsOut((byte)aSide, tTileEntity.getCoverIDAtSide((byte)aSide), tTileEntity.getCoverDataAtSide((byte)aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte)aSide).letsItemsIn((byte)aSide, tTileEntity.getCoverIDAtSide((byte)aSide), tTileEntity.getCoverDataAtSide((byte)aSide), i, tTileEntity))) tList.add(i); - int[] rArray = new int[tList.size()]; - for (int i = 0; i < rArray.length; i++) rArray[i] = tList.get(i); - return rArray; - } - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && (mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, mInventory[aIndex])) && allowPutStack(getBaseMetaTileEntity(), aIndex, (byte)aSide, aStack); - } - - @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && allowPullStack(getBaseMetaTileEntity(), aIndex, (byte)aSide, aStack); - } - - @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - return fill(aSide, new FluidStack(aFluid, 1), false) == 1; - } - - @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - return drain(aSide, new FluidStack(aFluid, 1), false) != null; - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[] {}; - return new FluidTankInfo[] {getInfo()}; - } - - public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - return fill(aFluid, doFill); - } - - @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - return fill_default(aSide, aFluid, doFill); - } - - @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { - if (getFluid() != null && aFluid != null && getFluid().isFluidEqual(aFluid)) return drain(aFluid.amount, doDrain); - return null; - } - - @Override - public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { - return drain(maxDrain, doDrain); - } - - @Override - public int getFluidAmount() { - return 0; - } - - @Override - public FluidTankInfo getInfo() { - return new FluidTankInfo(this); - } - - @Override - public String getMetaName() { - return mName; - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return null; - } - - @Override - public boolean doTickProfilingMessageDuringThisTick() { - return doTickProfilingInThisTick; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return false; - } - - @Override - public boolean connectsToItemPipe(byte aSide) { - return false; - } - - @Override - public void openInventory() { - // - } - - @Override - public void closeInventory() { - // - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public float getExplosionResistance(byte aSide) { - return 10.0F; - } - - @Override - public ItemStack[] getRealInventory() { - return mInventory; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public void markDirty() { - // - } - - @Override - public void onColorChangeServer(byte aColor) { - // - } - - @Override - public void onColorChangeClient(byte aColor) { - // - } - - public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - return 0; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean renderInInventory(Block aBlock, int aMeta, RenderBlocks aRenderer) { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean renderInWorld(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { - return false; - } - - @Override - public void doExplosion(long aExplosionPower) { - float tStrength = aExplosionPower<V[0]?1.0F:aExplosionPower<V[1]?2.0F:aExplosionPower<V[2]?3.0F:aExplosionPower<V[3]?4.0F:aExplosionPower<V[4]?5.0F:aExplosionPower<V[4]*2?6.0F:aExplosionPower<V[5]?7.0F:aExplosionPower<V[6]?8.0F:aExplosionPower<V[7]?9.0F:10.0F; - int tX=getBaseMetaTileEntity().getXCoord(), tY=getBaseMetaTileEntity().getYCoord(), tZ=getBaseMetaTileEntity().getZCoord(); - World tWorld = getBaseMetaTileEntity().getWorld(); - tWorld.setBlock(tX, tY, tZ, Blocks.air); - if (GregTech_API.sMachineExplosions) tWorld.createExplosion(null, tX+0.5, tY+0.5, tZ+0.5, tStrength, true); - } - - @Override - public int getLightOpacity() { - return 0; - } - - @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) { - AxisAlignedBB axisalignedbb1 = getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - if (axisalignedbb1 != null && inputAABB.intersectsWith(axisalignedbb1)) outputAABB.add(axisalignedbb1); - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX+1, aY+1, aZ+1); - } - - @Override - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { - // - } - - @Override - public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - // - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/main/java/gregtech/api/metatileentity/MetaTileEntity.java deleted file mode 100644 index ab2c3930f5..0000000000 --- a/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ /dev/null @@ -1,721 +0,0 @@ -package gregtech.api.metatileentity; - -import static gregtech.api.enums.GT_Values.GT; -import static gregtech.api.enums.GT_Values.V; -import gregtech.api.GregTech_API; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_Config; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * - * Extend this Class to add a new MetaMachine - * Call the Constructor with the desired ID at the load-phase (not preload and also not postload!) - * Implement the newMetaEntity-Method to return a new ready instance of your MetaTileEntity - * - * Call the Constructor like the following example inside the Load Phase, to register it. - * "new GT_MetaTileEntity_E_Furnace(54, "GT_E_Furnace", "Automatic E-Furnace");" - */ -public abstract class MetaTileEntity implements IMetaTileEntity { - /** - * Only assigned for the MetaTileEntity in the List! Also only used to get the localized Name for the ItemStack and for getInvName. - */ - public final String mName; - - public boolean doTickProfilingInThisTick = true; - - /** - * accessibility to this Field is no longer given, see below - */ - private IGregTechTileEntity mBaseMetaTileEntity; - - @Override - public IGregTechTileEntity getBaseMetaTileEntity() { - return mBaseMetaTileEntity; - } - - @Override - public ItemStack getStackForm(long aAmount) { - return new ItemStack(GregTech_API.sBlockMachines, (int)aAmount, getBaseMetaTileEntity().getMetaTileID()); - } - - public String getLocalName() { - return GT_LanguageManager.getTranslation("gt.blockmachines." + mName + ".name"); - } - - /** - * The Inventory of the MetaTileEntity. Amount of Slots can be larger than 256. HAYO! - */ - public final ItemStack[] mInventory; - - /** - * This registers your Machine at the List. - * Use only ID's larger than 2048, because i reserved these ones. - * See also the List in the API, as it has a Description containing all the reservations. - * @param aID the ID - * @example for Constructor overload. - * - * public GT_MetaTileEntity_EBench(int aID, String mName, String mNameRegional) { - * super(aID, mName, mNameRegional); - * } - */ - public MetaTileEntity(int aID, String aBasicName, String aRegionalName, int aInvSlotCount) { - if (GregTech_API.sPostloadStarted || !GregTech_API.sPreloadStarted) throw new IllegalAccessError("This Constructor has to be called in the load Phase"); - if (GregTech_API.METATILEENTITIES[aID] == null) { - GregTech_API.METATILEENTITIES[aID] = this; - } else { - throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!"); - } - mName = aBasicName.replaceAll(" ", "_").toLowerCase(); - setBaseMetaTileEntity(GregTech_API.constructBaseMetaTileEntity()); - getBaseMetaTileEntity().setMetaTileID((short)aID); - GT_LanguageManager.addStringLocalization("gt.blockmachines." + mName + ".name", aRegionalName); - mInventory = new ItemStack[aInvSlotCount]; - - if (GT.isClientSide()) { - ItemStack tStack = new ItemStack(GregTech_API.sBlockMachines, 1, aID); - tStack.getItem().addInformation(tStack, null, new ArrayList<String>(), true); - } - } - - @Override - public void setBaseMetaTileEntity(IGregTechTileEntity aBaseMetaTileEntity) { - if (mBaseMetaTileEntity != null && aBaseMetaTileEntity == null) { - mBaseMetaTileEntity.getMetaTileEntity().inValidate(); - mBaseMetaTileEntity.setMetaTileEntity(null); - } - mBaseMetaTileEntity = aBaseMetaTileEntity; - if (mBaseMetaTileEntity != null) { - mBaseMetaTileEntity.setMetaTileEntity(this); - } - } - - /** - * This is the normal Constructor. - */ - public MetaTileEntity(String aName, int aInvSlotCount) { - mInventory = new ItemStack[aInvSlotCount]; - mName = aName; - } - - @Override - public void onServerStart() {/*Do nothing*/} - @Override - public void onWorldSave(File aSaveDirectory) {/*Do nothing*/} - @Override - public void onWorldLoad(File aSaveDirectory) {/*Do nothing*/} - @Override - public void onConfigLoad(GT_Config aConfig) {/*Do nothing*/} - @Override - public void setItemNBT(NBTTagCompound aNBT) {/*Do nothing*/} - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister aBlockIconRegister) {/*Do nothing*/} - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) {return true;} - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {/*Do nothing*/} - @Override - public boolean onWrenchRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {if (getBaseMetaTileEntity().isValidFacing(aWrenchingSide)) {getBaseMetaTileEntity().setFrontFacing(aWrenchingSide); return true;} return false;} - @Override - public void onExplosion() {/*Do nothing*/} - @Override - public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {/*Do nothing*/} - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} - @Override - public void inValidate() {/*Do nothing*/} - @Override - public void onRemoval() {/*Do nothing*/} - @Override - public void initDefaultModes(NBTTagCompound aNBT) {/*Do nothing*/} - - /** - * When a GUI is opened - */ - public void onOpenGUI() {/*Do nothing*/} - - /** - * When a GUI is closed - */ - public void onCloseGUI() {/*Do nothing*/} - - /** - * a Player rightclicks the Machine - * Sneaky rightclicks are not getting passed to this! - */ - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {return false;} - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) {return onRightclick(aBaseMetaTileEntity, aPlayer);} - @Override - public void onLeftclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) {/*Do nothing*/} - @Override - public void onValueUpdate(byte aValue) {/*Do nothing*/} - @Override - public byte getUpdateData() {return 0;} - - @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/} - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) {/*Do nothing*/} - @Override - public void stopSoundLoop(byte aValue, double aX, double aY, double aZ) {/*Do nothing*/} - - @Override - public final void sendSound(byte aIndex) {if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte)4, aIndex);} - @Override - public final void sendLoopStart(byte aIndex) {if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte)5, aIndex);} - @Override - public final void sendLoopEnd(byte aIndex) {if (!getBaseMetaTileEntity().hasMufflerUpgrade()) getBaseMetaTileEntity().sendBlockEvent((byte)6, aIndex);} - - /** - * @return true if this Device emits Energy at all - */ - public boolean isElectric() {return true;} - - /** - * @return true if this Device emits Energy at all - */ - public boolean isPneumatic() {return false;} - - /** - * @return true if this Device emits Energy at all - */ - public boolean isSteampowered() {return false;} - - /** - * @return true if this Device emits Energy at all - */ - public boolean isEnetOutput() {return false;} - - /** - * @return true if this Device consumes Energy at all - */ - public boolean isEnetInput() {return false;} - - /** - * @return the amount of EU, which can be stored in this Device. Default is 0 EU. - */ - public long maxEUStore() {return 0;} - - /** - * @return the amount of EU/t, which can be accepted by this Device before it explodes. - */ - public long maxEUInput() {return 0;} - - /** - * @return the amount of EU/t, which can be outputted by this Device. - */ - public long maxEUOutput() {return 0;} - - /** - * @return the amount of E-net Impulses of the maxEUOutput size, which can be outputted by this Device. - * Default is 1 Pulse, this shouldn't be set to smaller Values than 1, as it won't output anything in that Case! - */ - public long maxAmperesOut() {return 1;} - - /** - * How many Amperes this Block can suck at max. Surpassing this value won't blow it up. - */ - public long maxAmperesIn() {return 1;} - - /** - * @return true if that Side is an Output. - */ - public boolean isOutputFacing(byte aSide) {return false;} - - /** - * @return true if that Side is an Input. - */ - public boolean isInputFacing(byte aSide) {return false;} - - /** - * @return true if Transformer Upgrades increase Packet Amount. - */ - public boolean isTransformingLowEnergy() {return true;} - - @Override - public boolean isFacingValid(byte aFacing) {return false;} - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) {return false;} - @Override - public boolean isValidSlot(int aIndex) {return true;} - @Override - public boolean setStackToZeroInsteadOfNull(int aIndex) {return false;} - - /** - * This is used to set the internal Energy to the given Parameter. I use this for the IDSU. - */ - public void setEUVar(long aEnergy) { - ((BaseMetaTileEntity)mBaseMetaTileEntity).mStoredEnergy = aEnergy; - } - - /** - * This is used to get the internal Energy. I use this for the IDSU. - */ - public long getEUVar() { - return ((BaseMetaTileEntity)mBaseMetaTileEntity).mStoredEnergy; - } - - /** - * This is used to set the internal Steam Energy to the given Parameter. - */ - public void setSteamVar(long aSteam) { - ((BaseMetaTileEntity)mBaseMetaTileEntity).mStoredSteam = aSteam; - } - - /** - * This is used to get the internal Steam Energy. - */ - public long getSteamVar() { - return ((BaseMetaTileEntity)mBaseMetaTileEntity).mStoredSteam; - } - - /** - * @return the amount of Steam, which can be stored in this Device. Default is 0 EU. - */ - public long maxSteamStore() {return 0;} - - /** - * @return the amount of EU, which this Device stores before starting to emit Energy. - * useful if you don't want to emit stored Energy until a certain Level is reached. - */ - public long getMinimumStoredEU() { - return 512; - } - - /** - * Determines the Tier of the Machine, used for de-charging Tools. - */ - public long getInputTier() { - return GT_Utility.getTier(getBaseMetaTileEntity().getInputVoltage()); - } - - /** - * Determines the Tier of the Machine, used for charging Tools. - */ - public long getOutputTier() { - return GT_Utility.getTier(getBaseMetaTileEntity().getOutputVoltage()); - } - - /** - * gets the first RechargerSlot - */ - public int rechargerSlotStartIndex() { - return 0; - } - - /** - * gets the amount of RechargerSlots - */ - public int rechargerSlotCount() { - return 0; - } - - /** - * gets the first DechargerSlot - */ - public int dechargerSlotStartIndex() { - return 0; - } - - /** - * gets the amount of DechargerSlots - */ - public int dechargerSlotCount() { - return 0; - } - - /** - * gets if this is protected from other Players per default or not - */ - public boolean ownerControl() { - return false; - } - - @Override - public ArrayList<String> getSpecialDebugInfo(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, int aLogLevel, ArrayList<String> aList) { - return aList; - } - - @Override - public boolean isLiquidInput(byte aSide) { - return true; - } - - @Override - public boolean isLiquidOutput(byte aSide) { - return true; - } - - /** - * gets the contained Liquid - */ - @Override - public FluidStack getFluid() {return null;} - - /** - * tries to fill this Tank - */ - @Override - public int fill(FluidStack resource, boolean doFill) {return 0;} - - /** - * tries to empty this Tank - */ - @Override - public FluidStack drain(int maxDrain, boolean doDrain) {return null;} - - /** - * Tank pressure - */ - public int getTankPressure() {return 0;} - - /** - * Liquid Capacity - */ - @Override - public int getCapacity() {return 0;} - - @Override - public void onMachineBlockUpdate() {/*Do nothing*/} - @Override - public void receiveClientEvent(byte aEventID, byte aValue) {/*Do nothing*/} - @Override - public boolean isSimpleMachine() {return false;} - - /** - * If this accepts up to 4 Overclockers - */ - public boolean isOverclockerUpgradable() {return false;} - - /** - * If this accepts Transformer Upgrades - */ - public boolean isTransformerUpgradable() {return false;} - - /** - * Progress this machine has already made - */ - public int getProgresstime() {return 0;} - - /** - * Progress this Machine has to do to produce something - */ - public int maxProgresstime() {return 0;} - - /** - * Increases the Progress, returns the overflown Progress. - */ - public int increaseProgress(int aProgress) {return 0;} - - /** - * If this TileEntity makes use of Sided Redstone behaviors. - * Determines only, if the Output Redstone Array is getting filled with 0 for true, or 15 for false. - */ - public boolean hasSidedRedstoneOutputBehavior() { - return false; - } - - /** - * When the Facing gets changed. - */ - public void onFacingChange() {/*Do nothing*/} - - /** - * if the IC2 Teleporter can drain from this. - */ - public boolean isTeleporterCompatible() { - return isEnetOutput() && getBaseMetaTileEntity().getOutputVoltage() >= 128 && getBaseMetaTileEntity().getUniversalEnergyCapacity() >= 500000; - } - - /** - * Gets the Output for the comparator on the given Side - */ - @Override - public byte getComparatorValue(byte aSide) { - return 0; - } - - @Override - public boolean acceptsRotationalEnergy(byte aSide) { - return false; - } - - @Override - public boolean injectRotationalEnergy(byte aSide, long aSpeed, long aEnergy) { - return false; - } - - @Override - public String getSpecialVoltageToolTip() {return null;} - - @Override - public boolean isGivingInformation() {return false;} - @Override - public String[] getInfoData() {return new String[]{};} - - public boolean isDigitalChest() {return false;} - public ItemStack[] getStoredItemData() {return null;} - public void setItemCount(int aCount) {/*Do nothing*/} - public int getMaxItemCount() {return 0;} - - @Override - public int getSizeInventory() {return mInventory.length;} - @Override - public ItemStack getStackInSlot(int aIndex) {if (aIndex >= 0 && aIndex < mInventory.length) return mInventory[aIndex]; return null;} - @Override - public void setInventorySlotContents(int aIndex, ItemStack aStack) {if (aIndex >= 0 && aIndex < mInventory.length) mInventory[aIndex] = aStack;} - @Override - public String getInventoryName() {if (GregTech_API.METATILEENTITIES[getBaseMetaTileEntity().getMetaTileID()] != null) return GregTech_API.METATILEENTITIES[getBaseMetaTileEntity().getMetaTileID()].getMetaName(); return "";} - @Override - public int getInventoryStackLimit() {return 64;} - @Override - public boolean isItemValidForSlot(int aIndex, ItemStack aStack) {return getBaseMetaTileEntity().isValidSlot(aIndex);} - - @Override - public ItemStack decrStackSize(int aIndex, int aAmount) { - ItemStack tStack = getStackInSlot(aIndex), rStack = GT_Utility.copy(tStack); - if (tStack != null) { - if (tStack.stackSize <= aAmount) { - if (setStackToZeroInsteadOfNull(aIndex)) tStack.stackSize = 0; else setInventorySlotContents(aIndex, null); - } else { - rStack = tStack.splitStack(aAmount); - if (tStack.stackSize == 0 && !setStackToZeroInsteadOfNull(aIndex)) setInventorySlotContents(aIndex, null); - } - } - return rStack; - } - - @Override - public int[] getAccessibleSlotsFromSide(int aSide) { - ArrayList<Integer> tList = new ArrayList<Integer>(); - IGregTechTileEntity tTileEntity = getBaseMetaTileEntity(); - boolean tSkip = tTileEntity.getCoverBehaviorAtSide((byte)aSide).letsItemsIn((byte)aSide, tTileEntity.getCoverIDAtSide((byte)aSide), tTileEntity.getCoverDataAtSide((byte)aSide), -2, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte)aSide).letsItemsOut((byte)aSide, tTileEntity.getCoverIDAtSide((byte)aSide), tTileEntity.getCoverDataAtSide((byte)aSide), -2, tTileEntity); - for (int i = 0; i < getSizeInventory(); i++) if (isValidSlot(i) && (tSkip || tTileEntity.getCoverBehaviorAtSide((byte)aSide).letsItemsOut((byte)aSide, tTileEntity.getCoverIDAtSide((byte)aSide), tTileEntity.getCoverDataAtSide((byte)aSide), i, tTileEntity) || tTileEntity.getCoverBehaviorAtSide((byte)aSide).letsItemsIn((byte)aSide, tTileEntity.getCoverIDAtSide((byte)aSide), tTileEntity.getCoverDataAtSide((byte)aSide), i, tTileEntity))) tList.add(i); - int[] rArray = new int[tList.size()]; - for (int i = 0; i < rArray.length; i++) rArray[i] = tList.get(i); - return rArray; - } - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int aSide) { - return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && (mInventory[aIndex] == null || GT_Utility.areStacksEqual(aStack, mInventory[aIndex])) && allowPutStack(getBaseMetaTileEntity(), aIndex, (byte)aSide, aStack); - } - - @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return isValidSlot(aIndex) && aStack != null && aIndex < mInventory.length && allowPullStack(getBaseMetaTileEntity(), aIndex, (byte)aSide, aStack); - } - - @Override - public boolean canFill(ForgeDirection aSide, Fluid aFluid) { - return fill(aSide, new FluidStack(aFluid, 1), false) == 1; - } - - @Override - public boolean canDrain(ForgeDirection aSide, Fluid aFluid) { - return drain(aSide, new FluidStack(aFluid, 1), false) != null; - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { - if (getCapacity() <= 0 && !getBaseMetaTileEntity().hasSteamEngineUpgrade()) return new FluidTankInfo[] {}; - return new FluidTankInfo[] {getInfo()}; - } - - public int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - return fill(aFluid, doFill); - } - - @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (getBaseMetaTileEntity().hasSteamEngineUpgrade() && GT_ModHandler.isSteam(aFluid) && aFluid.amount > 1) { - int tSteam = (int)Math.min(Integer.MAX_VALUE, Math.min(aFluid.amount/2, getBaseMetaTileEntity().getSteamCapacity() - getBaseMetaTileEntity().getStoredSteam())); - if (tSteam > 0) { - if (doFill) getBaseMetaTileEntity().increaseStoredSteam(tSteam, true); - return tSteam*2; - } - } else { - return fill_default(aSide, aFluid, doFill); - } - return 0; - } - - @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { - if (getFluid() != null && aFluid != null && getFluid().isFluidEqual(aFluid)) return drain(aFluid.amount, doDrain); - return null; - } - - @Override - public FluidStack drain(ForgeDirection aSide, int maxDrain, boolean doDrain) { - return drain(maxDrain, doDrain); - } - - @Override - public int getFluidAmount() { - return 0; - } - - @Override - public FluidTankInfo getInfo() { - return new FluidTankInfo(this); - } - - @Override - public String getMetaName() { - return mName; - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) { - return null; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public boolean doTickProfilingMessageDuringThisTick() { - return doTickProfilingInThisTick; - } - - @Override - public void markDirty() { - // - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return false; - } - - @Override - public void openInventory() { - // - } - - @Override - public void closeInventory() { - // - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return null; - } - - @Override - public boolean connectsToItemPipe(byte aSide) { - return false; - } - - @Override - public float getExplosionResistance(byte aSide) { - return 10.0F; - } - - @Override - public ItemStack[] getRealInventory() { - return mInventory; - } - - @Override - public void onColorChangeServer(byte aColor) { - // - } - - @Override - public void onColorChangeClient(byte aColor) { - // - } - - @Override - @SideOnly(Side.CLIENT) - public boolean renderInInventory(Block aBlock, int aMeta, RenderBlocks aRenderer) { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean renderInWorld(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { - return false; - } - - @Override - public void doExplosion(long aExplosionPower) { - float tStrength = aExplosionPower<V[0]?1.0F:aExplosionPower<V[1]?2.0F:aExplosionPower<V[2]?3.0F:aExplosionPower<V[3]?4.0F:aExplosionPower<V[4]?5.0F:aExplosionPower<V[4]*2?6.0F:aExplosionPower<V[5]?7.0F:aExplosionPower<V[6]?8.0F:aExplosionPower<V[7]?9.0F:10.0F; - int tX=getBaseMetaTileEntity().getXCoord(), tY=getBaseMetaTileEntity().getYCoord(), tZ=getBaseMetaTileEntity().getZCoord(); - World tWorld = getBaseMetaTileEntity().getWorld(); - GT_Utility.sendSoundToPlayers(tWorld, GregTech_API.sSoundList.get(209), 1.0F, -1, tX, tY, tZ); - tWorld.setBlock(tX, tY, tZ, Blocks.air); - if (GregTech_API.sMachineExplosions) tWorld.createExplosion(null, tX+0.5, tY+0.5, tZ+0.5, tStrength, true); - } - - @Override - public int getLightOpacity() { - return ((BaseMetaTileEntity)getBaseMetaTileEntity()).getLightValue() > 0 ? 0 : 255; - } - - @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List<AxisAlignedBB> outputAABB, Entity collider) { - AxisAlignedBB axisalignedbb1 = getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - if (axisalignedbb1 != null && inputAABB.intersectsWith(axisalignedbb1)) outputAABB.add(axisalignedbb1); - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX+1, aY+1, aZ+1); - } - - @Override - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { - // - } - - @Override - public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - // - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java b/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java deleted file mode 100644 index a393ae5d20..0000000000 --- a/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java +++ /dev/null @@ -1,56 +0,0 @@ -package gregtech.api.metatileentity.examples; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import net.minecraft.item.ItemStack; - -/** - * This Example Implementation still works, however I use something completely different in my own Code. - */ -public class GT_MetaTileEntity_E_Furnace extends GT_MetaTileEntity_BasicMachine { - public GT_MetaTileEntity_E_Furnace(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, "Not like using a Commodore 64", 1, 1, "E_Furnace.png", "smelting", new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_STEAM_FURNACE_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_STEAM_FURNACE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_FURNACE_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_FRONT_STEAM_FURNACE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_FURNACE_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TOP_STEAM_FURNACE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_STEAM_FURNACE_ACTIVE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_BOTTOM_STEAM_FURNACE)); - } - - public GT_MetaTileEntity_E_Furnace(String aName, int aTier, String aDescription, ITexture[][][] aTextures, String aGUIName, String aNEIName) { - super(aName, aTier, 1, aDescription, aTextures, 1, 1, aGUIName, aNEIName); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_E_Furnace(mName, mTier, mDescription, mTextures, mGUIName, mNEIName); - } - - @Override - public int checkRecipe() { - if (null != (mOutputItems[0] = GT_ModHandler.getSmeltingOutput(getInputAt(0), true, getOutputAt(0)))) { - mEUt = 4 * (1 << (mTier-1)) * (1 << (mTier-1)); - mMaxProgresstime = 128 / (1 << (mTier-1)); - return 2; - } - return 0; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64, aStack), false, null) != null; - } - - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1) GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(207), 10, 1.0F, aX, aY, aZ); - } - - @Override - public void startProcess() { - sendLoopStart((byte)1); - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java deleted file mode 100644 index 85104f4584..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ /dev/null @@ -1,253 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.VN; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Materials; -import gregtech.api.enums.TextureSet; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.metatileentity.IMetaTileEntityCable; -import gregtech.api.interfaces.tileentity.IColoredTileEntity; -import gregtech.api.interfaces.tileentity.IEnergyConnected; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.metatileentity.MetaPipeEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import ic2.api.energy.tile.IEnergySink; - -import java.util.ArrayList; -import java.util.Arrays; - -import cofh.api.energy.IEnergyReceiver; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTileEntityCable { - public long mTransferredAmperage = 0, mTransferredAmperageLast20 = 0, mTransferredVoltageLast20 = 0; - - public final float mThickNess; - public final Materials mMaterial; - public final long mCableLossPerMeter, mAmperage, mVoltage; - public final boolean mInsulated, mCanShock; - public long mRestRF; - - public GT_MetaPipeEntity_Cable(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { - super(aID, aName, aNameRegional, 0); - mThickNess = aThickNess; - mMaterial = aMaterial; - mAmperage = aAmperage; - mVoltage = aVoltage; - mInsulated = aInsulated; - mCanShock = aCanShock; - mCableLossPerMeter = aCableLossPerMeter; - } - - public GT_MetaPipeEntity_Cable(String aName, float aThickNess, Materials aMaterial, long aCableLossPerMeter, long aAmperage, long aVoltage, boolean aInsulated, boolean aCanShock) { - super(aName, 0); - mThickNess = aThickNess; - mMaterial = aMaterial; - mAmperage = aAmperage; - mVoltage = aVoltage; - mInsulated = aInsulated; - mCanShock = aCanShock; - mCableLossPerMeter = aCableLossPerMeter; - } - - @Override - public byte getTileEntityBaseType() { - return (byte)(mInsulated?9:8); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaPipeEntity_Cable(mName, mThickNess, mMaterial, mCableLossPerMeter, mAmperage, mVoltage, mInsulated, mCanShock); - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { - if (!mInsulated) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa)}; - if (aConnected) { - float tThickNess = getThickNess(); - if (tThickNess < 0.37F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_TINY , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.49F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_SMALL , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.74F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_MEDIUM , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - if (tThickNess < 0.99F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_LARGE , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[TextureSet.INDEX_wire], mMaterial.mRGBa), new GT_RenderedTexture(Textures.BlockIcons.INSULATION_HUGE , Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - } - return new ITexture[] {new GT_RenderedTexture(Textures.BlockIcons.INSULATION_FULL, Dyes.getModulation(aColorIndex, Dyes.CABLE_INSULATION.mRGBa))}; - } - - @Override - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) { - if (mCanShock && (((BaseMetaPipeEntity)getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase) GT_Utility.applyElectricityDamage((EntityLivingBase)aEntity, mTransferredVoltageLast20, mTransferredAmperageLast20); - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - if (!mCanShock) return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - return AxisAlignedBB.getBoundingBox(aX+0.125D, aY+0.125D, aZ+0.125D, aX+0.875D, aY+0.875D, aZ+0.875D); - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return false;} - @Override public boolean isValidSlot(int aIndex) {return true;} - @Override public final boolean renderInside(byte aSide) {return false;} - @Override public int getProgresstime() {return (int)mTransferredAmperage*64;} - @Override public int maxProgresstime() {return (int)mAmperage*64;} - - @Override - public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { - if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsEnergyIn(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity())) return 0; - return transferElectricity(aSide, aVoltage, aAmperage, new ArrayList<TileEntity>(Arrays.asList((TileEntity)getBaseMetaTileEntity()))); - } - - @Override - public long transferElectricity(byte aSide, long aVoltage, long aAmperage, ArrayList<TileEntity> aAlreadyPassedTileEntityList) { - long rUsedAmperes = 0; - aVoltage -= mCableLossPerMeter; - if (aVoltage > 0) for (byte i = 0; i < 6 && aAmperage > rUsedAmperes; i++) if (i != aSide && (mConnections & (1<<i)) != 0 && getBaseMetaTileEntity().getCoverBehaviorAtSide(i).letsEnergyOut(i, getBaseMetaTileEntity().getCoverIDAtSide(i), getBaseMetaTileEntity().getCoverDataAtSide(i), getBaseMetaTileEntity())) { - TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(i); - if (!aAlreadyPassedTileEntityList.contains(tTileEntity)) { - aAlreadyPassedTileEntityList.add(tTileEntity); - if (tTileEntity instanceof IEnergyConnected) { - if (getBaseMetaTileEntity().getColorization() >= 0) { - byte tColor = ((IEnergyConnected)tTileEntity).getColorization(); - if (tColor >= 0 && tColor != getBaseMetaTileEntity().getColorization()) continue; - } - if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity)tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable && ((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)).letsEnergyIn(GT_Utility.getOppositeSide(i), ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(GT_Utility.getOppositeSide(i)), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(GT_Utility.getOppositeSide(i)), ((IGregTechTileEntity)tTileEntity))) { - if (((IGregTechTileEntity)tTileEntity).getTimer() > 50) rUsedAmperes += ((IMetaTileEntityCable)((IGregTechTileEntity)tTileEntity).getMetaTileEntity()).transferElectricity(GT_Utility.getOppositeSide(i), aVoltage, aAmperage-rUsedAmperes, aAlreadyPassedTileEntityList); - } else { - rUsedAmperes += ((IEnergyConnected)tTileEntity).injectEnergyUnits(GT_Utility.getOppositeSide(i), aVoltage, aAmperage-rUsedAmperes); - } -// } else if (tTileEntity instanceof IEnergySink) { -// ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); -// if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), tDirection)) { -// if (((IEnergySink)tTileEntity).demandedEnergyUnits() > 0 && ((IEnergySink)tTileEntity).injectEnergyUnits(tDirection, aVoltage) < aVoltage) rUsedAmperes++; -// } - } else if (tTileEntity instanceof IEnergySink) { - ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - if (((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)getBaseMetaTileEntity(), tDirection)) { - if (((IEnergySink)tTileEntity).getDemandedEnergy() > 0 && ((IEnergySink)tTileEntity).injectEnergy(tDirection, aVoltage, aVoltage) < aVoltage) rUsedAmperes++; - } - } else if(GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver){ - ForgeDirection tDirection = ForgeDirection.getOrientation(i).getOpposite(); - int rfOut = (int) (aVoltage * GregTech_API.mEUtoRF / 100); - if(((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, true)==rfOut){ - ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, false); rUsedAmperes++; - }else if(((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, rfOut, true)>0){ - if(mRestRF==0){ - int RFtrans = ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, (int) rfOut, false);rUsedAmperes++; - mRestRF = rfOut - RFtrans; - }else{ - int RFtrans = ((IEnergyReceiver)tTileEntity).receiveEnergy(tDirection, (int) mRestRF, false); - mRestRF = mRestRF - RFtrans; - } - } - if(GregTech_API.mRFExplosions && ((IEnergyReceiver)tTileEntity).getMaxEnergyStored(tDirection) < rfOut * 600){ - if(rfOut > 32 * GregTech_API.mEUtoRF / 100) this.doExplosion(rfOut); - } - } - } - } - mTransferredAmperage += rUsedAmperes; - mTransferredVoltageLast20 = Math.max(mTransferredVoltageLast20, aVoltage); - mTransferredAmperageLast20 = Math.max(mTransferredAmperageLast20, mTransferredAmperage); - if (aVoltage > mVoltage || mTransferredAmperage > mAmperage) { - getBaseMetaTileEntity().setToFire(); - return aAmperage; - } - return rUsedAmperes; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - mTransferredAmperage = 0; - - if (aTick % 20 == 0) { - mTransferredVoltageLast20 = 0; - mTransferredAmperageLast20 = 0; - mConnections = 0; - for (byte i = 0, j = 0; i < 6; i++) { - j = GT_Utility.getOppositeSide(i); - if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity) || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyIn(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity) || aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsEnergyOut(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) { - TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); - if (tTileEntity instanceof IColoredTileEntity) { - if (aBaseMetaTileEntity.getColorization() >= 0) { - byte tColor = ((IColoredTileEntity)tTileEntity).getColorization(); - if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) continue; - } - } - if (tTileEntity instanceof IEnergyConnected && (((IEnergyConnected)tTileEntity).inputEnergyFrom(j) || ((IEnergyConnected)tTileEntity).outputsEnergyTo(j))) { - mConnections |= (1<<i); - continue; - } - if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity)tTileEntity).getMetaTileEntity() instanceof IMetaTileEntityCable) { - if (((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity)tTileEntity)) || ((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(j).letsEnergyIn(j, ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity)tTileEntity)) || ((IGregTechTileEntity)tTileEntity).getCoverBehaviorAtSide(j).letsEnergyOut(j, ((IGregTechTileEntity)tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity)tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity)tTileEntity))) { - mConnections |= (1<<i); - continue; - } - } - if (tTileEntity instanceof IEnergySink && ((IEnergySink)tTileEntity).acceptsEnergyFrom((TileEntity)aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { - mConnections |= (1<<i); - continue; - } - if(GregTech_API.mOutputRF && tTileEntity instanceof IEnergyReceiver && ((IEnergyReceiver)tTileEntity).canConnectEnergy(ForgeDirection.getOrientation(j))){ - mConnections |= (1<<i); - continue; - } - /* - if (tTileEntity instanceof IEnergyEmitter && ((IEnergyEmitter)tTileEntity).emitsEnergyTo((TileEntity)aBaseMetaTileEntity, ForgeDirection.getOrientation(j))) { - mConnections |= (1<<i); - continue; - }*/ - } - } - } - } - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public String[] getDescription() { - return new String[] { - "Max Voltage: " + EnumChatFormatting.GREEN + mVoltage + " (" + VN[GT_Utility.getTier(mVoltage)] + ")" + EnumChatFormatting.GRAY, - "Max Amperage: " + EnumChatFormatting.YELLOW + mAmperage + EnumChatFormatting.GRAY, - "Loss/Meter/Ampere: " + EnumChatFormatting.RED + mCableLossPerMeter + EnumChatFormatting.GRAY + " EU-Volt" - }; - } - - @Override - public float getThickNess() { - return mThickNess; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - // - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - // - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java deleted file mode 100644 index cb5c1b2f46..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java +++ /dev/null @@ -1,343 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.D1; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.SubTag; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.ICoverable; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.metatileentity.MetaPipeEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map.Entry; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; - -public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { - public FluidStack mFluid; - public byte mLastReceivedFrom = 0, oLastReceivedFrom = 0; - - public final float mThickNess; - public final Materials mMaterial; - public final int mCapacity, mHeatResistance; - public final boolean mGasProof; - - public GT_MetaPipeEntity_Fluid(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof) { - super(aID, aName, aNameRegional, 0); - mThickNess = aThickNess; - mMaterial = aMaterial; - mCapacity = aCapacity; - mGasProof = aGasProof; - mHeatResistance = aHeatResistance; - } - - public GT_MetaPipeEntity_Fluid(String aName, float aThickNess, Materials aMaterial, int aCapacity, int aHeatResistance, boolean aGasProof) { - super(aName, 0); - mThickNess = aThickNess; - mMaterial = aMaterial; - mCapacity = aCapacity; - mGasProof = aGasProof; - mHeatResistance = aHeatResistance; - } - - @Override - public byte getTileEntityBaseType() { - return mMaterial==null?4:(byte)((mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaPipeEntity_Fluid(mName, mThickNess, mMaterial, mCapacity, mHeatResistance, mGasProof); - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { - if (aConnected) { - float tThickNess = getThickNess(); - if (tThickNess < 0.37F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - if (tThickNess < 0.49F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - if (tThickNess < 0.74F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - if (tThickNess < 0.99F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - } - return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return false;} - @Override public boolean isValidSlot(int aIndex) {return false;} - @Override public final boolean renderInside(byte aSide) {return false;} - @Override public int getProgresstime() {return getFluidAmount();} - @Override public int maxProgresstime() {return getCapacity();} - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); - aNBT.setByte("mLastReceivedFrom", mLastReceivedFrom); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - mLastReceivedFrom = aNBT.getByte("mLastReceivedFrom"); - } - - @Override - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) { - if (mFluid != null && (((BaseMetaPipeEntity)getBaseMetaTileEntity()).mConnections & -128) == 0 && aEntity instanceof EntityLivingBase) { - int tTemperature = mFluid.getFluid().getTemperature(mFluid); - if (tTemperature > 320) { - GT_Utility.applyHeatDamage((EntityLivingBase)aEntity, (tTemperature - 300) / 50.0F); - } else if (tTemperature < 260) { - GT_Utility.applyFrostDamage((EntityLivingBase)aEntity, (270 - tTemperature) / 25.0F); - } - } - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - return AxisAlignedBB.getBoundingBox(aX+0.125D, aY+0.125D, aZ+0.125D, aX+0.875D, aY+0.875D, aZ+0.875D); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide() && aTick % 5 == 0) { - mLastReceivedFrom &= 63; - if (mLastReceivedFrom == 63) { - mLastReceivedFrom = 0; - } - - if (mFluid != null && mFluid.amount > 0) { - int tTemperature = mFluid.getFluid().getTemperature(mFluid); - if (tTemperature > mHeatResistance) { - if (aBaseMetaTileEntity.getRandomNumber(100) == 0) { - aBaseMetaTileEntity.setToFire(); - return; - } - aBaseMetaTileEntity.setOnFire(); - } - if (!mGasProof && mFluid.getFluid().isGaseous(mFluid)) { - mFluid.amount -= 5; - sendSound((byte)9); - if (tTemperature > 320) { - try { - for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>)getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getXCoord()-2, getBaseMetaTileEntity().getYCoord()-2, getBaseMetaTileEntity().getZCoord()-2, getBaseMetaTileEntity().getXCoord()+3, getBaseMetaTileEntity().getYCoord()+3, getBaseMetaTileEntity().getZCoord()+3))) { - GT_Utility.applyHeatDamage(tLiving, (tTemperature - 300) / 25.0F); - } - } catch(Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - } else if (tTemperature < 260) { - try { - for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>)getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getXCoord()-2, getBaseMetaTileEntity().getYCoord()-2, getBaseMetaTileEntity().getZCoord()-2, getBaseMetaTileEntity().getXCoord()+3, getBaseMetaTileEntity().getYCoord()+3, getBaseMetaTileEntity().getZCoord()+3))) { - GT_Utility.applyFrostDamage(tLiving, (270 - tTemperature) / 12.5F); - } - } catch(Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - } - if (mFluid.amount <= 0) mFluid = null; - } - } - - if (mLastReceivedFrom == oLastReceivedFrom) { - HashMap<IFluidHandler, ForgeDirection> tTanks = new HashMap<IFluidHandler, ForgeDirection>(); - - mConnections = 0; - - for (byte tSide = 0, i = 0, j = (byte)aBaseMetaTileEntity.getRandomNumber(6); i < 6; i++) { - tSide = (byte)((j + i) % 6); - - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(tSide); - if (tTileEntity != null) { - if (tTileEntity instanceof IGregTechTileEntity) { - if (aBaseMetaTileEntity.getColorization() >= 0) { - byte tColor = ((IGregTechTileEntity)tTileEntity).getColorization(); - if (tColor >= 0 && (tColor & 15) != (aBaseMetaTileEntity.getColorization() & 15)) { - continue; - } - } - } - FluidTankInfo[] tInfo = tTileEntity.getTankInfo(ForgeDirection.getOrientation(tSide).getOpposite()); - if (tInfo != null && tInfo.length > 0) { - if (tTileEntity instanceof ICoverable && ((ICoverable)tTileEntity).getCoverBehaviorAtSide(GT_Utility.getOppositeSide(tSide)).alwaysLookConnected(GT_Utility.getOppositeSide(tSide), ((ICoverable)tTileEntity).getCoverIDAtSide(GT_Utility.getOppositeSide(tSide)), ((ICoverable)tTileEntity).getCoverDataAtSide(GT_Utility.getOppositeSide(tSide)), ((ICoverable)tTileEntity))) { - mConnections |= (1<<tSide); - } - if (aBaseMetaTileEntity.getCoverBehaviorAtSide(tSide).letsFluidIn(tSide, aBaseMetaTileEntity.getCoverIDAtSide(tSide), aBaseMetaTileEntity.getCoverDataAtSide(tSide), null, aBaseMetaTileEntity)) { - mConnections |= (1<<tSide); - } - if (aBaseMetaTileEntity.getCoverBehaviorAtSide(tSide).letsFluidOut(tSide, aBaseMetaTileEntity.getCoverIDAtSide(tSide), aBaseMetaTileEntity.getCoverDataAtSide(tSide), null, aBaseMetaTileEntity)) { - mConnections |= (1<<tSide); - if (((1<<tSide) & mLastReceivedFrom) == 0) tTanks.put(tTileEntity, ForgeDirection.getOrientation(tSide).getOpposite()); - } - if (aBaseMetaTileEntity.getCoverBehaviorAtSide(tSide).alwaysLookConnected(tSide, aBaseMetaTileEntity.getCoverIDAtSide(tSide), aBaseMetaTileEntity.getCoverDataAtSide(tSide), aBaseMetaTileEntity)) { - mConnections |= (1<<tSide); - } - } - } - } - - if (mFluid != null && mFluid.amount > 0) { - int tAmount = Math.max(1, Math.min(mCapacity*10, mFluid.amount / 2)), tSuccessfulTankAmount = 0; - - for (Entry<IFluidHandler, ForgeDirection> tEntry : tTanks.entrySet()) if (tEntry.getKey().fill(tEntry.getValue(), drain(tAmount, false), false) > 0) tSuccessfulTankAmount++; - - if (tSuccessfulTankAmount > 0) { - if (tAmount >= tSuccessfulTankAmount) { - tAmount /= tSuccessfulTankAmount; - for (Entry<IFluidHandler, ForgeDirection> tTileEntity : tTanks.entrySet()) { - if (mFluid == null || mFluid.amount <= 0) break; - int tFilledAmount = tTileEntity.getKey().fill(tTileEntity.getValue(), drain(tAmount, false), false); - if (tFilledAmount > 0) tTileEntity.getKey().fill(tTileEntity.getValue(), drain(tFilledAmount, true), true); - } - } else { - for (Entry<IFluidHandler, ForgeDirection> tTileEntity : tTanks.entrySet()) { - if (mFluid == null || mFluid.amount <= 0) break; - int tFilledAmount = tTileEntity.getKey().fill(tTileEntity.getValue(), drain(mFluid.amount, false), false); - if (tFilledAmount > 0) tTileEntity.getKey().fill(tTileEntity.getValue(), drain(tFilledAmount, true), true); - } - } - } - } - - mLastReceivedFrom = 0; - } - - oLastReceivedFrom = mLastReceivedFrom; - } - } - - @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) { - super.doSound(aIndex, aX, aY, aZ); - if (aIndex == 9) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 5, 1.0F, aX, aY, aZ); - for (byte i = 0; i < 6; i++) for (int l = 0; l < 2; ++l) getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5 + Math.random(), aY - 0.5 + Math.random(), aZ - 0.5 + Math.random(), ForgeDirection.getOrientation(i).offsetX / 5.0, ForgeDirection.getOrientation(i).offsetY / 5.0, ForgeDirection.getOrientation(i).offsetZ / 5.0); - } - } - - @Override - public final int getCapacity() { - return mCapacity * 20; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public final FluidStack getFluid() { - return mFluid; - } - - @Override - public final int getFluidAmount() { - return mFluid != null ? mFluid.amount : 0; - } - - @Override - public final int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - if (aFluid == null || aFluid.getFluid().getID() <= 0) return 0; - - if (mFluid == null || mFluid.getFluid().getID() <= 0) { - if(aFluid.amount <= getCapacity()) { - if (doFill) { - mFluid = aFluid.copy(); - mLastReceivedFrom |= (1<<aSide.ordinal()); - } - return aFluid.amount; - } - if (doFill) { - mFluid = aFluid.copy(); - mLastReceivedFrom |= (1<<aSide.ordinal()); - mFluid.amount = getCapacity(); - } - return getCapacity(); - } - - if (!mFluid.isFluidEqual(aFluid)) return 0; - - int space = getCapacity() - mFluid.amount; - if (aFluid.amount <= space) { - if (doFill) { - mFluid.amount += aFluid.amount; - mLastReceivedFrom |= (1<<aSide.ordinal()); - } - return aFluid.amount; - } - if (doFill) { - mFluid.amount = getCapacity(); - mLastReceivedFrom |= (1<<aSide.ordinal()); - } - return space; - } - - @Override - public final FluidStack drain(int maxDrain, boolean doDrain) { - if (mFluid == null) return null; - if (mFluid.amount <= 0) { - mFluid = null; - return null; - } - - int used = maxDrain; - if (mFluid.amount < used) - used = mFluid.amount; - - if (doDrain) { - mFluid.amount -= used; - } - - FluidStack drained = mFluid.copy(); - drained.amount = used; - - if (mFluid.amount <= 0) { - mFluid = null; - } - - return drained; - } - - @Override - public int getTankPressure() { - return (mFluid==null?0:mFluid.amount) - (getCapacity()/2); - } - - @Override - public String[] getDescription() { - return new String[] { - EnumChatFormatting.BLUE + "Fluid Capacity: " + (mCapacity*20) + "L/sec" + EnumChatFormatting.GRAY, - EnumChatFormatting.RED + "Heat Limit: " + mHeatResistance + " K" + EnumChatFormatting.GRAY - }; - } - - @Override - public float getThickNess() { - return mThickNess; - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java deleted file mode 100644 index a1ec9af85e..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java +++ /dev/null @@ -1,59 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.RA; -import gregtech.api.enums.*; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaPipeEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_ModHandler.RecipeBits; -import gregtech.api.util.GT_OreDictUnificator; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public class GT_MetaPipeEntity_Frame extends MetaPipeEntity { - public final Materials mMaterial; - - public GT_MetaPipeEntity_Frame(int aID, String aName, String aNameRegional, Materials aMaterial) { - super(aID, aName, aNameRegional, 0); - mMaterial = aMaterial; - - GT_OreDictUnificator.registerOre(OrePrefixes.frameGt, aMaterial, getStackForm(1)); - GT_ModHandler.addCraftingRecipe(getStackForm(2), RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.BUFFERED, new Object[] {"SSS", "SwS", "SSS", 'S', OrePrefixes.stick.get(mMaterial)}); - RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.stick, aMaterial, 4), ItemList.Circuit_Integrated.getWithDamage(0, 4), getStackForm(1), 64, 8); - } - - public GT_MetaPipeEntity_Frame(String aName, Materials aMaterial) { - super(aName, 0); - mMaterial = aMaterial; - } - - @Override - public byte getTileEntityBaseType() { - return mMaterial==null?4:(byte)((mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaPipeEntity_Frame(mName, mMaterial); - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { - return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - } - - @Override public String[] getDescription() {return new String[] {"Just something you can put a Cover or CFoam on."};} - - @Override public final boolean isSimpleMachine() {return true;} - @Override public final boolean isFacingValid(byte aFacing) {return false;} - @Override public final boolean isValidSlot(int aIndex) {return false;} - @Override public final boolean renderInside(byte aSide) {return true;} - @Override public final float getThickNess() {return 1.0F;} - @Override public final void saveNBTData(NBTTagCompound aNBT) {/*Do nothing*/} - @Override public final void loadNBTData(NBTTagCompound aNBT) {/*Do nothing*/} - @Override public final boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {return false;} - @Override public final boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {return false;} -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java deleted file mode 100644 index 59ff78e372..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java +++ /dev/null @@ -1,269 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.*; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.metatileentity.IMetaTileEntityItemPipe; -import gregtech.api.interfaces.tileentity.ICoverable; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.metatileentity.MetaPipeEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; - -import java.util.ArrayList; -import java.util.HashMap; - -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityDispenser; -import net.minecraft.tileentity.TileEntityHopper; - -public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileEntityItemPipe { - public int mTransferredItems = 0; - public byte mLastReceivedFrom = 0, oLastReceivedFrom = 0; - public boolean mIsRestrictive = false; - - public final float mThickNess; - public final Materials mMaterial; - public final int mStepSize; - - public GT_MetaPipeEntity_Item(int aID, String aName, String aNameRegional, float aThickNess, Materials aMaterial, int aInvSlotCount, int aStepSize, boolean aIsRestrictive) { - super(aID, aName, aNameRegional, aInvSlotCount); - mIsRestrictive = aIsRestrictive; - mThickNess = aThickNess; - mMaterial = aMaterial; - mStepSize = aStepSize; - } - - public GT_MetaPipeEntity_Item(String aName, float aThickNess, Materials aMaterial, int aInvSlotCount, int aStepSize, boolean aIsRestrictive) { - super(aName, aInvSlotCount); - mIsRestrictive = aIsRestrictive; - mThickNess = aThickNess; - mMaterial = aMaterial; - mStepSize = aStepSize; - } - - @Override - public byte getTileEntityBaseType() { - return mMaterial==null?4:(byte)((mMaterial.contains(SubTag.WOOD) ? 12 : 4) + Math.max(0, Math.min(3, mMaterial.mToolQuality))); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaPipeEntity_Item(mName, mThickNess, mMaterial, mInventory.length, mStepSize, mIsRestrictive); - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { - if (mIsRestrictive) { - if (aConnected) { - float tThickNess = getThickNess(); - if (tThickNess < 0.37F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR)}; - if (tThickNess < 0.49F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR)}; - if (tThickNess < 0.74F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR)}; - if (tThickNess < 0.99F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR)}; - return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR)}; - } - return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.PIPE_RESTRICTOR)}; - } - if (aConnected) { - float tThickNess = getThickNess(); - if (tThickNess < 0.37F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeTiny.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - if (tThickNess < 0.49F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeSmall.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - if (tThickNess < 0.74F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeMedium.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - if (tThickNess < 0.99F) return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeLarge.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipeHuge.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - } - return new ITexture[] {new GT_RenderedTexture(mMaterial.mIconSet.mTextures[OrePrefixes.pipe.mTextureIndex ], Dyes.getModulation(aColorIndex, mMaterial.mRGBa))}; - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return false;} - @Override public boolean isValidSlot(int aIndex) {return true;} - @Override public final boolean renderInside(byte aSide) {return false;} - @Override public int getProgresstime() {return getPipeContent()*64;} - @Override public int maxProgresstime() {return getMaxPipeCapacity()*64;} - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("mLastReceivedFrom", mLastReceivedFrom); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mLastReceivedFrom = aNBT.getByte("mLastReceivedFrom"); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide() && aTick % 10 == 0) { - mConnections = 0; - if (aTick % 20 == 0) mTransferredItems = 0; - - for (byte i = 0; i < 6; i++) { - TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); - if (tTileEntity != null) { - boolean temp = GT_Utility.isConnectableNonInventoryPipe(tTileEntity, GT_Utility.getOppositeSide(i)); - if (tTileEntity instanceof IGregTechTileEntity) { - temp = true; - if (((IGregTechTileEntity)tTileEntity).getMetaTileEntity() == null) continue; - if (aBaseMetaTileEntity.getColorization() >= 0) { - byte tColor = ((IGregTechTileEntity)tTileEntity).getColorization(); - if (tColor >= 0 && tColor != aBaseMetaTileEntity.getColorization()) { - continue; - } - } - if (((IGregTechTileEntity)tTileEntity).getMetaTileEntity().connectsToItemPipe(GT_Utility.getOppositeSide(i))) { - mConnections |= (1<<i); - continue; - } - } - if (tTileEntity instanceof IInventory) { - temp = true; - if (((IInventory)tTileEntity).getSizeInventory() <= 0) { - continue; - } - } - if (tTileEntity instanceof ISidedInventory) { - temp = true; - int[] tSlots = ((ISidedInventory)tTileEntity).getAccessibleSlotsFromSide(GT_Utility.getOppositeSide(i)); - if (tSlots == null || tSlots.length <= 0) { - continue; - } - } - if (temp) { - if (tTileEntity instanceof ICoverable && ((ICoverable)tTileEntity).getCoverBehaviorAtSide(GT_Utility.getOppositeSide(i)).alwaysLookConnected(GT_Utility.getOppositeSide(i), ((ICoverable)tTileEntity).getCoverIDAtSide(GT_Utility.getOppositeSide(i)), ((ICoverable)tTileEntity).getCoverDataAtSide(GT_Utility.getOppositeSide(i)), ((ICoverable)tTileEntity))) { - mConnections |= (1<<i); - continue; - } - if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) { - mConnections |= (1<<i); - continue; - } - if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsItemsIn(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), -1, aBaseMetaTileEntity)) { - mConnections |= (1<<i); - continue; - } - if (aBaseMetaTileEntity.getCoverBehaviorAtSide(i).letsItemsOut(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), -1, aBaseMetaTileEntity)) { - mConnections |= (1<<i); - continue; - } - } - } - } - - if (oLastReceivedFrom == mLastReceivedFrom) { - doTickProfilingInThisTick = false; - - ArrayList<IMetaTileEntityItemPipe> tPipeList = new ArrayList<IMetaTileEntityItemPipe>(); - - for (boolean temp = true; temp && !isInventoryEmpty() && pipeCapacityCheck();) { - temp = false; - tPipeList.clear(); - for (IMetaTileEntityItemPipe tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes(this, new HashMap<IMetaTileEntityItemPipe, Long>(), 0, false, false)).keySet()) { - if (temp) break; - tPipeList.add(tTileEntity); - while (!temp && !isInventoryEmpty() && tTileEntity.sendItemStack(aBaseMetaTileEntity)) for (IMetaTileEntityItemPipe tPipe : tPipeList) if (!tPipe.incrementTransferCounter(1)) temp = true; - } - } - } - - if (isInventoryEmpty()) mLastReceivedFrom = 6; - oLastReceivedFrom = mLastReceivedFrom; - } - } - - @Override - public boolean incrementTransferCounter(int aIncrement) { - mTransferredItems += aIncrement; - return pipeCapacityCheck(); - } - - @Override - public boolean sendItemStack(Object aSender) { - if (pipeCapacityCheck()) { - byte tOffset = (byte)getBaseMetaTileEntity().getRandomNumber(6), tSide = 0; - for (byte i = 0; i < 6; i++) { - tSide = (byte)((i+tOffset)%6); - if (isInventoryEmpty() || (tSide != mLastReceivedFrom || aSender != getBaseMetaTileEntity())) { - if (insertItemStackIntoTileEntity(aSender, tSide)) return true; - } - } - } - return false; - } - - @Override - public boolean insertItemStackIntoTileEntity(Object aSender, byte aSide) { - if (getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).letsItemsOut(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), -1, getBaseMetaTileEntity())) { - TileEntity tInventory = getBaseMetaTileEntity().getTileEntityAtSide(aSide); - if (tInventory != null && !(tInventory instanceof BaseMetaPipeEntity)) { - if ((!(tInventory instanceof TileEntityHopper) && !(tInventory instanceof TileEntityDispenser)) || getBaseMetaTileEntity().getMetaIDAtSide(aSide) != GT_Utility.getOppositeSide(aSide)) { - return GT_Utility.moveOneItemStack(aSender, tInventory, (byte)6, GT_Utility.getOppositeSide(aSide), null, false, (byte)64, (byte)1, (byte)64, (byte)1) > 0; - } - } - } - return false; - } - - @Override - public boolean pipeCapacityCheck() { - return mTransferredItems <= 0 || getPipeContent() < getMaxPipeCapacity(); - } - - private int getPipeContent() { - return mTransferredItems; - } - - private int getMaxPipeCapacity() { - return Math.max(1, getPipeCapacity()); - } - - /** - * Amount of ItemStacks this Pipe can conduct per Second. - */ - public int getPipeCapacity() { - return mInventory.length; - } - - @Override - public int getStepSize() { - return mStepSize; - } - - @Override - public boolean canExtractItem(int aIndex, ItemStack aStack, int aSide) { - return true; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (isInventoryEmpty()) mLastReceivedFrom = aSide; - return mLastReceivedFrom == aSide && mInventory[aIndex] == null; - } - - @Override - public String[] getDescription() { - return new String[] {"Item Capacity: "+getMaxPipeCapacity()+" Stacks/sec", "Routing Value: " + mStepSize}; - } - - private boolean isInventoryEmpty() { - for (ItemStack tStack : mInventory) if (tStack != null) return false; - return true; - } - - @Override - public float getThickNess() { - return mThickNess; - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java deleted file mode 100644 index 72df4d7cdb..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicBatteryBuffer.java +++ /dev/null @@ -1,213 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.V; -import ic2.api.item.IElectricItem; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.gui.*; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.items.GT_MetaBase_Item; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * - * This is the main construct for my Basic Machines such as the Automatic Extractor - * Extend this class to make a simple Machine - */ -public class GT_MetaTileEntity_BasicBatteryBuffer extends GT_MetaTileEntity_TieredMachineBlock { - public boolean mCharge = false, mDecharge = false; - public int mBatteryCount = 0, mChargeableCount = 0; - - public GT_MetaTileEntity_BasicBatteryBuffer(int aID, String aName, String aNameRegional, int aTier, String aDescription, int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aSlotCount, aDescription); - } - - public GT_MetaTileEntity_BasicBatteryBuffer(String aName, int aTier, String aDescription, ITexture[][][] aTextures, int aSlotCount) { - super(aName, aTier, aSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] {mDescription, mInventory.length + " Slots"}; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[2][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[ 0][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1]}; - rTextures[ 1][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier] : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; - } - return rTextures; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[aSide == aFacing ? 1 : 0][aColorIndex+1]; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_BasicBatteryBuffer(mName, mTier, mDescription, mTextures, mInventory.length); - } - - @Override public boolean isSimpleMachine() {return false;} - @Override public boolean isElectric() {return true;} - @Override public boolean isValidSlot(int aIndex) {return true;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isEnetInput() {return true;} - @Override public boolean isEnetOutput() {return true;} - @Override public boolean isInputFacing(byte aSide) {return aSide!=getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isOutputFacing(byte aSide) {return aSide==getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isTeleporterCompatible() {return false;} - @Override public long getMinimumStoredEU() {return V[mTier]*16*mInventory.length;} - @Override public long maxEUStore() {return V[mTier]*64*mInventory.length;} - @Override public long maxEUInput() {return V[mTier];} - @Override public long maxEUOutput() {return V[mTier];} - @Override public long maxAmperesIn() {return mChargeableCount * 2;} - @Override public long maxAmperesOut() {return mBatteryCount;} - @Override public int rechargerSlotStartIndex() {return 0;} - @Override public int dechargerSlotStartIndex() {return 0;} - @Override public int rechargerSlotCount() {return mCharge?mInventory.length:0;} - @Override public int dechargerSlotCount() {return mDecharge?mInventory.length:0;} - @Override public int getProgresstime() {return (int)getBaseMetaTileEntity().getUniversalEnergyStored();} - @Override public int maxProgresstime() {return (int)getBaseMetaTileEntity().getUniversalEnergyCapacity();} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - // - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - // - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mInventory.length) { - case 1: return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); - case 4: return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); - case 9: return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); - case 16: return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); - } - return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mInventory.length) { - case 1: return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - case 4: return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - case 9: return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - case 16: return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - } - return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; - mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; - mBatteryCount = 0; - mChargeableCount = 0; - for (ItemStack tStack : mInventory) if (GT_ModHandler.isElectricItem(tStack, mTier)) { - if (GT_ModHandler.isChargerItem(tStack)) mBatteryCount++; - mChargeableCount++; - } - } - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if(GT_ModHandler.isElectricItem(aStack)&&aStack.getUnlocalizedName().startsWith("gt.metaitem.01.")){ - String name = aStack.getUnlocalizedName(); - if(name.equals("gt.metaitem.01.32510")|| - name.equals("gt.metaitem.01.32511")|| - name.equals("gt.metaitem.01.32520")|| - name.equals("gt.metaitem.01.32521")|| - name.equals("gt.metaitem.01.32530")|| - name.equals("gt.metaitem.01.32531")){ - return true;} - } - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if(!GT_Utility.isStackValid(aStack)){ - return false; - } - if(GT_ModHandler.isElectricItem(aStack, this.mTier)){ - return true; - } - return false; - } - - public long[] getStoredEnergy(){ - long tScale = getBaseMetaTileEntity().getEUCapacity(); - long tStored = getBaseMetaTileEntity().getStoredEU(); - if(mInventory!=null){ - for(ItemStack aStack : mInventory){ - if (GT_ModHandler.isElectricItem(aStack)) { - - if(aStack.getItem() instanceof GT_MetaBase_Item){ - Long[] stats = ((GT_MetaBase_Item)aStack.getItem()).getElectricStats(aStack); - if(stats!=null){ - tScale = tScale + stats[0]; - tStored = tStored + ((GT_MetaBase_Item)aStack.getItem()).getRealCharge(aStack); - } - }else if(aStack.getItem() instanceof IElectricItem){ - tStored = tStored + (long)ic2.api.item.ElectricItem.manager.getCharge(aStack); - tScale = tScale + (long)((IElectricItem)aStack.getItem()).getMaxCharge(aStack); - } - } - } - - } - return new long[] {tStored,tScale}; - } - - private long count=0; - private long mStored=0; - private long mMax=0; - - @Override - public String[] getInfoData() { - count++; - if(mMax==0||count%20==0){ - long[] tmp = getStoredEnergy(); - mStored=tmp[0]; - mMax=tmp[1]; - } - - return new String[] { - getLocalName(), - "Stored Items:", - GT_Utility.formatNumbers(mStored)+" EU /", - GT_Utility.formatNumbers(mMax)+" EU"}; - } - - @Override - public boolean isGivingInformation() { - return true; - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java deleted file mode 100644 index 97d189170e..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicGenerator.java +++ /dev/null @@ -1,167 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.V; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Utility; - -import java.util.Collection; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -public abstract class GT_MetaTileEntity_BasicGenerator extends GT_MetaTileEntity_BasicTank { - public GT_MetaTileEntity_BasicGenerator(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, 3, aDescription, aTextures); - } - - public GT_MetaTileEntity_BasicGenerator(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[ 0][i+1] = getFront(i); - rTextures[ 1][i+1] = getBack(i); - rTextures[ 2][i+1] = getBottom(i); - rTextures[ 3][i+1] = getTop(i); - rTextures[ 4][i+1] = getSides(i); - rTextures[ 5][i+1] = getFrontActive(i); - rTextures[ 6][i+1] = getBackActive(i); - rTextures[ 7][i+1] = getBottomActive(i); - rTextures[ 8][i+1] = getTopActive(i); - rTextures[ 9][i+1] = getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[(aActive?5:0)+(aSide==aFacing?0:aSide==GT_Utility.getOppositeSide(aFacing)?1:aSide==0?2:aSide==1?3:4)][aColorIndex+1]; - } - - @Override - public String[] getDescription() { - return new String[] {mDescription, "Fuel Efficiency: " + getEfficiency() + "%"}; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - public ITexture[] getFront(byte aColor) {return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]};} - public ITexture[] getBack(byte aColor) {return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]};} - public ITexture[] getBottom(byte aColor) {return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]};} - public ITexture[] getTop(byte aColor) {return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]};} - public ITexture[] getSides(byte aColor) {return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]};} - - public ITexture[] getFrontActive(byte aColor) {return getFront(aColor);} - public ITexture[] getBackActive(byte aColor) {return getBack(aColor);} - public ITexture[] getBottomActive(byte aColor) {return getBottom(aColor);} - public ITexture[] getTopActive(byte aColor) {return getTop(aColor);} - public ITexture[] getSidesActive(byte aColor) {return getSides(aColor);} - - @Override public boolean isFacingValid(byte aSide) {return aSide > 1;} - @Override public boolean isSimpleMachine() {return false;} - @Override public boolean isValidSlot(int aIndex) {return aIndex < 2;} - @Override public boolean isEnetOutput() {return true;} - @Override public boolean isOutputFacing(byte aSide) {return true;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override public long maxEUOutput() {return getBaseMetaTileEntity().isAllowedToWork()?V[mTier]:0;} - @Override public long maxEUStore() {return Math.max(getEUVar(), V[mTier] * 20 + getMinimumStoredEU());} - - @Override public boolean doesFillContainers() {return getBaseMetaTileEntity().isAllowedToWork();} - @Override public boolean doesEmptyContainers() {return getBaseMetaTileEntity().isAllowedToWork();} - @Override public boolean canTankBeFilled() {return getBaseMetaTileEntity().isAllowedToWork();} - @Override public boolean canTankBeEmptied() {return getBaseMetaTileEntity().isAllowedToWork();} - @Override public boolean displaysItemStack() {return true;} - @Override public boolean displaysStackSize() {return false;} - @Override public boolean isFluidInputAllowed(FluidStack aFluid) {return getFuelValue(aFluid) > 0;} - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork() && aTick%10==0) { - if (mFluid == null) { - if (aBaseMetaTileEntity.getUniversalEnergyStored() < maxEUOutput() + getMinimumStoredEU()) { - mInventory[getStackDisplaySlot()] = null; - } else { - if (mInventory[getStackDisplaySlot()] == null) mInventory[getStackDisplaySlot()] = new ItemStack(Blocks.fire, 1); - mInventory[getStackDisplaySlot()].setStackDisplayName("Generating: " + (aBaseMetaTileEntity.getUniversalEnergyStored() - getMinimumStoredEU()) + " EU"); - } - } else { - int tFuelValue = getFuelValue(mFluid), tConsumed = consumedFluidPerOperation(mFluid); - if (tFuelValue > 0 && tConsumed > 0 && mFluid.amount > tConsumed) { - long tFluidAmountToUse = Math.min(mFluid.amount / tConsumed, (maxEUOutput() * 20 + getMinimumStoredEU() - aBaseMetaTileEntity.getUniversalEnergyStored()) / tFuelValue); - if (tFluidAmountToUse > 0 && aBaseMetaTileEntity.increaseStoredEnergyUnits(tFluidAmountToUse * tFuelValue, true)) mFluid.amount -= tFluidAmountToUse * tConsumed; - } - } - if (mInventory[getInputSlot()] != null && aBaseMetaTileEntity.getUniversalEnergyStored() < (maxEUOutput() * 20 + getMinimumStoredEU()) && GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true) == null) { - int tFuelValue = getFuelValue(mInventory[getInputSlot()]); - if (tFuelValue > 0) { - ItemStack tEmptyContainer = getEmptyContainer(mInventory[getInputSlot()]); - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tEmptyContainer)) { - aBaseMetaTileEntity.increaseStoredEnergyUnits(tFuelValue, true); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - } - } - } - } - - if (aBaseMetaTileEntity.isServerSide()) aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.getUniversalEnergyStored() >= maxEUOutput() + getMinimumStoredEU()); - } - - public abstract GT_Recipe_Map getRecipes(); - - public abstract int getEfficiency(); - - public int consumedFluidPerOperation(FluidStack aLiquid) { - return 1; - } - - public int getFuelValue(FluidStack aLiquid) { - if (aLiquid == null || getRecipes() == null) return 0; - FluidStack tLiquid; - Collection<GT_Recipe> tRecipeList = getRecipes().mRecipeList; - if (tRecipeList != null) for (GT_Recipe tFuel : tRecipeList) if ((tLiquid = GT_Utility.getFluidForFilledItem(tFuel.getRepresentativeInput(0), true)) != null) if (aLiquid.isFluidEqual(tLiquid)) return (int)(((long)tFuel.mSpecialValue * getEfficiency() * consumedFluidPerOperation(tLiquid)) / 100); - return 0; - } - - public int getFuelValue(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return 0; - GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) return (int)((tFuel.mSpecialValue * 1000L * getEfficiency()) / 100); - return 0; - } - - public ItemStack getEmptyContainer(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack) || getRecipes() == null) return null; - GT_Recipe tFuel = getRecipes().findRecipe(getBaseMetaTileEntity(), false, Long.MAX_VALUE, null, aStack); - if (tFuel != null) return GT_Utility.copy(tFuel.getOutput(0)); - return GT_Utility.getContainerItem(aStack, true); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (getFuelValue(aStack) > 0 || getFuelValue(GT_Utility.getFluidForFilledItem(aStack, true)) > 0); - } - - @Override - public int getCapacity() { - return 16000; - } - - @Override - public int getTankPressure() { - return -100; - } -} diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull.java deleted file mode 100644 index b74310f8d8..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull.java +++ /dev/null @@ -1,99 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.V; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -public class GT_MetaTileEntity_BasicHull extends GT_MetaTileEntity_BasicTank { - public GT_MetaTileEntity_BasicHull(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, 1, aDescription, aTextures); - } - - public GT_MetaTileEntity_BasicHull(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GT_MetaTileEntity_BasicHull(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_BasicHull(mName, mTier, mInventory.length, mDescription, mTextures); - } - - @Override public boolean isElectric() {return true;} - @Override public boolean isEnetInput() {return true;} - @Override public boolean isEnetOutput() {return true;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override public boolean isInputFacing(byte aSide) {return !isOutputFacing(aSide);} - @Override public boolean isOutputFacing(byte aSide) {return aSide == getBaseMetaTileEntity().getFrontFacing();} - @Override public long getMinimumStoredEU() {return 512;} - @Override public long maxEUStore() {return 512+V[mTier]*50;} - @Override public long maxEUInput() {return V[mTier];} - @Override public long maxEUOutput() {return V[mTier];} - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isValidSlot(int aIndex) {return true;} - @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {return true;} - @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {return true;} - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aConnected, boolean aRedstone) { - return mTextures[Math.min(2, aSide) + (aSide==aFacing?3:0)][aColorIndex+1]; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[6][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[ 0][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1]}; - rTextures[ 1][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1]}; - rTextures[ 2][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1]}; - rTextures[ 3][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; - rTextures[ 4][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; - rTextures[ 5][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; - } - return rTextures; - } - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return true; - } - - @Override - public boolean canTankBeEmptied() { - return true; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean displaysStackSize() { - return false; - } - - @Override - public int getCapacity() { - return (mTier + 1) * 1000; - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull_NonElectric.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull_NonElectric.java deleted file mode 100644 index 948e63124f..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicHull_NonElectric.java +++ /dev/null @@ -1,32 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - -public abstract class GT_MetaTileEntity_BasicHull_NonElectric extends GT_MetaTileEntity_BasicHull { - public GT_MetaTileEntity_BasicHull_NonElectric(int aID, String aName, String aNameRegional, int aTier, String aDescription) { - super(aID, aName, aNameRegional, aTier, aDescription); - } - - public GT_MetaTileEntity_BasicHull_NonElectric(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 1, aDescription, aTextures); - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aConnections, byte aColorIndex, boolean aConnected, boolean aRedstone) { - return mTextures[Math.min(2, aSide)][aColorIndex+1]; - } - - @Override public boolean isElectric() {return false;} - @Override public boolean isEnetInput() {return false;} - @Override public boolean isEnetOutput() {return false;} - @Override public boolean isInputFacing(byte aSide) {return false;} - @Override public boolean isOutputFacing(byte aSide) {return false;} - @Override public long getMinimumStoredEU() {return 0;} - @Override public long maxEUStore() {return 0;} - @Override public long maxEUInput() {return 0;} - @Override public long maxEUOutput() {return 0;} - - @Override - public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java deleted file mode 100644 index b0cba5024c..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ /dev/null @@ -1,602 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.V; -import gregtech.api.GregTech_API; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.gui.GT_Container_BasicMachine; -import gregtech.api.gui.GT_GUIContainer_BasicMachine; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Utility; - -import java.util.Arrays; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidHandler; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * - * This is the main construct for my Basic Machines such as the Automatic Extractor - * Extend this class to make a simple Machine - */ -public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_BasicTank { - public boolean mAllowInputFromOutputSide = false, mFluidTransfer = false, mItemTransfer = false, mHasBeenUpdated = false, mStuttering = false, mCharge = false, mDecharge = false; - public int mMainFacing = -1, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mOutputBlocked = 0; - public FluidStack mOutputFluid; - private FluidStack mFluidOut; - public String mGUIName = "", mNEIName = ""; - - public final ItemStack[] mOutputItems; - public final int mInputSlotCount, mAmperage; - - private static final int OTHER_SLOT_COUNT = 4; - - /** - * @param aOverlays - * 0 = SideFacingActive - * 1 = SideFacingInactive - * 2 = FrontFacingActive - * 3 = FrontFacingInactive - * 4 = TopFacingActive - * 5 = TopFacingInactive - * 6 = BottomFacingActive - * 7 = BottomFacingInactive - * ----- Not all Array Elements have to be initialised, you can also just use 8 Parameters for the Default Pipe Texture Overlays ----- - * 8 = BottomFacingPipeActive - * 9 = BottomFacingPipeInactive - * 10 = TopFacingPipeActive - * 11 = TopFacingPipeInactive - * 12 = SideFacingPipeActive - * 13 = SideFacingPipeInactive - */ - public GT_MetaTileEntity_BasicMachine(int aID, String aName, String aNameRegional, int aTier, int aAmperage, String aDescription, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName, ITexture... aOverlays) { - super(aID, aName, aNameRegional, aTier, OTHER_SLOT_COUNT+aInputSlotCount+aOutputSlotCount+1, aDescription, aOverlays); - mInputSlotCount = Math.max(0, aInputSlotCount); - mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; - mAmperage = aAmperage; - mGUIName = aGUIName; - mNEIName = aNEIName; - } - - public GT_MetaTileEntity_BasicMachine(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, String aGUIName, String aNEIName) { - super(aName, aTier, OTHER_SLOT_COUNT+aInputSlotCount+aOutputSlotCount+1, aDescription, aTextures); - mInputSlotCount = Math.max(0, aInputSlotCount); - mOutputItems = new ItemStack[Math.max(0, aOutputSlotCount)]; - mAmperage = aAmperage; - mGUIName = aGUIName; - mNEIName = aNEIName; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[14][17][]; - aTextures = Arrays.copyOf(aTextures, 14); - - for (int i = 0; i < aTextures.length; i++) if (aTextures[i] != null) for (byte c = -1; c < 16; c++) { - if (rTextures[ i][c+1] == null) rTextures[ i][c+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][c+1], aTextures[i]}; - } - - for (byte c = -1; c < 16; c++) { - if (rTextures[ 0][c+1] == null) rTextures[ 0][c+1] = getSideFacingActive(c); - if (rTextures[ 1][c+1] == null) rTextures[ 1][c+1] = getSideFacingInactive(c); - if (rTextures[ 2][c+1] == null) rTextures[ 2][c+1] = getFrontFacingActive(c); - if (rTextures[ 3][c+1] == null) rTextures[ 3][c+1] = getFrontFacingInactive(c); - if (rTextures[ 4][c+1] == null) rTextures[ 4][c+1] = getTopFacingActive(c); - if (rTextures[ 5][c+1] == null) rTextures[ 5][c+1] = getTopFacingInactive(c); - if (rTextures[ 6][c+1] == null) rTextures[ 6][c+1] = getBottomFacingActive(c); - if (rTextures[ 7][c+1] == null) rTextures[ 7][c+1] = getBottomFacingInactive(c); - if (rTextures[ 8][c+1] == null) rTextures[ 8][c+1] = getBottomFacingPipeActive(c); - if (rTextures[ 9][c+1] == null) rTextures[ 9][c+1] = getBottomFacingPipeInactive(c); - if (rTextures[10][c+1] == null) rTextures[10][c+1] = getTopFacingPipeActive(c); - if (rTextures[11][c+1] == null) rTextures[11][c+1] = getTopFacingPipeInactive(c); - if (rTextures[12][c+1] == null) rTextures[12][c+1] = getSideFacingPipeActive(c); - if (rTextures[13][c+1] == null) rTextures[13][c+1] = getSideFacingPipeInactive(c); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[mMainFacing<2?aSide==aFacing?aActive?2:3:aSide==0?aActive?6:7:aSide==1?aActive?4:5:aActive?0:1:aSide==mMainFacing?aActive?2:3:(showPipeFacing()&&aSide==aFacing)?aSide==0?aActive?8:9:aSide==1?aActive?10:11:aActive?12:13:aSide==0?aActive?6:7:aSide==1?aActive?4:5:aActive?0:1][aColorIndex+1]; - } - - @Override public boolean isSimpleMachine() {return false;} - @Override public boolean isOverclockerUpgradable() {return false;} - @Override public boolean isTransformerUpgradable() {return false;} - @Override public boolean isElectric() {return true;} - @Override public boolean isValidSlot(int aIndex) {return aIndex > 0 && super.isValidSlot(aIndex) && aIndex != OTHER_SLOT_COUNT+mInputSlotCount+mOutputItems.length;} - @Override public boolean isFacingValid(byte aFacing) {return mMainFacing > 1 || aFacing > 1;} - @Override public boolean isEnetInput() {return true;} - @Override public boolean isInputFacing(byte aSide) {return aSide!=mMainFacing;} - @Override public boolean isOutputFacing(byte aSide) {return false;} - @Override public boolean isTeleporterCompatible() {return false;} - @Override public boolean isLiquidInput(byte aSide) {return aSide!=mMainFacing && (mAllowInputFromOutputSide || aSide != getBaseMetaTileEntity().getFrontFacing());} - @Override public boolean isLiquidOutput(byte aSide) {return aSide!=mMainFacing;} - @Override public long getMinimumStoredEU() {return V[mTier]*16;} - @Override public long maxEUStore() {return V[mTier]*64;} - @Override public long maxEUInput() {return V[mTier];} - @Override public long maxSteamStore() {return maxEUStore();} - @Override public long maxAmperesIn() {return (mEUt * 2) / V[mTier] + 1;} - @Override public int getInputSlot() {return OTHER_SLOT_COUNT;} - @Override public int getOutputSlot() {return OTHER_SLOT_COUNT+mInputSlotCount;} - @Override public int getStackDisplaySlot() {return 2;} - @Override public int rechargerSlotStartIndex() {return 1;} - @Override public int dechargerSlotStartIndex() {return 1;} - @Override public int rechargerSlotCount() {return mCharge?1:0;} - @Override public int dechargerSlotCount() {return mDecharge?1:0;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override public int getProgresstime() {return mProgresstime;} - @Override public int maxProgresstime() {return mMaxProgresstime;} - @Override public int increaseProgress(int aProgress) {mProgresstime += aProgress; return mMaxProgresstime-mProgresstime;} - @Override public boolean isFluidInputAllowed(FluidStack aFluid) {return getFillableStack() != null || (getRecipeList() != null && getRecipeList().containsInput(aFluid));} - @Override public boolean isFluidChangingAllowed() {return true;} - @Override public boolean doesFillContainers() {return false;} - @Override public boolean doesEmptyContainers() {return false;} - @Override public boolean canTankBeFilled() {return true;} - @Override public boolean canTankBeEmptied() {return true;} - @Override public boolean displaysItemStack() {return true;} - @Override public boolean displaysStackSize() {return true;} - @Override public FluidStack getDisplayedFluid() {return displaysOutputFluid()?getDrainableStack():null;} - @Override public FluidStack getDrainableStack() {return mFluidOut;} - @Override public FluidStack setDrainableStack(FluidStack aFluid){mFluidOut = aFluid; return mFluidOut;} - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : ""); - } - - @Override - public void initDefaultModes(NBTTagCompound aNBT) { - mMainFacing = -1; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mFluidTransfer", mFluidTransfer); - aNBT.setBoolean("mItemTransfer", mItemTransfer); - aNBT.setBoolean("mHasBeenUpdated", mHasBeenUpdated); - aNBT.setBoolean("mAllowInputFromOutputSide", mAllowInputFromOutputSide); - aNBT.setInteger("mEUt", mEUt); - aNBT.setInteger("mMainFacing", mMainFacing); - aNBT.setInteger("mProgresstime", mProgresstime); - aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); - if (mOutputFluid != null) aNBT.setTag("mOutputFluid", mOutputFluid.writeToNBT(new NBTTagCompound())); - if (mFluidOut != null) aNBT.setTag("mFluidOut", mFluidOut.writeToNBT(new NBTTagCompound())); - - for (int i = 0; i < mOutputItems.length; i++) if (mOutputItems[i] != null) aNBT.setTag("mOutputItem"+i, mOutputItems[i].writeToNBT(new NBTTagCompound())); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mFluidTransfer = aNBT.getBoolean("mFluidTransfer"); - mItemTransfer = aNBT.getBoolean("mItemTransfer"); - mHasBeenUpdated = aNBT.getBoolean("mHasBeenUpdated"); - mAllowInputFromOutputSide = aNBT.getBoolean("mAllowInputFromOutputSide"); - mEUt = aNBT.getInteger("mEUt"); - mMainFacing = aNBT.getInteger("mMainFacing"); - mProgresstime = aNBT.getInteger("mProgresstime"); - mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - mOutputFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mOutputFluid")); - mFluidOut = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluidOut")); - - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem"+i); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - - if (aBaseMetaTileEntity.isServerSide()) { - mCharge = aBaseMetaTileEntity.getStoredEU() / 2 > aBaseMetaTileEntity.getEUCapacity() / 3; - mDecharge = aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity() / 3; - - doDisplayThings(); - - boolean tSucceeded = false; - - if (mMaxProgresstime > 0 && (mProgresstime >= 0 || aBaseMetaTileEntity.isAllowedToWork())) { - aBaseMetaTileEntity.setActive(true); - if (mProgresstime < 0 || drainEnergyForProcess(mEUt)) { - if (++mProgresstime>=mMaxProgresstime) { - for (int i = 0; i < mOutputItems.length; i++) for (int j = 0; j < mOutputItems.length; j++) if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot()+((j+i)%mOutputItems.length), mOutputItems[i])) break; - if (mOutputFluid != null) if (getDrainableStack() == null) setDrainableStack(mOutputFluid.copy()); else if (mOutputFluid.isFluidEqual(getDrainableStack())) getDrainableStack().amount += mOutputFluid.amount; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; - mOutputFluid = null; - mEUt = 0; - mProgresstime = 0; - mMaxProgresstime = 0; - mStuttering = false; - tSucceeded = true; - endProcess(); - } - if (mProgresstime > 5) mStuttering = false; - } else { - if (!mStuttering) { - stutterProcess(); - if (canHaveInsufficientEnergy()) mProgresstime = -100; - mStuttering = true; - } - } - } else { - aBaseMetaTileEntity.setActive(false); - } - - boolean tRemovedOutputFluid = false; - - if (doesAutoOutputFluids() && getDrainableStack() != null && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || aTick%20 == 0)) { - IFluidHandler tTank = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); - if (tTank != null) { - FluidStack tDrained = drain(1000, false); - if (tDrained != null) { - int tFilledAmount = tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); - if (tFilledAmount > 0) tTank.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), drain(tFilledAmount, true), true); - } - } - if (getDrainableStack() == null) tRemovedOutputFluid = true; - } - - if (doesAutoOutput() && !isOutputEmpty() && aBaseMetaTileEntity.getFrontFacing() != mMainFacing && (tSucceeded || mOutputBlocked%300 == 1 || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick%600 == 0)) { - TileEntity tTileEntity2 = aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getFrontFacing()); - for (int i = 0, tCosts = 1; i < mOutputItems.length && tCosts > 0 && aBaseMetaTileEntity.isUniversalEnergyStored(128); i++) { - tCosts = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, tTileEntity2, aBaseMetaTileEntity.getFrontFacing(), aBaseMetaTileEntity.getBackFacing(), null, false, (byte)64, (byte)1, (byte)64, (byte)1); - if (tCosts > 0) aBaseMetaTileEntity.decreaseStoredEnergyUnits(tCosts, true); - } - } - - if (mOutputBlocked != 0) if (isOutputEmpty()) mOutputBlocked = 0; else mOutputBlocked++; - - if (allowToCheckRecipe()) { - if (mMaxProgresstime <= 0 && aBaseMetaTileEntity.isAllowedToWork() && (tRemovedOutputFluid || tSucceeded || aBaseMetaTileEntity.hasInventoryBeenModified() || aTick%600 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) && hasEnoughEnergyToCheckRecipe()) { - if (checkRecipe() == 2) { - if (mInventory[3] != null && mInventory[3].stackSize <= 0) mInventory[3] = null; - for (int i=getInputSlot() , j=i+mInputSlotCount ; i<j; i++) if (mInventory[i]!=null&&mInventory[i].stackSize<=0) mInventory[i]=null; - for (int i=0; i<mOutputItems.length; i++) { - mOutputItems[i] = GT_Utility.copy(mOutputItems[i]); - if (mOutputItems[i]!=null&&mOutputItems[i].stackSize>64) mOutputItems[i].stackSize=64; - mOutputItems[i] = GT_OreDictUnificator.get(true, mOutputItems[i]); - } - if (mFluid != null && mFluid.amount <= 0) mFluid = null; - mMaxProgresstime = Math.max(1, mMaxProgresstime); - if (GT_Utility.isDebugItem(mInventory[dechargerSlotStartIndex()])) { - mEUt = mMaxProgresstime = 1; - } - startProcess(); - } else { - mMaxProgresstime = 0; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = null; - mOutputFluid = null; - } - } - } else { - if (!mStuttering) { - stutterProcess(); - mStuttering = true; - } - } - } - } - - protected void doDisplayThings() { - if (mMainFacing < 2 && getBaseMetaTileEntity().getFrontFacing() > 1) { - mMainFacing = getBaseMetaTileEntity().getFrontFacing(); - } - if (mMainFacing >= 2 && !mHasBeenUpdated) { - mHasBeenUpdated = true; - getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); - } - - if (displaysInputFluid()) { - int tDisplayStackSlot = OTHER_SLOT_COUNT+mInputSlotCount+mOutputItems.length; - if (getFillableStack() == null) { - if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) mInventory[tDisplayStackSlot] = null; - } else { - mInventory[tDisplayStackSlot] = GT_Utility.getFluidDisplayStack(getFillableStack(), displaysStackSize()); - } - } - } - - protected boolean hasEnoughEnergyToCheckRecipe() { - return getBaseMetaTileEntity().isUniversalEnergyStored(getMinimumStoredEU() / 2); - } - - protected boolean drainEnergyForProcess(long aEUt) { - return getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEUt, false); - } - - protected void calculateOverclockedNess(GT_Recipe aRecipe) { - calculateOverclockedNess(aRecipe.mEUt, aRecipe.mDuration); - } - - protected void calculateOverclockedNess(int aEUt, int aDuration) { - if (aEUt <= 16) { - mEUt = aEUt * (1 << (mTier-1)) * (1 << (mTier-1)); - mMaxProgresstime = aDuration / (1 << (mTier-1)); - } else { - mEUt = aEUt; - mMaxProgresstime = aDuration; - while (mEUt <= V[mTier-1] * mAmperage) { - mEUt *= 4; - mMaxProgresstime /= 2; - } - } - } - - protected ItemStack getSpecialSlot() { - return mInventory[3]; - } - - protected ItemStack getOutputAt(int aIndex) { - return mInventory[getOutputSlot()+aIndex]; - } - - protected ItemStack[] getAllOutputs() { - ItemStack[] rOutputs = new ItemStack[mOutputItems.length]; - for (int i = 0; i < mOutputItems.length; i++) rOutputs[i] = getOutputAt(i); - return rOutputs; - } - - protected boolean canOutput(GT_Recipe aRecipe) { - return aRecipe != null && (aRecipe.mNeedsEmptyOutput ? isOutputEmpty() && getDrainableStack() == null : canOutput(aRecipe.getFluidOutput(0)) && canOutput(aRecipe.mOutputs)); - } - - protected boolean canOutput(ItemStack... aOutputs) { - if (aOutputs == null) return true; - ItemStack[] tOutputSlots = getAllOutputs(); - for (int i = 0; i < tOutputSlots.length && i < aOutputs.length; i++) if (tOutputSlots[i] != null && aOutputs[i] != null && (!GT_Utility.areStacksEqual(tOutputSlots[i], aOutputs[i], false) || tOutputSlots[i].stackSize + aOutputs[i].stackSize > tOutputSlots[i].getMaxStackSize())) { - mOutputBlocked++; - return false; - } - return true; - } - - protected boolean canOutput(FluidStack aOutput) { - return getDrainableStack() == null || aOutput == null || (getDrainableStack().isFluidEqual(aOutput) && (getDrainableStack().amount <= 0 || getDrainableStack().amount + aOutput.amount <= getCapacity())); - } - - protected ItemStack getInputAt(int aIndex) { - return mInventory[getInputSlot()+aIndex]; - } - - protected ItemStack[] getAllInputs() { - ItemStack[] rInputs = new ItemStack[mInputSlotCount]; - for (int i = 0; i < mInputSlotCount; i++) rInputs[i] = getInputAt(i); - return rInputs; - } - - protected boolean isOutputEmpty() { - boolean rIsEmpty = true; - for (ItemStack tOutputSlotContent : getAllOutputs()) if (tOutputSlotContent != null) rIsEmpty = false; - return rIsEmpty; - } - - protected boolean displaysInputFluid() { - return true; - } - - protected boolean displaysOutputFluid() { - return true; - } - - @Override - public void onValueUpdate(byte aValue) { - mMainFacing = aValue; - } - - @Override - public byte getUpdateData() { - return (byte)mMainFacing; - } - - @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) { - super.doSound(aIndex, aX, aY, aZ); - if (aIndex == 8) GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(210), 100, 1.0F, aX, aY, aZ); - } - - public boolean doesAutoOutput() { - return mItemTransfer; - } - - public boolean doesAutoOutputFluids() { - return mFluidTransfer; - } - - public boolean allowToCheckRecipe() { - return true; - } - - public boolean showPipeFacing() { - return true; - } - - /** Called whenever the Machine successfully started a Process, useful for Sound Effects */ - public void startProcess() { - // - } - - /** Called whenever the Machine successfully finished a Process, useful for Sound Effects */ - public void endProcess() { - // - } - - /** Called whenever the Machine aborted a Process, useful for Sound Effects */ - public void abortProcess() { - // - } - - /** Called whenever the Machine aborted a Process but still works on it, useful for Sound Effects */ - public void stutterProcess() { - if (useStandardStutterSound()) sendSound((byte)8); - } - - /** If this Machine can have the Insufficient Energy Line Problem */ - public boolean canHaveInsufficientEnergy() { - return true; - } - - public boolean useStandardStutterSound() { - return true; - } - - @Override - public String[] getInfoData() { - return new String[] { - mNEIName, - "Progress:", (mProgresstime/20)+" secs", - (mMaxProgresstime/20)+" secs", - "Stored Energy:", - getBaseMetaTileEntity().getStoredEU()+"EU", - getBaseMetaTileEntity().getEUCapacity()+"EU"}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getFrontFacing() || aSide == mMainFacing) { - mAllowInputFromOutputSide = !mAllowInputFromOutputSide; - GT_Utility.sendChatToPlayer(aPlayer, mAllowInputFromOutputSide?"Input from Output Side allowed":"Input from Output Side forbidden"); - } - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return (aSide!=mMainFacing||GregTech_API.getCoverBehavior(aCoverID.toStack()).isGUIClickable(aSide, GT_Utility.stackToInt(aCoverID.toStack()), 0, getBaseMetaTileEntity())); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide!=mMainFacing&&aIndex>=getOutputSlot()&&aIndex<getOutputSlot()+mOutputItems.length; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aSide==mMainFacing||aIndex<getInputSlot()||aIndex>=getInputSlot()+mInputSlotCount||(!mAllowInputFromOutputSide&&aSide==aBaseMetaTileEntity.getFrontFacing())) return false; - for (int i=getInputSlot(), j=i+mInputSlotCount; i<j; i++) if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i==aIndex; - return true; - } - - /** @return the Recipe List which is used for this Machine, this is a useful Default Handler */ - public GT_Recipe_Map getRecipeList() { - return null; - } - - /** return values for checkRecipe() */ - protected static final int - DID_NOT_FIND_RECIPE = 0, - FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS = 1, - FOUND_AND_SUCCESSFULLY_USED_RECIPE = 2; - - /** Contains the Recipe which has been previously used, or null if there was no previous Recipe, which could have been buffered */ - protected GT_Recipe mLastRecipe = null; - - /** - * Override this to check the Recipes yourself, super calls to this could be useful if you just want to add a special case - * - * I thought about Enum too, but Enum doesn't add support for people adding other return Systems. - * - * Funny how Eclipse marks the word Enum as not correctly spelled. - * - * @return see constants above - */ - public int checkRecipe() { - GT_Recipe_Map tMap = getRecipeList(); - if (tMap == null) return DID_NOT_FIND_RECIPE; - GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, V[mTier], new FluidStack[] {getFillableStack()}, getSpecialSlot(), getAllInputs()); - if (tRecipe == null) return DID_NOT_FIND_RECIPE; - if (tRecipe.mCanBeBuffered) mLastRecipe = tRecipe; - if (!canOutput(tRecipe)) {mOutputBlocked++; return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS;} - if (!tRecipe.isRecipeInputEqual(true, new FluidStack[] {getFillableStack()}, getAllInputs())) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; - - for (int i = 0; i < mOutputItems.length; i++) if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(i)) mOutputItems[i] = tRecipe.getOutput(i); - mOutputFluid = tRecipe.getFluidOutput(0); - calculateOverclockedNess(tRecipe); - return FOUND_AND_SUCCESSFULLY_USED_RECIPE; - } - - public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]}; - } - - public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]}; - } - - public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]}; - } - - public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]}; - } - - public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]}; - } - - public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]}; - } - - public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]}; - } - - public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1]}; - } - - public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColor+1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java deleted file mode 100644 index 3d923db52c..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Bronze.java +++ /dev/null @@ -1,187 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.D1; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; - -import java.util.ArrayList; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraftforge.common.util.ForgeDirection; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * - * This is the main construct for my Basic Machines such as the Automatic Extractor - * Extend this class to make a simple Machine - */ -public abstract class GT_MetaTileEntity_BasicMachine_Bronze extends GT_MetaTileEntity_BasicMachine { - public GT_MetaTileEntity_BasicMachine_Bronze(int aID, String aName, String aNameRegional, String aDescription, int aInputSlotCount, int aOutputSlotCount, boolean aBricked) { - super(aID, aName, aNameRegional, aBricked?1:0, 0, aDescription, aInputSlotCount, aOutputSlotCount, "", ""); - } - - public GT_MetaTileEntity_BasicMachine_Bronze(String aName, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, boolean aBricked) { - super(aName, aBricked?1:0, 0, aDescription, aTextures, aInputSlotCount, aOutputSlotCount, "", ""); - } - /* - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_BasicMachine_Bronze(mTier, mDescription, mTextures); - } - */ - public boolean mNeedsSteamVenting = false; - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setBoolean("mNeedsSteamVenting", mNeedsSteamVenting); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mNeedsSteamVenting = aNBT.getBoolean("mNeedsSteamVenting"); - } - - @Override public boolean isElectric() {return false;} - @Override public boolean isEnetInput() {return false;} - @Override public boolean isInputFacing(byte aSide) {return false;} - @Override public long maxEUStore() {return 0;} - @Override public long maxEUInput() {return 0;} - @Override public int rechargerSlotCount() {return 0;} - @Override public int dechargerSlotCount() {return 0;} - - @Override public boolean isSteampowered() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return super.isFacingValid(aFacing) && aFacing != mMainFacing;} - @Override public long getMinimumStoredEU() {return 1000;} - @Override public long maxSteamStore() {return 16000;} - @Override public boolean isLiquidInput (byte aSide) {return aSide != mMainFacing;} - @Override public boolean isLiquidOutput(byte aSide) {return aSide != mMainFacing;} - - @Override - public boolean doesAutoOutput() { - return false; - } - - @Override - public boolean allowToCheckRecipe() { - if (mNeedsSteamVenting && getBaseMetaTileEntity().getCoverIDAtSide(getBaseMetaTileEntity().getFrontFacing()) == 0 && !GT_Utility.hasBlockHitBox(getBaseMetaTileEntity().getWorld(), getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1), getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1), getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1))) { - sendSound((byte)9); - mNeedsSteamVenting = false; - try { - for (EntityLivingBase tLiving : (ArrayList<EntityLivingBase>)getBaseMetaTileEntity().getWorld().getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1), getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1), getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1), getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1)+1, getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1)+1, getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1)+1))) { - GT_Utility.applyHeatDamage(tLiving, getSteamDamage()); - } - } catch(Throwable e) { - if (D1) e.printStackTrace(GT_Log.err); - } - } - return !mNeedsSteamVenting; - } - - @Override - public void endProcess() { - if (isSteampowered()) mNeedsSteamVenting = true; - } - - @Override - public void doSound(byte aIndex, double aX, double aY, double aZ) { - super.doSound(aIndex, aX, aY, aZ); - if (aIndex == 9) { - GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(4), 5, 1.0F, aX, aY, aZ); - for (int l = 0; l < 8; ++l) getBaseMetaTileEntity().getWorld().spawnParticle("largesmoke", aX - 0.5 + Math.random(), aY - 0.5 + Math.random(), aZ - 0.5 + Math.random(), ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetX / 5.0, ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetY / 5.0, ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing()).offsetZ / 5.0); - } - } - - @Override - public boolean isGivingInformation() { - return false; - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return GregTech_API.getCoverBehavior(aCoverID.toStack()).isSimpleCover() && super.allowCoverOnSide(aSide, aCoverID); - } - - public float getSteamDamage() { - return 6.0F; - } - - @Override - public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE:Textures.BlockIcons.MACHINE_BRONZE_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE:Textures.BlockIcons.MACHINE_BRONZE_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE:Textures.BlockIcons.MACHINE_BRONZE_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE:Textures.BlockIcons.MACHINE_BRONZE_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP:Textures.BlockIcons.MACHINE_BRONZE_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP:Textures.BlockIcons.MACHINE_BRONZE_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM:Textures.BlockIcons.MACHINE_BRONZE_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM:Textures.BlockIcons.MACHINE_BRONZE_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM:Textures.BlockIcons.MACHINE_BRONZE_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_BOTTOM:Textures.BlockIcons.MACHINE_BRONZE_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP:Textures.BlockIcons.MACHINE_BRONZE_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_TOP:Textures.BlockIcons.MACHINE_BRONZE_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE:Textures.BlockIcons.MACHINE_BRONZE_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_BRONZEBRICKS_SIDE:Textures.BlockIcons.MACHINE_BRONZE_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java deleted file mode 100644 index 30272cee80..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java +++ /dev/null @@ -1,319 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.GT_Values.W; -import gregtech.api.enums.*; -import gregtech.api.gui.GT_Container_BasicMachine; -import gregtech.api.gui.GT_GUIContainer_BasicMachine; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_ModHandler.RecipeBits; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Utility; - -import java.util.Random; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * - * This is the main construct for my Basic Machines such as the Automatic Extractor - * Extend this class to make a simple Machine - */ -public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_BasicMachine { - public static enum X {PUMP, WIRE, WIRE4, HULL, PIPE, GLASS, PLATE, MOTOR, ROTOR, SENSOR, PISTON, CIRCUIT, EMITTER, CONVEYOR, ROBOT_ARM, COIL_HEATING, COIL_ELECTRIC, STICK_MAGNETIC, STICK_DISTILLATION, BETTER_CIRCUIT, FIELD_GENERATOR, COIL_HEATING_DOUBLE, STICK_ELECTROMAGNETIC;} - - private final GT_Recipe_Map mRecipes; - private final int mTankCapacity, mSpecialEffect; - private final String mSound; - private final boolean mSharedTank, mRequiresFluidForFiltering; - private final byte mGUIParameterA, mGUIParameterB; - - public GT_MetaTileEntity_BasicMachine_GT_Recipe(int aID, String aName, String aNameRegional, int aTier, String aDescription, GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe) { - super(aID, aName, aNameRegional, aTier, aRecipes.mAmperage, aDescription, aInputSlots, aOutputSlots, aGUIName, aRecipes.mNEIName, new ITexture[] {new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_TOP_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_TOP")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/" + aOverlays.toLowerCase() + "/OVERLAY_BOTTOM"))}); - mSharedTank = aSharedTank; - mTankCapacity = aTankCapacity; - mSpecialEffect = aSpecialEffect; - mRequiresFluidForFiltering = aRequiresFluidForFiltering; - mRecipes = aRecipes; - mSound = aSound; - mGUIParameterA = (byte)aGUIParameterA; - mGUIParameterB = (byte)aGUIParameterB; - - if (aRecipe != null) { - for (int i = 3; i < aRecipe.length; i++) { - if (aRecipe[i] == X.CIRCUIT) {aRecipe[i] = Tier.ELECTRIC[mTier].mManagingObject; continue;} - if (aRecipe[i] == X.BETTER_CIRCUIT) {aRecipe[i] = Tier.ELECTRIC[mTier].mBetterManagingObject; continue;} - if (aRecipe[i] == X.HULL) {aRecipe[i] = Tier.ELECTRIC[mTier].mHullObject; continue;} - if (aRecipe[i] == X.WIRE) {aRecipe[i] = Tier.ELECTRIC[mTier].mConductingObject; continue;} - if (aRecipe[i] == X.WIRE4) {aRecipe[i] = Tier.ELECTRIC[mTier].mLargerConductingObject; continue;} - - if (aRecipe[i] == X.GLASS) {switch(mTier) { - default: aRecipe[i] = new ItemStack(Blocks.glass, 1, W); break; - }continue;} - - if (aRecipe[i] == X.PLATE) {switch(mTier) { - case 0: case 1: aRecipe[i] = OrePrefixes.plate.get(Materials.Steel); break; - case 2: aRecipe[i] = OrePrefixes.plate.get(Materials.Aluminium); break; - case 3: aRecipe[i] = OrePrefixes.plate.get(Materials.StainlessSteel); break; - case 4: aRecipe[i] = OrePrefixes.plate.get(Materials.Titanium); break; - default: aRecipe[i] = OrePrefixes.plate.get(Materials.TungstenSteel); break; - }continue;} - - if (aRecipe[i] == X.PIPE) {switch(mTier) { - case 0: case 1: aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Bronze); break; - case 2: aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Steel); break; - case 3: aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.StainlessSteel); break; - case 4: aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.Titanium); break; - default: aRecipe[i] = OrePrefixes.pipeMedium.get(Materials.TungstenSteel); break; - }continue;} - - if (aRecipe[i] == X.COIL_HEATING) {switch(mTier) { - case 0: case 1: aRecipe[i] = OrePrefixes.wireGt02.get(Materials.AnyCopper); break; - case 2: aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Cupronickel); break; - case 3: aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Kanthal); break; - case 4: aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Nichrome); break; - default: aRecipe[i] = OrePrefixes.wireGt08.get(Materials.Nichrome); break; - }continue;} - - if (aRecipe[i] == X.COIL_HEATING_DOUBLE) {switch(mTier) { - case 0: case 1: aRecipe[i] = OrePrefixes.wireGt04.get(Materials.AnyCopper); break; - case 2: aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Cupronickel); break; - case 3: aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Kanthal); break; - case 4: aRecipe[i] = OrePrefixes.wireGt04.get(Materials.Nichrome); break; - default: aRecipe[i] = OrePrefixes.wireGt16.get(Materials.Nichrome); break; - }continue;} - - if (aRecipe[i] == X.STICK_DISTILLATION) {switch(mTier) { - default: aRecipe[i] = OrePrefixes.stick.get(Materials.Blaze); break; - }continue;} - - if (aRecipe[i] == X.STICK_MAGNETIC) {switch(mTier) { - case 0: case 1: aRecipe[i] = OrePrefixes.stick.get(Materials.IronMagnetic); break; - case 2: case 3: aRecipe[i] = OrePrefixes.stick.get(Materials.SteelMagnetic); break; - default: aRecipe[i] = OrePrefixes.stick.get(Materials.NeodymiumMagnetic); break; - }continue;} - - if (aRecipe[i] == X.STICK_ELECTROMAGNETIC) {switch(mTier) { - case 0: case 1: aRecipe[i] = OrePrefixes.stick.get(Materials.AnyIron); break; - case 2: case 3: aRecipe[i] = OrePrefixes.stick.get(Materials.Steel); break; - case 4: aRecipe[i] = OrePrefixes.stick.get(Materials.Neodymium); break; - default: aRecipe[i] = OrePrefixes.stick.get(Materials.VanadiumGallium); break; - }continue;} - - if (aRecipe[i] == X.COIL_ELECTRIC) {switch(mTier) { - case 0: aRecipe[i] = OrePrefixes.wireGt01.get(Materials.Tin); break; - case 1: aRecipe[i] = OrePrefixes.wireGt02.get(Materials.Tin); break; - case 2: aRecipe[i] = OrePrefixes.wireGt02.get(Materials.AnyCopper); break; - case 3: aRecipe[i] = OrePrefixes.wireGt04.get(Materials.AnyCopper); break; - case 4: aRecipe[i] = OrePrefixes.wireGt08.get(Materials.AnnealedCopper); break; - default: aRecipe[i] = OrePrefixes.wireGt16.get(Materials.AnnealedCopper); break; - }continue;} - - if (aRecipe[i] == X.ROBOT_ARM) {switch(mTier) { - case 0: case 1: aRecipe[i] = ItemList.Robot_Arm_LV; break; - case 2: aRecipe[i] = ItemList.Robot_Arm_MV; break; - case 3: aRecipe[i] = ItemList.Robot_Arm_HV; break; - case 4: aRecipe[i] = ItemList.Robot_Arm_EV; break; - case 5: aRecipe[i] = ItemList.Robot_Arm_IV; break; - case 6: aRecipe[i] = ItemList.Robot_Arm_LuV; break; - case 7: aRecipe[i] = ItemList.Robot_Arm_ZPM; break; - default: aRecipe[i] = ItemList.Robot_Arm_UV; break; - }continue;} - - if (aRecipe[i] == X.PUMP) {switch(mTier) { - case 0: case 1: aRecipe[i] = ItemList.Electric_Pump_LV; break; - case 2: aRecipe[i] = ItemList.Electric_Pump_MV; break; - case 3: aRecipe[i] = ItemList.Electric_Pump_HV; break; - case 4: aRecipe[i] = ItemList.Electric_Pump_EV; break; - case 5: aRecipe[i] = ItemList.Electric_Pump_IV; break; - case 6: aRecipe[i] = ItemList.Electric_Pump_LuV; break; - case 7: aRecipe[i] = ItemList.Electric_Pump_ZPM; break; - default: aRecipe[i] = ItemList.Electric_Pump_UV; break; - }continue;} - - if (aRecipe[i] == X.ROTOR) {switch(mTier) { - case 0: case 1: aRecipe[i] = OrePrefixes.rotor.get(Materials.Tin); break; - case 2: aRecipe[i] = OrePrefixes.rotor.get(Materials.Bronze); break; - case 3: aRecipe[i] = OrePrefixes.rotor.get(Materials.Steel); break; - case 4: aRecipe[i] = OrePrefixes.rotor.get(Materials.StainlessSteel); break; - case 5: aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); break; - case 6: aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); break; - case 7: aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); break; - default: aRecipe[i] = OrePrefixes.rotor.get(Materials.TungstenSteel); break; - }continue;} - - if (aRecipe[i] == X.MOTOR) {switch(mTier) { - case 0: case 1: aRecipe[i] = ItemList.Electric_Motor_LV; break; - case 2: aRecipe[i] = ItemList.Electric_Motor_MV; break; - case 3: aRecipe[i] = ItemList.Electric_Motor_HV; break; - case 4: aRecipe[i] = ItemList.Electric_Motor_EV; break; - case 5: aRecipe[i] = ItemList.Electric_Motor_IV; break; - case 6: aRecipe[i] = ItemList.Electric_Motor_LuV; break; - case 7: aRecipe[i] = ItemList.Electric_Motor_ZPM; break; - default: aRecipe[i] = ItemList.Electric_Motor_UV; break; - }continue;} - - if (aRecipe[i] == X.PISTON) {switch(mTier) { - case 0: case 1: aRecipe[i] = ItemList.Electric_Piston_LV; break; - case 2: aRecipe[i] = ItemList.Electric_Piston_MV; break; - case 3: aRecipe[i] = ItemList.Electric_Piston_HV; break; - case 4: aRecipe[i] = ItemList.Electric_Piston_EV; break; - case 5: aRecipe[i] = ItemList.Electric_Piston_IV; break; - case 6: aRecipe[i] = ItemList.Electric_Piston_LuV; break; - case 7: aRecipe[i] = ItemList.Electric_Piston_ZPM; break; - default: aRecipe[i] = ItemList.Electric_Piston_UV; break; - }continue;} - - if (aRecipe[i] == X.CONVEYOR) {switch(mTier) { - case 0: case 1: aRecipe[i] = ItemList.Conveyor_Module_LV; break; - case 2: aRecipe[i] = ItemList.Conveyor_Module_MV; break; - case 3: aRecipe[i] = ItemList.Conveyor_Module_HV; break; - case 4: aRecipe[i] = ItemList.Conveyor_Module_EV; break; - case 5: aRecipe[i] = ItemList.Conveyor_Module_IV; break; - case 6: aRecipe[i] = ItemList.Conveyor_Module_LuV; break; - case 7: aRecipe[i] = ItemList.Conveyor_Module_ZPM; break; - default: aRecipe[i] = ItemList.Conveyor_Module_UV; break; - }continue;} - - if (aRecipe[i] == X.EMITTER) {switch(mTier) { - case 0: case 1: aRecipe[i] = ItemList.Emitter_LV; break; - case 2: aRecipe[i] = ItemList.Emitter_MV; break; - case 3: aRecipe[i] = ItemList.Emitter_HV; break; - case 4: aRecipe[i] = ItemList.Emitter_EV; break; - case 5: aRecipe[i] = ItemList.Emitter_IV; break; - case 6: aRecipe[i] = ItemList.Emitter_LuV; break; - case 7: aRecipe[i] = ItemList.Emitter_ZPM; break; - default: aRecipe[i] = ItemList.Emitter_UV; break; - }continue;} - - if (aRecipe[i] == X.SENSOR) {switch(mTier) { - case 0: case 1: aRecipe[i] = ItemList.Sensor_LV; break; - case 2: aRecipe[i] = ItemList.Sensor_MV; break; - case 3: aRecipe[i] = ItemList.Sensor_HV; break; - case 4: aRecipe[i] = ItemList.Sensor_EV; break; - case 5: aRecipe[i] = ItemList.Sensor_IV; break; - case 6: aRecipe[i] = ItemList.Sensor_LuV; break; - case 7: aRecipe[i] = ItemList.Sensor_ZPM; break; - default: aRecipe[i] = ItemList.Sensor_UV; break; - }continue;} - - if (aRecipe[i] == X.FIELD_GENERATOR) {switch(mTier) { - case 0: case 1: aRecipe[i] = ItemList.Field_Generator_LV; break; - case 2: aRecipe[i] = ItemList.Field_Generator_MV; break; - case 3: aRecipe[i] = ItemList.Field_Generator_HV; break; - case 4: aRecipe[i] = ItemList.Field_Generator_EV; break; - case 5: aRecipe[i] = ItemList.Field_Generator_IV; break; - case 6: aRecipe[i] = ItemList.Field_Generator_LuV; break; - case 7: aRecipe[i] = ItemList.Field_Generator_ZPM; break; - default: aRecipe[i] = ItemList.Field_Generator_UV; break; - }continue;} - - if (aRecipe[i] instanceof X) throw new IllegalArgumentException("MISSING TIER MAPPING FOR: " + aRecipe[i] + " AT TIER " + mTier); - } - - if (!GT_ModHandler.addCraftingRecipe(getStackForm(1), RecipeBits.DISMANTLEABLE | RecipeBits.BUFFERED | RecipeBits.NOT_REMOVABLE | RecipeBits.REVERSIBLE, aRecipe)) { - throw new IllegalArgumentException("INVALID CRAFTING RECIPE FOR: " + getStackForm(1).getDisplayName()); - } - } - } - - public GT_MetaTileEntity_BasicMachine_GT_Recipe(String aName, int aTier, String aDescription, GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) { - super(aName, aTier, aAmperage, aDescription, aTextures, aInputSlots, aOutputSlots, aGUIName, aNEIName); - mSharedTank = aSharedTank; - mTankCapacity = aTankCapacity; - mSpecialEffect = aSpecialEffect; - mRequiresFluidForFiltering = aRequiresFluidForFiltering; - mRecipes = aRecipes; - mSound = aSound; - mGUIParameterA = (byte)aGUIParameterA; - mGUIParameterB = (byte)aGUIParameterB; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_BasicMachine_GT_Recipe(mName, mTier, mDescription, mRecipes, mInputSlotCount, mOutputItems==null?0:mOutputItems.length, mTankCapacity, mAmperage, mGUIParameterA, mGUIParameterB, mTextures, mGUIName, mNEIName, mSound, mSharedTank, mRequiresFluidForFiltering, mSpecialEffect); - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_BasicMachine(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), mGUIName, GT_Utility.isStringValid(mNEIName) ? mNEIName : getRecipeList() != null ? getRecipeList().mUnlocalizedName : "", mGUIParameterA, mGUIParameterB); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false; - if (mInventory[aIndex] != null) return true; - switch (mInputSlotCount) { - case 0: return false; - case 1: return getFillableStack() == null ? !mRequiresFluidForFiltering && getRecipeList().containsInput(aStack) : null!=getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[] {getFillableStack()}, getSpecialSlot(), new ItemStack[] {aStack}); - case 2: return (!mRequiresFluidForFiltering || getFillableStack() != null) && (((getInputAt(0)!=null&&getInputAt(1)!=null) || (getInputAt(0)==null&&getInputAt(1)==null?getRecipeList().containsInput(aStack):null!=getRecipeList().findRecipe(getBaseMetaTileEntity(), mLastRecipe, true, V[mTier], new FluidStack[] {getFillableStack()}, getSpecialSlot(), aIndex == getInputSlot() ? new ItemStack[] {aStack, getInputAt(1)} : new ItemStack[] {getInputAt(0), aStack})))); - default: return getRecipeList().containsInput(aStack); - } - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { - switch (mSpecialEffect) { - case 0: - break; - case 1: - if (aBaseMetaTileEntity.getFrontFacing() != 1 && aBaseMetaTileEntity.getCoverIDAtSide((byte)1) == 0 && !aBaseMetaTileEntity.getOpacityAtSide((byte)1)) { - Random tRandom = aBaseMetaTileEntity.getWorld().rand; - aBaseMetaTileEntity.getWorld().spawnParticle("smoke", aBaseMetaTileEntity.getXCoord() + 0.8F -tRandom.nextFloat()*0.6F, aBaseMetaTileEntity.getYCoord() + 0.9F + tRandom.nextFloat()*0.2F, aBaseMetaTileEntity.getZCoord() + 0.8F -tRandom.nextFloat()*0.6F, 0.0D, 0.0D, 0.0D); - } - break; - } - } - } - - @Override - public GT_Recipe_Map getRecipeList() { - return mRecipes; - } - - @Override - public int getCapacity() { - return mTankCapacity; - } - - @Override - public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { - super.startSoundLoop(aIndex, aX, aY, aZ); - if (aIndex == 1 && GT_Utility.isStringValid(mSound)) GT_Utility.doSoundAtClient(mSound, 100, 1.0F, aX, aY, aZ); - } - - @Override - public void startProcess() { - if (GT_Utility.isStringValid(mSound)) sendLoopStart((byte)1); - } - - @Override - public FluidStack getFillableStack() { - return mSharedTank ? getDrainableStack() : super.getFillableStack(); - } - - @Override - public FluidStack setFillableStack(FluidStack aFluid) { - return mSharedTank ? setDrainableStack(aFluid) : super.setFillableStack(aFluid); - } - - @Override - protected boolean displaysOutputFluid() { - return !mSharedTank; - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.java deleted file mode 100644 index a9a172bb17..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_Steel.java +++ /dev/null @@ -1,103 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.objects.GT_RenderedTexture; - - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * - * This is the main construct for my Basic Machines such as the Automatic Extractor - * Extend this class to make a simple Machine - */ -public abstract class GT_MetaTileEntity_BasicMachine_Steel extends GT_MetaTileEntity_BasicMachine_Bronze { - public GT_MetaTileEntity_BasicMachine_Steel(int aID, String aName, String aNameRegional, String aDescription, int aInputSlotCount, int aOutputSlotCount, boolean aBricked) { - super(aID, aName, aNameRegional, aDescription, aInputSlotCount, aOutputSlotCount, aBricked); - } - - public GT_MetaTileEntity_BasicMachine_Steel(String aName, String aDescription, ITexture[][][] aTextures, int aInputSlotCount, int aOutputSlotCount, boolean aBricked) { - super(aName, aDescription, aTextures, aInputSlotCount, aOutputSlotCount, aBricked); - } - /* - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_BasicMachine_Steel(mTier, mDescription, mTextures); - } - */ - @Override - public float getSteamDamage() { - return 12.0F; - } - - @Override - public ITexture[] getSideFacingActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE:Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getSideFacingInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE:Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getFrontFacingActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE:Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getFrontFacingInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE:Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getTopFacingActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_TOP:Textures.BlockIcons.MACHINE_STEEL_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getTopFacingInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_TOP:Textures.BlockIcons.MACHINE_STEEL_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getBottomFacingActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_BOTTOM:Textures.BlockIcons.MACHINE_STEEL_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getBottomFacingInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_BOTTOM:Textures.BlockIcons.MACHINE_STEEL_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa))}; - } - - @Override - public ITexture[] getBottomFacingPipeActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_BOTTOM:Textures.BlockIcons.MACHINE_STEEL_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getBottomFacingPipeInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_BOTTOM:Textures.BlockIcons.MACHINE_STEEL_BOTTOM, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getTopFacingPipeActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_TOP:Textures.BlockIcons.MACHINE_STEEL_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getTopFacingPipeInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_TOP:Textures.BlockIcons.MACHINE_STEEL_TOP, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getSideFacingPipeActive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE:Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getSideFacingPipeInactive(byte aColor) { - return new ITexture[] {new GT_RenderedTexture(mTier==1?Textures.BlockIcons.MACHINE_STEELBRICKS_SIDE:Textures.BlockIcons.MACHINE_STEEL_SIDE, Dyes.getModulation(aColor, Dyes._NULL.mRGBa)), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java deleted file mode 100644 index 594411c3dd..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java +++ /dev/null @@ -1,206 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import gregtech.api.enums.ItemList; -import gregtech.api.gui.GT_Container_BasicTank; -import gregtech.api.gui.GT_GUIContainer_BasicTank; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * - * This is the main construct for my generic Tanks. Filling and emptying behavior have to be implemented manually - */ -public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_TieredMachineBlock { - - public FluidStack mFluid; - - /** - * @param aInvSlotCount should be 3 - */ - public GT_MetaTileEntity_BasicTank(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GT_MetaTileEntity_BasicTank(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override public boolean isSimpleMachine() {return false;} - @Override public boolean isValidSlot(int aIndex) {return aIndex != getStackDisplaySlot();} - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); - } - - public abstract boolean doesFillContainers(); - public abstract boolean doesEmptyContainers(); - public abstract boolean canTankBeFilled(); - public abstract boolean canTankBeEmptied(); - public abstract boolean displaysItemStack(); - public abstract boolean displaysStackSize(); - public int getInputSlot() {return 0;} - public int getOutputSlot() {return 1;} - public int getStackDisplaySlot() {return 2;} - - public boolean isFluidInputAllowed(FluidStack aFluid) {return true;} - public boolean isFluidChangingAllowed() {return true;} - - public FluidStack getFillableStack() {return mFluid;} - public FluidStack setFillableStack(FluidStack aFluid) {mFluid = aFluid; return mFluid;} - public FluidStack getDrainableStack() {return mFluid;} - public FluidStack setDrainableStack(FluidStack aFluid) {mFluid = aFluid; return mFluid;} - public FluidStack getDisplayedFluid() {return getDrainableStack();} - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_BasicTank(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_BasicTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0) setFillableStack(null); - - if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) { - if (getDisplayedFluid() == null) { - if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) mInventory[getStackDisplaySlot()] = null; - } else { - mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); - } - } - - if (doesEmptyContainers()) { - FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); - if (tFluid != null && isFluidInputAllowed(tFluid)) { - if (getFillableStack() == null) { - if (isFluidInputAllowed(tFluid) && tFluid.amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { - setFillableStack(tFluid.copy()); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - } - } - } else { - if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) { - if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { - getFillableStack().amount+=tFluid.amount; - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - } - } - } - } - } - - if (doesFillContainers()) { - ItemStack tOutput = GT_Utility.fillFluidContainer(getDrainableStack(), mInventory[getInputSlot()], false, true); - if (tOutput != null && aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), tOutput, 1)) { - FluidStack tFluid = GT_Utility.getFluidForFilledItem(tOutput, true); - aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); - if (tFluid != null) getDrainableStack().amount -= tFluid.amount; - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) setDrainableStack(null); - } - } - } - } - - @Override - public FluidStack getFluid() { - return getDrainableStack(); - } - - @Override - public int getFluidAmount() { - return getDrainableStack() != null ? getDrainableStack().amount : 0; - } - - @Override - public int fill(FluidStack aFluid, boolean doFill) { - if (aFluid == null || aFluid.getFluid().getID() <= 0 || aFluid.amount <= 0 || !canTankBeFilled() || !isFluidInputAllowed(aFluid)) return 0; - - if (getFillableStack() == null || getFillableStack().getFluid().getID() <= 0) { - if(aFluid.amount <= getCapacity()) { - if (doFill) { - setFillableStack(aFluid.copy()); - getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) { - setFillableStack(aFluid.copy()); - getFillableStack().amount = getCapacity(); - getBaseMetaTileEntity().markDirty(); - } - return getCapacity(); - } - - if (!getFillableStack().isFluidEqual(aFluid)) - return 0; - - int space = getCapacity() - getFillableStack().amount; - if (aFluid.amount <= space) { - if (doFill) { - getFillableStack().amount += aFluid.amount; - getBaseMetaTileEntity().markDirty(); - } - return aFluid.amount; - } - if (doFill) - getFillableStack().amount = getCapacity(); - return space; - } - - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - if (getDrainableStack() == null || !canTankBeEmptied()) return null; - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { - setDrainableStack(null); - getBaseMetaTileEntity().markDirty(); - return null; - } - - int used = maxDrain; - if (getDrainableStack().amount < used) - used = getDrainableStack().amount; - - if (doDrain) { - getDrainableStack().amount -= used; - getBaseMetaTileEntity().markDirty(); - } - - FluidStack drained = getDrainableStack().copy(); - drained.amount = used; - - if (getDrainableStack().amount <= 0 && isFluidChangingAllowed()) { - setDrainableStack(null); - getBaseMetaTileEntity().markDirty(); - } - - return drained; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex==getOutputSlot(); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex==getInputSlot(); - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java deleted file mode 100644 index e6d5fe7386..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ /dev/null @@ -1,172 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.V; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredMachineBlock { - public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false; - public int mSuccess = 0, mTargetStackSize = 0; - - public GT_MetaTileEntity_Buffer(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription); - } - - public GT_MetaTileEntity_Buffer(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[6][17][]; - ITexture tIcon = getOverlayIcon(), tOut = new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT), tUp = new GT_RenderedTexture(Textures.BlockIcons.ARROW_UP), tDown = new GT_RenderedTexture(Textures.BlockIcons.ARROW_DOWN), tLeft = new GT_RenderedTexture(Textures.BlockIcons.ARROW_LEFT), tRight = new GT_RenderedTexture(Textures.BlockIcons.ARROW_RIGHT); - for (byte i = -1; i < 16; i++) { - rTextures[ 0][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], tOut }; - rTextures[ 1][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], tRight , tIcon }; - rTextures[ 2][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], tDown , tIcon }; - rTextures[ 3][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], tLeft , tIcon }; - rTextures[ 4][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], tUp , tIcon }; - rTextures[ 5][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1] , tIcon }; - } - return rTextures; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) return mTextures[5][aColorIndex+1]; - if (GT_Utility.getOppositeSide(aSide) == aFacing) return mTextures[0][aColorIndex+1]; - switch (aFacing) { - case 0: - return mTextures[4][aColorIndex+1]; - case 1: - return mTextures[2][aColorIndex+1]; - case 2: switch (aSide) { - case 0: return mTextures[2][aColorIndex+1]; - case 1: return mTextures[2][aColorIndex+1]; - case 4: return mTextures[1][aColorIndex+1]; - case 5: return mTextures[3][aColorIndex+1]; - } - case 3: switch (aSide) { - case 0: return mTextures[4][aColorIndex+1]; - case 1: return mTextures[4][aColorIndex+1]; - case 4: return mTextures[3][aColorIndex+1]; - case 5: return mTextures[1][aColorIndex+1]; - } - case 4: switch (aSide) { - case 0: return mTextures[3][aColorIndex+1]; - case 1: return mTextures[1][aColorIndex+1]; - case 2: return mTextures[3][aColorIndex+1]; - case 3: return mTextures[1][aColorIndex+1]; - } - case 5: switch (aSide) { - case 0: return mTextures[1][aColorIndex+1]; - case 1: return mTextures[3][aColorIndex+1]; - case 2: return mTextures[1][aColorIndex+1]; - case 3: return mTextures[3][aColorIndex+1]; - } - } - return mTextures[5][aColorIndex+1]; - } - - @Override public boolean isSimpleMachine() {return false;} - @Override public boolean isValidSlot(int aIndex) {return aIndex<mInventory.length-1;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isEnetInput() {return true;} - @Override public boolean isEnetOutput() {return true;} - @Override public boolean isInputFacing(byte aSide) {return !isOutputFacing(aSide);} - @Override public boolean isOutputFacing(byte aSide) {return getBaseMetaTileEntity().getBackFacing() == aSide;} - @Override public boolean isTeleporterCompatible() {return false;} - @Override public long getMinimumStoredEU() {return 512;} - @Override public long maxEUStore() {return 512+V[mTier]*50;} - @Override public long maxEUInput() {return V[mTier];} - @Override public long maxEUOutput() {return bOutput?V[mTier]:0;} - @Override public long maxAmperesIn() {return 2;} - @Override public long maxAmperesOut() {return 2;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - - public abstract ITexture getOverlayIcon(); - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("bInvert", bInvert); - aNBT.setBoolean("bOutput", bOutput); - aNBT.setBoolean("bRedstoneIfFull", bRedstoneIfFull); - aNBT.setInteger("mTargetStackSize", mTargetStackSize); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - bInvert = aNBT.getBoolean("bInvert"); - bOutput = aNBT.getBoolean("bOutput"); - bRedstoneIfFull = aNBT.getBoolean("bRedstoneIfFull"); - mTargetStackSize = aNBT.getInteger("mTargetStackSize"); - } - - @Override - public void setItemNBT(NBTTagCompound aNBT) { - super.setItemNBT(aNBT); - if (mTargetStackSize > 0) aNBT.setInteger("mTargetStackSize", mTargetStackSize); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (aSide == getBaseMetaTileEntity().getBackFacing()) { - mTargetStackSize=(byte)((mTargetStackSize+1)%65); - if (mTargetStackSize == 0) { - GT_Utility.sendChatToPlayer(aPlayer, "Do not regulate Item Stack Size"); - } else { - GT_Utility.sendChatToPlayer(aPlayer, "Regulate Item Stack Size to: " + mTargetStackSize); - } - } - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isUniversalEnergyStored(getMinimumStoredEU()) && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer%200 == 0 || mSuccess > 0)) { - mSuccess--; - moveItems(aBaseMetaTileEntity, aTimer); - aBaseMetaTileEntity.setGenericRedstoneOutput(bInvert); - if (bRedstoneIfFull) { - aBaseMetaTileEntity.setGenericRedstoneOutput(!bInvert); - for (int i = 0; i < mInventory.length; i++) if (isValidSlot(i)) { - if (mInventory[i] == null) { - aBaseMetaTileEntity.setGenericRedstoneOutput(bInvert); - aBaseMetaTileEntity.decreaseStoredEnergyUnits(1, true); - break; - } - } - } - } - } - - protected void moveItems(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - int tCost = GT_Utility.moveOneItemStack(aBaseMetaTileEntity, aBaseMetaTileEntity.getTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.getBackFacing(), aBaseMetaTileEntity.getFrontFacing(), null, false, mTargetStackSize==0?64:(byte)mTargetStackSize, mTargetStackSize==0?1:(byte)mTargetStackSize, (byte)64, (byte)1); - if (tCost > 0 || aBaseMetaTileEntity.hasInventoryBeenModified()) { - mSuccess = 50; - aBaseMetaTileEntity.decreaseStoredEnergyUnits(Math.abs(tCost), true); - } - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide != aBaseMetaTileEntity.getBackFacing(); - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java deleted file mode 100644 index 709f3d4f7a..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch.java +++ /dev/null @@ -1,89 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.nbt.NBTTagCompound; - -public abstract class GT_MetaTileEntity_Hatch extends GT_MetaTileEntity_BasicTank { - - public byte mMachineBlock = 0; - - public static int getSlots(int aTier) - { - return aTier < 1 ? 1 : aTier == 1 ? 4 : aTier == 2 ? 9 : 16; - } - - public GT_MetaTileEntity_Hatch(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aTier, aInvSlotCount, aDescription, aTextures); - } - - public GT_MetaTileEntity_Hatch(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - public abstract ITexture[] getTexturesActive(ITexture aBaseTexture); - public abstract ITexture[] getTexturesInactive(ITexture aBaseTexture); - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return aSide != aFacing ? mMachineBlock != 0 ? new ITexture[] {Textures.BlockIcons.CASING_BLOCKS[mMachineBlock]} : new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex+1]} : mMachineBlock != 0 ? aActive ? getTexturesActive(Textures.BlockIcons.CASING_BLOCKS[mMachineBlock]) : getTexturesInactive(Textures.BlockIcons.CASING_BLOCKS[mMachineBlock]) : aActive ? getTexturesActive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex+1]) : getTexturesInactive(Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex+1]); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setByte("mMachineBlock", mMachineBlock); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mMachineBlock = aNBT.getByte("mMachineBlock"); - } - - @Override - public final void onValueUpdate(byte aValue) { - mMachineBlock = (byte)(aValue & 127); - } - - @Override - public final byte getUpdateData() { - return (byte)(mMachineBlock & 127); - } - - @Override - public boolean doesFillContainers() { - return false; - } - - @Override - public boolean doesEmptyContainers() { - return false; - } - - @Override - public boolean canTankBeFilled() { - return false; - } - - @Override - public boolean canTankBeEmptied() { - return false; - } - - @Override - public boolean displaysItemStack() { - return false; - } - - @Override - public boolean displaysStackSize() { - return false; - } -} diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java deleted file mode 100644 index caeec17bb1..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Dynamo.java +++ /dev/null @@ -1,54 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.V; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -public class GT_MetaTileEntity_Hatch_Dynamo extends GT_MetaTileEntity_Hatch { - public GT_MetaTileEntity_Hatch_Dynamo(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 0, "Generating electric Energy from Multiblocks"); - } - - public GT_MetaTileEntity_Hatch_Dynamo(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 0, aDescription, aTextures); - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override public boolean isEnetOutput() {return true;} - @Override public boolean isOutputFacing(byte aSide) {return aSide==getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isValidSlot(int aIndex) {return false;} - @Override public long getMinimumStoredEU() {return 512;} - @Override public long maxEUOutput() {return V[mTier];} - @Override public long maxEUStore() {return 512+V[mTier+1]*2;} - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Dynamo(mName, mTier, mDescription, mTextures); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } -} diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java deleted file mode 100644 index 571fbe0135..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Energy.java +++ /dev/null @@ -1,55 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.V; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -public class GT_MetaTileEntity_Hatch_Energy extends GT_MetaTileEntity_Hatch { - public GT_MetaTileEntity_Hatch_Energy(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 0, "Energy Injector for Multiblocks"); - } - - public GT_MetaTileEntity_Hatch_Energy(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 0, aDescription, aTextures); - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override public boolean isEnetInput() {return true;} - @Override public boolean isInputFacing(byte aSide) {return aSide==getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isValidSlot(int aIndex) {return false;} - @Override public long getMinimumStoredEU() {return 512;} - @Override public long maxEUInput() {return V[mTier];} - @Override public long maxEUStore() {return 512+V[mTier]*8;} - @Override public long maxAmperesIn() {return 2;} - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Energy(mName, mTier, mDescription, mTextures); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java deleted file mode 100644 index 64f2aaad99..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java +++ /dev/null @@ -1,86 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { - public GT_Recipe_Map mRecipeMap = null; - - public GT_MetaTileEntity_Hatch_Input(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "Fluid Input for Multiblocks (" + 8000 * (aTier + 1) + "L)"); - } - - public GT_MetaTileEntity_Hatch_Input(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Input(mName, mTier, mDescription, mTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override public boolean doesFillContainers() {return true;} - @Override public boolean doesEmptyContainers() {return true;} - @Override public boolean canTankBeFilled() {return true;} - @Override public boolean canTankBeEmptied() {return true;} - @Override public boolean displaysItemStack() {return true;} - @Override public boolean displaysStackSize() {return false;} - - public void updateSlots() { - if (mInventory[getInputSlot()] != null && mInventory[getInputSlot()].stackSize <= 0) mInventory[getInputSlot()] = null; - } - - @Override - public boolean isFluidInputAllowed(FluidStack aFluid) { - return mRecipeMap == null || mRecipeMap.containsInput(aFluid); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 1; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0 && (mRecipeMap == null || mRecipeMap.containsInput(aStack) || mRecipeMap.containsInput(GT_Utility.getFluidForFilledItem(aStack, true))); - } - - @Override - public int getCapacity() { - return 8000 * (mTier + 1); - } - - @Override - public int getTankPressure() { - return -100; - } -} diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java deleted file mode 100644 index ac66ea6ce0..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_InputBus.java +++ /dev/null @@ -1,101 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import gregtech.api.enums.Textures; -import gregtech.api.gui.*; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - -public class GT_MetaTileEntity_Hatch_InputBus extends GT_MetaTileEntity_Hatch { - public GT_Recipe_Map mRecipeMap = null; - - public GT_MetaTileEntity_Hatch_InputBus(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, getSlots(aTier), "Item Input for Multiblocks (" + getSlots(aTier) + " slot" + (getSlots(aTier) >= 2 ? "s" : "") + ")"); - } - - public GT_MetaTileEntity_Hatch_InputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aTier<1?1:aTier==1?4:aTier==2?9:16, aDescription, aTextures); - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override public boolean isValidSlot(int aIndex) {return true;} - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_InputBus(mName, mTier, mDescription, mTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - case 0: return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); - case 1: return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); - case 2: return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); - default: return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); - } - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mInventory.length) { - case 1: return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, "Input Bus"); - case 4: return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Input Bus"); - case 9: return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, "Input Bus"); - case 16: return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Input Bus"); - default: return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Input Bus"); - } - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.hasInventoryBeenModified()) { - fillStacksIntoFirstSlots(); - } - } - - public void updateSlots() { - for (int i = 0; i < mInventory.length; i++) if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; - fillStacksIntoFirstSlots(); - } - - protected void fillStacksIntoFirstSlots() { - for (int i = 0; i < mInventory.length; i++) for (int j = i + 1; j < mInventory.length; j++) if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) { - GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte)64, (byte)1, (byte)64, (byte)1); - } - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == getBaseMetaTileEntity().getFrontFacing() && (mRecipeMap == null || mRecipeMap.containsInput(aStack)); - } -} diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java deleted file mode 100644 index cd04a07d41..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Maintenance.java +++ /dev/null @@ -1,108 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.gui.GT_Container_MaintenanceHatch; -import gregtech.api.gui.GT_GUIContainer_MaintenanceHatch; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public class GT_MetaTileEntity_Hatch_Maintenance extends GT_MetaTileEntity_Hatch { - public boolean mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, mCrowbar = false; - - public GT_MetaTileEntity_Hatch_Maintenance(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 1, "For maintaining Multiblocks"); - } - - public GT_MetaTileEntity_Hatch_Maintenance(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 1, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] {mDescription, "Cannot be shared between Multiblocks!"}; - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_MAINTENANCE)}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_MAINTENANCE), new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_DUCTTAPE)}; - } - - @Override - public void initDefaultModes(NBTTagCompound aNBT) { - getBaseMetaTileEntity().setActive(true); - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override public boolean isValidSlot(int aIndex) {return false;} - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Maintenance(mName, mTier, mDescription, mTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) { - if (aBaseMetaTileEntity.isClientSide()) return true; - if (aSide == aBaseMetaTileEntity.getFrontFacing()) aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_MaintenanceHatch(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MaintenanceHatch(aPlayerInventory, aBaseMetaTileEntity); - } - - public void onToolClick(ItemStack aStack, EntityLivingBase aPlayer) { - if (aStack == null || aPlayer == null) return; - if (GT_Utility.isStackInList(aStack, GregTech_API.sWrenchList ) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) mWrench = true; - if (GT_Utility.isStackInList(aStack, GregTech_API.sScrewdriverList ) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) mScrewdriver = true; - if (GT_Utility.isStackInList(aStack, GregTech_API.sSoftHammerList ) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) mSoftHammer = true; - if (GT_Utility.isStackInList(aStack, GregTech_API.sHardHammerList ) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) mHardHammer = true; - if (GT_Utility.isStackInList(aStack, GregTech_API.sCrowbarList ) && GT_ModHandler.damageOrDechargeItem(aStack, 1, 1000, aPlayer)) mCrowbar = true; - if (GT_ModHandler.useSolderingIron(aStack, aPlayer)) mSolderingTool = true; - if (GT_OreDictUnificator.isItemStackInstanceOf(aStack, "craftingDuctTape")) { - mWrench = mScrewdriver = mSoftHammer = mHardHammer = mCrowbar = mSolderingTool = true; - getBaseMetaTileEntity().setActive(false); - aStack.stackSize--; - } - if(mSolderingTool&&aPlayer instanceof EntityPlayerMP){ - EntityPlayerMP tPlayer = (EntityPlayerMP) aPlayer; - try{GT_Mod.instance.achievements.issueAchievement( tPlayer, "maintainance");}catch(Exception e){} - } - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } -} diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java deleted file mode 100644 index de3b9968ac..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Muffler.java +++ /dev/null @@ -1,58 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -public class GT_MetaTileEntity_Hatch_Muffler extends GT_MetaTileEntity_Hatch { - public GT_MetaTileEntity_Hatch_Muffler(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 0, "Outputs the Pollution (Pollution might come later)"); - } - - public GT_MetaTileEntity_Hatch_Muffler(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 0, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] {mDescription, "DO NOT OBSTRUCT THE OUTPUT!"}; - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_MUFFLER)}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_MUFFLER)}; - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override public boolean isValidSlot(int aIndex) {return false;} - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Muffler(mName, mTier, mDescription, mTextures); - } - - public boolean polluteEnvironment() { - return (mTier > 1 && getBaseMetaTileEntity().getRandomNumber(mTier) != 0) || getBaseMetaTileEntity().getAirAtSide(getBaseMetaTileEntity().getFrontFacing()); - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } -} diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java deleted file mode 100644 index ecf6627a09..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java +++ /dev/null @@ -1,141 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidHandler; - -public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { - public byte mMode = 0; - - public GT_MetaTileEntity_Hatch_Output(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "Fluid Output for Multiblocks (" + 8000 * (aTier + 1) + "L) (Screwdriver for output type)"); - } - - public GT_MetaTileEntity_Hatch_Output(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override public boolean isLiquidInput(byte aSide) {return false;} - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Output(mName, mTier, mDescription, mTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (aBaseMetaTileEntity.isServerSide() && aBaseMetaTileEntity.isAllowedToWork()) { - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(aBaseMetaTileEntity.getFrontFacing()); - if (tTileEntity != null) { - for (boolean temp = true; temp && mFluid != null;) { - temp = false; - FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()), Math.max(1, mFluid.amount), false); - if (tDrained != null) { - int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), tDrained, false); - if (tFilledAmount > 0) { - temp = true; - tTileEntity.fill(ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()), tFilledAmount, true), true); - } - } - } - } - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - aNBT.setByte("mMode", mMode); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - mMode = aNBT.getByte("mMode"); - } - - @Override public boolean doesFillContainers() {return true;} - @Override public boolean doesEmptyContainers() {return true;} - @Override public boolean canTankBeFilled() {return true;} - @Override public boolean canTankBeEmptied() {return true;} - @Override public boolean displaysItemStack() {return true;} - @Override public boolean displaysStackSize() {return false;} - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 1; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0; - } - - @Override - public int getCapacity() { - return 8000 * (mTier + 1); - } - - @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (!getBaseMetaTileEntity().getCoverBehaviorAtSide(aSide).isGUIClickable(aSide, getBaseMetaTileEntity().getCoverIDAtSide(aSide), getBaseMetaTileEntity().getCoverDataAtSide(aSide), getBaseMetaTileEntity())) return; - mMode = (byte)((mMode + 1) % 8); - switch (mMode) { - case 0: GT_Utility.sendChatToPlayer(aPlayer, "Outputs Liquids, Steam and Items"); break; - case 1: GT_Utility.sendChatToPlayer(aPlayer, "Outputs Steam and Items"); break; - case 2: GT_Utility.sendChatToPlayer(aPlayer, "Outputs Steam and Liquids"); break; - case 3: GT_Utility.sendChatToPlayer(aPlayer, "Outputs Steam"); break; - case 4: GT_Utility.sendChatToPlayer(aPlayer, "Outputs Liquids and Items"); break; - case 5: GT_Utility.sendChatToPlayer(aPlayer, "Outputs only Items"); break; - case 6: GT_Utility.sendChatToPlayer(aPlayer, "Outputs only Liquids"); break; - case 7: GT_Utility.sendChatToPlayer(aPlayer, "Outputs nothing"); break; - } - } - - public boolean outputsSteam() { - return mMode < 4; - } - - public boolean outputsLiquids() { - return mMode % 2 == 0; - } - - public boolean outputsItems() { - return mMode % 4 < 2; - } - - @Override - public int getTankPressure() { - return +100; - } -} diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java deleted file mode 100644 index 8baff8d4f4..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java +++ /dev/null @@ -1,79 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import gregtech.api.enums.Textures; -import gregtech.api.gui.*; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; - -public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { - public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, getSlots(aTier), "Item Output for Multiblocks (" + getSlots(aTier) + " slot" + (getSlots(aTier) >= 2 ? "s" : "") + ")"); - } - - public GT_MetaTileEntity_Hatch_OutputBus(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, aTier<1?1:aTier==1?4:aTier==2?9:16, aDescription, aTextures); - } - - @Override - public ITexture[] getTexturesActive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override - public ITexture[] getTexturesInactive(ITexture aBaseTexture) { - return new ITexture[] {aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_OUT)}; - } - - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override public boolean isValidSlot(int aIndex) {return true;} - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_OutputBus(mName, mTier, mDescription, mTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - case 0: return new GT_Container_1by1(aPlayerInventory, aBaseMetaTileEntity); - case 1: return new GT_Container_2by2(aPlayerInventory, aBaseMetaTileEntity); - case 2: return new GT_Container_3by3(aPlayerInventory, aBaseMetaTileEntity); - default: return new GT_Container_4by4(aPlayerInventory, aBaseMetaTileEntity); - } - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - switch (mTier) { - case 0: return new GT_GUIContainer_1by1(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); - case 1: return new GT_GUIContainer_2by2(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); - case 2: return new GT_GUIContainer_3by3(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); - case 3: return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); - default: return new GT_GUIContainer_4by4(aPlayerInventory, aBaseMetaTileEntity, "Output Bus"); - } - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aSide == aBaseMetaTileEntity.getFrontFacing(); - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } -} diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java deleted file mode 100644 index 1cb3c89a84..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ /dev/null @@ -1,729 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.V; -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.enums.ConfigCategories; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.gui.GT_Container_MultiMachine; -import gregtech.api.gui.GT_GUIContainer_MultiMachine; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.items.GT_MetaGenerated_Tool; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -import gregtech.api.util.GT_Utility; -import gregtech.common.items.GT_MetaGenerated_Tool_01; -import gregtech.common.tools.GT_Tool_Turbine; - -import java.util.ArrayList; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.fluids.FluidStack; - -public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { - - public boolean mMachine = false, mWrench = false, mScrewdriver = false, mSoftHammer = false, mHardHammer = false, mSolderingTool = false, mCrowbar = false, mRunningOnLoad = false; - public int mPollution = 0, mProgresstime = 0, mMaxProgresstime = 0, mEUt = 0, mEfficiencyIncrease = 0, mUpdate = 0, mStartUpCheck = 100, mRuntime = 0, mEfficiency = 0; - public ItemStack[] mOutputItems = null; - public FluidStack[] mOutputFluids = null; - public static boolean disableMaintenance; - - public ArrayList<GT_MetaTileEntity_Hatch_Input> mInputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Input>(); - public ArrayList<GT_MetaTileEntity_Hatch_Output> mOutputHatches = new ArrayList<GT_MetaTileEntity_Hatch_Output>(); - public ArrayList<GT_MetaTileEntity_Hatch_InputBus> mInputBusses = new ArrayList<GT_MetaTileEntity_Hatch_InputBus>(); - public ArrayList<GT_MetaTileEntity_Hatch_OutputBus> mOutputBusses = new ArrayList<GT_MetaTileEntity_Hatch_OutputBus>(); - public ArrayList<GT_MetaTileEntity_Hatch_Dynamo> mDynamoHatches = new ArrayList<GT_MetaTileEntity_Hatch_Dynamo>(); - public ArrayList<GT_MetaTileEntity_Hatch_Muffler> mMufflerHatches = new ArrayList<GT_MetaTileEntity_Hatch_Muffler>(); - public ArrayList<GT_MetaTileEntity_Hatch_Energy> mEnergyHatches = new ArrayList<GT_MetaTileEntity_Hatch_Energy>(); - public ArrayList<GT_MetaTileEntity_Hatch_Maintenance> mMaintenanceHatches = new ArrayList<GT_MetaTileEntity_Hatch_Maintenance>(); - - public GT_MetaTileEntity_MultiBlockBase(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional, 2); - this.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); - } - - public GT_MetaTileEntity_MultiBlockBase(String aName) { - super(aName, 2); - this.disableMaintenance = GregTech_API.sMachineFile.get(ConfigCategories.machineconfig, "MultiBlockMachines.disableMaintenance", false); - } - - @Override - public boolean allowCoverOnSide(byte aSide, GT_ItemStack aCoverID) { - return aSide != getBaseMetaTileEntity().getFrontFacing(); - } - - @Override public boolean isSimpleMachine() {return false;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override public boolean isValidSlot(int aIndex) {return aIndex > 0;} - @Override public int getProgresstime() {return mProgresstime;} - @Override public int maxProgresstime() {return mMaxProgresstime;} - @Override public int increaseProgress(int aProgress) {return aProgress;} - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mEUt", mEUt); - aNBT.setInteger("mProgresstime", mProgresstime); - aNBT.setInteger("mMaxProgresstime", mMaxProgresstime); - aNBT.setInteger("mEfficiencyIncrease", mEfficiencyIncrease); - aNBT.setInteger("mEfficiency", mEfficiency); - aNBT.setInteger("mPollution", mPollution); - aNBT.setInteger("mRuntime", mRuntime); - - if (mOutputItems != null) for (int i = 0; i < mOutputItems.length; i++) if (mOutputItems[i] != null) { - NBTTagCompound tNBT = new NBTTagCompound(); - mOutputItems[i].writeToNBT(tNBT); - aNBT.setTag("mOutputItem"+i, tNBT); - } - if (mOutputFluids != null) for (int i = 0; i < mOutputFluids.length; i++) if (mOutputFluids[i] != null) { - NBTTagCompound tNBT = new NBTTagCompound(); - mOutputFluids[i].writeToNBT(tNBT); - aNBT.setTag("mOutputFluids"+i, tNBT); - } - - aNBT.setBoolean("mWrench", mWrench); - aNBT.setBoolean("mScrewdriver", mScrewdriver); - aNBT.setBoolean("mSoftHammer", mSoftHammer); - aNBT.setBoolean("mHardHammer", mHardHammer); - aNBT.setBoolean("mSolderingTool", mSolderingTool); - aNBT.setBoolean("mCrowbar", mCrowbar); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - mEUt = aNBT.getInteger("mEUt"); - mProgresstime = aNBT.getInteger("mProgresstime"); - mMaxProgresstime = aNBT.getInteger("mMaxProgresstime"); - if(mMaxProgresstime>0)mRunningOnLoad=true; - mEfficiencyIncrease = aNBT.getInteger("mEfficiencyIncrease"); - mEfficiency = aNBT.getInteger("mEfficiency"); - mPollution = aNBT.getInteger("mPollution"); - mRuntime = aNBT.getInteger("mRuntime"); - mOutputItems = new ItemStack[getAmountOfOutputs()]; - for (int i = 0; i < mOutputItems.length; i++) mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); - mOutputFluids = new FluidStack[getAmountOfOutputs()]; - for (int i = 0; i < mOutputFluids.length; i++) mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); - mWrench = aNBT.getBoolean("mWrench"); - mScrewdriver = aNBT.getBoolean("mScrewdriver"); - mSoftHammer = aNBT.getBoolean("mSoftHammer"); - mHardHammer = aNBT.getBoolean("mHardHammer"); - mSolderingTool = aNBT.getBoolean("mSolderingTool"); - mCrowbar = aNBT.getBoolean("mCrowbar"); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - - @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_MultiMachine(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "MultiblockDisplay.png"); - } - - @Override - public byte getTileEntityBaseType() { - return 2; - } - - @Override - public void onMachineBlockUpdate() { - mUpdate = 50; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - if (mEfficiency < 0) mEfficiency = 0; - if (--mUpdate==0 || --mStartUpCheck==0) { - mInputHatches.clear(); - mInputBusses.clear(); - mOutputHatches.clear(); - mOutputBusses.clear(); - mDynamoHatches.clear(); - mEnergyHatches.clear(); - mMufflerHatches.clear(); - mMaintenanceHatches.clear(); - mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); - } - if (mStartUpCheck < 0) { - if (mMachine) { - for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) { - if (isValidMetaTileEntity(tHatch)) { - if(!this.disableMaintenance){ - if (tHatch.mWrench) mWrench = true; - if (tHatch.mScrewdriver) mScrewdriver = true; - if (tHatch.mSoftHammer) mSoftHammer = true; - if (tHatch.mHardHammer) mHardHammer = true; - if (tHatch.mSolderingTool) mSolderingTool = true; - if (tHatch.mCrowbar) mCrowbar = true;}else{ - mWrench = true; - mScrewdriver = true; - mSoftHammer = true; - mHardHammer = true; - mSolderingTool = true; - mCrowbar = true; - } - - tHatch.mWrench = false; - tHatch.mScrewdriver = false; - tHatch.mSoftHammer = false; - tHatch.mHardHammer = false; - tHatch.mSolderingTool = false; - tHatch.mCrowbar = false; - } - } - if (getRepairStatus() > 0) { - if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) { - if (onRunningTick(mInventory[1])) { - if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) { - stopMachine(); - } - if (mMaxProgresstime > 0 && ++mProgresstime>=mMaxProgresstime) { - if (mOutputItems != null) for (ItemStack tStack : mOutputItems) if (tStack != null) { - try{GT_Mod.instance.achievements.issueAchivementHatch(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), tStack);}catch(Exception e){} - addOutput(tStack);} - if (mOutputFluids != null&&mOutputFluids.length==1) {for (FluidStack tStack : mOutputFluids) if (tStack != null) {addOutput(tStack);}} - else if(mOutputFluids!=null&&mOutputFluids.length>1){ - addFluidOutputs(mOutputFluids);} - mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); - mOutputItems = null; - mProgresstime = 0; - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipe(mInventory[1]); - if(mOutputFluids!=null&&mOutputFluids.length>0){ - if(mOutputFluids.length>1){GT_Mod.instance.achievements.issueAchievement(aBaseMetaTileEntity.getWorld().getPlayerEntityByName(aBaseMetaTileEntity.getOwnerName()), "oilplant");} - } - } - } - } else { - if (aTick % 100 == 0 || aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified()) { - - if (aBaseMetaTileEntity.isAllowedToWork()) { - checkRecipe(mInventory[1]);} - if (mMaxProgresstime <= 0) mEfficiency = Math.max(0, mEfficiency - 1000); - } - } - } else { - stopMachine(); - } - } else { - stopMachine(); - } - } - aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID()&~127)|(mWrench?0:1)|(mScrewdriver?0:2)|(mSoftHammer?0:4)|(mHardHammer?0:8)|(mSolderingTool?0:16)|(mCrowbar?0:32)|(mMachine?0:64)); - aBaseMetaTileEntity.setActive(mMaxProgresstime>0); - } - } - - public boolean polluteEnvironment(int aPollutionLevel) { - mPollution += aPollutionLevel; - for (GT_MetaTileEntity_Hatch_Muffler tHatch : mMufflerHatches) { - if (isValidMetaTileEntity(tHatch)) { - if (mPollution >= 10000) { - if (tHatch.polluteEnvironment()) { - mPollution -= 10000; - } - } else { - break; - } - } - } - return mPollution < 10000; - } - - /** - * Called every tick the Machine runs - */ - public boolean onRunningTick(ItemStack aStack) { - if (mEUt > 0) { - addEnergyOutput(((long)mEUt * mEfficiency) / 10000); - return true; - } - if (mEUt < 0) { - if (!drainEnergyInput(((long)-mEUt * 10000) / Math.max(1000, mEfficiency))) { - stopMachine(); - return false; - } - } - return true; - } - - /** - * Checks if this is a Correct Machine Part for this kind of Machine (Turbine Rotor for example) - */ - public abstract boolean isCorrectMachinePart(ItemStack aStack); - - /** - * Checks the Recipe - */ - public abstract boolean checkRecipe(ItemStack aStack); - - /** - * Checks the Machine. You have to assign the MetaTileEntities for the Hatches here. - */ - public abstract boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack); - - /** - * Gets the maximum Efficiency that spare Part can get (0 - 10000) - */ - public abstract int getMaxEfficiency(ItemStack aStack); - - /** - * Gets the pollution this Device outputs to a Muffler per tick (10000 = one Pullution Block) - */ - public abstract int getPollutionPerTick(ItemStack aStack); - - /** - * Gets the damage to the ItemStack, usually 0 or 1. - */ - public abstract int getDamageToComponent(ItemStack aStack); - - /** - * Gets the Amount of possibly outputted Items for loading the Output Stack Array from NBT. - * This should be the largest Amount that can ever happen legitimately. - */ - public abstract int getAmountOfOutputs(); - - /** - * If it explodes when the Component has to be replaced. - */ - public abstract boolean explodesOnComponentBreak(ItemStack aStack); - - public void stopMachine() { - mOutputItems = null; - mEUt = 0; - mEfficiency = 0; - mProgresstime = 0; - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - getBaseMetaTileEntity().disableWorking(); - } - - public int getRepairStatus() { - return (mWrench?1:0) + (mScrewdriver?1:0) + (mSoftHammer?1:0) + (mHardHammer?1:0) + (mSolderingTool?1:0) + (mCrowbar?1:0); - } - - public int getIdealStatus() { - return 6; - } - - public static boolean isValidMetaTileEntity(MetaTileEntity aMetaTileEntity) { - return aMetaTileEntity.getBaseMetaTileEntity() != null && aMetaTileEntity.getBaseMetaTileEntity().getMetaTileEntity() == aMetaTileEntity && !aMetaTileEntity.getBaseMetaTileEntity().isDead(); - } - - public boolean doRandomMaintenanceDamage() { - if (!isCorrectMachinePart(mInventory[1]) || getRepairStatus() == 0) { - stopMachine(); - return false; - } - if (mRuntime++>1000) { - mRuntime = 0; - if (getBaseMetaTileEntity().getRandomNumber(6000) == 0) { - switch (getBaseMetaTileEntity().getRandomNumber(6)) { - case 0: mWrench = false; break; - case 1: mScrewdriver = false; break; - case 2: mSoftHammer = false; break; - case 3: mHardHammer = false; break; - case 4: mSolderingTool = false; break; - case 5: mCrowbar = false; break; - } - } - if (mInventory[1] != null && getBaseMetaTileEntity().getRandomNumber(2) == 0 &&!mInventory[1].getUnlocalizedName().startsWith("gt.blockmachines.basicmachine.")) { - if(mInventory[1].getItem() instanceof GT_MetaGenerated_Tool_01){ - NBTTagCompound tNBT = mInventory[1].getTagCompound(); - if (tNBT != null) - { - NBTTagCompound tNBT2 = tNBT.getCompoundTag("GT.CraftingComponents"); - if (!tNBT.getBoolean("mDis")) - { - tNBT2 = new NBTTagCompound(); - Materials tMaterial = GT_MetaGenerated_Tool.getPrimaryMaterial(mInventory[1]); - ItemStack tTurbine = GT_OreDictUnificator.get(OrePrefixes.turbineBlade, tMaterial, 1); - int i = mInventory[1].getItemDamage(); - if(i == 170){ - ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); - tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); - tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong,Materials.Magnalium,1); - tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); - }else if(i == 172){ - ItemStack tStack = GT_Utility.copyAmount(1, tTurbine); - tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); - tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong,Materials.Titanium,1); - tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); - }else if(i == 174){ - ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); - tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); - tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong,Materials.TungstenSteel,1); - tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); - }else if(i == 176){ - ItemStack tStack = GT_Utility.copyAmount(2, tTurbine); - tNBT2.setTag("Ingredient.0", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.1", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.2", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.3", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.5", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.6", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.7", tStack.writeToNBT(new NBTTagCompound())); - tNBT2.setTag("Ingredient.8", tStack.writeToNBT(new NBTTagCompound())); - tStack = GT_OreDictUnificator.get(OrePrefixes.stickLong,Materials.Americium,1); - tNBT2.setTag("Ingredient.4", tStack.writeToNBT(new NBTTagCompound())); - } - tNBT.setTag("GT.CraftingComponents", tNBT2); - tNBT.setBoolean("mDis", true); - mInventory[1].setTagCompound(tNBT); - - } - } - - ((GT_MetaGenerated_Tool)mInventory[1].getItem()).doDamage(mInventory[1], (long) Math.min(mEUt/5, Math.pow(mEUt, 0.7))); - if(mInventory[1].stackSize==0)mInventory[1]=null; - } - } - } - return true; - } - - public void explodeMultiblock() { - mInventory[1] = null; - for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mInputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mOutputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mDynamoHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mMufflerHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mEnergyHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - for (MetaTileEntity tTileEntity : mMaintenanceHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[8]); - getBaseMetaTileEntity().doExplosion(V[8]); - } - - public boolean addEnergyOutput(long aEU) { - if (aEU <= 0) return true; - for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { - if (isValidMetaTileEntity(tHatch)) { - if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU, false)) { - return true; - } - } - } - return false; - } - - public long getMaxInputVoltage() { - long rVoltage = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); - return rVoltage; - } - - public boolean drainEnergyInput(long aEU) { - if (aEU <= 0) return true; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) if (isValidMetaTileEntity(tHatch)) { - if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU, false)) return true; - } - return false; - } - - public boolean addOutput(FluidStack aLiquid) { - if (aLiquid == null) return false; - FluidStack tLiquid = aLiquid.copy(); - for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { - if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid)?tHatch.outputsSteam():tHatch.outputsLiquids()) { - int tAmount = tHatch.fill(tLiquid, false); - if (tAmount >= tLiquid.amount) { - return tHatch.fill(tLiquid, true) >= tLiquid.amount; - }else if(tAmount>0){ - tLiquid.amount = tLiquid.amount - tHatch.fill(tLiquid, true); - } - } - } - return false; - } - - private void addFluidOutputs(FluidStack[] mOutputFluids2) { - for(int i=0;i<mOutputFluids2.length;i++){ - if(mOutputHatches.size()>i&&mOutputHatches.get(i)!=null&&mOutputFluids2[i]!=null&&isValidMetaTileEntity(mOutputHatches.get(i))){ - mOutputHatches.get(i).fill(mOutputFluids2[i], true); - } - } - - } - - public boolean depleteInput(FluidStack aLiquid) { - if (aLiquid == null) return false; - for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { - tHatch.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - FluidStack tLiquid = tHatch.getFluid(); - if (tLiquid != null && tLiquid.isFluidEqual(aLiquid)) { - tLiquid = tHatch.drain(aLiquid.amount, false); - if (tLiquid != null && tLiquid.amount >= aLiquid.amount) { - tLiquid = tHatch.drain(aLiquid.amount, true); - return tLiquid != null && tLiquid.amount >= aLiquid.amount; - } - } - } - } - return false; - } - - public boolean addOutput(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) return false; - aStack = GT_Utility.copy(aStack); -// FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); -// if (aLiquid == null) { - for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { - if (isValidMetaTileEntity(tHatch)) { - for (int i = tHatch.getSizeInventory() - 1; i >= 0; i--) { - if (tHatch.getBaseMetaTileEntity().addStackToSlot(i, aStack)) return true; - } - } - } - for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { - if (isValidMetaTileEntity(tHatch) && tHatch.outputsItems()) { - if (tHatch.getBaseMetaTileEntity().addStackToSlot(1, aStack)) return true; - } - } -// }else { -// for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { -// if (isValidMetaTileEntity(tHatch) && GT_ModHandler.isSteam(aLiquid)?tHatch.outputsSteam():tHatch.outputsLiquids()) { -// int tAmount = tHatch.fill(aLiquid, false); -// if (tAmount >= aLiquid.amount) { -// return tHatch.fill(aLiquid, true) >= aLiquid.amount; -// } -// } -// } -// } - return false; - } - - public boolean depleteInput(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) return false; - FluidStack aLiquid = GT_Utility.getFluidForFilledItem(aStack, true); - if (aLiquid != null) return depleteInput(aLiquid); - for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { - tHatch.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(0))) { - if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { - tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); - return true; - } - } - } - } - for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) { - tHatch.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (GT_Utility.areStacksEqual(aStack, tHatch.getBaseMetaTileEntity().getStackInSlot(i))) { - if (tHatch.getBaseMetaTileEntity().getStackInSlot(0).stackSize >= aStack.stackSize) { - tHatch.getBaseMetaTileEntity().decrStackSize(0, aStack.stackSize); - return true; - } - } - } - } - } - return false; - } - - public ArrayList<ItemStack> getStoredOutputs() { - ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); - for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { - if (isValidMetaTileEntity(tHatch)) { - rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(1)); - } - } - for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { - if (isValidMetaTileEntity(tHatch)) { - for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - } - return rList; - } - - public ArrayList<FluidStack> getStoredFluids() { - ArrayList<FluidStack> rList = new ArrayList<FluidStack>(); - for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { - tHatch.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { - rList.add(tHatch.getFillableStack()); - } - } - return rList; - } - - public ArrayList<ItemStack> getStoredInputs() { - ArrayList<ItemStack> rList = new ArrayList<ItemStack>(); - for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { - tHatch.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().getStackInSlot(0) != null) { - rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(0)); - } - } - for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) { - tHatch.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tHatch)) { - for (int i = tHatch.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tHatch.getBaseMetaTileEntity().getStackInSlot(i) != null) rList.add(tHatch.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - } - return rList; - } - - public GT_Recipe_Map getRecipeMap() { - return null; - } - - public void updateSlots() { - for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); - for (GT_MetaTileEntity_Hatch_InputBus tHatch : mInputBusses) if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); - } - - public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) ((GT_MetaTileEntity_Hatch)aMetaTileEntity).mMachineBlock = (byte)aBaseCasingIndex; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) return mInputHatches.add((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus)aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output)aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus)aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy)aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo)aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance)aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler)aMetaTileEntity); - return false; - } - - public boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).mMachineBlock = (byte)aBaseCasingIndex; - return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance)aMetaTileEntity); - } - return false; - } - - public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) { - return false;} - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).mMachineBlock = (byte)aBaseCasingIndex; - return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy)aMetaTileEntity); - } - return false; - } - - public boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).mMachineBlock = (byte)aBaseCasingIndex; - return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo)aMetaTileEntity); - } - return false; - } - - public boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).mMachineBlock = (byte)aBaseCasingIndex; - return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler)aMetaTileEntity); - } - return false; - } - - public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).mMachineBlock = (byte)aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity).mRecipeMap = getRecipeMap(); - return mInputHatches.add((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).mMachineBlock = (byte)aBaseCasingIndex; - ((GT_MetaTileEntity_Hatch_InputBus)aMetaTileEntity).mRecipeMap = getRecipeMap(); - return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus)aMetaTileEntity); - } - return false; - } - - public boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; - IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).mMachineBlock = (byte)aBaseCasingIndex; - return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output)aMetaTileEntity); - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).mMachineBlock = (byte)aBaseCasingIndex; - return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus)aMetaTileEntity); - } - return false; - } - - @Override - public String[] getInfoData() { - return new String[] {"Progress:", (mProgresstime/20)+"secs", (mMaxProgresstime/20)+"secs", "Efficiency:", (mEfficiency/100.0F)+"%", "Problems:", ""+(getIdealStatus() - getRepairStatus())}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } -} diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java deleted file mode 100644 index daffadecfe..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_TieredMachineBlock.java +++ /dev/null @@ -1,65 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.GT; -import gregtech.api.interfaces.ITexture; -import gregtech.api.metatileentity.MetaTileEntity; - -public abstract class GT_MetaTileEntity_TieredMachineBlock extends MetaTileEntity { - /** - * Value between [0 - 9] to describe the Tier of this Machine. - */ - public final byte mTier; - - /** - * A simple Description. - */ - public final String mDescription; - - /** - * Contains all Textures used by this Block. - */ - public final ITexture[][][] mTextures; - - public GT_MetaTileEntity_TieredMachineBlock(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription, ITexture... aTextures) { - super(aID, aName, aNameRegional, aInvSlotCount); - mTier = (byte)Math.max(0, Math.min(aTier, 9)); - mDescription = aDescription; - - // must always be the last call! - if (GT.isClientSide()) mTextures = getTextureSet(aTextures); else mTextures = null; - } - - public GT_MetaTileEntity_TieredMachineBlock(String aName, int aTier, int aInvSlotCount, String aDescription, ITexture[][][] aTextures) { - super(aName, aInvSlotCount); - mTier = (byte)aTier; - mDescription = aDescription; - mTextures = aTextures; - } - - @Override - public byte getTileEntityBaseType() { - return (byte)(Math.min(3, mTier<=0?0:1+((mTier-1) / 4))); - } - - @Override - public long getInputTier() { - return mTier; - } - - @Override - public long getOutputTier() { - return mTier; - } - - @Override - public String[] getDescription() { - return new String[] {mDescription}; - } - - /** - * Used Client Side to get a Texture Set for this Block. - * Called after setting the Tier and the Description so that those two are accessible. - * @param aTextures is the optional Array you can give to the Constructor. - */ - public abstract ITexture[][][] getTextureSet(ITexture[] aTextures); -}
\ No newline at end of file diff --git a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java b/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java deleted file mode 100644 index c0d8a4bade..0000000000 --- a/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Transformer.java +++ /dev/null @@ -1,144 +0,0 @@ -package gregtech.api.metatileentity.implementations; - -import static gregtech.api.enums.GT_Values.V; -import cofh.api.energy.IEnergyProvider; -import cofh.api.energy.IEnergyStorage; -import crazypants.enderio.machine.capbank.TileCapBank; -import crazypants.enderio.machine.capbank.network.ICapBankNetwork; -import crazypants.enderio.power.IPowerContainer; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; -import ic2.api.energy.tile.IEnergySource; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - * - * This is the main construct for my Basic Machines such as the Automatic Extractor - * Extend this class to make a simple Machine - */ -public class GT_MetaTileEntity_Transformer extends GT_MetaTileEntity_TieredMachineBlock { - public GT_MetaTileEntity_Transformer(int aID, String aName, String aNameRegional, int aTier, String aDescription) { - super(aID, aName, aNameRegional, aTier, 0, aDescription); - } - - public GT_MetaTileEntity_Transformer(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 0, aDescription, aTextures); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[12][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[ 0][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; - rTextures[ 1][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; - rTextures[ 2][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT[mTier]}; - rTextures[ 3][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; - rTextures[ 4][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; - rTextures[ 5][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[mTier]}; - rTextures[ 6][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier]}; - rTextures[ 7][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier]}; - rTextures[ 8][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_IN[mTier]}; - rTextures[ 9][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; - rTextures[10][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; - rTextures[11][i+1] = new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][i+1], Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[mTier]}; - } - return rTextures; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return mTextures[Math.min(2,aSide)+(aSide==aFacing?3:0)+(aActive?0:6)][aColorIndex+1]; - } - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Transformer(mName, mTier, mDescription, mTextures); - } - - @Override public boolean isAccessAllowed(EntityPlayer aPlayer) {return true;} - @Override public boolean isSimpleMachine() {return true;} - @Override public boolean isFacingValid(byte aFacing) {return true;} - @Override public boolean isEnetInput() {return true;} - @Override public boolean isEnetOutput() {return true;} - @Override public boolean isInputFacing(byte aSide) {return getBaseMetaTileEntity().isAllowedToWork()?aSide==getBaseMetaTileEntity().getFrontFacing():aSide!=getBaseMetaTileEntity().getFrontFacing();} - @Override public boolean isOutputFacing(byte aSide) {return !isInputFacing(aSide);} - @Override public boolean isTeleporterCompatible() {return false;} - @Override public long getMinimumStoredEU() {return 512;} - @Override public long maxEUStore() {return 512+V[mTier+1]*2;} - @Override public long maxEUInput() {return V[getBaseMetaTileEntity().isAllowedToWork()?mTier+1:mTier];} - @Override public long maxEUOutput() {return V[getBaseMetaTileEntity().isAllowedToWork()?mTier:mTier+1];} - @Override public long maxAmperesOut() {return getBaseMetaTileEntity().isAllowedToWork()?V[mTier+1]/V[mTier]:1;} - @Override public long maxAmperesIn() {return getBaseMetaTileEntity().isAllowedToWork()?1:V[mTier+1]/V[mTier];} - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - aBaseMetaTileEntity.setActive(aBaseMetaTileEntity.isAllowedToWork()); - for (byte i = 0; i < 6 && aBaseMetaTileEntity.getStoredEU() < aBaseMetaTileEntity.getEUCapacity(); i++) if (aBaseMetaTileEntity.inputEnergyFrom(i)) { - TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); - if (tTileEntity instanceof IEnergySource && ((IEnergySource)tTileEntity).emitsEnergyTo((TileEntity)aBaseMetaTileEntity, ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)))) { - long tEU = Math.min(maxEUInput(), (long)((IEnergySource)tTileEntity).getOfferedEnergy()); - ((IEnergySource)tTileEntity).drawEnergy(tEU); - aBaseMetaTileEntity.injectEnergyUnits((byte)6, tEU, 1); - }else if (GregTech_API.mInputRF && tTileEntity instanceof IEnergyProvider&& ((IEnergyProvider)tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)),1,true)==1) { - long tEU = (long)((IEnergyProvider)tTileEntity).extractEnergy(ForgeDirection.getOrientation(GT_Utility.getOppositeSide(i)),(int) maxEUInput()* 100 / GregTech_API.mRFtoEU ,false); - tEU = tEU * GregTech_API.mRFtoEU / 100; - aBaseMetaTileEntity.injectEnergyUnits((byte)6, Math.min(tEU,maxEUInput()), 1); - }else if (GregTech_API.mInputRF && tTileEntity instanceof IEnergyStorage&& ((IEnergyStorage)tTileEntity).extractEnergy(1,true)==1) { - long tEU = (long)((IEnergyStorage)tTileEntity).extractEnergy((int) maxEUInput()* 100 / GregTech_API.mRFtoEU ,false); - tEU = tEU * GregTech_API.mRFtoEU / 100; - aBaseMetaTileEntity.injectEnergyUnits((byte)6, Math.min(tEU,maxEUInput()), 1); - }else if (GregTech_API.mInputRF && GregTech_API.meIOLoaded && tTileEntity instanceof IPowerContainer && ((IPowerContainer)tTileEntity).getEnergyStored()>0) { - int storedRF = ((IPowerContainer)tTileEntity).getEnergyStored(); - int extractRF = (int) maxEUInput()* 100 / GregTech_API.mRFtoEU; - long tEU =0; - if(tTileEntity instanceof TileCapBank){ - ICapBankNetwork network = ((TileCapBank)tTileEntity).getNetwork(); - if(network!=null&&network.getEnergyStoredL()>0){ - tEU = Math.min((Math.min(Math.min(network.getEnergyStoredL(), storedRF-extractRF),network.getMaxOutput())) * GregTech_API.mRFtoEU / 100,maxEUInput()); - network.addEnergy((int) -(tEU * 100 / GregTech_API.mRFtoEU)); - } - }else{ - if(storedRF>extractRF){ - ((IPowerContainer)tTileEntity).setEnergyStored(storedRF-extractRF); - tEU = maxEUInput(); - }else{ - ((IPowerContainer)tTileEntity).setEnergyStored(0); - tEU = storedRF * GregTech_API.mRFtoEU / 100 ; - } - } - aBaseMetaTileEntity.injectEnergyUnits((byte)6, Math.min(tEU,maxEUInput()), 1); - } - } - } - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - // - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - // - } - - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return false; - } -}
\ No newline at end of file |