player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Предмет));
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int var6, float var7, float var8, float var9){
if(!world.isRemote){
ItemStack currentStack = player.getCurrentEquippedItem();
if(currentStack != null && currentStack.getItem().equals(Game.OilBlock)){
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Game.OilBlockHot));
return true;
}
}
return false;
}
Заменить на другой предмет(блок)То-есть изменить? Заменить на другой или что ты хочешь с ним сделать?
А какой код для замены у тебя?
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int var6, float var7, float var8, float var9){
if(!world.isRemote){
ItemStack currentStack = player.getCurrentEquippedItem();
if(currentStack != null && currentStack.getItem().equals(Game.OilBlock)){
player.setItemInUse(player.getCurrentEquippedItem(), Game.OilBlockHot);
return true;
}
}
return false;
}
я тут немного натупил, написал другой код но он только для итемов а мне нужно блоки сменить, что делать :?А какой код для замены у тебя?
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int var6, float var7, float var8, float var9){
if(!world.isRemote){
ItemStack currentStack = player.getCurrentEquippedItem();
if(currentStack != null && currentStack.getItem().equals(Game.OilBL)){
player.inventory.consumeInventoryItem(Game.OilBL);
player.inventory.setItemStack(Game.OilBlockHot);
return true;
}
}
return false;
}
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Предмет));
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int var6, float var7, float var8, float var9){
if(!world.isRemote){
ItemStack currentStack = player.getCurrentEquippedItem();
if(currentStack != null && currentStack.getItem().equals(Game.OilBlock)){
player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Game.OilBlockHot));
return true;
}
}
return false;
}
Хмм...Потому что этот метод не заменяет предмет.
Можно попробовать так:
Java:player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Предмет));
Java:public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int var6, float var7, float var8, float var9){ if(!world.isRemote){ ItemStack currentStack = player.getCurrentEquippedItem(); if(currentStack != null && currentStack.getItem().equals(Game.OilBlock)){ player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Game.OilBlockHot)); return true; } } return false; }
player.inventory.consumeInventoryItem(Game.OilBL);
player.inventory.setItemStack(new ItemStack(Game.OilBlockHot));
У меня пропадает итем но не появляется блок :/Можно попробовать так:
Java:player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Предмет));
Java:public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int var6, float var7, float var8, float var9){ if(!world.isRemote){ ItemStack currentStack = player.getCurrentEquippedItem(); if(currentStack != null && currentStack.getItem().equals(Game.OilBlock)){ player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Game.OilBlockHot)); return true; } } return false; }
спасибо, не знаю почему мои 2 строки не хотят пахать...Можно попробовать так:
Java:player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Предмет));
Java:public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int var6, float var7, float var8, float var9){ if(!world.isRemote){ ItemStack currentStack = player.getCurrentEquippedItem(); if(currentStack != null && currentStack.getItem().equals(Game.OilBlock)){ player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Game.OilBlockHot)); return true; } } return false; }