This commit is contained in:
Shadows_of_Fire 2017-07-29 20:53:30 -04:00
parent 7a171c939a
commit 5dbd7aa414

View file

@ -21,6 +21,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.MathHelper;
import java.util.List; import java.util.List;
@ -156,11 +157,15 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
} }
} }
if(StackUtil.isValid(this.slots.getStackInSlot(1)) && this.slots.getStackInSlot(1).getItem() instanceof ItemSolidifiedExperience){ ItemStack stack = this.slots.getStackInSlot(1);
this.amount += StackUtil.getStackSize(this.slots.getStackInSlot(1)); if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemSolidifiedExperience){
this.slots.setStackInSlot(1, StackUtil.getNull()); int remainingSpace = MathHelper.clamp(Integer.MAX_VALUE - amount, 0, stack.getCount());
if(stack.getCount() >= remainingSpace && remainingSpace != 0) {
this.amount += remainingSpace;
stack.shrink(remainingSpace);
this.markDirty(); this.markDirty();
} }
}
if(this.lastAmount != this.amount && this.sendUpdateWithInterval()){ if(this.lastAmount != this.amount && this.sendUpdateWithInterval()){
this.lastAmount = this.amount; this.lastAmount = this.amount;
@ -170,7 +175,7 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return false; return i == 1 && stack.getItem() == InitItems.itemSolidifiedExperience;
} }
@Override @Override
@ -178,6 +183,12 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
return true; return true;
} }
@Override
public void markDirty() {
if(amount < 0) amount = Integer.MAX_VALUE; //don't u go negative on me weird number
super.markDirty();
}
@Override @Override
public void onButtonPressed(int buttonID, EntityPlayer player){ public void onButtonPressed(int buttonID, EntityPlayer player){
if(buttonID < this.buttonAmounts.length){ if(buttonID < this.buttonAmounts.length){