- 129
- 0
При перезарядке патроны пополняют всё оружие в инвентаре ,как сделать так чтоб патроны пополняли только то оружие которое у тебя в руке?
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
{
EntityPlayer player = (EntityPlayer)par3Entity;
ItemStack is = player.inventory.getCurrentItem();
if (MyKEY.keyPressed ){
if (par1ItemStack.stackTagCompound == null) {
par1ItemStack.stackTagCompound = new NBTTagCompound();
par1ItemStack.stackTagCompound.setInteger("pat", 0);
}
if (is != null && is.getItem().itemID == BurntOut.Gun.itemID){
if (player.inventory.hasItem(BurntOut.Mag3.itemID)){
if(par1ItemStack.getTagCompound().getInteger("pat") < Batt){
par1ItemStack.getTagCompound().setInteger("pat", Batt);
player.inventory.consumeInventoryItem(BurntOut.Mag3.itemID);
}
}
}
}
}
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
{
EntityPlayer player = (EntityPlayer)par3Entity;
ItemStack is = player.inventory.getCurrentItem();
if (MyKEY.keyPressed ){
if (par1ItemStack.stackTagCompound == null) {
par1ItemStack.stackTagCompound = new NBTTagCompound();
par1ItemStack.stackTagCompound.setInteger("pat", 0);
}
if (is != null && is.getItem().itemID == BurntOut.Gun.itemID){
if (player.inventory.hasItem(BurntOut.Mag3.itemID)){
if(par1ItemStack.getTagCompound().getInteger("pat") < Batt){
par1ItemStack.getTagCompound().setInteger("pat", Batt);
player.inventory.consumeInventoryItem(BurntOut.Mag3.itemID);
}
}
}
}
}