Fixes empty slots in ConfigEditorGui item select

This commit is contained in:
Christian Koop 2022-03-18 14:32:55 +01:00
parent a0050aadd6
commit a42d03aec3
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
2 changed files with 12 additions and 5 deletions

View File

@ -1277,7 +1277,7 @@ public enum CompatibleMaterial {
YELLOW_WOOL("WOOL", (byte) 4), YELLOW_WOOL("WOOL", (byte) 4),
ZOMBIE_HEAD("SKULL_ITEM", (byte) 2), ZOMBIE_HEAD("SKULL_ITEM", (byte) 2),
ZOMBIE_HORSE_SPAWN_EGG("MONSTER_EGG", (byte) 29), ZOMBIE_HORSE_SPAWN_EGG("MONSTER_EGG", (byte) 29),
ZOMBIE_PIGMAN_SPAWN_EGG("MONSTER_EGG", (byte) 57), ZOMBIE_PIGMAN_SPAWN_EGG("MONSTER_EGG", (byte) 57), // FIXME: The name changed in newer versions (nether update maybe?)
ZOMBIE_SPAWN_EGG("MONSTER_EGG", (byte) 54), ZOMBIE_SPAWN_EGG("MONSTER_EGG", (byte) 54),
ZOMBIE_VILLAGER_SPAWN_EGG("MONSTER_EGG", (byte) 27), ZOMBIE_VILLAGER_SPAWN_EGG("MONSTER_EGG", (byte) 27),
ZOMBIE_WALL_HEAD("SKULL", (byte) 2), ZOMBIE_WALL_HEAD("SKULL", (byte) 2),

View File

@ -131,10 +131,17 @@ public class ConfigEditorGui extends SimplePagedGui {
paged.setItem(4, configItem(CompatibleMaterial.FILLED_MAP, settingKey, node, settingKey, "Choose an item to change this value to")); paged.setItem(4, configItem(CompatibleMaterial.FILLED_MAP, settingKey, node, settingKey, "Choose an item to change this value to"));
int i = 9; int i = 9;
for (CompatibleMaterial mat : CompatibleMaterial.getAllValidItemMaterials()) { for (CompatibleMaterial mat : CompatibleMaterial.getAllValidItemMaterials()) {
paged.setButton(i++, GuiUtils.createButtonItem(mat, mat.name()), ClickType.LEFT, (matEvent) -> { try {
ItemStack buttonItem = GuiUtils.createButtonItem(mat, mat.name());
if (!buttonItem.getType().isItem()) continue;
paged.setButton(i++, buttonItem, ClickType.LEFT, (matEvent) -> {
setMaterial(event.slot, settingKey, matEvent.clickedItem); setMaterial(event.slot, settingKey, matEvent.clickedItem);
matEvent.player.closeInventory(); matEvent.player.closeInventory();
}); });
} catch (IllegalArgumentException ex) {
// FIXME: CompatibleMaterial is not working properly for 'ZOMBIE_PIGMAN_SPAWN_EGG'
}
} }
event.manager.showGUI(event.player, paged); event.manager.showGUI(event.player, paged);
}); });