So, i have coded sth, but the output is just "1" (if i have the item), or "0" if i dont have one. But how can i do it, so it shows the actual amount of the item.
PS: Im just using minecraft, not Bukkit/Spigot or other addons.
ItemStack apple = new ItemStack(Item.getByNameOrId("minecraft:apple"));
int amount = 0;
@SubscribeEvent
public void addItemStackToInventory(TickEvent.ClientTickEvent e) {
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
if (p instanceof EntityPlayer) {
if (p.inventory.hasItemStack(apple)) {
for(int i = 0; i < 64; i++) {
amount = apple.stackSize;
}
} else {
amount = 0;
}
}
}
So, i have coded sth, but the output is just "1" (if i have the item), or "0" if i dont have one. But how can i do it, so it shows the actual amount of the item.
PS: Im just using minecraft, not Bukkit/Spigot or other addons.
ItemStack apple = new ItemStack(Item.getByNameOrId("minecraft:apple"));
int amount = 0;
@SubscribeEvent
public void addItemStackToInventory(TickEvent.ClientTickEvent e) {
EntityPlayer p = Minecraft.getMinecraft().thePlayer;
if (p instanceof EntityPlayer) {
if (p.inventory.hasItemStack(apple)) {
for(int i = 0; i < 64; i++) {
amount = apple.stackSize;
}
} else {
amount = 0;
}
}
}
You are setting the amount of apple to the stake size of the apple. You need to add them.