Added display tool tip to bags

Closes #407
This commit is contained in:
Ellpeck 2016-11-25 22:05:19 +01:00
parent eeac084481
commit bc220573e8

View file

@ -53,7 +53,19 @@ public class ItemBag extends ItemBase{
@Override @Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced){ public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced){
tooltip.add(TextFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID+".previously"+(this.isVoid ? "VoidBag" : "Bag"))); NonNullList<ItemStack> slots = StackUtil.createSlots(ContainerBag.getSlotAmount(this.isVoid));
ItemDrill.loadSlotsFromNBT(slots, stack);
int slotsTotal = slots.size();
int slotsFilled = 0;
for(ItemStack slotStack : slots){
if(StackUtil.isValid(slotStack)){
slotsFilled++;
}
}
tooltip.add(TextFormatting.ITALIC.toString()+slotsFilled+"/"+slotsTotal+" filled slots");
} }
@SubscribeEvent @SubscribeEvent
@ -124,14 +136,9 @@ public class ItemBag extends ItemBase{
} }
} }
if(!StackUtil.isValid(stack)){
item.setDead();
}
else{
item.setEntityItemStack(stack); item.setEntityItemStack(stack);
} }
} }
}
@Override @Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){ public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){