diff options
author | Connor-Colenso <52056774+Connor-Colenso@users.noreply.github.com> | 2023-09-04 03:05:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-04 03:05:22 +0100 |
commit | 76719d65a90d98e228a914774d3b11ed9f01ac8e (patch) | |
tree | ce0d35f954e441e9cc4aa95aa347073728e6f4ee /src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities | |
parent | 0393b582eb3edcb5c575330804b6747577a55e27 (diff) | |
download | GT5-Unofficial-76719d65a90d98e228a914774d3b11ed9f01ac8e.tar.gz GT5-Unofficial-76719d65a90d98e228a914774d3b11ed9f01ac8e.tar.bz2 GT5-Unofficial-76719d65a90d98e228a914774d3b11ed9f01ac8e.zip |
Clean-up v2 (#729)
* Remove test items from NEI with no texture
* Add number formatting to hand pumps
* Remove heavy plates (no recipes & completely unused).
* Remove helium generator (no texture, no recipe)
* Remove fire pit and fire starter (no use, no recipe, no textures)
* Remove giant chicken and associated unused stuff, has no texture and is unobtainable. Used to be relevant but isn't anymore.
* Remove villagers with silly trades like 1 motor + 1 hull = 1 hull. Why?
* Remove trade bench, no recipe, missing textures. Unused.
* Remove farm processors, no texture, no recipe. Unused.
* Remove MAX tier components, these exist in GT now, have no recipe here and are unused.
* Hide untextured light block from NEI
* Update buildscript
* Remove unused backpacks, no recipe and contains dupe bugs. Bad.
* Remove eatotronic, universal toolbox and magic tool bag. All 3 are missing textures and uncraftable.
* Remove eatotronic, universal toolbox and magic tool bag. All 3 are missing textures and uncraftable. part 2
* Remove dragon catcher (what?), no texture, no recipe, unused.
* Remove empty item, does nothing, has no recipe, no idea why it is here.
* Empty item v2 removal
* Revert "Empty item v2 removal"
This reverts commit 75bcd3ccfaf55bbfe2c12b2e4167d5c37636030d.
* Revert "Remove empty item, does nothing, has no recipe, no idea why it is here."
This reverts commit e41a9f484392776331c58530ab1faa5ef978ef36.
* Remove debug square. No recipe, unused.
* Number formatting overflow covers
* Remove JVM garbage collection block. Unused, no recipe.
* Remove nanotubes, no recipe for them. Unused.
* Remove "git" item, doesn't seem to work. Has no recipe.
* Remove uncraftable food with awful textures.
* Remove "bat king" mob, unused content. Does not spawn.
* Remove uncraftable doors with bad textures. Unused content.
* Remove uncraftable, unlocalised redstone stuff that crashes game when placed.
* Remove weird spawner item. No recipe, does not exist in world.
* Remove sunnarium bit, no recipe, no usage.
* Remove unused modularity table and some misc uncraftable, unused items.
* Remove Interconnecting Storage Crate, no recipe, unused.
* Delete worse debug power gen, this already exists as part of GT. Unneeded duplication.
* Delete unused placeholder circuit
* Delete uncraftable generator hatches.
* Spotless
* Remove XP tank thing, unused and uncraftable.
* Remove null item, this fluid registry only seemed to register one null fluid. All others exist?
* Remove EU -> RF battery. Unused in GTNH.
* Remove some shelf nonsense, why is this in this mod?
* Remove some weird random tools. These have no realistic usage in GTNH.
* Remove firemaker. Useless in GTNH.
* Removed helium blob. Deprecated item, not used anymore, uncraftable.
* spotlessApply (#730)
Co-authored-by: GitHub GTNH Actions <>
* Stop modulators generating unused blocks with no textures
* Remove more unused untextured casings
* Remove more unused untextured casings
* Remove more unused untextured casings
* Remove more unused untextured casings
* Remove more unused untextured casings
* Remove some weird methods and uncraftable mining parts, probably part of deprecated multiblock.
* spotlessApply (#732)
Co-authored-by: GitHub GTNH Actions <>
* Remove gem shards, unused.
* Remove unused atoms
* Remove unused gum
* Remove unused elements/materials
* Bye bye
* Remove some unused reflection stuff
* Remove control cores, obsolete now.
* Remove mob killing thing with no texture and no recipe.
* Remove uncraftable covers
* Remove pizza gloves
* Net and rope removal, unused
* Remove force crop
* Removal of some old event stuff
* Remove unused nuclear chem items
* Remove player safe, mostly because of the horrible event code that was intercepting every block break. I can't see any real usage of this via discord.
* Remove Force material and associated other nonsense. Also remove some nuclear chem stuff.
* Remove force for realsies
* Skookum Chooker purge.
* Remove some enderio compat, these plates/dusts are added via GT5 anyway now. This is obsolete.
* spotlessApply (#733)
Co-authored-by: GitHub GTNH Actions <>
* Unused textures
* Bump dep
* Revert "Remove force for realsies"
This reverts commit 0d288912a99f9dabce56d2a2623d4d3510f4804e.
* Revert "Remove Force material and associated other nonsense. Also remove some nuclear chem stuff."
This reverts commit 3455e6e916defe1f2aef923be6f9696a6cf3095b.
* Remove nuclear items that are unused
* spotlessApply (#734)
Co-authored-by: GitHub GTNH Actions <>
---------
Co-authored-by: GTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com>
Co-authored-by: Connor Colenso <colen@CONNORSPC>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities')
11 files changed, 0 insertions, 2114 deletions
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java index 51d7b4d186..3b54fb46a7 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/GregtechMetaTileEntity_RTG.java @@ -28,7 +28,6 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; public class GregtechMetaTileEntity_RTG extends GT_MetaTileEntity_BasicGenerator { public int mEfficiency; - private int mDays; private long mTicksToBurnFor; private int mVoltage = 0; private GT_Recipe mCurrentRecipe; @@ -79,7 +78,6 @@ public class GregtechMetaTileEntity_RTG extends GT_MetaTileEntity_BasicGenerator @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - // this.mMachineBlock = aNBT.getByte("mMachineBlock"); this.mTicksToBurnFor = aNBT.getLong("mTicksToBurnFor"); this.mVoltage = aNBT.getInteger("mVoltage"); this.mDaysRemaining = aNBT.getInteger("mDaysRemaining"); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java deleted file mode 100644 index c04a04ae3c..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/generators/creative/GregtechMetaCreativeEnergyBuffer.java +++ /dev/null @@ -1,234 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.generators.creative; - -import static gregtech.api.enums.GT_Values.V; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import com.gtnewhorizon.gtnhlib.reflect.Fields; - -import gregtech.api.enums.GT_Values; -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.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.core.util.sys.KeyboardUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; -import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GregtechMetaEnergyBuffer; - -/** - * 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 GregtechMetaCreativeEnergyBuffer extends GregtechMetaEnergyBuffer { - - private int mVoltageTier = 3; - - public GregtechMetaCreativeEnergyBuffer(final String aName, final int aTier, final String aDescription, - final ITexture[][][] aTextures, final int aSlotCount) { - super(aName, aTier, aDescription, aTextures, aSlotCount); - // TODO Auto-generated constructor stub - } - - public GregtechMetaCreativeEnergyBuffer(final int aID, final String aName, final String aNameRegional, - final int aTier, final String aDescription, final int aSlotCount) { - super(aID, aName, aNameRegional, aTier, aDescription, aSlotCount); - } - - @Override - public String[] getDescription() { - return new String[] { this.mDescription, "Use Screwdriver to change voltage", - "Hold Shift while using Screwdriver to change amperage", EnumChatFormatting.GREEN + "CREATIVE MACHINE", - CORE.GT_Tooltip.get() }; - } - - /* - * MACHINE_STEEL_SIDE - */ - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - CustomIcon h = TexturesGtBlock.Casing_Material_RedSteel; - CustomIcon g = TexturesGtBlock.Casing_Material_Grisium; - CustomIcon k; - boolean j = MathUtils.isNumberEven(this.mVoltageTier); - final ITexture[][][] rTextures = new ITexture[2][17][]; - k = j ? g : h; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = new ITexture[] { new GT_RenderedTexture(k) }; - rTextures[1][i + 1] = new ITexture[] { new GT_RenderedTexture(k), - this.mInventory.length > 4 ? Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[this.mVoltageTier] - : Textures.BlockIcons.OVERLAYS_ENERGY_OUT[this.mVoltageTier] }; - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[side == facing ? 1 : 0][aColorIndex + 1]; - } - - @Override - protected void showEnergy(final World worldIn, final EntityPlayer playerIn) { - final long tempStorage = this.getBaseMetaTileEntity().getStoredEU(); - final double c = ((double) tempStorage / this.maxEUStore()) * 100; - final double roundOff = Math.round(c * 100.00) / 100.00; - PlayerUtils.messagePlayer( - playerIn, - "Energy: " + GT_Utility - .formatNumbers(tempStorage) + " EU at " + V[this.mVoltageTier] + "v (" + roundOff + "%)"); - PlayerUtils.messagePlayer(playerIn, "Amperage: " + GT_Utility.formatNumbers(maxAmperesOut()) + "A"); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaCreativeEnergyBuffer( - this.mName, - this.mTier, - this.mDescription, - this.mTextures, - this.mInventory.length); - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public long maxEUStore() { - return Long.MAX_VALUE; - } - - @Override - public long maxEUInput() { - return V[mVoltageTier]; - } - - @Override - public long maxEUOutput() { - return V[mVoltageTier]; - } - - @Override - public long maxAmperesIn() { - return aCurrentOutputAmperage; - } - - @Override - public long maxAmperesOut() { - return aCurrentOutputAmperage; - } - - @Override - public int getProgresstime() { - return Integer.MAX_VALUE; - } - - @Override - public int maxProgresstime() { - return Integer.MAX_VALUE; - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - if (aBaseMetaTileEntity.isServerSide()) { - aBaseMetaTileEntity.increaseStoredEnergyUnits(Integer.MAX_VALUE, true); - } - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public String[] getInfoData() { - String[] infoData = super.getInfoData(); - return new String[] { infoData[0], "THIS IS A CREATIVE ITEM - FOR TESTING | Tier: " + this.mVoltageTier, - infoData[1], infoData[2] }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mVoltageTier", this.mVoltageTier); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.mVoltageTier = aNBT.getInteger("mVoltageTier"); - super.loadNBTData(aNBT); - } - - private static Fields.ClassFields<GregtechMetaCreativeEnergyBuffer>.Field<ITexture[][][]> mTexturesAccessor; - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (KeyboardUtils.isShiftKeyDown()) { - super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); - } else { - if (this.mVoltageTier < (GT_Values.VN[9].equals("UHV") ? GT_Values.V.length - 1 : 9)) { - this.mVoltageTier++; - } else { - this.mVoltageTier = 0; - } - this.markDirty(); - try { - if (mTexturesAccessor == null) { - mTexturesAccessor = Fields.ofClass(GregtechMetaCreativeEnergyBuffer.class) - .getField(Fields.LookupType.PUBLIC, "mTextures", ITexture[][][].class); - } - ITexture[][][] V = getTextureSet(null); - if (V != null) { - Logger.REFLECTION("Got Valid Textures."); - if (this.getBaseMetaTileEntity().isClientSide()) { - Logger.REFLECTION("Clientside Call."); - Logger.REFLECTION("Refreshing Textures on buffer."); - mTexturesAccessor.setValue(this, V); - Logger.REFLECTION("Refreshed Textures on buffer."); - } else { - Logger.REFLECTION("Serverside Call."); - } - } else { - Logger.REFLECTION("Bad mTextures setter."); - } - } catch (Throwable t) { - // Bad refresh. - t.printStackTrace(); - Logger.REFLECTION("Bad mTextures setter."); - } - PlayerUtils.messagePlayer(aPlayer, "Now running at " + GT_Values.VOLTAGE_NAMES[this.mVoltageTier] + "."); - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java deleted file mode 100644 index e815a622d9..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaGarbageCollector.java +++ /dev/null @@ -1,386 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.machines.basic; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -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.objects.GT_RenderedTexture; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTileEntity; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GregtechMetaGarbageCollector extends GregtechMetaTileEntity { - - long mLastCleanup = 0; - long mLocalTickVar = 0; - int mFrequency = 5; - - public GregtechMetaGarbageCollector(final String aName, final String aNameRegional, final String aDescription) { - super(991, aName, aNameRegional, 5, 0, aDescription); - } - - public GregtechMetaGarbageCollector(final String aName, final String aDescription, final ITexture[][][] aTextures) { - super(aName, 5, 0, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return new String[] { this.mDescription, "Can request the JVM to perform garbage collection", - "Configurable to run once every 5 minute interval (5-180)", "This Machine has no recipe", - "Admin Tool, Limit one per world if possible", CORE.GT_Tooltip.get() }; - } - - @Override - public ITexture[][][] getTextureSet(final ITexture[] aTextures) { - final ITexture[][][] rTextures = new ITexture[10][17][]; - for (byte i = -1; i < 16; i++) { - rTextures[0][i + 1] = this.getFront(i); - rTextures[1][i + 1] = this.getBack(i); - rTextures[2][i + 1] = this.getBottom(i); - rTextures[3][i + 1] = this.getTop(i); - rTextures[4][i + 1] = this.getSides(i); - rTextures[5][i + 1] = this.getFrontActive(i); - rTextures[6][i + 1] = this.getBackActive(i); - rTextures[7][i + 1] = this.getBottomActive(i); - rTextures[8][i + 1] = this.getTopActive(i); - rTextures[9][i + 1] = this.getSidesActive(i); - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - return this.mTextures[(aActive ? 5 : 0) - + (side == facing ? 0 - : side == facing.getOpposite() ? 1 - : side == ForgeDirection.DOWN ? 2 : side == ForgeDirection.UP ? 3 : 4)][aColorIndex - + 1]; - } - - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel) }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium) }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redox_3) }; - } - - public ITexture[] getFrontActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel) }; - } - - public ITexture[] getBackActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Material_RedSteel) }; - } - - public ITexture[] getBottomActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium) }; - } - - public ITexture[] getTopActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Material_Grisium) }; - } - - public ITexture[] getSidesActive(final byte aColor) { - return new ITexture[] { Textures.BlockIcons.MACHINE_CASINGS[this.mTier + 3][aColor + 1], - new GT_RenderedTexture(TexturesGtBlock.Casing_Redox_3) }; - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (mFrequency < 180) { - mFrequency += 5; - } else { - mFrequency = 5; - } - PlayerUtils.messagePlayer(aPlayer, "Running every " + mFrequency + " minutes."); - super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaGarbageCollector(this.mName, this.mDescription, this.mTextures); - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isElectric() { - return false; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return false; - } - - @Override - public boolean isFacingValid(final ForgeDirection facing) { - return true; - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isInputFacing(final ForgeDirection side) { - return side != this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public boolean isOutputFacing(final ForgeDirection side) { - return side == this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public boolean isTeleporterCompatible() { - return false; - } - - @Override - public long getMinimumStoredEU() { - return 0; - } - - @Override - public long maxEUStore() { - return 0; - } - - @Override - public int getCapacity() { - return 0; - } - - @Override - public long maxEUInput() { - return 0; - } - - @Override - public long maxEUOutput() { - return 0; - } - - @Override - public long maxAmperesIn() { - return 0; - } - - @Override - public long maxAmperesOut() { - return 0; - } - - @Override - public int rechargerSlotStartIndex() { - return 0; - } - - @Override - public int dechargerSlotStartIndex() { - return 0; - } - - @Override - public int rechargerSlotCount() { - return 0; - } - - @Override - public int dechargerSlotCount() { - return 0; - } - - @Override - public int getProgresstime() { - return (int) this.getBaseMetaTileEntity().getUniversalEnergyStored(); - } - - @Override - public int maxProgresstime() { - return (int) this.getBaseMetaTileEntity().getUniversalEnergyCapacity(); - } - - @Override - public boolean isAccessAllowed(final EntityPlayer aPlayer) { - return true; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - this.showPollution(aPlayer.getEntityWorld(), aPlayer); - return true; - } - - private void showPollution(final World worldIn, final EntityPlayer playerIn) { - PlayerUtils.messagePlayer( - playerIn, - "Running every " + mFrequency + " minutes. Owner: " + this.getBaseMetaTileEntity().getOwnerName()); - long aDiff = mLocalTickVar - this.mLastCleanup; - PlayerUtils.messagePlayer(playerIn, "Last run: " + Utils.getSecondsFromMillis(aDiff) + " seconds ago."); - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return false; - } - - @Override - public String[] getInfoData() { - return new String[] { this.getLocalName() }; - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(final int p_94128_1_) { - return new int[] {}; - } - - @Override - public boolean canInsertItem(final int p_102007_1_, final ItemStack p_102007_2_, final int p_102007_3_) { - return false; - } - - @Override - public boolean canExtractItem(final int p_102008_1_, final ItemStack p_102008_2_, final int p_102008_3_) { - return false; - } - - @Override - public int getSizeInventory() { - return 0; - } - - @Override - public ItemStack getStackInSlot(final int p_70301_1_) { - return null; - } - - @Override - public ItemStack decrStackSize(final int p_70298_1_, final int p_70298_2_) { - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(final int p_70304_1_) { - return null; - } - - @Override - public void setInventorySlotContents(final int p_70299_1_, final ItemStack p_70299_2_) {} - - @Override - public String getInventoryName() { - return null; - } - - @Override - public boolean hasCustomInventoryName() { - return false; - } - - @Override - public int getInventoryStackLimit() { - return 0; - } - - @Override - public boolean isUseableByPlayer(final EntityPlayer p_70300_1_) { - return true; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - @Override - public boolean isItemValidForSlot(final int p_94041_1_, final ItemStack p_94041_2_) { - return false; - } - - @Override - public boolean isOverclockerUpgradable() { - return false; - } - - @Override - public boolean isTransformerUpgradable() { - return false; - } - - @Override - public void saveNBTData(final NBTTagCompound aNBT) {} - - @Override - public void loadNBTData(final NBTTagCompound aNBT) {} - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - if (this.getBaseMetaTileEntity().isServerSide()) { - mLocalTickVar = System.currentTimeMillis(); - long aDiff = mLocalTickVar - this.mLastCleanup; - if (Utils.getSecondsFromMillis(aDiff) >= (this.mFrequency * 60)) { - System.gc(); - this.mLastCleanup = mLocalTickVar; - } - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_ConnectableCrate.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_ConnectableCrate.java deleted file mode 100644 index 9a073e9e30..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_ConnectableCrate.java +++ /dev/null @@ -1,578 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage; - -import net.minecraft.block.Block; -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; - -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.common.widget.DrawableWidget; -import com.gtnewhorizons.modularui.common.widget.SlotWidget; -import com.gtnewhorizons.modularui.common.widget.TextWidget; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures.BlockIcons; -import gregtech.api.gui.modularui.GT_UIInfos; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.modularui.IAddUIWidgets; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.util.data.ArrayUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GT_MetaTileEntity_ConnectableCrate extends GT_MetaTileEntity_TieredMachineBlock implements IAddUIWidgets { - - /* - * sides.put(getUp()); sides.put(getDown()); sides.put(getXPos()); sides.put(getXNeg()); sides.put(getZPos()); - * sides.put(getZNeg()); - */ - - public int mItemCount = 0; - public ItemStack mItemStack = null; - private static final double mStorageFactor = 2; - - // Meta Tile ID - public static final int mCrateID = 955; - - // Sides - public static final int SIDE_Up = 0; - public static final int SIDE_Down = 1; - public static final int SIDE_XPos = 2; - public static final int SIDE_XNeg = 3; - public static final int SIDE_ZPos = 4; - public static final int SIDE_ZNeg = 5; - public static final int[] SIDES = new int[] { SIDE_Up, SIDE_Down, SIDE_XPos, SIDE_XNeg, SIDE_ZPos, SIDE_ZNeg }; - - // Neighbour Cache - private GT_MetaTileEntity_ConnectableCrate[] mNeighbourCache = new GT_MetaTileEntity_ConnectableCrate[6]; - // Cached Crate Location - private BlockPos mCurrentPos = null; - // Master Crate Position - protected BlockPos mMasterCrateLocation = null; - // Is Master? - protected boolean mIsMaster = false; - // Is Connected? - protected boolean mIsConnected[] = new boolean[] { false, false, false, false, false, false }; - // How many are connected? - protected int mConnectedCount = 0; - // Map of connected locations - protected AutoMap<String> mConnectedCache = new AutoMap<String>(); - - public GT_MetaTileEntity_ConnectableCrate(int aID, String aName, String aNameRegional, int aTier) { - super( - aID, - aName, - aNameRegional, - aTier, - 3, - "This Crate stores " + (int) (Math.pow(6.0D, (double) aTier) * mStorageFactor) + " Items", - new ITexture[0]); - } - - public GT_MetaTileEntity_ConnectableCrate(String aName, int aTier, String[] aDescription, - ITexture[][][] aTextures) { - super(aName, aTier, 3, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return org.apache.commons.lang3.ArrayUtils.add(this.mDescriptionArray, CORE.GT_Tooltip.get()); - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - public boolean isFacingValid(ForgeDirection facing) { - 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_ConnectableCrate(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); - } - - public int getOppositeSide(int side) { - if (side == SIDE_Up) { - return SIDE_Down; - } else if (side == SIDE_Down) { - return SIDE_Up; - } else if (side == SIDE_XNeg) { - return SIDE_XPos; - } else if (side == SIDE_XPos) { - return SIDE_XNeg; - } else if (side == SIDE_ZNeg) { - return SIDE_ZPos; - } else { - return SIDE_ZNeg; - } - } - - public boolean calculateOwnershipIfConnected() { - if (mCurrentPos == null) { - mCurrentPos = new BlockPos( - this.getBaseMetaTileEntity().getXCoord(), - this.getBaseMetaTileEntity().getYCoord(), - this.getBaseMetaTileEntity().getZCoord(), - this.getBaseMetaTileEntity().getWorld()); - } - AutoMap<BlockPos> n = mCurrentPos.getSurroundingBlocks(); - int p = 0; - for (BlockPos i : n) { - if (i != null) { - if (doesSideContainCrate(p)) { - GT_MetaTileEntity_ConnectableCrate yu = getCrateAtBlockPos(i); - if (yu != null) { - mNeighbourCache[p] = yu; - } - } - } - p++; - } - - int e4 = 0; - if (mNeighbourCache.length > 0) { - for (GT_MetaTileEntity_ConnectableCrate e : mNeighbourCache) { - this.mConnectedCount = this.mConnectedCache.size(); - if (e != null) { - // First, we check if this Crate is a Master, if not, continue checking what it is. - if (this.mIsMaster) { - // So this other Crate is also a master? Which is more Powerful - if (e.mIsMaster) { - // This crate holds more connected, it becomes master now. - if (this.mConnectedCount > e.mConnectedCount) { - e.mIsMaster = false; - e.mMasterCrateLocation = this.mCurrentPos; - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - this.mConnectedCache = ArrayUtils.mergeTwoMaps(this.mConnectedCache, e.mConnectedCache); - continue; - } - // Other crate held more connected, it is now master. - else { - this.mIsMaster = false; - this.mMasterCrateLocation = e.mCurrentPos; - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - e.mConnectedCache = ArrayUtils.mergeTwoMaps(e.mConnectedCache, this.mConnectedCache); - // Best wipe our cache of connected blocks then, since they no longer hold value. - mConnectedCache.clear(); - continue; - } - } - // Other Crate was not a Master, but we are, time to inherit it into our connection hivemind. - else { - // It would appear this controller has another master, time to query it. - if (e.mMasterCrateLocation != null && !e.mMasterCrateLocation.getUniqueIdentifier() - .equalsIgnoreCase(this.mMasterCrateLocation.getUniqueIdentifier())) { - GT_MetaTileEntity_ConnectableCrate gM = getCrateAtBlockPos(e.mMasterCrateLocation); - if (gM != null) { - // Lets compare controller strengths - int gM_Owned = gM.mConnectedCount; - // We are stronger, let's inherit it. - if (this.mConnectedCount > gM_Owned) { - e.mIsMaster = false; - e.mMasterCrateLocation = this.mCurrentPos; - gM.mIsMaster = false; - gM.mMasterCrateLocation = this.mCurrentPos; - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - this.mConnectedCache = ArrayUtils - .mergeTwoMaps(this.mConnectedCache, gM.mConnectedCache); - continue; - } - // We lost, time to submit to a new master crate - else { - this.mIsMaster = false; - this.mMasterCrateLocation = e.mMasterCrateLocation; - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - gM.mConnectedCache = ArrayUtils - .mergeTwoMaps(gM.mConnectedCache, this.mConnectedCache); - // Best wipe our cache of connected blocks then, since they no longer hold - // value. - mConnectedCache.clear(); - continue; - } - } else { - // Could not get the Tile Entity for the Other Master Crate.. Guess I can just - // ignore this case for now~ TODO - continue; - } - } - // Either the other crate has no known Master or it is already this crate. - else { - // The other crate has no master, time to inherit. - if (e.mMasterCrateLocation == null || (!e.mIsConnected[getOppositeSide(e4)])) { - e.mMasterCrateLocation = this.mCurrentPos; - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - mConnectedCache.put(e.mCurrentPos.getUniqueIdentifier()); - continue; - } else { - // Do nothing, we own this Crate already :) - continue; - } - } - } - } - - // We are not a Storage Master Crate, into a brave new world we go - else { - // Best wipe our cache of connected blocks then, since they no longer hold value. - mConnectedCache.clear(); - - // Dang, the other crate is a master, time to get incorporated. - if (e.mIsMaster) { - this.mIsMaster = false; - this.mMasterCrateLocation = e.mCurrentPos; - this.mIsConnected[e4] = true; - if (!e.mIsConnected[e4]) { - e.mIsConnected[e4] = true; - } - if (e.mMasterCrateLocation == null) { - e.mMasterCrateLocation = e.mCurrentPos; - } - e.mConnectedCache.put(this.mCurrentPos.getUniqueIdentifier()); - continue; - } - // So the Crate we Checked is not a Master, so let's see if it knows where one is - else { - // So, this Crate we have found knows about a master - if (e.mMasterCrateLocation != null) { - GT_MetaTileEntity_ConnectableCrate gM = getCrateAtBlockPos(e.mMasterCrateLocation); - // Found the master crate - if (gM != null) { - this.mIsMaster = false; - this.mMasterCrateLocation = e.mMasterCrateLocation; - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - gM.mConnectedCache.put(this.mCurrentPos.getUniqueIdentifier()); - continue; - } else { - // Could not get the Tile Entity for the Other Master Crate.. Guess I can just - // ignore this case for now~ TODO - continue; - } - } - // This crate has no master, not going to check if it's connected. - else { - this.mIsMaster = true; - this.mMasterCrateLocation = this.mCurrentPos; - e.mIsMaster = false; - e.mMasterCrateLocation = this.mCurrentPos; - if (!e.mIsConnected[getOppositeSide(e4)]) { - e.mIsConnected[getOppositeSide(e4)] = true; - } - if (!this.mIsConnected[e4]) { - this.mIsConnected[e4] = true; - } - mConnectedCache.put(e.mCurrentPos.getUniqueIdentifier()); - continue; - } - } - } - } - e4++; - } - return true; - } else { - return false; - } - } - - public boolean doesSideContainCrate(int side) { - return checkSideForDataType(0, side); - } - - public boolean isCrateAtSideController(int side) { - return checkSideForDataType(1, side); - } - - private boolean checkSideForDataType(int aType, int ordinalSide) { - BlockPos mPosToCheck = ordinalSide == SIDE_Up ? mCurrentPos.getUp() - : ordinalSide == SIDE_Down ? mCurrentPos.getDown() - : ordinalSide == SIDE_XPos ? mCurrentPos.getXPos() - : ordinalSide == SIDE_XNeg ? mCurrentPos.getXNeg() - : ordinalSide == SIDE_ZPos ? mCurrentPos.getZPos() : mCurrentPos.getZNeg(); - GT_MetaTileEntity_ConnectableCrate g = getCrateAtBlockPos(mPosToCheck); - if (g != null) { - if (aType == 0) { - return true; - } else { - if (g.mIsMaster) { - return true; - } - } - } - return false; - } - - public GT_MetaTileEntity_ConnectableCrate getCrateAtBlockPos(BlockPos pos) { - if (pos != null) { - Block b = pos.getBlockAtPos(); - int m = pos.getMetaAtPos(); - TileEntity t = pos.world.getTileEntity(pos.xPos, pos.yPos, pos.zPos); - if (b != null && t != null) { - if (b == GregTech_API.sBlockMachines && m == mCrateID) { - if (t instanceof IGregTechTileEntity) { - IGregTechTileEntity g = (IGregTechTileEntity) t; - final IMetaTileEntity aMetaTileEntity = g.getMetaTileEntity(); - if (aMetaTileEntity == null) { - return null; - } - if (aMetaTileEntity instanceof GT_MetaTileEntity_ConnectableCrate) { - return ((GT_MetaTileEntity_ConnectableCrate) aMetaTileEntity); - } - } - } - } - } - return null; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); - return true; - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { - if (this.getBaseMetaTileEntity().isServerSide() && this.getBaseMetaTileEntity().isAllowedToWork()) { - if (this.getItemCount() <= 0) { - this.mItemStack = null; - this.mItemCount = 0; - } - - if (this.mItemStack == null && this.mInventory[0] != null) { - this.mItemStack = this.mInventory[0].copy(); - } - - if (this.mInventory[0] != null && this.mItemCount < this.getMaxItemCount() - && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { - this.mItemCount += this.mInventory[0].stackSize; - if (this.mItemCount > this.getMaxItemCount()) { - this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); - this.mItemCount = this.getMaxItemCount(); - } else { - this.mInventory[0] = null; - } - } - - if (this.mInventory[1] == null && this.mItemStack != null) { - this.mInventory[1] = this.mItemStack.copy(); - this.mInventory[1].stackSize = Math.min(this.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(); - this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); - } else { - this.mInventory[2] = null; - } - } - } - - private int getItemCount() { - return this.mItemCount; - } - - @Override - public void setItemCount(int aCount) { - this.mItemCount = aCount; - } - - @Override - public int getProgresstime() { - return this.mItemCount + (this.mInventory[0] == null ? 0 : this.mInventory[0].stackSize) - + (this.mInventory[1] == null ? 0 : this.mInventory[1].stackSize); - } - - @Override - public int maxProgresstime() { - return this.getMaxItemCount(); - } - - @Override - public int getMaxItemCount() { - return (int) (Math.pow(6.0D, (double) this.mTier) * mStorageFactor - 128.0D); - } - - public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - return aIndex == 1; - } - - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, - ItemStack aStack) { - return aIndex == 0 && (this.mInventory[0] == null || GT_Utility.areStacksEqual(this.mInventory[0], aStack)); - } - - @Override - public String[] getInfoData() { - return this.mItemStack == null - ? new String[] { "Super Storage Chest", "Stored Items:", "No Items", Integer.toString(0), - Integer.toString(this.getMaxItemCount()) } - : new String[] { "Super Storage Chest", "Stored Items:", this.mItemStack.getDisplayName(), - Integer.toString(this.mItemCount), Integer.toString(this.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())); - } - aNBT.setString("mMasterCrateLocation", mMasterCrateLocation.getUniqueIdentifier()); - aNBT.setBoolean("mIsMaster", mIsMaster); - for (int y = 0; y < this.mIsConnected.length; y++) { - aNBT.setBoolean("mIsConnected" + y, mIsConnected[y]); - } - aNBT.setInteger("mConnectedCount", mConnectedCount); - } - - @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")); - } - if (aNBT.hasKey("mMasterCrateLocation")) { - this.mMasterCrateLocation = BlockPos.generateBlockPos(aNBT.getString("mMasterCrateLocation")); - } - if (aNBT.hasKey("mIsMaster")) { - this.mIsMaster = aNBT.getBoolean("mIsMaster"); - } - - for (int y = 0; y < this.mIsConnected.length; y++) { - if (aNBT.hasKey("mIsConnected" + y)) { - this.mIsConnected[y] = aNBT.getBoolean("mIsConnected" + y); - } - } - - if (aNBT.hasKey("mConnectedCount")) { - this.mConnectedCount = aNBT.getInteger("mConnectedCount"); - } - } - - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, - int aColorIndex, boolean aActive, boolean aRedstone) { - return aBaseMetaTileEntity.getFrontFacing() == ForgeDirection.DOWN && side == ForgeDirection.WEST - ? new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.TEXTURE_CASING_AMAZON), - new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST) } - : (side == aBaseMetaTileEntity.getFrontFacing() - ? new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.TEXTURE_CASING_AMAZON), - new GT_RenderedTexture(BlockIcons.OVERLAY_QCHEST) } - : new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.TEXTURE_CASING_AMAZON) }); - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @Override - public void onExplosion() { - // TODO Auto-generated method stub - super.onExplosion(); - } - - @Override - public void onRemoval() { - // TODO Auto-generated method stub - super.onRemoval(); - } - - @Override - public void onMachineBlockUpdate() { - // TODO Auto-generated method stub - super.onMachineBlockUpdate(); - } - - @Override - public boolean useModularUI() { - return true; - } - - @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - builder.widget( - new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK).setPos(7, 16).setSize(71, 45)) - .widget( - new SlotWidget(inventoryHandler, 0) - .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_IN) - .setPos(79, 16)) - .widget( - new SlotWidget(inventoryHandler, 1).setAccess(true, false) - .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_OUT) - .setPos(79, 52)) - .widget( - SlotWidget.phantom(inventoryHandler, 2).disableInteraction() - .setBackground(GT_UITextures.TRANSPARENT).setPos(59, 42)) - .widget(new TextWidget("Item Amount").setDefaultColor(COLOR_TEXT_WHITE.get()).setPos(10, 20)).widget( - TextWidget.dynamicString(() -> GT_Utility.parseNumberToString(mItemCount)) - .setDefaultColor(COLOR_TEXT_WHITE.get()).setPos(10, 30)); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaSafeBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaSafeBlock.java deleted file mode 100644 index 9e7b7d03e5..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GregtechMetaSafeBlock.java +++ /dev/null @@ -1,77 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage; - -import org.apache.commons.lang3.ArrayUtils; - -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.common.widget.ButtonWidget; -import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; -import com.gtnewhorizons.modularui.common.widget.SlotGroup; -import com.gtnewhorizons.modularui.common.widget.TextWidget; - -import gregtech.api.enums.Textures; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.modularui.IAddUIWidgets; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.xmod.gregtech.api.gui.GTPP_UITextures; -import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.machines.GregtechMetaSafeBlockBase; - -public class GregtechMetaSafeBlock extends GregtechMetaSafeBlockBase implements IAddUIWidgets { - - public GregtechMetaSafeBlock(final int aID, final String aName, final String aNameRegional, final int aTier) { - super(aID, aName, aNameRegional, aTier, 28, "Protecting your items from sticky fingers."); - } - - public GregtechMetaSafeBlock(final String aName, final int aTier, final int aInvSlotCount, - final String[] aDescription, final ITexture[][][] aTextures) { - super(aName, aTier, aInvSlotCount, aDescription, aTextures); - } - - @Override - public String[] getDescription() { - return ArrayUtils.add(this.mDescriptionArray, CORE.GT_Tooltip.get()); - } - - @Override - public IMetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { - return new GregtechMetaSafeBlock( - this.mName, - this.mTier, - this.mInventory.length, - this.mDescriptionArray, - this.mTextures); - } - - @Override - public ITexture getOverlayIcon() { - return new GT_RenderedTexture(Textures.BlockIcons.VOID); - } - - @Override - public boolean isValidSlot(final int aIndex) { - return aIndex < (this.mInventory.length - 1); - } - - @Override - public boolean useModularUI() { - return true; - } - - @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - builder.widget(SlotGroup.ofItemHandler(inventoryHandler, 9).endAtSlot(26).build().setPos(7, 4)) - .widget( - new ButtonWidget().setOnClick((clickData, widget) -> bUnbreakable = !bUnbreakable) - .setBackground(GT_UITextures.BUTTON_STANDARD, GTPP_UITextures.OVERLAY_BUTTON_LOCK) - .setPos(43, 62).setSize(18, 18)) - .widget(new TextWidget("Safe Status").setPos(76, 61)) - .widget( - TextWidget.dynamicString(() -> bUnbreakable ? "Locked" : "Unlocked").setSynced(false) - .setPos(82, 73)) - .widget(new FakeSyncWidget.BooleanSyncer(() -> bUnbreakable, val -> bUnbreakable = val)); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf.java deleted file mode 100644 index aeea5b33e8..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf.java +++ /dev/null @@ -1,365 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; - -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; - -import org.apache.commons.lang3.ArrayUtils; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicHull_NonElectric; -import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Utility; -import gregtech.common.items.GT_MetaGenerated_Tool_01; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.core.util.sys.KeyboardUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock.CustomIcon; - -public class GT4Entity_Shelf extends GT_MetaTileEntity_BasicHull_NonElectric { - - public byte mType = 0; - public boolean mLocked = false; - protected byte mIndex = (byte) MathUtils.randInt(1, 3); - public static GT_RenderedTexture texBottom = new GT_RenderedTexture( - new CustomIcon("TileEntities/gt4/machine_bottom")); - public static GT_RenderedTexture texTop = new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_top")); - public static GT_RenderedTexture texSide = new GT_RenderedTexture(new CustomIcon("TileEntities/gt4/machine_side")); - public static GT_RenderedTexture texSideCabinet = new GT_RenderedTexture( - new CustomIcon("TileEntities/gt4/machine_side_cabinet")); - - public GT4Entity_Shelf(final int aID, final String aName, final String aNameRegional, final String aDescription) { - super(aID, aName, aNameRegional, 0, aDescription); - } - - public GT4Entity_Shelf(final String aName, final String[] aDescription, final ITexture[][][] aTextures) { - super(aName, 0, aDescription, aTextures); - } - - @Override - public boolean isSimpleMachine() { - return true; - } - - @Override - public boolean isFacingValid(ForgeDirection facing) { - return facing.offsetY == 0; - } - - @Override - public boolean isAccessAllowed(EntityPlayer aPlayer) { - if (this.getBaseMetaTileEntity().getOwnerName().equalsIgnoreCase(aPlayer.getDisplayName())) { - return true; - } - PlayerUtils.messagePlayer( - aPlayer, - "This container belongs to " + this.getBaseMetaTileEntity().getOwnerName() + "."); - return false; - } - - @Override - public boolean ownerControl() { - return false; - } - - @Override - public boolean isEnetOutput() { - return false; - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public boolean isOutputFacing(final ForgeDirection side) { - return side != this.getBaseMetaTileEntity().getFrontFacing(); - } - - @Override - public boolean isInputFacing(ForgeDirection side) { - return false; - } - - @Override - public boolean onRightclick(IGregTechTileEntity aTile, EntityPlayer aPlayer) { - if (aTile.isClientSide()) { - return true; - } - ItemStack tStack = aPlayer.inventory.getStackInSlot(aPlayer.inventory.currentItem); - if (tStack == null) { - if (KeyboardUtils.isCtrlKeyDown()) { - if (this.mInventory[0] != null) { - PlayerUtils.messagePlayer( - aPlayer, - "Contains " + this.mInventory[0].getDisplayName() - + " x" - + this.mInventory[0].stackSize - + "."); - } - return false; - } else { - if ((this.mInventory[0] != null) && (this.mInventory[0].stackSize > 0)) { - if (!this.mLocked) { - PlayerUtils.messagePlayer( - aPlayer, - "Removed " + this.mInventory[0].getDisplayName() - + " x" - + this.mInventory[0].stackSize - + "."); - aPlayer.inventory.setInventorySlotContents(aPlayer.inventory.currentItem, this.mInventory[0]); - getBaseMetaTileEntity().setInventorySlotContents(0, null); - this.mType = 0; - return true; - } else { - PlayerUtils.messagePlayer( - aPlayer, - "This container is locked. It belongs to " + aTile.getOwnerName() + "."); - return false; - } - } - return false; - } - } else if (tStack != null && this.mInventory[0] == null) { - - if (KeyboardUtils.isCtrlKeyDown() || GT_MetaGenerated_Tool_01.class.isInstance(tStack.getItem())) { - return false; - } - PlayerUtils.messagePlayer(aPlayer, "Stored " + tStack.getDisplayName() + " x" + tStack.stackSize + "."); - aPlayer.inventory.setInventorySlotContents(aPlayer.inventory.currentItem, null); - getBaseMetaTileEntity().setInventorySlotContents(0, tStack); - this.mType = (byte) MathUtils.randInt(1, 3); - return true; - } else { - if (this.mInventory[0] == null) { - this.mType = 0; - } - return super.onRightclick(aTile, aPlayer); - } - } - - @Override - public void onLeftclick(IGregTechTileEntity aTile, EntityPlayer aPlayer) { - if ((this.mInventory[0] != null) && (this.mInventory[0].stackSize > 0)) { - ItemStack tOutput = GT_Utility.copy(new Object[] { this.mInventory[0] }); - if (!aPlayer.isSneaking()) { - tOutput.stackSize = 1; - } - getBaseMetaTileEntity().decrStackSize(0, tOutput.stackSize); - EntityItem tEntity = new EntityItem( - getBaseMetaTileEntity().getWorld(), - getBaseMetaTileEntity().getOffsetX(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5D, - getBaseMetaTileEntity().getOffsetY(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5D, - getBaseMetaTileEntity().getOffsetZ(getBaseMetaTileEntity().getFrontFacing(), 1) + 0.5D, - tOutput); - tEntity.motionX = 0.0D; - tEntity.motionY = 0.0D; - tEntity.motionZ = 0.0D; - getBaseMetaTileEntity().getWorld().spawnEntityInWorld(tEntity); - if (this.mInventory[0] == null) { - this.mType = 0; - } - } - super.onLeftclick(aTile, aPlayer); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_Shelf(this.mName, this.mDescriptionArray, this.mTextures); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { // mLocked - aNBT.setInteger("mType", this.mType); - aNBT.setBoolean("mLocked", this.mLocked); - aNBT.setByte("mIndex", this.mIndex); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - if (aNBT.hasKey("mIndex")) { - this.mType = ((byte) aNBT.getInteger("mType")); - } - if (aNBT.hasKey("mIndex")) { - this.mLocked = (aNBT.getBoolean("mLocked")); - } - if (aNBT.hasKey("mIndex")) { - this.mIndex = aNBT.getByte("mIndex"); - } - } - - @Override - public void onValueUpdate(byte aValue) { - this.mType = aValue; - } - - @Override - public byte getUpdateData() { - return this.mType; - } - - @Override - public String[] getDescription() { - return ArrayUtils.addAll( - mDescriptionArray, - "Decorative Item Storage", - "Right click to store/remove something", - "Ctrl + Rmb to check contents", - "Ctrl + Rmb with a screwdriver to lock"); - } - - @Override - public byte getTileEntityBaseType() { - return 0; - } - - @Override - public boolean allowCoverOnSide(ForgeDirection side, GT_ItemStack aStack) { - // return side != getBaseMetaTileEntity().getFrontFacing(); - return false; - } - - @Override - public boolean allowPullStack(IGregTechTileEntity p0, int p1, ForgeDirection side, ItemStack p3) { - return true; - } - - @Override - public boolean allowPutStack(IGregTechTileEntity p0, int p1, ForgeDirection side, ItemStack p3) { - return false; - } - - @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - ITexture[][][] rTextures = new ITexture[7][17][]; - for (byte i = -1; i < 16; i = (byte) (i + 1)) { - ITexture[] tmp0 = { this.getBottom((byte) 0)[0] }; - rTextures[0][(i + 1)] = tmp0; - ITexture[] tmp1 = { this.getTop((byte) 0)[0] }; - rTextures[1][(i + 1)] = tmp1; - ITexture[] tmp2 = { this.getSides((byte) 0)[0] }; - rTextures[2][(i + 1)] = tmp2; - ITexture[] tmp4 = { this.getSides((byte) 0)[0] }; - rTextures[3][(i + 1)] = tmp4; - ITexture[] tmp5 = { this.getSides((byte) 0)[0], getFront((byte) 0)[0] }; - rTextures[4][(i + 1)] = tmp5; - ITexture[] tmp6 = { this.getSides((byte) 0)[0], getFront((byte) 1)[0] }; - rTextures[5][(i + 1)] = tmp6; - ITexture[] tmp7 = { this.getSides((byte) 0)[0], getFront((byte) 2)[0] }; - rTextures[6][(i + 1)] = tmp7; - } - return rTextures; - } - - @Override - public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final ForgeDirection side, - final ForgeDirection facing, final int aColorIndex, final boolean aActive, final boolean aRedstone) { - - ITexture[] tmp = this.mTextures[(side.offsetY == 0) - ? ((side != facing) ? 2 - : ((byte) this.mType == 0 ? 4 - : this.mType == 1 || this.mType == 2 ? 5 : this.mType == 3 ? 6 : 0)) - : side.ordinal()][aColorIndex + 1]; - if (side != facing && tmp.length == 2) { - tmp = new ITexture[] { tmp[0] }; - } - return tmp; - } - - private static GT_RenderedTexture x1 = new GT_RenderedTexture(TexturesGtBlock.OVERLAY_WOODEN_SHELF_FRONT); - private static GT_RenderedTexture x2 = new GT_RenderedTexture(TexturesGtBlock.OVERLAY_WOODEN_SHELF_PAPER_FRONT); - private static GT_RenderedTexture x3 = new GT_RenderedTexture(TexturesGtBlock.OVERLAY_WOODEN_SHELF_CANS_FRONT); - - public ITexture[] getFrontNormal() { - return new ITexture[] { x1 }; - } - - public ITexture[] getFrontActive() { - return new ITexture[] { x2 }; - } - - public ITexture[] getFrontAlternative() { - return new ITexture[] { x3 }; - } - - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks) }; - } - - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.Casing_Machine_Acacia_Log) }; - } - - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks) }; - } - - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks) }; - } - - public ITexture[] getFrontActive(final byte aColor) { - return this.getFrontNormal(); - } - - public ITexture[] getBackActive(final byte aColor) { - return this.getBack(aColor); - } - - public ITexture[] getBottomActive(final byte aColor) { - return this.getBottom(aColor); - } - - public ITexture[] getTopActive(final byte aColor) { - return this.getTop(aColor); - } - - public ITexture[] getSidesActive(final byte aColor) { - return this.getSides(aColor); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - public ITexture[] getFront(byte aColour) { - if (aColour == 1) { - return getFrontActive(); - } else if (aColour == 2) { - return getFrontAlternative(); - } - return getFrontNormal(); - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (KeyboardUtils.isCtrlKeyDown()) { - if (!aPlayer.getDisplayName().equalsIgnoreCase(this.getBaseMetaTileEntity().getOwnerName())) { - PlayerUtils.messagePlayer(aPlayer, "Container is not yours to lock."); - } else { - this.mLocked = Utils.invertBoolean(this.mLocked); - if (this.mLocked) { - PlayerUtils.messagePlayer(aPlayer, "Container is now locked."); - } else { - PlayerUtils.messagePlayer(aPlayer, "Container is now unlocked."); - } - } - } else { - super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); - } - } - - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.onPreTick(aBaseMetaTileEntity, aTick); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Compartment.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Compartment.java deleted file mode 100644 index fec96cbdd4..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Compartment.java +++ /dev/null @@ -1,40 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GT4Entity_Shelf_Compartment extends GT4Entity_Shelf { - - public GT4Entity_Shelf_Compartment(final int aID, final String aName, final String aNameRegional, - final String aDescription) { - super(aID, aName, aNameRegional, aDescription); - } - - public GT4Entity_Shelf_Compartment(String mName, String[] mDescriptionArray, ITexture[][][] mTextures) { - super(mName, mDescriptionArray, mTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_Shelf_Compartment(this.mName, this.mDescriptionArray, this.mTextures); - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (side == getBaseMetaTileEntity().getFrontFacing()) { - this.mType = ((byte) ((this.mType + 1) % 16)); - PlayerUtils.messagePlayer(aPlayer, "Set type to " + this.mType + "."); - } - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { TexturesGtBlock.OVERLAYS_COMPARTMENT_FRONT[this.mType < 16 ? this.mType : 0] }; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Desk.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Desk.java deleted file mode 100644 index e486292995..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Desk.java +++ /dev/null @@ -1,49 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.objects.GT_RenderedTexture; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GT4Entity_Shelf_Desk extends GT4Entity_Shelf { - - public GT4Entity_Shelf_Desk(final int aID, final String aName, final String aNameRegional, - final String aDescription) { - super(aID, aName, aNameRegional, aDescription); - } - - public GT4Entity_Shelf_Desk(String mName, String[] mDescriptionArray, ITexture[][][] mTextures) { - super(mName, mDescriptionArray, mTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_Shelf_Desk(this.mName, this.mDescriptionArray, this.mTextures); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { TexturesGtBlock.OVERLAYS_CABINET_FRONT[this.mType < 16 ? this.mType : 0] }; - } - - @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks) }; - } - - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks) }; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks) }; - } - - @Override - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { new GT_RenderedTexture(TexturesGtBlock.VanillaIcon_OakPlanks) }; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_FileCabinet.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_FileCabinet.java deleted file mode 100644 index 60fc4d511e..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_FileCabinet.java +++ /dev/null @@ -1,60 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; - -public class GT4Entity_Shelf_FileCabinet extends GT4Entity_Shelf { - - public GT4Entity_Shelf_FileCabinet(final int aID, final String aName, final String aNameRegional, - final String aDescription) { - super(aID, aName, aNameRegional, aDescription); - } - - public GT4Entity_Shelf_FileCabinet(String mName, String[] mDescriptionArray, ITexture[][][] mTextures) { - super(mName, mDescriptionArray, mTextures); - } - - @Override - public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (side == getBaseMetaTileEntity().getFrontFacing()) { - this.mType = ((byte) ((this.mType + 1) % 16)); - PlayerUtils.messagePlayer(aPlayer, "Set type to " + this.mType + "."); - } - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_Shelf_FileCabinet(this.mName, this.mDescriptionArray, this.mTextures); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { TexturesGtBlock.OVERLAYS_CABINET_FRONT[this.mType < 16 ? this.mType : 0] }; - } - - @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { texSide }; - } - - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { texBottom }; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { texTop }; - } - - @Override - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { texSide }; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Iron.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Iron.java deleted file mode 100644 index e870113951..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Iron.java +++ /dev/null @@ -1,47 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; - -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; - -public class GT4Entity_Shelf_Iron extends GT4Entity_Shelf { - - public GT4Entity_Shelf_Iron(final int aID, final String aName, final String aNameRegional, - final String aDescription) { - super(aID, aName, aNameRegional, aDescription); - } - - public GT4Entity_Shelf_Iron(String mName, String[] mDescriptionArray, ITexture[][][] mTextures) { - super(mName, mDescriptionArray, mTextures); - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_Shelf_Iron(this.mName, this.mDescriptionArray, this.mTextures); - } - - @Override - public ITexture[] getFront(final byte aColor) { - return new ITexture[] { texSideCabinet }; - } - - @Override - public ITexture[] getBack(final byte aColor) { - return new ITexture[] { texSide }; - } - - @Override - public ITexture[] getBottom(final byte aColor) { - return new ITexture[] { texBottom }; - } - - @Override - public ITexture[] getTop(final byte aColor) { - return new ITexture[] { texTop }; - } - - @Override - public ITexture[] getSides(final byte aColor) { - return new ITexture[] { texSide }; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Large.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Large.java deleted file mode 100644 index c2fd2674d8..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/shelving/GT4Entity_Shelf_Large.java +++ /dev/null @@ -1,276 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.tileentities.storage.shelving; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTBase; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.common.util.ForgeDirection; - -import com.gtnewhorizons.modularui.api.screen.ModularWindow; -import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.common.widget.DrawableWidget; -import com.gtnewhorizons.modularui.common.widget.SlotWidget; -import com.gtnewhorizons.modularui.common.widget.TextWidget; - -import gregtech.api.gui.modularui.GT_UIInfos; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.MetaTileEntity; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.minecraft.PlayerUtils; -import gtPlusPlus.core.util.sys.KeyboardUtils; - -public class GT4Entity_Shelf_Large extends GT4Entity_Shelf { - - private final int mSize; - public int mItemCount; - public ItemStack mItemStack; - - public GT4Entity_Shelf_Large(final int aID, final String aName, final String aNameRegional, - final String aDescription, final int aSize) { - super(aID, aName, aNameRegional, aDescription); - this.mSize = aSize; - this.mItemCount = 0; - this.mItemStack = null; - } - - public GT4Entity_Shelf_Large(String mName, String[] mDescriptionArray, final int aSize, ITexture[][][] mTextures) { - super(mName, mDescriptionArray, mTextures); - this.mSize = aSize; - this.mItemCount = 0; - this.mItemStack = null; - } - - @Override - public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT4Entity_Shelf_Large(this.mName, this.mDescriptionArray, mSize, this.mTextures); - } - - @Override - public boolean isGivingInformation() { - return true; - } - - @Override - public boolean isDigitalChest() { - return true; - } - - @Override - public boolean isValidSlot(final int aIndex) { - return true; - } - - @Override - public boolean onRightclick(final IGregTechTileEntity aBaseMetaTileEntity, final EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) { - return true; - } - if (KeyboardUtils.isCtrlKeyDown()) { - String itemName = (this.mItemStack != null ? this.mItemStack.getDisplayName() : "Nothing."); - String itemAmount = (this.mItemCount > 0 ? "" + this.mItemCount : "bad"); - String itemMessage = "This container currently holds " - + (itemAmount.equalsIgnoreCase("bad") ? "nothing." : itemName + " x" + itemAmount + "."); - PlayerUtils.messagePlayer(aPlayer, itemMessage); - } else { - GT_UIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); - } - return true; - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setInteger("mItemCount", this.mItemCount); - if (this.mItemStack != null) { - aNBT.setTag("mItemStack", (NBTBase) this.mItemStack.writeToNBT(new NBTTagCompound())); - } - super.saveNBTData(aNBT); - } - - @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")); - } - super.loadNBTData(aNBT); - } - - @Override - public void onOpenGUI() { - super.onOpenGUI(); - } - - @Override - public void onPostTick(final IGregTechTileEntity aBaseMetaTileEntity, final long aTimer) { - if (this.getBaseMetaTileEntity().isServerSide() && this.getBaseMetaTileEntity().isAllowedToWork()) { - try { - if (this.mInventory[0] != null) { - this.mType = (byte) this.mIndex; - } else { - this.mType = 0; - } - - if (this.getItemCount() <= 0) { - this.mItemStack = null; - this.mItemCount = 0; - } - if (this.mItemStack == null && this.mInventory[0] != null) { - this.mItemStack = this.mInventory[0].copy(); - } - if (this.mInventory[0] != null && this.mItemCount < this.getMaxItemCount() - && GT_Utility.areStacksEqual(this.mInventory[0], this.mItemStack)) { - this.mItemCount += this.mInventory[0].stackSize; - if (this.mItemCount > this.getMaxItemCount()) { - this.mInventory[0].stackSize = this.mItemCount - this.getMaxItemCount(); - this.mItemCount = this.getMaxItemCount(); - } else { - this.mInventory[0] = null; - } - } - if (this.mInventory[1] == null && this.mItemStack != null) { - this.mInventory[1] = this.mItemStack.copy(); - this.mInventory[1].stackSize = Math.min(this.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) { - final int tmp = Math.min( - this.mItemCount, - this.mInventory[1].getMaxStackSize() - this.mInventory[1].stackSize); - final ItemStack itemStack = this.mInventory[1]; - itemStack.stackSize += tmp; - this.mItemCount -= tmp; - } - if (this.mItemStack != null) { - this.mInventory[2] = this.mItemStack.copy(); - this.mInventory[2].stackSize = Math.min(this.mItemStack.getMaxStackSize(), this.mItemCount); - } else { - this.mInventory[2] = null; - } - } catch (Throwable t) { - if (t instanceof ArrayIndexOutOfBoundsException) {} - } - } - } - - private int getItemCount() { - return this.mItemCount; - } - - @Override - public void setItemCount(final int aCount) { - this.mItemCount = aCount; - } - - @Override - public int getProgresstime() { - try { - return this.mItemCount + ((this.mInventory[0] == null) ? 0 : this.mInventory[0].stackSize) - + ((this.mInventory[1] == null) ? 0 : this.mInventory[1].stackSize); - } catch (Throwable t) { - return 0; - } - } - - @Override - public int maxProgresstime() { - return this.getMaxItemCount(); - } - - @Override - public int getMaxItemCount() { - return this.mSize; - } - - @Override - public boolean allowPullStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return aIndex == 1; - } - - @Override - public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, - final ForgeDirection side, final ItemStack aStack) { - return aIndex == 0 && ((this.mInventory[0] == null && this.mItemStack == null) - || GT_Utility.areStacksEqual(this.mInventory[0], aStack) - || (this.mItemStack != null && GT_Utility.areStacksEqual(this.mItemStack, aStack))); - } - - @Override - public String[] getInfoData() { - if (this.mItemStack == null) { - return new String[] { this.getLocalName(), "No Items Stored", - "Free Space: " + Integer.toString(this.getMaxItemCount()) }; - } - return new String[] { this.getLocalName(), - "Storing: " + this.mItemStack.getDisplayName() + " x" + Integer.toString(this.mItemCount), - "Space Remaining: " + Integer.toString(this.getMaxItemCount() - this.getItemCount()) - + "/" - + Integer.toString(this.getMaxItemCount()) }; - } - - @Override - public String[] getDescription() { - String[] mSuper = super.getDescription(); - String[] desc = new String[mSuper.length + 1]; - for (int i = 0; i > mSuper.length; i++) { - desc[i] = mSuper[i]; - } - desc[desc.length - 1] = "Control + Rmb block to check contents"; - return desc; - } - - @Override - public boolean isItemValidForSlot(int aIndex, ItemStack aStack) { - Logger.INFO("1:" + aIndex); - if (aIndex == 2) { - if (ItemStack.areItemStacksEqual(aStack, mItemStack)) { - return true; - } else { - if (mItemStack == null) { - return true; - } - return false; - } - } - return super.isItemValidForSlot(aIndex, aStack); - } - - @Override - public boolean canInsertItem(int aIndex, ItemStack aStack, int ordinalSide) { - Logger.INFO("2:" + aIndex); - if (aIndex == 0) { - if (ItemStack.areItemStacksEqual(aStack, mItemStack)) { - return true; - } else { - if (mItemStack == null) { - return true; - } - return false; - } - } - return super.canInsertItem(aIndex, aStack, ordinalSide); - } - - @Override - public boolean useModularUI() { - return true; - } - - @Override - public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - builder.widget( - new DrawableWidget().setDrawable(GT_UITextures.PICTURE_SCREEN_BLACK).setPos(7, 16).setSize(71, 45)) - .widget( - new SlotWidget(inventoryHandler, 0) - .setBackground(getGUITextureSet().getItemSlot(), GT_UITextures.OVERLAY_SLOT_IN) - .setPos(79, 16)) - .widget(new TextWidget("Item Amount").setDefaultColor(COLOR_TEXT_WHITE.get()).setPos(10, 20)).widget( - TextWidget.dynamicString(() -> GT_Utility.parseNumberToString(mItemCount)) - .setDefaultColor(COLOR_TEXT_WHITE.get()).setPos(10, 30)); - } -} |