mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
Added the ability to put items back into the XP solidifier + made the storage crate not be a full block
This commit is contained in:
parent
1853ddf31b
commit
1ac651ac6f
4 changed files with 35 additions and 13 deletions
|
@ -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
|
@Override
|
||||||
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack stack, EnumFacing par6, float par7, float par8, float par9){
|
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){
|
if(!world.isRemote){
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.inventory;
|
package de.ellpeck.actuallyadditions.mod.inventory;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
|
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.TileEntityBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -27,7 +28,8 @@ public class ContainerXPSolidifier extends Container{
|
||||||
public ContainerXPSolidifier(InventoryPlayer inventory, TileEntityBase tile){
|
public ContainerXPSolidifier(InventoryPlayer inventory, TileEntityBase tile){
|
||||||
this.solidifier = (TileEntityXPSolidifier)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 i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 9; j++){
|
for(int j = 0; j < 9; j++){
|
||||||
|
@ -41,7 +43,7 @@ public class ContainerXPSolidifier extends Container{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
||||||
int inventoryStart = 1;
|
int inventoryStart = 2;
|
||||||
int inventoryEnd = inventoryStart+26;
|
int inventoryEnd = inventoryStart+26;
|
||||||
int hotbarStart = inventoryEnd+1;
|
int hotbarStart = inventoryEnd+1;
|
||||||
int hotbarEnd = hotbarStart+8;
|
int hotbarEnd = hotbarStart+8;
|
||||||
|
@ -54,7 +56,12 @@ public class ContainerXPSolidifier extends Container{
|
||||||
|
|
||||||
//Other Slots in Inventory excluded
|
//Other Slots in Inventory excluded
|
||||||
if(slot >= inventoryStart){
|
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)){
|
if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import net.minecraft.util.EnumFacing;
|
||||||
|
|
||||||
public class TileEntityXPSolidifier extends TileEntityInventoryBase implements IButtonReactor{
|
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{
|
static{
|
||||||
for(int i = 0; i < XP_MAP.length; i++){
|
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};
|
private final int[] buttonAmounts = new int[]{1, 5, 10, 20, 30, 40, 50, 64, -999};
|
||||||
public short amount;
|
public int amount;
|
||||||
private short lastAmount;
|
private int lastAmount;
|
||||||
|
|
||||||
public TileEntityXPSolidifier(){
|
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){
|
public static int getExperienceForLevel(int level){
|
||||||
if(level >= 0 && level < XP_MAP.length){
|
if(level >= 0 && level < XP_MAP.length){
|
||||||
return XP_MAP[level];
|
return XP_MAP[level];
|
||||||
|
@ -85,10 +89,6 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
|
||||||
return (int)(getExperienceForLevel(player.experienceLevel)+(player.experience*player.xpBarCap()));
|
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){
|
public static void addPlayerXP(EntityPlayer player, int amount){
|
||||||
int experience = Math.max(0, getPlayerXP(player)+amount);
|
int experience = Math.max(0, getPlayerXP(player)+amount);
|
||||||
player.experienceTotal = experience;
|
player.experienceTotal = experience;
|
||||||
|
@ -100,13 +100,13 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
|
||||||
@Override
|
@Override
|
||||||
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
|
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
|
||||||
super.writeSyncableNBT(compound, type);
|
super.writeSyncableNBT(compound, type);
|
||||||
compound.setShort("Amount", this.amount);
|
compound.setInteger("Amount", this.amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
|
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
|
||||||
super.readSyncableNBT(compound, type);
|
super.readSyncableNBT(compound, type);
|
||||||
this.amount = compound.getShort("Amount");
|
this.amount = compound.getInteger("Amount");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -127,6 +127,11 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()){
|
if(this.lastAmount != this.amount && this.sendUpdateWithInterval()){
|
||||||
this.lastAmount = this.amount;
|
this.lastAmount = this.amount;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.3 KiB |
Loading…
Reference in a new issue