From 1ac651ac6f8b0bba7db30db57af9b8e4c1482b5e Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 12 Aug 2016 18:44:09 +0200 Subject: [PATCH] Added the ability to put items back into the XP solidifier + made the storage crate not be a full block --- .../mod/blocks/BlockGiantChest.java | 10 +++++++ .../mod/inventory/ContainerXPSolidifier.java | 13 ++++++--- .../mod/tile/TileEntityXPSolidifier.java | 25 +++++++++++------- .../textures/gui/guiXPSolidifier.png | Bin 1763 -> 1283 bytes 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java index c7633dc74..1f3f7dac6 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/blocks/BlockGiantChest.java @@ -67,6 +67,16 @@ public class BlockGiantChest extends BlockContainerBase{ } } + @Override + public boolean isFullCube(IBlockState state){ + return false; + } + + @Override + public boolean isOpaqueCube(IBlockState state){ + return false; + } + @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){ if(!world.isRemote){ diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerXPSolidifier.java index a224ac39e..7e3f04bf7 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/inventory/ContainerXPSolidifier.java @@ -11,6 +11,7 @@ package de.ellpeck.actuallyadditions.mod.inventory; import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput; +import de.ellpeck.actuallyadditions.mod.items.ItemSolidifiedExperience; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier; import net.minecraft.entity.player.EntityPlayer; @@ -27,7 +28,8 @@ public class ContainerXPSolidifier extends Container{ public ContainerXPSolidifier(InventoryPlayer inventory, TileEntityBase tile){ this.solidifier = (TileEntityXPSolidifier)tile; - this.addSlotToContainer(new SlotOutput(this.solidifier, 0, 80, 8)); + this.addSlotToContainer(new SlotOutput(this.solidifier, 0, 95, 8)); + this.addSlotToContainer(new Slot(this.solidifier, 1, 65, 8)); for(int i = 0; i < 3; i++){ for(int j = 0; j < 9; j++){ @@ -41,7 +43,7 @@ public class ContainerXPSolidifier extends Container{ @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot){ - int inventoryStart = 1; + int inventoryStart = 2; int inventoryEnd = inventoryStart+26; int hotbarStart = inventoryEnd+1; int hotbarEnd = hotbarStart+8; @@ -54,7 +56,12 @@ public class ContainerXPSolidifier extends Container{ //Other Slots in Inventory excluded if(slot >= inventoryStart){ - if(slot >= inventoryStart && slot <= inventoryEnd){ + if(newStack.getItem() instanceof ItemSolidifiedExperience){ + if(!this.mergeItemStack(newStack, 1, 2, false)){ + return null; + } + } + else if(slot >= inventoryStart && slot <= inventoryEnd){ if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){ return null; } diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java index cf5190a36..26119c278 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/tile/TileEntityXPSolidifier.java @@ -21,7 +21,7 @@ import net.minecraft.util.EnumFacing; public class TileEntityXPSolidifier extends TileEntityInventoryBase implements IButtonReactor{ - private static final Integer[] XP_MAP = new Integer[256]; + private static final int[] XP_MAP = new int[256]; static{ for(int i = 0; i < XP_MAP.length; i++){ @@ -30,13 +30,17 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I } private final int[] buttonAmounts = new int[]{1, 5, 10, 20, 30, 40, 50, 64, -999}; - public short amount; - private short lastAmount; + public int amount; + private int lastAmount; public TileEntityXPSolidifier(){ - super(1, "xpSolidifier"); + super(2, "xpSolidifier"); } + /* + * The below methods were excerpted from EnderIO by SleepyTrousers with permission, thanks! + */ + public static int getExperienceForLevel(int level){ if(level >= 0 && level < XP_MAP.length){ return XP_MAP[level]; @@ -85,10 +89,6 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I return (int)(getExperienceForLevel(player.experienceLevel)+(player.experience*player.xpBarCap())); } - /* - * The below methods were excerpted from EnderIO by SleepyTrousers with permission, thanks! - */ - public static void addPlayerXP(EntityPlayer player, int amount){ int experience = Math.max(0, getPlayerXP(player)+amount); player.experienceTotal = experience; @@ -100,13 +100,13 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I @Override public void writeSyncableNBT(NBTTagCompound compound, NBTType type){ super.writeSyncableNBT(compound, type); - compound.setShort("Amount", this.amount); + compound.setInteger("Amount", this.amount); } @Override public void readSyncableNBT(NBTTagCompound compound, NBTType type){ super.readSyncableNBT(compound, type); - this.amount = compound.getShort("Amount"); + this.amount = compound.getInteger("Amount"); } @Override @@ -126,6 +126,11 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I this.amount -= toAdd; } } + + if(this.slots[1] != null && this.slots[1].getItem() instanceof ItemSolidifiedExperience){ + this.amount+=this.slots[1].stackSize; + this.slots[1] = null; + } if(this.lastAmount != this.amount && this.sendUpdateWithInterval()){ this.lastAmount = this.amount; diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiXPSolidifier.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiXPSolidifier.png index f31beeab410360642b8ff1c49afa04a6f939f951..505fc681a6c7f154857ecf43cbedec015d07d37c 100644 GIT binary patch literal 1283 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6&2?&#~tz_78O`%fY(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