diff options
author | Léa Gris <lea.gris@noiraude.net> | 2021-05-05 09:02:31 +0200 |
---|---|---|
committer | Léa Gris <lea.gris@noiraude.net> | 2021-05-21 13:38:30 +0200 |
commit | cca2933c1d616ccbb211e1d5f2e49e7c456cee9a (patch) | |
tree | dce1cb2649f5f05cba26a2f17fa82ccf76769a34 /src/main/java/gregtech/common/tileentities/storage | |
parent | 37e18fc8c73df4f27776b7a873a355f6412ee200 (diff) | |
download | GT5-Unofficial-cca2933c1d616ccbb211e1d5f2e49e7c456cee9a.tar.gz GT5-Unofficial-cca2933c1d616ccbb211e1d5f2e49e7c456cee9a.tar.bz2 GT5-Unofficial-cca2933c1d616ccbb211e1d5f2e49e7c456cee9a.zip |
feat(render): first set of glow textures
Add glowing textures to:
- Qantum or Super Tanks and Chests
- Active Bronze and Bricked Blast Furnaces
- Active Magical Absorber Top
- Fusion Reactor Control Computer Screen
- Active Yellow Glass Fusion Casing used on:
- Active Fusion Reactor Controller and Hatches
- Plasma Generator
- Lightning Rod
- Computer Screen Cover
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/storage')
4 files changed, 421 insertions, 395 deletions
diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java index 1876a16c1b..057d19af7e 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_DigitalChestBase.java @@ -1,15 +1,12 @@ package gregtech.common.tileentities.storage; -import java.util.HashMap; -import java.util.Map; - import cpw.mods.fml.common.Optional; 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.implementations.GT_MetaTileEntity_TieredMachineBlock; import gregtech.api.objects.AE2DigitalChestHandler; +import gregtech.api.objects.GT_RenderedGlowTexture; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; import gregtech.common.gui.GT_Container_QuantumChest; @@ -21,11 +18,51 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import java.util.HashMap; +import java.util.Map; + +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_SCHEST; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_SCHEST_GLOW; + @Optional.Interface(iface = "appeng.api.storage.IMEMonitor", modid = "appliedenergistics2", striprefs = true) public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEntity_TieredMachineBlock implements appeng.api.storage.IMEMonitor<appeng.api.storage.data.IAEItemStack> { + protected boolean mVoidOverflow = false; private Map<appeng.api.storage.IMEMonitorHandlerReceiver<appeng.api.storage.data.IAEItemStack>, Object> listeners = null; + public GT_MetaTileEntity_DigitalChestBase(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "This Chest stores " + CommonSizeCompute(aTier) + " Blocks Use a screwdriver to enable voiding items on overflow"); + super(aID, aName, aNameRegional, aTier, 3, new String[]{ + "This Chest stores " + commonSizeCompute(aTier) + " Blocks", + "Use a screwdriver to enable", + "voiding items on overflow" + }); + } + + protected static int commonSizeCompute(int tier) { + switch (tier) { + case 1: + return 4000000; + case 2: + return 8000000; + case 3: + return 16000000; + case 4: + return 32000000; + case 5: + return 64000000; + case 6: + return 128000000; + case 7: + return 256000000; + case 8: + return 512000000; + case 9: + return 1024000000; + case 10: + return 2147483640; + default: + return 0; + } } public GT_MetaTileEntity_DigitalChestBase(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -36,199 +73,111 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti super(aName, aTier, 3, aDescription, aTextures); } - @Override - public boolean isSimpleMachine() { - return true; + @Optional.Method(modid = "appliedenergistics2") + public static void registerAEIntegration() { + appeng.api.AEApi.instance().registries().externalStorage().addExternalStorageInterface(new AE2DigitalChestHandler()); } + @Optional.Method(modid = "appliedenergistics2") @Override - public boolean isFacingValid(byte aFacing) { - return true; + public void addListener(appeng.api.storage.IMEMonitorHandlerReceiver<appeng.api.storage.data.IAEItemStack> imeMonitorHandlerReceiver, Object o) { + if (listeners == null) + listeners = new HashMap<>(); + listeners.put(imeMonitorHandlerReceiver, o); } + @Optional.Method(modid = "appliedenergistics2") @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - return true; + public void removeListener(appeng.api.storage.IMEMonitorHandlerReceiver<appeng.api.storage.data.IAEItemStack> imeMonitorHandlerReceiver) { + if (listeners == null) + listeners = new HashMap<>(); + listeners.remove(imeMonitorHandlerReceiver); } + @Optional.Method(modid = "appliedenergistics2") @Override - public boolean isValidSlot(int aIndex) { - return true; + public appeng.api.config.AccessRestriction getAccess() { + return appeng.api.config.AccessRestriction.READ_WRITE; } + @Optional.Method(modid = "appliedenergistics2") @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); - return true; + public boolean isPrioritized(appeng.api.storage.data.IAEItemStack iaeItemStack) { + return false; } - - protected boolean mVoidOverflow = false; + @Optional.Method(modid = "appliedenergistics2") @Override - public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mVoidOverflow = !mVoidOverflow; - GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal(mVoidOverflow ? "GT5U.machines.voidoveflow.enabled" : "GT5U.machines.voidoveflow.disabled")); + public boolean canAccept(appeng.api.storage.data.IAEItemStack iaeItemStack) { + ItemStack s = getItemStack(); + if (s == null || iaeItemStack == null) + return true; + return iaeItemStack.isSameType(s); } + @Optional.Method(modid = "appliedenergistics2") @Override - public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_Container_QuantumChest(aPlayerInventory, aBaseMetaTileEntity); + public int getPriority() { + return 0; } + @Optional.Method(modid = "appliedenergistics2") @Override - public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_QuantumChest(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); + public int getSlot() { + return 0; } + @Optional.Method(modid = "appliedenergistics2") @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - - if (getBaseMetaTileEntity().isServerSide() && getBaseMetaTileEntity().isAllowedToWork()) { - if ((getItemCount() <= 0)) { - setItemStack(null); - setItemCount(0); - } - if (getItemStack() == null && mInventory[0] != null) { - setItemStack(mInventory[0].copy()); - } - int count = getItemCount(); - ItemStack stack = getItemStack(); - int savedCount = count; - - if ((mInventory[0] != null) && ((count < getMaxItemCount())|| mVoidOverflow ) && GT_Utility.areStacksEqual(mInventory[0], stack)) { - count += mInventory[0].stackSize; - if (count <= getMaxItemCount()) { - mInventory[0] = null; - } else { - if (mVoidOverflow) { - mInventory[0] = null; - } else { - mInventory[0].stackSize = (count - getMaxItemCount()); - } - count = getMaxItemCount(); - } - } - if (mInventory[1] == null && stack != null) { - mInventory[1] = stack.copy(); - mInventory[1].stackSize = Math.min(stack.getMaxStackSize(), count); - count -= mInventory[1].stackSize; - } else if ((count > 0) && GT_Utility.areStacksEqual(mInventory[1], stack) && mInventory[1].getMaxStackSize() > mInventory[1].stackSize) { - int tmp = Math.min(count, mInventory[1].getMaxStackSize() - mInventory[1].stackSize); - mInventory[1].stackSize += tmp; - count -= tmp; - } - setItemCount(count); - if (stack != null) { - mInventory[2] = stack.copy(); - mInventory[2].stackSize = Math.min(stack.getMaxStackSize(), count); - } else { - mInventory[2] = null; - } - - if (GregTech_API.mAE2) - notifyListeners(count - savedCount, stack); - if (count != savedCount) - getBaseMetaTileEntity().markDirty(); - } + public boolean validForPass(int i) { + return true; } - abstract protected int getItemCount(); - abstract public void setItemCount(int aCount); - abstract protected ItemStack getItemStack(); - abstract protected void setItemStack(ItemStack s); - - @Override - public int getProgresstime() { - return getItemCount() + (mInventory[0] == null ? 0 : mInventory[0].stackSize) + (mInventory[1] == null ? 0 : mInventory[1].stackSize); - } + protected abstract ItemStack getItemStack(); - @Override - public int maxProgresstime() { - return getMaxItemCount(); - } + protected abstract void setItemStack(ItemStack s); - protected static int CommonSizeCompute(int tier){ - switch(tier){ - case 1: - return 4000000; - case 2: - return 8000000; - case 3: - return 16000000; - case 4: - return 32000000; - case 5: - return 64000000; - case 6: - return 128000000; - case 7: - return 256000000; - case 8: - return 512000000; - case 9: - return 1024000000; - case 10: - return 2147483640; - default: - return 0; + @Optional.Method(modid = "appliedenergistics2") + public appeng.api.storage.data.IItemList<appeng.api.storage.data.IAEItemStack> getAvailableItems(final appeng.api.storage.data.IItemList out) { + ItemStack storedStack = getItemStack(); + if (storedStack != null) { + appeng.util.item.AEItemStack s = appeng.util.item.AEItemStack.create(storedStack); + s.setStackSize(getItemCount()); + out.add(s); } + return out; } + @Optional.Method(modid = "appliedenergistics2") @Override - public int getMaxItemCount() { - return CommonSizeCompute(mTier); - } - @Override - public ItemStack[] getStoredItemData() { - return mInventory; - } - @Override - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == 1; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return aIndex == 0 && (mInventory[0] == null || GT_Utility.areStacksEqual(mInventory[0], aStack)); + public appeng.api.storage.data.IItemList<appeng.api.storage.data.IAEItemStack> getStorageList() { + appeng.api.storage.data.IItemList<appeng.api.storage.data.IAEItemStack> res = new appeng.util.item.ItemList(); + ItemStack storedStack = getItemStack(); + if (storedStack != null) { + appeng.util.item.AEItemStack s = appeng.util.item.AEItemStack.create(storedStack); + s.setStackSize(getItemCount()); + res.add(s); + } + return res; } - abstract protected String chestName(); + protected abstract int getItemCount(); - @Optional.Method(modid = "appliedenergistics2") - public static void registerAEIntegration() { - appeng.api.AEApi.instance().registries().externalStorage().addExternalStorageInterface(new AE2DigitalChestHandler()); - } + public abstract void setItemCount(int aCount); @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mItemCount", getItemCount()); - if (getItemStack() != null) - aNBT.setTag("mItemStack", getItemStack().writeToNBT(new NBTTagCompound())); - aNBT.setBoolean("mVoidOverflow", mVoidOverflow); + public int getMaxItemCount() { + return commonSizeCompute(mTier); } @Override - public void loadNBTData(NBTTagCompound aNBT) { - if (aNBT.hasKey("mItemCount")) - setItemCount(aNBT.getInteger("mItemCount")); - if (aNBT.hasKey("mItemStack")) - setItemStack(ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack"))); - mVoidOverflow = aNBT.getBoolean("mVoidOverflow"); - + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_QuantumChest(aPlayerInventory, aBaseMetaTileEntity); } @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]); + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_QuantumChest(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); } @Override @@ -236,27 +185,6 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti return new ITexture[0][0][0]; } - @Override - public String[] getInfoData() { - - if (getItemStack() == null) { - return new String[]{ - EnumChatFormatting.BLUE + chestName() + EnumChatFormatting.RESET, - "Stored Items:", - EnumChatFormatting.GOLD + "No Items" + EnumChatFormatting.RESET, - EnumChatFormatting.GREEN + "0" + EnumChatFormatting.RESET + " " + - EnumChatFormatting.YELLOW + getMaxItemCount() + EnumChatFormatting.RESET - }; - } - return new String[]{ - EnumChatFormatting.BLUE + chestName() + EnumChatFormatting.RESET, - "Stored Items:", - EnumChatFormatting.GOLD + getItemStack().getDisplayName() + EnumChatFormatting.RESET, - EnumChatFormatting.GREEN + Integer.toString(getItemCount()) + EnumChatFormatting.RESET + " " + - EnumChatFormatting.YELLOW + getMaxItemCount() + EnumChatFormatting.RESET - }; - } - @Optional.Method(modid = "appliedenergistics2") public appeng.api.storage.data.IAEItemStack injectItems(final appeng.api.storage.data.IAEItemStack input, final appeng.api.config.Actionable mode, final appeng.api.networking.security.BaseActionSource src) { final ItemStack inputStack = input.getItemStack(); @@ -267,35 +195,27 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti ItemStack storedStack = getItemStack(); if (storedStack != null) { if (GT_Utility.areStacksEqual(storedStack, inputStack)) { - if (input.getStackSize() + getItemCount() > getMaxItemCount()) - { - if (mVoidOverflow) - { + if (input.getStackSize() + getItemCount() > getMaxItemCount()) { + if (mVoidOverflow) { if (mode != appeng.api.config.Actionable.SIMULATE) setItemCount(getMaxItemCount()); return null; } - else - { - return createOverflowStack(input.getStackSize() + getItemCount(), mode); - } - } - else { - if (mode != appeng.api.config.Actionable.SIMULATE) - setItemCount(getItemCount() + (int) input.getStackSize()); + return createOverflowStack(input.getStackSize() + getItemCount(), mode); } + if (mode != appeng.api.config.Actionable.SIMULATE) + setItemCount(getItemCount() + (int) input.getStackSize()); return null; - } else - return input; - } else { - if (mode != appeng.api.config.Actionable.SIMULATE) - setItemStack(inputStack.copy()); - if (input.getStackSize() > getMaxItemCount()) - return createOverflowStack(input.getStackSize(), mode); - else if (mode != appeng.api.config.Actionable.SIMULATE) - setItemCount((int) input.getStackSize()); - return null; + } + return input; } + if (mode != appeng.api.config.Actionable.SIMULATE) + setItemStack(inputStack.copy()); + if (input.getStackSize() > getMaxItemCount()) + return createOverflowStack(input.getStackSize(), mode); + if (mode != appeng.api.config.Actionable.SIMULATE) + setItemCount((int) input.getStackSize()); + return null; } @Optional.Method(modid = "appliedenergistics2") @@ -332,85 +252,133 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti return appeng.api.storage.StorageChannel.ITEMS; } - @Optional.Method(modid = "appliedenergistics2") - public appeng.api.storage.data.IItemList<appeng.api.storage.data.IAEItemStack> getAvailableItems(final appeng.api.storage.data.IItemList out) { - ItemStack storedStack = getItemStack(); - if (storedStack != null) { - appeng.util.item.AEItemStack s = appeng.util.item.AEItemStack.create(storedStack); - s.setStackSize(getItemCount()); - out.add(s); - } - return out; + @Override + public final void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + mVoidOverflow = !mVoidOverflow; + GT_Utility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal(mVoidOverflow ? "GT5U.machines.voidoveflow.enabled" : "GT5U.machines.voidoveflow.disabled")); } - @Optional.Method(modid = "appliedenergistics2") @Override - public appeng.api.storage.data.IItemList<appeng.api.storage.data.IAEItemStack> getStorageList() { - appeng.api.storage.data.IItemList<appeng.api.storage.data.IAEItemStack> res = new appeng.util.item.ItemList(); - ItemStack storedStack = getItemStack(); - if (storedStack != null) { - appeng.util.item.AEItemStack s = appeng.util.item.AEItemStack.create(storedStack); - s.setStackSize(getItemCount()); - res.add(s); + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + + if (getBaseMetaTileEntity().isServerSide() && getBaseMetaTileEntity().isAllowedToWork()) { + if ((getItemCount() <= 0)) { + setItemStack(null); + setItemCount(0); + } + if (getItemStack() == null && mInventory[0] != null) { + setItemStack(mInventory[0].copy()); + } + int count = getItemCount(); + ItemStack stack = getItemStack(); + int savedCount = count; + + if ((mInventory[0] != null) && ((count < getMaxItemCount()) || mVoidOverflow) && GT_Utility.areStacksEqual(mInventory[0], stack)) { + count += mInventory[0].stackSize; + if (count <= getMaxItemCount()) { + mInventory[0] = null; + } else { + if (mVoidOverflow) { + mInventory[0] = null; + } else { + mInventory[0].stackSize = (count - getMaxItemCount()); + } + count = getMaxItemCount(); + } + } + if (mInventory[1] == null && stack != null) { + mInventory[1] = stack.copy(); + mInventory[1].stackSize = Math.min(stack.getMaxStackSize(), count); + count -= mInventory[1].stackSize; + } else if ((count > 0) && GT_Utility.areStacksEqual(mInventory[1], stack) && mInventory[1].getMaxStackSize() > mInventory[1].stackSize) { + int tmp = Math.min(count, mInventory[1].getMaxStackSize() - mInventory[1].stackSize); + mInventory[1].stackSize += tmp; + count -= tmp; + } + setItemCount(count); + if (stack != null) { + mInventory[2] = stack.copy(); + mInventory[2].stackSize = Math.min(stack.getMaxStackSize(), count); + } else { + mInventory[2] = null; + } + + if (GregTech_API.mAE2) + notifyListeners(count - savedCount, stack); + if (count != savedCount) + getBaseMetaTileEntity().markDirty(); } - return res; } - @Optional.Method(modid = "appliedenergistics2") @Override - public void addListener(appeng.api.storage.IMEMonitorHandlerReceiver<appeng.api.storage.data.IAEItemStack> imeMonitorHandlerReceiver, Object o) { - if (listeners == null) - listeners = new HashMap<>(); - listeners.put(imeMonitorHandlerReceiver, o); + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (!aBaseMetaTileEntity.isClientSide()) aBaseMetaTileEntity.openGUI(aPlayer); + return true; } - @Optional.Method(modid = "appliedenergistics2") @Override - public void removeListener(appeng.api.storage.IMEMonitorHandlerReceiver<appeng.api.storage.data.IAEItemStack> imeMonitorHandlerReceiver) { - if (listeners == null) - listeners = new HashMap<>(); - listeners.remove(imeMonitorHandlerReceiver); + public boolean isFacingValid(byte aFacing) { + return true; } - @Optional.Method(modid = "appliedenergistics2") @Override - public appeng.api.config.AccessRestriction getAccess() { - return appeng.api.config.AccessRestriction.READ_WRITE; + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; } - @Optional.Method(modid = "appliedenergistics2") @Override - public boolean isPrioritized(appeng.api.storage.data.IAEItemStack iaeItemStack) { - return false; + public boolean isValidSlot(int aIndex) { + return true; } - @Optional.Method(modid = "appliedenergistics2") @Override - public boolean canAccept(appeng.api.storage.data.IAEItemStack iaeItemStack) { - ItemStack s = getItemStack(); - if (s == null || iaeItemStack == null) - return true; - return iaeItemStack.isSameType(s); + public boolean isSimpleMachine() { + return true; } - @Optional.Method(modid = "appliedenergistics2") @Override - public int getPriority() { - return 0; + public int getProgresstime() { + return getItemCount() + (mInventory[0] == null ? 0 : mInventory[0].stackSize) + (mInventory[1] == null ? 0 : mInventory[1].stackSize); } - @Optional.Method(modid = "appliedenergistics2") @Override - public int getSlot() { - return 0; + public int maxProgresstime() { + return getMaxItemCount(); } - @Optional.Method(modid = "appliedenergistics2") @Override - public boolean validForPass(int i) { + public boolean isGivingInformation() { return true; } + @Override + public String[] getInfoData() { + + if (getItemStack() == null) { + return new String[]{ + EnumChatFormatting.BLUE + chestName() + EnumChatFormatting.RESET, + "Stored Items:", + EnumChatFormatting.GOLD + "No Items" + EnumChatFormatting.RESET, + EnumChatFormatting.GREEN + "0" + EnumChatFormatting.RESET + " " + + EnumChatFormatting.YELLOW + getMaxItemCount() + EnumChatFormatting.RESET + }; + } + return new String[]{ + EnumChatFormatting.BLUE + chestName() + EnumChatFormatting.RESET, + "Stored Items:", + EnumChatFormatting.GOLD + getItemStack().getDisplayName() + EnumChatFormatting.RESET, + EnumChatFormatting.GREEN + Integer.toString(getItemCount()) + EnumChatFormatting.RESET + " " + + EnumChatFormatting.YELLOW + getMaxItemCount() + EnumChatFormatting.RESET + }; + } + + @Override + public ItemStack[] getStoredItemData() { + return mInventory; + } + + protected abstract String chestName(); + @Optional.Method(modid = "appliedenergistics2") private void notifyListeners(int count, ItemStack stack) { if (listeners == null) { @@ -423,11 +391,49 @@ public abstract class GT_MetaTileEntity_DigitalChestBase extends GT_MetaTileEnti appeng.util.item.AEItemStack s = appeng.util.item.AEItemStack.create(stack); s.setStackSize(count); change.add(s); - listeners.forEach((l,o) ->{ + listeners.forEach((l, o) -> { if (l.isValid(o)) l.postChange(this, change, null); else removeListener(l); }); } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mItemCount", getItemCount()); + if (getItemStack() != null) + aNBT.setTag("mItemStack", getItemStack().writeToNBT(new NBTTagCompound())); + aNBT.setBoolean("mVoidOverflow", mVoidOverflow); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + if (aNBT.hasKey("mItemCount")) + setItemCount(aNBT.getInteger("mItemCount")); + if (aNBT.hasKey("mItemStack")) + setItemStack(ItemStack.loadItemStackFromNBT((NBTTagCompound) aNBT.getTag("mItemStack"))); + mVoidOverflow = aNBT.getBoolean("mVoidOverflow"); + + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 1; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aIndex == 0 && (mInventory[0] == null || GT_Utility.areStacksEqual(mInventory[0], aStack)); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide != aFacing) return new ITexture[]{MACHINE_CASINGS[mTier][aColorIndex + 1]}; + return new ITexture[]{ + MACHINE_CASINGS[mTier][aColorIndex + 1], + new GT_RenderedTexture(OVERLAY_SCHEST), + new GT_RenderedGlowTexture(OVERLAY_SCHEST_GLOW) + }; + } } 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 812f9970ea..6484e541f9 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 @@ -1,18 +1,39 @@ package gregtech.common.tileentities.storage; -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_BasicTank; +import gregtech.api.objects.GT_RenderedGlowTexture; import gregtech.api.objects.GT_RenderedTexture; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_QTANK; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_QTANK_GLOW; 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 " + CommonSizeCompute(aTier) + "L of fluid"); + super(aID, aName, aNameRegional, aTier, 3, "Stores " + commonSizeCompute(aTier) + "L of fluid"); + } + + private static int commonSizeCompute(int tier) { + switch (tier) { + case 6: + return 128000000; + case 7: + return 256000000; + case 8: + return 512000000; + case 9: + return 1024000000; + case 10: + return 2147483640; + default: + return 0; + } } public GT_MetaTileEntity_QuantumTank(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -29,96 +50,84 @@ public class GT_MetaTileEntity_QuantumTank extends GT_MetaTileEntity_BasicTank { } @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]}; + public boolean isSimpleMachine() { + return true; } @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); + public boolean doesFillContainers() { + return true; } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + public boolean doesEmptyContainers() { return true; } @Override - public boolean isSimpleMachine() { + public boolean canTankBeFilled() { return true; } @Override - public boolean isFacingValid(byte aFacing) { + public boolean canTankBeEmptied() { return true; } @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { + public boolean displaysItemStack() { return true; } @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); + public boolean displaysStackSize() { + return false; } @Override - public final byte getUpdateData() { - return 0x00; + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_QuantumTank(mName, mTier, mDescriptionArray, mTextures); } @Override - public boolean doesFillContainers() { - return true; + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide != ForgeDirection.UP.ordinal()) return new ITexture[]{MACHINE_CASINGS[mTier][aColorIndex + 1]}; + return new ITexture[]{ + MACHINE_CASINGS[mTier][aColorIndex + 1], + new GT_RenderedTexture(OVERLAY_QTANK), + new GT_RenderedGlowTexture(OVERLAY_QTANK_GLOW) + }; } @Override - public boolean doesEmptyContainers() { + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (!aBaseMetaTileEntity.isClientSide()) aBaseMetaTileEntity.openGUI(aPlayer); return true; } @Override - public boolean canTankBeFilled() { - return true; + public final byte getUpdateData() { + return 0x00; } @Override - public boolean canTankBeEmptied() { + public boolean isFacingValid(byte aFacing) { return true; } @Override - public boolean displaysItemStack() { + public boolean isAccessAllowed(EntityPlayer aPlayer) { return true; } @Override - public boolean displaysStackSize() { - return false; + public int getTankPressure() { + return 100; } @Override - public String[] getInfoData() { - - if (mFluid == null) { - return new String[]{ - EnumChatFormatting.BLUE + "Quantum Tank"+ EnumChatFormatting.RESET, - "Stored Fluid:", - EnumChatFormatting.GOLD + "No Fluid"+ EnumChatFormatting.RESET, - EnumChatFormatting.GREEN + Integer.toString(0) + " L"+ EnumChatFormatting.RESET+" "+ - EnumChatFormatting.YELLOW + Integer.toString(getCapacity()) + " L"+ EnumChatFormatting.RESET - }; - } - return new String[]{ - EnumChatFormatting.BLUE + "Quantum Tank"+ EnumChatFormatting.RESET, - "Stored Fluid:", - EnumChatFormatting.GOLD + mFluid.getLocalizedName()+ EnumChatFormatting.RESET, - EnumChatFormatting.GREEN + Integer.toString(mFluid.amount) + " L"+ EnumChatFormatting.RESET+" "+ - EnumChatFormatting.YELLOW+ Integer.toString(getCapacity()) + " L"+ EnumChatFormatting.RESET - }; + public int getCapacity() { + return commonSizeCompute(mTier); } @Override @@ -127,35 +136,24 @@ public class GT_MetaTileEntity_QuantumTank extends GT_MetaTileEntity_BasicTank { } @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_QuantumTank(mName, mTier, mDescriptionArray, mTextures); - } + public String[] getInfoData() { - private static int CommonSizeCompute(int tier){ - switch(tier){ - case 6: - return 128000000; - case 7: - return 256000000; - case 8: - return 512000000; - case 9: - return 1024000000; - case 10: - return 2147483640; - default: - return 0; + if (mFluid == null) { + return new String[]{ + EnumChatFormatting.BLUE + "Quantum Tank" + EnumChatFormatting.RESET, + "Stored Fluid:", + EnumChatFormatting.GOLD + "No Fluid" + EnumChatFormatting.RESET, + EnumChatFormatting.GREEN + Integer.toString(0) + " L" + EnumChatFormatting.RESET + " " + + EnumChatFormatting.YELLOW + Integer.toString(getCapacity()) + " L" + EnumChatFormatting.RESET + }; } - } - - @Override - public int getCapacity() { - return CommonSizeCompute(mTier); - } - - @Override - public int getTankPressure() { - return 100; + return new String[]{ + EnumChatFormatting.BLUE + "Quantum Tank" + EnumChatFormatting.RESET, + "Stored Fluid:", + EnumChatFormatting.GOLD + mFluid.getLocalizedName() + EnumChatFormatting.RESET, + EnumChatFormatting.GREEN + Integer.toString(mFluid.amount) + " L" + EnumChatFormatting.RESET + " " + + EnumChatFormatting.YELLOW + Integer.toString(getCapacity()) + " L" + EnumChatFormatting.RESET + }; } } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java index 3f53058f8d..373cfa731a 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperChest.java @@ -3,7 +3,17 @@ package gregtech.common.tileentities.storage; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.objects.GT_RenderedGlowTexture; +import gregtech.api.objects.GT_RenderedTexture; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.ArrayList; +import java.util.Collection; + +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_SCHEST; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_SCHEST_GLOW; public class GT_MetaTileEntity_SuperChest extends GT_MetaTileEntity_DigitalChestBase { public int mItemCount = 0; @@ -20,20 +30,34 @@ public class GT_MetaTileEntity_SuperChest extends GT_MetaTileEntity_DigitalChest public GT_MetaTileEntity_SuperChest(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); } + @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SuperChest(mName, mTier, mDescriptionArray, mTextures); + protected ItemStack getItemStack() { + return mItemStack; } + @Override - protected String chestName(){ return "Super Chest"; } + protected void setItemStack(ItemStack s) { + mItemStack = s; + } + @Override - protected int getItemCount() { return mItemCount; } + protected int getItemCount() { + return mItemCount; + } + @Override public void setItemCount(int aCount) { mItemCount = aCount; } + @Override - protected ItemStack getItemStack(){ return mItemStack; } + protected String chestName() { + return "Super Chest"; + } + @Override - protected void setItemStack(ItemStack s){ mItemStack = s; } + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_SuperChest(mName, mTier, mDescriptionArray, mTextures); + } } diff --git a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java index c8b4bf20d8..65de4b3362 100644 --- a/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java +++ b/src/main/java/gregtech/common/tileentities/storage/GT_MetaTileEntity_SuperTank.java @@ -1,18 +1,39 @@ package gregtech.common.tileentities.storage; -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_BasicTank; +import gregtech.api.objects.GT_RenderedGlowTexture; import gregtech.api.objects.GT_RenderedTexture; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_QTANK; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_QTANK_GLOW; public class GT_MetaTileEntity_SuperTank extends GT_MetaTileEntity_BasicTank { public GT_MetaTileEntity_SuperTank(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, "Stores " + CommonSizeCompute(aTier) + "L of fluid"); + super(aID, aName, aNameRegional, aTier, 3, "Stores " + commonSizeCompute(aTier) + "L of fluid"); + } + + private static int commonSizeCompute(int tier) { + switch (tier) { + case 1: + return 4000000; + case 2: + return 8000000; + case 3: + return 16000000; + case 4: + return 32000000; + case 5: + return 64000000; + default: + return 0; + } } public GT_MetaTileEntity_SuperTank(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { @@ -29,96 +50,84 @@ public class GT_MetaTileEntity_SuperTank extends GT_MetaTileEntity_BasicTank { } @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_STANK)} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1]}; + public boolean isSimpleMachine() { + return true; } @Override - public void saveNBTData(NBTTagCompound aNBT) { - super.saveNBTData(aNBT); + public boolean doesFillContainers() { + return true; } @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; - aBaseMetaTileEntity.openGUI(aPlayer); + public boolean doesEmptyContainers() { return true; } @Override - public boolean isSimpleMachine() { + public boolean canTankBeFilled() { return true; } @Override - public boolean isFacingValid(byte aFacing) { + public boolean canTankBeEmptied() { return true; } @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { + public boolean displaysItemStack() { return true; } @Override - public void loadNBTData(NBTTagCompound aNBT) { - super.loadNBTData(aNBT); + public boolean displaysStackSize() { + return false; } @Override - public final byte getUpdateData() { - return 0x00; + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_SuperTank(mName, mTier, mDescription, mTextures); } @Override - public boolean doesFillContainers() { - return true; + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + if (aSide != ForgeDirection.UP.ordinal()) return new ITexture[]{MACHINE_CASINGS[mTier][aColorIndex + 1]}; + return new ITexture[]{ + MACHINE_CASINGS[mTier][aColorIndex + 1], + new GT_RenderedTexture(OVERLAY_QTANK), + new GT_RenderedGlowTexture(OVERLAY_QTANK_GLOW) + }; } @Override - public boolean doesEmptyContainers() { + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (!aBaseMetaTileEntity.isClientSide()) aBaseMetaTileEntity.openGUI(aPlayer); return true; } @Override - public boolean canTankBeFilled() { - return true; + public final byte getUpdateData() { + return 0x00; } @Override - public boolean canTankBeEmptied() { + public boolean isFacingValid(byte aFacing) { return true; } @Override - public boolean displaysItemStack() { + public boolean isAccessAllowed(EntityPlayer aPlayer) { return true; } @Override - public boolean displaysStackSize() { - return false; + public int getTankPressure() { + return 100; } @Override - public String[] getInfoData() { - - if (mFluid == null) { - return new String[]{ - EnumChatFormatting.BLUE + "Super Tank"+ EnumChatFormatting.RESET, - "Stored Fluid:", - EnumChatFormatting.GOLD + "No Fluid"+ EnumChatFormatting.RESET, - EnumChatFormatting.GREEN + Integer.toString(0) + " L"+ EnumChatFormatting.RESET+" "+ - EnumChatFormatting.YELLOW + Integer.toString(getCapacity()) + " L"+ EnumChatFormatting.RESET - }; - } - return new String[]{ - EnumChatFormatting.BLUE + "Super Tank"+ EnumChatFormatting.RESET, - "Stored Fluid:", - EnumChatFormatting.GOLD + mFluid.getLocalizedName()+ EnumChatFormatting.RESET, - EnumChatFormatting.GREEN + Integer.toString(mFluid.amount) + " L"+ EnumChatFormatting.RESET+" "+ - EnumChatFormatting.YELLOW+ Integer.toString(getCapacity()) + " L"+ EnumChatFormatting.RESET - }; + public int getCapacity() { + return commonSizeCompute(mTier); } @Override @@ -127,35 +136,24 @@ public class GT_MetaTileEntity_SuperTank extends GT_MetaTileEntity_BasicTank { } @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_SuperTank(mName, mTier, mDescription, mTextures); - } + public String[] getInfoData() { - private static int CommonSizeCompute(int tier){ - switch(tier){ - case 1: - return 4000000; - case 2: - return 8000000; - case 3: - return 16000000; - case 4: - return 32000000; - case 5: - return 64000000; - default: - return 0; + if (mFluid == null) { + return new String[]{ + EnumChatFormatting.BLUE + "Super Tank" + EnumChatFormatting.RESET, + "Stored Fluid:", + EnumChatFormatting.GOLD + "No Fluid" + EnumChatFormatting.RESET, + EnumChatFormatting.GREEN + "0 L" + EnumChatFormatting.RESET + " " + + EnumChatFormatting.YELLOW + getCapacity() + " L" + EnumChatFormatting.RESET + }; } - } - - @Override - public int getCapacity() { - return CommonSizeCompute(mTier); - } - - @Override - public int getTankPressure() { - return 100; + return new String[]{ + EnumChatFormatting.BLUE + "Super Tank" + EnumChatFormatting.RESET, + "Stored Fluid:", + EnumChatFormatting.GOLD + mFluid.getLocalizedName() + EnumChatFormatting.RESET, + EnumChatFormatting.GREEN + Integer.toString(mFluid.amount) + " L" + EnumChatFormatting.RESET + " " + + EnumChatFormatting.YELLOW + getCapacity() + " L" + EnumChatFormatting.RESET + }; } } |