Add more fallback material

This commit is contained in:
fullwall 2021-02-10 22:02:14 +08:00
parent 5c62a3f92f
commit 352ec56f5e
4 changed files with 12 additions and 3 deletions

View File

@ -33,7 +33,7 @@ import net.citizensnpcs.api.util.SpigotUtil;
slots = { @MenuSlot(
filter = InventoryAction.UNKNOWN,
pat = 'x',
material = Material.GLASS_PANE,
compatMaterial = { "GLASS_PANE", "FIRE" },
title = "<4>Unused") },
value = "xxx")
public class EndermanEquipperGUI extends InventoryMenuPage {

View File

@ -30,7 +30,7 @@ import net.citizensnpcs.trait.Saddle;
slots = { @MenuSlot(
filter = InventoryAction.UNKNOWN,
pat = 'x',
material = Material.GLASS_PANE,
compatMaterial = { "GLASS_PANE", "FIRE" },
title = "<4>Unused") },
value = "xxx")
public class PigEquipperGUI extends InventoryMenuPage {

View File

@ -88,7 +88,8 @@ public class DropsTrait extends Trait {
ctx.getInventory().setItem(islot, drop.drop.clone());
}
InventoryMenuSlot slot = ctx.getSlot(i * 9 + j);
slot.setItemStack(new ItemStack(Material.GLASS_PANE), "Drop chance <e>" + chance + "%");
slot.setItemStack(new ItemStack(Util.getFallbackMaterial("GLASS_PANE", "FIRE")),
"Drop chance <e>" + chance + "%");
slot.addClickHandler(new PercentageSlotHandler((pct) -> {
if (chances.containsKey(islot)) {
chances.put(islot, pct / 100.0);

View File

@ -107,6 +107,14 @@ public class Util {
return entity instanceof LivingEntity ? ((LivingEntity) entity).getEyeLocation() : entity.getLocation();
}
public static Material getFallbackMaterial(String first, String second) {
try {
return Material.valueOf(first);
} catch (IllegalArgumentException e) {
return Material.valueOf(second);
}
}
public static Random getFastRandom() {
return new XORShiftRNG();
}