diff options
| author | Shawn Buckley <shawntbuckley@gmail.com> | 2015-10-21 22:15:09 -0400 |
|---|---|---|
| committer | Shawn Buckley <shawntbuckley@gmail.com> | 2015-10-21 22:15:09 -0400 |
| commit | 123aa6ed288b2f67b0d47177f4d27cd6893daf3a (patch) | |
| tree | 358e3704182f5b6fda44fa8b20605ab63edca092 /src/main/java/gregtech/common/tileentities/storage | |
| parent | 43ddecc7b9715d2038747566f89930b5db8d0181 (diff) | |
| download | GT5-Unofficial-123aa6ed288b2f67b0d47177f4d27cd6893daf3a.tar.gz GT5-Unofficial-123aa6ed288b2f67b0d47177f4d27cd6893daf3a.tar.bz2 GT5-Unofficial-123aa6ed288b2f67b0d47177f4d27cd6893daf3a.zip | |
Reformat code
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/storage')
3 files changed, 443 insertions, 482 deletions
diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_Locker.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_Locker.java index f0beaa4584..c9b57fc728 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_Locker.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_Locker.java @@ -2,7 +2,6 @@ package gregtech.common.tileentities.storage; import gregtech.api.GregTech_API;
import gregtech.api.enums.Textures;
-import gregtech.api.enums.Textures.BlockIcons;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
@@ -10,188 +9,152 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachi import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.GT_RenderedTexture;
import gregtech.api.util.GT_Utility;
-
-import java.util.Map;
-
import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
public class GT_MetaTileEntity_Locker
- extends GT_MetaTileEntity_TieredMachineBlock
-{
- public byte mType = 0;
-
- public GT_MetaTileEntity_Locker(int aID, String aName, String aNameRegional, int aTier)
- {
- super(aID, aName, aNameRegional, aTier, 4, "Stores and recharges Armor", new ITexture[0]);
- }
-
- public GT_MetaTileEntity_Locker(String aName, int aTier, String aDescription, ITexture[][][] aTextures)
- {
- super(aName, aTier, 4, aDescription, aTextures);
- }
-
- public String[] getDescription()
- {
- return new String[] { this.mDescription, "Click with Screwdriver to change Style" };
- }
-
- public ITexture[][][] getTextureSet(ITexture[] aTextures)
- {
- ITexture[][][] rTextures = new ITexture[3][17][];
- for (byte i = -1; i < 16; i = (byte)(i + 1))
- {ITexture[] tmp0 ={ Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(i + 1)] };
- rTextures[0][(i + 1)] = tmp0;
- ITexture[] tmp1 ={ Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(i + 1)], Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier] };
-rTextures[1][(i + 1)] = tmp1;
- ITexture[] tmp2 = { Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(i + 1)], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_LOCKER) };
-rTextures[2][(i + 1)] =tmp2;
- }
- return rTextures;
- }
-
- public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone)
- {
- if (aSide == aFacing) {
- return new ITexture[] { this.mTextures[2][(aColorIndex + 1)][0], this.mTextures[2][(aColorIndex + 1)][1], Textures.BlockIcons.LOCKERS[java.lang.Math.abs(this.mType % Textures.BlockIcons.LOCKERS.length)] };
- }
- return this.mTextures[0][(aColorIndex + 1)];
- }
-
- public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity)
- {
- return new GT_MetaTileEntity_Locker(this.mName, this.mTier, this.mDescription, this.mTextures);
- }
-
- public boolean isSimpleMachine()
- {
- return false;
- }
-
- public boolean isElectric()
- {
- return true;
- }
-
- public boolean isValidSlot(int aIndex)
- {
- return true;
- }
-
- public boolean isFacingValid(byte aFacing)
- {
- return aFacing > 1;
- }
-
- public boolean isEnetInput()
- {
- return true;
- }
-
- public boolean isInputFacing(byte aSide)
- {
- return aSide == getBaseMetaTileEntity().getBackFacing();
- }
-
- public boolean isTeleporterCompatible()
- {
- return false;
- }
-
- public long maxEUStore()
- {
- return gregtech.api.enums.GT_Values.V[this.mTier] * maxAmperesIn();
- }
-
- public long maxEUInput()
- {
- return gregtech.api.enums.GT_Values.V[this.mTier];
- }
-
- public long maxAmperesIn()
- {
- return this.mInventory.length * 2;
- }
-
- public int rechargerSlotStartIndex()
- {
- return 0;
- }
-
- public int rechargerSlotCount()
- {
- return getBaseMetaTileEntity().isAllowedToWork() ? this.mInventory.length : 0;
- }
-
- public boolean isAccessAllowed(EntityPlayer aPlayer)
- {
- return true;
- }
-
- public void saveNBTData(NBTTagCompound aNBT)
- {
- aNBT.setByte("mType", this.mType);
- }
-
- public void loadNBTData(NBTTagCompound aNBT)
- {
- this.mType = aNBT.getByte("mType");
- }
-
- public void onValueUpdate(byte aValue)
- {
- this.mType = aValue;
- }
-
- public byte getUpdateData()
- {
- return this.mType;
- }
-
- public void doSound(byte aIndex, double aX, double aY, double aZ)
- {
- if (aIndex == 16) {
- GT_Utility.doSoundAtClient((String)GregTech_API.sSoundList.get(Integer.valueOf(3)), 1, 1.0F);
- }
- }
-
- public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ)
- {
- if (aSide == getBaseMetaTileEntity().getFrontFacing()) {
- this.mType = ((byte)(this.mType + 1));
- }
- }
-
- public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack)
- {
- return aSide != getBaseMetaTileEntity().getFrontFacing();
- }
-
- public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ)
- {
- if ((aBaseMetaTileEntity.isServerSide()) && (aSide == aBaseMetaTileEntity.getFrontFacing()))
- {
- for (int i = 0; i < 4; i++)
- {
- ItemStack tSwapStack = this.mInventory[i];
- this.mInventory[i] = aPlayer.inventory.armorInventory[i];
- aPlayer.inventory.armorInventory[i] = tSwapStack;
- }
- aPlayer.inventoryContainer.detectAndSendChanges();
- sendSound((byte)16);
- }
- return true;
- }
-
- public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack)
- {
- return false;
- }
-
- public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack)
- {
- return false;
- }
+ extends GT_MetaTileEntity_TieredMachineBlock {
+ public byte mType = 0;
+
+ public GT_MetaTileEntity_Locker(int aID, String aName, String aNameRegional, int aTier) {
+ super(aID, aName, aNameRegional, aTier, 4, "Stores and recharges Armor", new ITexture[0]);
+ }
+
+ public GT_MetaTileEntity_Locker(String aName, int aTier, String aDescription, ITexture[][][] aTextures) {
+ super(aName, aTier, 4, aDescription, aTextures);
+ }
+
+ public String[] getDescription() {
+ return new String[]{this.mDescription, "Click with Screwdriver to change Style"};
+ }
+
+ public ITexture[][][] getTextureSet(ITexture[] aTextures) {
+ ITexture[][][] rTextures = new ITexture[3][17][];
+ for (byte i = -1; i < 16; i = (byte) (i + 1)) {
+ ITexture[] tmp0 = {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(i + 1)]};
+ rTextures[0][(i + 1)] = tmp0;
+ ITexture[] tmp1 = {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(i + 1)], Textures.BlockIcons.OVERLAYS_ENERGY_IN[this.mTier]};
+ rTextures[1][(i + 1)] = tmp1;
+ ITexture[] tmp2 = {Textures.BlockIcons.MACHINE_CASINGS[this.mTier][(i + 1)], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_LOCKER)};
+ rTextures[2][(i + 1)] = tmp2;
+ }
+ return rTextures;
+ }
+
+ public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) {
+ if (aSide == aFacing) {
+ return new ITexture[]{this.mTextures[2][(aColorIndex + 1)][0], this.mTextures[2][(aColorIndex + 1)][1], Textures.BlockIcons.LOCKERS[java.lang.Math.abs(this.mType % Textures.BlockIcons.LOCKERS.length)]};
+ }
+ return this.mTextures[0][(aColorIndex + 1)];
+ }
+
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_Locker(this.mName, this.mTier, this.mDescription, this.mTextures);
+ }
+
+ public boolean isSimpleMachine() {
+ return false;
+ }
+
+ public boolean isElectric() {
+ return true;
+ }
+
+ public boolean isValidSlot(int aIndex) {
+ return true;
+ }
+
+ public boolean isFacingValid(byte aFacing) {
+ return aFacing > 1;
+ }
+
+ public boolean isEnetInput() {
+ return true;
+ }
+
+ public boolean isInputFacing(byte aSide) {
+ return aSide == getBaseMetaTileEntity().getBackFacing();
+ }
+
+ public boolean isTeleporterCompatible() {
+ return false;
+ }
+
+ public long maxEUStore() {
+ return gregtech.api.enums.GT_Values.V[this.mTier] * maxAmperesIn();
+ }
+
+ public long maxEUInput() {
+ return gregtech.api.enums.GT_Values.V[this.mTier];
+ }
+
+ public long maxAmperesIn() {
+ return this.mInventory.length * 2;
+ }
+
+ public int rechargerSlotStartIndex() {
+ return 0;
+ }
+
+ public int rechargerSlotCount() {
+ return getBaseMetaTileEntity().isAllowedToWork() ? this.mInventory.length : 0;
+ }
+
+ public boolean isAccessAllowed(EntityPlayer aPlayer) {
+ return true;
+ }
+
+ public void saveNBTData(NBTTagCompound aNBT) {
+ aNBT.setByte("mType", this.mType);
+ }
+
+ public void loadNBTData(NBTTagCompound aNBT) {
+ this.mType = aNBT.getByte("mType");
+ }
+
+ public void onValueUpdate(byte aValue) {
+ this.mType = aValue;
+ }
+
+ public byte getUpdateData() {
+ return this.mType;
+ }
+
+ public void doSound(byte aIndex, double aX, double aY, double aZ) {
+ if (aIndex == 16) {
+ GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(Integer.valueOf(3)), 1, 1.0F);
+ }
+ }
+
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (aSide == getBaseMetaTileEntity().getFrontFacing()) {
+ this.mType = ((byte) (this.mType + 1));
+ }
+ }
+
+ public boolean allowCoverOnSide(byte aSide, GT_ItemStack aStack) {
+ return aSide != getBaseMetaTileEntity().getFrontFacing();
+ }
+
+ public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, byte aSide, float aX, float aY, float aZ) {
+ if ((aBaseMetaTileEntity.isServerSide()) && (aSide == aBaseMetaTileEntity.getFrontFacing())) {
+ for (int i = 0; i < 4; i++) {
+ ItemStack tSwapStack = this.mInventory[i];
+ this.mInventory[i] = aPlayer.inventory.armorInventory[i];
+ aPlayer.inventory.armorInventory[i] = tSwapStack;
+ }
+ aPlayer.inventoryContainer.detectAndSendChanges();
+ sendSound((byte) 16);
+ }
+ return true;
+ }
+
+ public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
+
+ public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) {
+ return false;
+ }
}
diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java index 08428153aa..a05ca2baf4 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java @@ -1,63 +1,62 @@ package gregtech.common.tileentities.storage; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import gregtech.api.enums.Textures; -import gregtech.api.gui.GT_ContainerMetaTile_Machine; -import gregtech.api.gui.GT_Container_1by1; -import gregtech.api.gui.GT_Container_2by2; -import gregtech.api.gui.GT_Container_3by3; -import gregtech.api.gui.GT_Container_4by4; -import gregtech.api.gui.GT_Container_BasicTank; -import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; -import gregtech.api.gui.GT_GUIContainer_1by1; -import gregtech.api.gui.GT_GUIContainer_2by2; -import gregtech.api.gui.GT_GUIContainer_3by3; -import gregtech.api.gui.GT_GUIContainer_4by4; -import gregtech.api.gui.GT_GUIContainer_BasicTank; import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; import gregtech.common.gui.GT_Container_QuantumChest; import gregtech.common.gui.GT_GUIContainer_QuantumChest; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class GT_MetaTileEntity_QuantumChest extends GT_MetaTileEntity_TieredMachineBlock { + public int mItemCount = 0; + public ItemStack mItemStack = null; + public GT_MetaTileEntity_QuantumChest(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, "This Chest stores " + ((int) ((Math.pow(6, aTier)) * 270000)) + " Blocks"); + } + + public GT_MetaTileEntity_QuantumChest(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @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_QuantumChest(mName, mTier, mDescription, mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } -public class GT_MetaTileEntity_QuantumChest extends GT_MetaTileEntity_TieredMachineBlock{ - public GT_MetaTileEntity_QuantumChest(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "This Chest stores "+((int)((Math.pow(6, aTier))*270000))+" Blocks"); - } - - - public int mItemCount = 0; - public ItemStack mItemStack = null; - - public GT_MetaTileEntity_QuantumChest(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @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_QuantumChest(mName, mTier, mDescription, mTextures); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; - } - // public void onRightclick(EntityPlayer aPlayer) // { // ItemStack tPlayerItem = aPlayer.inventory.getCurrentItem(); @@ -95,143 +94,133 @@ public class GT_MetaTileEntity_QuantumChest extends GT_MetaTileEntity_TieredMach // aPlayer.field_71069_bz.func_75142_b(); // } // } - - @Override + + @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_QuantumChest(aPlayerInventory, aBaseMetaTileEntity); - } - - @Override + return new GT_Container_QuantumChest(aPlayerInventory, aBaseMetaTileEntity); + } + + @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_QuantumChest(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - - if (getBaseMetaTileEntity().isServerSide()&& getBaseMetaTileEntity().isAllowedToWork()) - { - if ((getItemCount() <= 0) ){ - this.mItemStack = null; - this.mItemCount = 0; - } - if (this.mItemStack == null&&this.mInventory[0]!=null) - { - this.mItemStack = mInventory[0].copy(); - } - if ((this.mInventory[0]!=null)&&(this.mItemCount < getMaxItemCount()) && GT_Utility.areStacksEqual(this.mInventory[0],this.mItemStack)) - { - this.mItemCount += this.mInventory[0].stackSize; - if (this.mItemCount > getMaxItemCount()) - { - this.mInventory[0].stackSize = (this.mItemCount - getMaxItemCount()); - this.mItemCount = getMaxItemCount(); - } - else - { - this.mInventory[0] = null; - } - } - if (this.mInventory[1] == null&&mItemStack!=null) - { - this.mInventory[1] = mItemStack.copy(); - this.mInventory[1].stackSize = Math.min(mItemStack.getMaxStackSize(), this.mItemCount); - this.mItemCount -= this.mInventory[1].stackSize; - } - else if ((this.mItemCount > 0) && GT_Utility.areStacksEqual(this.mInventory[1],this.mItemStack)&&this.mInventory[1].getMaxStackSize()>this.mInventory[1].stackSize) - { - int tmp = Math.min(this.mItemCount, this.mInventory[1].getMaxStackSize()-this.mInventory[1].stackSize); - this.mInventory[1].stackSize += tmp; - this.mItemCount -= tmp; - } - if(this.mItemStack!=null){ - this.mInventory[2]= this.mItemStack.copy(); - }else{this.mInventory[2]=null;} - } - } - - private int getItemCount() - { - return this.mItemCount; - } - - public int getProgresstime() - { - return this.mItemCount + (this.mInventory[0] == null ? 0 : this.mInventory[0].stackSize) + (this.mInventory[1] == null ? 0 : this.mInventory[1].stackSize); - } - - public int maxProgresstime() - { - return getMaxItemCount(); - } - - public int getMaxItemCount() - { - return (int) (((Math.pow(6, mTier))*270000) - 128); - } - - public void setItemCount(int aCount) - { - this.mItemCount = aCount; - } - - @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 true; - } - - @Override - public String[] getInfoData() { - - if(mItemStack==null){ - return new String[]{ - "Quantum Chest", - "Stored Items:", - "No Items", - Integer.toString(0), - Integer.toString(getMaxItemCount())}; - } - return new String[] { - "Quantum Chest", - "Stored Items:", - mItemStack.getDisplayName(), - Integer.toString(mItemCount), - Integer.toString(getMaxItemCount())}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mItemCount", this.mItemCount); - if(this.mItemStack!=null) - aNBT.setTag("mItemStack", this.mItemStack.writeToNBT(new NBTTagCompound())); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - if(aNBT.hasKey("mItemCount")) - this.mItemCount = aNBT.getInteger("mItemCount"); - if(aNBT.hasKey("mItemStack")) - this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity,byte aSide, byte aFacing, byte aColorIndex, boolean aActive,boolean aRedstone) { - if(aBaseMetaTileEntity.getFrontFacing()==0&&aSide==4){return new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex+1],new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_QCHEST)}; } - return aSide == aBaseMetaTileEntity.getFrontFacing() ? new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex+1],new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_QCHEST)} :new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex+1]};//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 ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; - } + return new GT_GUIContainer_QuantumChest(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + + if (getBaseMetaTileEntity().isServerSide() && getBaseMetaTileEntity().isAllowedToWork()) { + if ((getItemCount() <= 0)) { + this.mItemStack = null; + this.mItemCount = 0; + } + if (this.mItemStack == null && this.mInventory[0] != null) { + this.mItemStack = mInventory[0].copy(); + } + if ((this.mInventory[0] != null) && (this.mItemCount < getMaxItemCount()) && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { + this.mItemCount += this.mInventory[0].stackSize; + if (this.mItemCount > getMaxItemCount()) { + this.mInventory[0].stackSize = (this.mItemCount - getMaxItemCount()); + this.mItemCount = getMaxItemCount(); + } else { + this.mInventory[0] = null; + } + } + if (this.mInventory[1] == null && mItemStack != null) { + this.mInventory[1] = mItemStack.copy(); + this.mInventory[1].stackSize = Math.min(mItemStack.getMaxStackSize(), this.mItemCount); + this.mItemCount -= this.mInventory[1].stackSize; + } else if ((this.mItemCount > 0) && GT_Utility.areStacksEqual(this.mInventory[1], this.mItemStack) && this.mInventory[1].getMaxStackSize() > this.mInventory[1].stackSize) { + int tmp = Math.min(this.mItemCount, this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); + this.mInventory[1].stackSize += tmp; + this.mItemCount -= tmp; + } + if (this.mItemStack != null) { + this.mInventory[2] = this.mItemStack.copy(); + } else { + this.mInventory[2] = null; + } + } + } + + private int getItemCount() { + return this.mItemCount; + } + + public void setItemCount(int aCount) { + this.mItemCount = aCount; + } + + public int getProgresstime() { + return this.mItemCount + (this.mInventory[0] == null ? 0 : this.mInventory[0].stackSize) + (this.mInventory[1] == null ? 0 : this.mInventory[1].stackSize); + } + + public int maxProgresstime() { + return getMaxItemCount(); + } + + public int getMaxItemCount() { + return (int) (((Math.pow(6, mTier)) * 270000) - 128); + } + + @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 true; + } + + @Override + public String[] getInfoData() { + + if (mItemStack == null) { + return new String[]{ + "Quantum Chest", + "Stored Items:", + "No Items", + Integer.toString(0), + Integer.toString(getMaxItemCount())}; + } + return new String[]{ + "Quantum Chest", + "Stored Items:", + mItemStack.getDisplayName(), + Integer.toString(mItemCount), + Integer.toString(getMaxItemCount())}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mItemCount", this.mItemCount); + if (this.mItemStack != null) + aNBT.setTag("mItemStack", this.mItemStack.writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mItemCount")) + this.mItemCount = aNBT.getInteger("mItemCount"); + if (aNBT.hasKey("mItemStack")) + this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aBaseMetaTileEntity.getFrontFacing() == 0 && aSide == 4) { + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_QCHEST)}; + } + return aSide == aBaseMetaTileEntity.getFrontFacing() ? new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_QCHEST)} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]};//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 ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } }
\ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java index a27feb5814..1be8e2ff6f 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java @@ -2,128 +2,137 @@ package gregtech.common.tileentities.storage; 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.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.*; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.objects.GT_RenderedTexture; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.nbt.NBTTagCompound; public class GT_MetaTileEntity_QuantumTank - extends GT_MetaTileEntity_BasicTank -{ - public GT_MetaTileEntity_QuantumTank(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "Stores "+((int)(Math.pow(6, aTier)*267000))+"L of fluid"); - } - - public GT_MetaTileEntity_QuantumTank(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return aSide ==1 ? new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex+1],new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_QTANK)} :new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex+1]}; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return 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 void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); - } - - @Override - public final byte getUpdateData() { - return 0x00; - } - - @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 String[] getInfoData() { - - if(mFluid==null){ - return new String[]{ - "Quantum Tank", - "Stored Fluid:", - "No Fluid", - Integer.toString(0)+"L", - Integer.toString(getCapacity())+"L"}; - } - return new String[] { - "Quantum Tank", - "Stored Fluid:", - mFluid.getLocalizedName(), - Integer.toString(mFluid.amount)+"L", - Integer.toString(getCapacity())+"L"}; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_QuantumTank(mName, mTier, mDescription, mTextures); - } - - @Override - public int getCapacity() { - return (int) (Math.pow(6, mTier)*267000); - } - - @Override - public int getTankPressure() { - return 100; - } - + extends GT_MetaTileEntity_BasicTank { + public GT_MetaTileEntity_QuantumTank(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, "Stores " + ((int) (Math.pow(6, aTier) * 267000)) + "L of fluid"); + } + + public GT_MetaTileEntity_QuantumTank(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == 1 ? new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_QTANK)} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]}; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) return true; + aBaseMetaTileEntity.openGUI(aPlayer); + return 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 void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + } + + @Override + public final byte getUpdateData() { + return 0x00; + } + + @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; + } |
