Привет, я хочу спросить, вы не знаете как сделать чтобы когда ты выкидывал два предмета на один блок, то эти два предмета удалялись и появлялся другой предмет.
Например:
Игрок кидает на землю кожаные поножи и слиток железа. Они удаляются и на их месте появляются железные поножи.
Если сможете помочь буду очень благодарен. :)
Вот пример моего кода:
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) {
Item droppedItem = event.getItemDrop();
ItemStack itemStack = droppedItem.getItemStack();
// Check if the dropped item is iron leggings with CustomModelData 1001
if (itemStack.getType() == Material.IRON_LEGGINGS && itemStack.hasItemMeta()) {
ItemMeta itemMeta = itemStack.getItemMeta();
// Check if the dropped item has CustomModelData 1001
if (itemMeta.getCustomModelData() == 1001) {
Block block = droppedItem.getLocation().subtract(0, -0.0625, 0).getBlock();
// Check if the block beneath the dropped item is a grown potato crop
if (block.getType() == Material.POTATOES && block.getBlockData() instanceof Ageable) {
Ageable ageable = (Ageable) block.getBlockData();
// Check if the potato crop is fully grown
if (ageable.getAge() == ageable.getMaximumAge()) {
// Create a new ItemStack with iron leggings and CustomModelData 1002
ItemStack newLeggings = new ItemStack(Material.IRON_LEGGINGS);
ItemMeta newLeggingsMeta = newLeggings.getItemMeta();
newLeggingsMeta.setCustomModelData(1002);
newLeggings.setItemMeta(newLeggingsMeta);
// Replace the dropped item with the new iron leggings
droppedItem.setItemStack(newLeggings);
}
}
}
}
}