diff options
author | Blood-Asp <Blood@Asp> | 2015-04-30 19:34:16 +0200 |
---|---|---|
committer | Blood-Asp <Blood@Asp> | 2015-04-30 19:34:16 +0200 |
commit | eba3a051ca6f7f65e085c69e382656780ebf1fdb (patch) | |
tree | d9c7c73ea5a8201c48abbe56fe1fd2a7533c4ae8 /main/java/gregtech/common/tileentities/storage | |
parent | 7c0de38a9fe24ef60ab328e074432881ce4fbda4 (diff) | |
download | GT5-Unofficial-eba3a051ca6f7f65e085c69e382656780ebf1fdb.tar.gz GT5-Unofficial-eba3a051ca6f7f65e085c69e382656780ebf1fdb.tar.bz2 GT5-Unofficial-eba3a051ca6f7f65e085c69e382656780ebf1fdb.zip |
QChest + Wireless RS
Diffstat (limited to 'main/java/gregtech/common/tileentities/storage')
-rw-r--r-- | main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java | 208 | ||||
-rw-r--r-- | main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java | 205 |
2 files changed, 300 insertions, 113 deletions
diff --git a/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java b/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java new file mode 100644 index 0000000000..708fe4b195 --- /dev/null +++ b/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumChest.java @@ -0,0 +1,208 @@ +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; + +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(); +// if (tPlayerItem == null) +// { +// if (this.mItemID > 0) +// { +// for (int i = 0; (this.mItemCount < getMaxItemCount()) && (i < aPlayer.field_71071_by.func_70302_i_()); i++) +// { +// if ((aPlayer.field_71071_by.func_70301_a(i) != null) && (aPlayer.field_71071_by.func_70301_a(i).field_77993_c == this.mItemID) && (aPlayer.field_71071_by.func_70301_a(i).func_77960_j() == this.mItemMeta) && (!aPlayer.field_71071_by.func_70301_a(i).func_77942_o())) +// { +// this.mItemCount += aPlayer.field_71071_by.func_70301_a(i).field_77994_a; +// if (aPlayer.field_71071_by.func_70301_a(i).field_77994_a == 111) +// { +// this.mItemCount = (getMaxItemCount() + 192 - (this.mItemCount + (this.mInventory[0] == null ? 0 : this.mInventory[0].field_77994_a) + (this.mInventory[1] == null ? 0 : this.mInventory[1].field_77994_a) + (this.mInventory[2] == null ? 0 : this.mInventory[2].field_77994_a))); +// } +// else if (this.mItemCount > getMaxItemCount()) +// { +// aPlayer.field_71071_by.func_70301_a(i).field_77994_a = (this.mItemCount - getMaxItemCount()); +// this.mItemCount = getMaxItemCount(); +// } +// else +// { +// aPlayer.field_71071_by.func_70301_a(i).field_77994_a = 0; +// } +// } +// if ((aPlayer.field_71071_by.func_70301_a(i) != null) && (aPlayer.field_71071_by.func_70301_a(i).field_77994_a <= 0)) { +// aPlayer.field_71071_by.func_70299_a(i, null); +// } +// } +// GT_Utility.sendChatToPlayer(aPlayer, this.mItemCount + (this.mInventory[0] == null ? 0 : this.mInventory[0].field_77994_a) + (this.mInventory[1] == null ? 0 : this.mInventory[1].field_77994_a) + (this.mInventory[2] == null ? 0 : this.mInventory[2].field_77994_a) + " of " + new ItemStack(this.mItemID, 1, this.mItemMeta).func_82833_r()); +// } +// } +// if (aPlayer.field_71069_bz != null) { +// aPlayer.field_71069_bz.func_75142_b(); +// } +// } + + @Override + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + 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 = new ItemStack(mInventory[0].getItem()); + } + if ((this.mInventory[0]!=null)&&(this.mItemCount < getMaxItemCount()) && (this.mInventory[0].getItem() == this.mItemStack.getItem())) + { + 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) + { + this.mInventory[1] = new ItemStack(mItemStack.getItem(),Math.min(mItemStack.getMaxStackSize(), this.mItemCount)); + this.mItemCount -= this.mInventory[1].stackSize; + } + else if ((this.mItemCount > 0) && (this.mInventory[1].getItem() == this.mItemStack.getItem())&&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]= new ItemStack(this.mItemStack.getItem()); + }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 void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mItemCount", this.mItemCount); + aNBT.setTag("mItemStack", this.mItemStack.writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + this.mItemCount = aNBT.getInteger("mItemCount"); + this.mItemStack = ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity,byte aSide, byte aFacing, byte aColorIndex, boolean aActive,boolean aRedstone) { + return aSide == aBaseMetaTileEntity.getFrontFacing() ? new ITexture[] {Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex+1],new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SCREEN)} :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/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java b/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java index 7810ea6217..56b06addec 100644 --- a/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java +++ b/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_QuantumTank.java @@ -1,126 +1,105 @@ 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.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) - { - super(aID, aName, aNameRegional, aID, aID, aNameRegional, null); - } - - public boolean unbreakable() - { - return true; - } - - public boolean isSimpleMachine() - { - return false; - } - - public boolean isValidSlot(int aIndex) - { - return aIndex < 2; - } - - public boolean isFacingValid(byte aFacing) - { - return false; - } - - public void onRightclick(EntityPlayer aPlayer) - { - getBaseMetaTileEntity().openGUI(aPlayer, 114); - } - - public boolean isAccessAllowed(EntityPlayer aPlayer) - { - return true; - } - - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) - { - return new GT_MetaTileEntity_QuantumTank(mTier, mDescription, mDescription); - } - - public boolean doesFillContainers() - { - return true; - } - - public boolean doesEmptyContainers() - { - return true; - } - - public boolean canTankBeFilled() - { - return true; - } - - public boolean canTankBeEmptied() - { - return true; - } - - public boolean displaysItemStack() - { - return true; - } - - public boolean displaysStackSize() - { - return false; - } - - public boolean isFluidChangingAllowed() - { - return getBaseMetaTileEntity().isAllowedToWork(); - } - - public int getTextureIndex(byte aSide, byte aFacing, boolean aActive, boolean aRedstone) - { - if (aSide == 0) { - return 38; - } - if (aSide == 1) { - return 37; - } - return 36; - } - - public String[] getDescription() - { - return new String[]{"With a capacity of 488.28125 Chunks!"}; - } - - public int getCapacity() - { - return 2000000000; - } - - public int getTankPressure() - { - return 100; - } + public GT_MetaTileEntity_QuantumTank(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, "Stores "+((int)(Math.pow(6, aTier)*270000))+"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) { - // TODO Auto-generated method stub - return null; -} + @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_SCREEN)} :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 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 false; + } + + @Override + public boolean displaysStackSize() { + return false; + } -@Override -public ITexture[][][] getTextureSet(ITexture[] aTextures) { - // TODO Auto-generated method stub - return null; -} -} + @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)*270000); + } + + @Override + public int getTankPressure() { + return 100; + } + +}
\ No newline at end of file |