Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
ItemStack currentItem = player.getCurrentEquippedItem();
TileEntity tile = world.getTileEntity(x, y, z);
if (currentItem != null && currentItem.getItem() == Items.nether_star) {
//
}
else if (tile != null && tile instanceof IInventory) {
player.openGui(MyMod.instance, idGUI, player.worldObj, x, y, z);
}
return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
}
int cont = 0;
Item item = Items.stick;//Наш предмет
for (ItemStack slot : player.inventory.mainInventory) {
if (slot != null && slot.getItem() == item) cont += slot.stackSize;//Считаем количество нашего предмета в слотах(-е).
}
if (cont >= 5) {//Если равно или больше 5, то ..
for (int i = 0; i < 5; ++i) {//... пять раз ...
player.inventory.consumeInventoryItem(item);// ... удаляем предмет
}
}