1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Java16 Sonar Changes - 6

This commit is contained in:
Sefiraat 2022-07-02 21:51:08 +01:00
parent 75375cef45
commit dbf55be230
20 changed files with 115 additions and 154 deletions

View File

@ -49,8 +49,8 @@ public class Juice extends SimpleSlimefunItem<ItemConsumptionHandler> {
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
if (meta instanceof PotionMeta) { if (meta instanceof PotionMeta potionMeta) {
effects = ((PotionMeta) meta).getCustomEffects(); effects = potionMeta.getCustomEffects();
} else { } else {
effects = new ArrayList<>(); effects = new ArrayList<>();
} }

View File

@ -107,8 +107,7 @@ public class InfusedHopper extends SimpleSlimefunItem<BlockTicker> {
} }
private boolean isValidItem(@Nonnull Location l, @Nonnull Entity entity) { private boolean isValidItem(@Nonnull Location l, @Nonnull Entity entity) {
if (entity instanceof Item && entity.isValid()) { if (entity instanceof Item item && entity.isValid()) {
Item item = (Item) entity;
// Check if the item cannot be picked up or has the "no pickup" metadata // Check if the item cannot be picked up or has the "no pickup" metadata
return item.getPickupDelay() <= 0 && !SlimefunUtils.hasNoPickupFlag(item) && item.getLocation().distanceSquared(l) > 0.25; return item.getPickupDelay() <= 0 && !SlimefunUtils.hasNoPickupFlag(item) && item.getLocation().distanceSquared(l) > 0.25;
} }

View File

@ -61,12 +61,12 @@ public class MagicalZombiePills extends SimpleSlimefunItem<EntityInteractHandler
Player p = e.getPlayer(); Player p = e.getPlayer();
if (entity instanceof ZombieVillager) { if (entity instanceof ZombieVillager zombieVillager) {
useItem(p, item); useItem(p, item);
healZombieVillager((ZombieVillager) entity, p); healZombieVillager(zombieVillager, p);
} else if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16) && entity instanceof PigZombie) { } else if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16) && entity instanceof PigZombie pigZombie) {
useItem(p, item); useItem(p, item);
healZombifiedPiglin((PigZombie) entity); healZombifiedPiglin(pigZombie);
} }
}; };
} }

View File

@ -183,9 +183,7 @@ public class EnchantmentRune extends SimpleSlimefunItem<ItemDropHandler> {
} }
private boolean findCompatibleItem(@Nonnull Entity n) { private boolean findCompatibleItem(@Nonnull Entity n) {
if (n instanceof Item) { if (n instanceof Item item) {
Item item = (Item) n;
return !isItem(item.getItemStack()); return !isItem(item.getItemStack());
} }

View File

@ -43,10 +43,8 @@ public class VillagerRune extends SimpleSlimefunItem<EntityInteractHandler> {
return; return;
} }
if (e.getRightClicked() instanceof Villager) { if (e.getRightClicked() instanceof Villager villager) {
Villager v = (Villager) e.getRightClicked(); if (villager.getProfession() == Profession.NONE || villager.getProfession() == Profession.NITWIT) {
if (v.getProfession() == Profession.NONE || v.getProfession() == Profession.NITWIT) {
return; return;
} }
@ -55,16 +53,16 @@ public class VillagerRune extends SimpleSlimefunItem<EntityInteractHandler> {
} }
// Reset Villager // Reset Villager
v.setVillagerExperience(0); villager.setVillagerExperience(0);
v.setVillagerLevel(1); villager.setVillagerLevel(1);
v.setProfession(Profession.NONE); villager.setProfession(Profession.NONE);
e.setCancelled(true); e.setCancelled(true);
double offset = ThreadLocalRandom.current().nextDouble(0.5); double offset = ThreadLocalRandom.current().nextDouble(0.5);
v.getWorld().playSound(v.getLocation(), Sound.ENTITY_VILLAGER_CELEBRATE, 1, 1.4F); villager.getWorld().playSound(villager.getLocation(), Sound.ENTITY_VILLAGER_CELEBRATE, 1, 1.4F);
v.getWorld().spawnParticle(Particle.CRIMSON_SPORE, v.getLocation(), 10, 0, offset / 2, 0, 0); villager.getWorld().spawnParticle(Particle.CRIMSON_SPORE, villager.getLocation(), 10, 0, offset / 2, 0, 0);
v.getWorld().spawnParticle(Particle.ENCHANTMENT_TABLE, v.getLocation(), 5, 0.04, 1, 0.04); villager.getWorld().spawnParticle(Particle.ENCHANTMENT_TABLE, villager.getLocation(), 5, 0.04, 1, 0.04);
} }
}; };
} }

View File

@ -162,12 +162,10 @@ public class Talisman extends SlimefunItem {
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public static boolean trigger(Event e, SlimefunItem item, boolean sendMessage) { public static boolean trigger(Event e, SlimefunItem item, boolean sendMessage) {
if (!(item instanceof Talisman)) { if (!(item instanceof Talisman talisman)) {
return false; return false;
} }
Talisman talisman = (Talisman) item;
if (ThreadLocalRandom.current().nextInt(100) > talisman.getChance()) { if (ThreadLocalRandom.current().nextInt(100) > talisman.getChance()) {
return false; return false;
} }
@ -239,8 +237,8 @@ public class Talisman extends SlimefunItem {
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
private static void cancelEvent(Event e, Talisman talisman) { private static void cancelEvent(Event e, Talisman talisman) {
if (e instanceof Cancellable && talisman.isEventCancelled()) { if (e instanceof Cancellable cancellable && talisman.isEventCancelled()) {
((Cancellable) e).setCancelled(true); cancellable.setCancelled(true);
} }
} }
@ -301,18 +299,18 @@ public class Talisman extends SlimefunItem {
@Nullable @Nullable
private static Player getPlayerByEventType(@Nonnull Event e) { private static Player getPlayerByEventType(@Nonnull Event e) {
if (e instanceof EntityDeathEvent) { if (e instanceof EntityDeathEvent entityDeathEvent) {
return ((EntityDeathEvent) e).getEntity().getKiller(); return entityDeathEvent.getEntity().getKiller();
} else if (e instanceof BlockBreakEvent) { } else if (e instanceof BlockBreakEvent blockBreakEvent) {
return ((BlockBreakEvent) e).getPlayer(); return blockBreakEvent.getPlayer();
} else if (e instanceof BlockDropItemEvent) { } else if (e instanceof BlockDropItemEvent blockDropItemEvent) {
return ((BlockDropItemEvent) e).getPlayer(); return blockDropItemEvent.getPlayer();
} else if (e instanceof PlayerEvent) { } else if (e instanceof PlayerEvent playerEvent) {
return ((PlayerEvent) e).getPlayer(); return playerEvent.getPlayer();
} else if (e instanceof EntityEvent) { } else if (e instanceof EntityEvent entityEvent) {
return (Player) ((EntityEvent) e).getEntity(); return (Player) entityEvent.getEntity();
} else if (e instanceof EnchantItemEvent) { } else if (e instanceof EnchantItemEvent enchantItemEvent) {
return ((EnchantItemEvent) e).getEnchanter(); return enchantItemEvent.getEnchanter();
} }
return null; return null;

View File

@ -70,10 +70,8 @@ public class StrangeNetherGoo extends SimpleSlimefunItem<ItemUseHandler> impleme
private EntityInteractHandler onRightClickEntity() { private EntityInteractHandler onRightClickEntity() {
return (e, item, hand) -> { return (e, item, hand) -> {
if (e.getRightClicked() instanceof Sheep) { if (e.getRightClicked() instanceof Sheep sheep) {
Sheep s = (Sheep) e.getRightClicked(); if (sheep.getCustomName() != null) {
if (s.getCustomName() != null) {
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
@ -83,9 +81,9 @@ public class StrangeNetherGoo extends SimpleSlimefunItem<ItemUseHandler> impleme
} }
// Give Sheep color, name and effect // Give Sheep color, name and effect
s.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 60, 2)); sheep.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 60, 2));
s.setColor(DyeColor.PURPLE); sheep.setColor(DyeColor.PURPLE);
s.setCustomName(ChatColor.DARK_PURPLE + "Tainted Sheep"); sheep.setCustomName(ChatColor.DARK_PURPLE + "Tainted Sheep");
e.setCancelled(true); e.setCancelled(true);
} }

View File

@ -41,9 +41,8 @@ abstract class AbstractSmeltery extends MultiBlockMachine {
Block dispBlock = b.getRelative(BlockFace.DOWN); Block dispBlock = b.getRelative(BlockFace.DOWN);
BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
if (state instanceof Dispenser) { if (state instanceof Dispenser dispenser) {
Dispenser disp = (Dispenser) state; Inventory inv = dispenser.getInventory();
Inventory inv = disp.getInventory();
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this); List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
for (int i = 0; i < inputs.size(); i++) { for (int i = 0; i < inputs.size(); i++) {

View File

@ -31,12 +31,11 @@ public class ArmorForge extends AbstractCraftingTable {
@Override @Override
public void onInteract(Player p, Block b) { public void onInteract(Player p, Block b) {
Block dispenser = b.getRelative(BlockFace.DOWN); Block possibleDispenser = b.getRelative(BlockFace.DOWN);
BlockState state = PaperLib.getBlockState(dispenser, false).getState(); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState();
if (state instanceof Dispenser) { if (state instanceof Dispenser dispenser) {
Dispenser disp = (Dispenser) state; Inventory inv = dispenser.getInventory();
Inventory inv = disp.getInventory();
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this); List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
for (int i = 0; i < inputs.size(); i++) { for (int i = 0; i < inputs.size(); i++) {
@ -44,7 +43,7 @@ public class ArmorForge extends AbstractCraftingTable {
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
if (SlimefunUtils.canPlayerUseItem(p, output, true)) { if (SlimefunUtils.canPlayerUseItem(p, output, true)) {
craft(p, output, inv, dispenser); craft(p, output, inv, possibleDispenser);
} }
return; return;

View File

@ -57,9 +57,8 @@ public class Compressor extends MultiBlockMachine {
Block dispBlock = b.getRelative(BlockFace.DOWN); Block dispBlock = b.getRelative(BlockFace.DOWN);
BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
if (state instanceof Dispenser) { if (state instanceof Dispenser dispenser) {
Dispenser disp = (Dispenser) state; Inventory inv = dispenser.getInventory();
Inventory inv = disp.getInventory();
for (ItemStack item : inv.getContents()) { for (ItemStack item : inv.getContents()) {
for (ItemStack recipeInput : RecipeType.getRecipeInputs(this)) { for (ItemStack recipeInput : RecipeType.getRecipeInputs(this)) {

View File

@ -33,12 +33,11 @@ public class EnhancedCraftingTable extends AbstractCraftingTable {
@Override @Override
public void onInteract(Player p, Block b) { public void onInteract(Player p, Block b) {
Block dispenser = b.getRelative(BlockFace.DOWN); Block possibleDispenser = b.getRelative(BlockFace.DOWN);
BlockState state = PaperLib.getBlockState(dispenser, false).getState(); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState();
if (state instanceof Dispenser) { if (state instanceof Dispenser dispenser) {
Dispenser disp = (Dispenser) state; Inventory inv = dispenser.getInventory();
Inventory inv = disp.getInventory();
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this); List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
for (int i = 0; i < inputs.size(); i++) { for (int i = 0; i < inputs.size(); i++) {
@ -46,7 +45,7 @@ public class EnhancedCraftingTable extends AbstractCraftingTable {
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone(); ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
if (SlimefunUtils.canPlayerUseItem(p, output, true)) { if (SlimefunUtils.canPlayerUseItem(p, output, true)) {
craft(inv, dispenser, p, b, output); craft(inv, possibleDispenser, p, b, output);
} }
return; return;
@ -68,8 +67,8 @@ public class EnhancedCraftingTable extends AbstractCraftingTable {
if (outputInv != null) { if (outputInv != null) {
SlimefunItem sfItem = SlimefunItem.getByItem(output); SlimefunItem sfItem = SlimefunItem.getByItem(output);
if (sfItem instanceof SlimefunBackpack) { if (sfItem instanceof SlimefunBackpack slimefunBackpack) {
upgradeBackpack(p, inv, (SlimefunBackpack) sfItem, output); upgradeBackpack(p, inv, slimefunBackpack, output);
} }
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {

View File

@ -106,18 +106,17 @@ public class GrindStone extends MultiBlockMachine {
@Override @Override
public void onInteract(Player p, Block b) { public void onInteract(Player p, Block b) {
Block dispBlock = b.getRelative(BlockFace.DOWN); Block possibleDispenser = b.getRelative(BlockFace.DOWN);
BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState();
if (state instanceof Dispenser) { if (state instanceof Dispenser dispenser) {
Dispenser disp = (Dispenser) state; Inventory inv = dispenser.getInventory();
Inventory inv = disp.getInventory();
for (ItemStack current : inv.getContents()) { for (ItemStack current : inv.getContents()) {
for (ItemStack convert : RecipeType.getRecipeInputs(this)) { for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) { if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) {
ItemStack output = RecipeType.getRecipeOutput(this, convert); ItemStack output = RecipeType.getRecipeOutput(this, convert);
Inventory outputInv = findOutputInventory(output, dispBlock, inv); Inventory outputInv = findOutputInventory(output, possibleDispenser, inv);
if (outputInv != null) { if (outputInv != null) {
ItemStack removing = current.clone(); ItemStack removing = current.clone();

View File

@ -50,18 +50,17 @@ public class Juicer extends MultiBlockMachine {
@Override @Override
public void onInteract(Player p, Block b) { public void onInteract(Player p, Block b) {
Block dispBlock = b.getRelative(BlockFace.DOWN); Block possibleDispenser = b.getRelative(BlockFace.DOWN);
BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState();
if (state instanceof Dispenser) { if (state instanceof Dispenser dispenser) {
Dispenser disp = (Dispenser) state; Inventory inv = dispenser.getInventory();
Inventory inv = disp.getInventory();
for (ItemStack current : inv.getContents()) { for (ItemStack current : inv.getContents()) {
for (ItemStack convert : RecipeType.getRecipeInputs(this)) { for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) { if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) {
ItemStack adding = RecipeType.getRecipeOutput(this, convert); ItemStack adding = RecipeType.getRecipeOutput(this, convert);
Inventory outputInv = findOutputInventory(adding, dispBlock, inv); Inventory outputInv = findOutputInventory(adding, possibleDispenser, inv);
if (outputInv != null) { if (outputInv != null) {
ItemStack removing = current.clone(); ItemStack removing = current.clone();

View File

@ -43,8 +43,7 @@ public class MagicWorkbench extends AbstractCraftingTable {
BlockState state = PaperLib.getBlockState(dispenser, false).getState(); BlockState state = PaperLib.getBlockState(dispenser, false).getState();
if (state instanceof Dispenser) { if (state instanceof Dispenser disp) {
Dispenser disp = (Dispenser) state;
Inventory inv = disp.getInventory(); Inventory inv = disp.getInventory();
List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this); List<ItemStack[]> inputs = RecipeType.getRecipeInputList(this);
@ -76,8 +75,8 @@ public class MagicWorkbench extends AbstractCraftingTable {
if (outputInv != null) { if (outputInv != null) {
SlimefunItem sfItem = SlimefunItem.getByItem(output); SlimefunItem sfItem = SlimefunItem.getByItem(output);
if (sfItem instanceof SlimefunBackpack) { if (sfItem instanceof SlimefunBackpack slimefunBackpack) {
upgradeBackpack(p, inv, (SlimefunBackpack) sfItem, output); upgradeBackpack(p, inv, slimefunBackpack, output);
} }
for (int j = 0; j < 9; j++) { for (int j = 0; j < 9; j++) {

View File

@ -173,18 +173,17 @@ public class OreCrusher extends MultiBlockMachine {
@Override @Override
public void onInteract(Player p, Block b) { public void onInteract(Player p, Block b) {
Block dispBlock = b.getRelative(BlockFace.DOWN); Block possibleDispenser = b.getRelative(BlockFace.DOWN);
BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState();
if (state instanceof Dispenser) { if (state instanceof Dispenser dispenser) {
Dispenser disp = (Dispenser) state; Inventory inv = dispenser.getInventory();
Inventory inv = disp.getInventory();
for (ItemStack current : inv.getContents()) { for (ItemStack current : inv.getContents()) {
for (ItemStack convert : RecipeType.getRecipeInputs(this)) { for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) { if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) {
ItemStack adding = RecipeType.getRecipeOutput(this, convert); ItemStack adding = RecipeType.getRecipeOutput(this, convert);
Inventory outputInv = findOutputInventory(adding, dispBlock, inv); Inventory outputInv = findOutputInventory(adding, possibleDispenser, inv);
if (SlimefunUtils.canPlayerUseItem(p, adding, true)) { if (SlimefunUtils.canPlayerUseItem(p, adding, true)) {
if (outputInv != null) { if (outputInv != null) {

View File

@ -39,25 +39,24 @@ public class PressureChamber extends MultiBlockMachine {
@Override @Override
public void onInteract(Player p, Block b) { public void onInteract(Player p, Block b) {
Block dispBlock = b.getRelative(BlockFace.UP).getRelative(BlockFace.UP); Block possibleDispenser = b.getRelative(BlockFace.UP).getRelative(BlockFace.UP);
BlockState state = PaperLib.getBlockState(dispBlock, false).getState(); BlockState state = PaperLib.getBlockState(possibleDispenser, false).getState();
if (state instanceof Dispenser) { if (state instanceof Dispenser dispenser) {
Dispenser disp = (Dispenser) state; Inventory inv = dispenser.getInventory();
Inventory inv = disp.getInventory();
for (ItemStack current : inv.getContents()) { for (ItemStack current : inv.getContents()) {
for (ItemStack convert : RecipeType.getRecipeInputs(this)) { for (ItemStack convert : RecipeType.getRecipeInputs(this)) {
if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) { if (convert != null && SlimefunUtils.isItemSimilar(current, convert, true)) {
ItemStack output = RecipeType.getRecipeOutput(this, convert); ItemStack output = RecipeType.getRecipeOutput(this, convert);
Inventory outputInv = findOutputInventory(output, dispBlock, inv); Inventory outputInv = findOutputInventory(output, possibleDispenser, inv);
if (outputInv != null) { if (outputInv != null) {
ItemStack removing = current.clone(); ItemStack removing = current.clone();
removing.setAmount(convert.getAmount()); removing.setAmount(convert.getAmount());
inv.removeItem(removing); inv.removeItem(removing);
craft(p, b, output, inv, dispBlock); craft(p, b, output, inv, possibleDispenser);
} else { } else {
Slimefun.getLocalization().sendMessage(p, "machines.full-inventory", true); Slimefun.getLocalization().sendMessage(p, "machines.full-inventory", true);
} }

View File

@ -143,7 +143,6 @@ class MiningTask implements Runnable {
if (fuelLevel <= 0) { if (fuelLevel <= 0) {
// This Miner has not enough fuel. // This Miner has not enough fuel.
stop(MinerStoppingReason.NO_FUEL); stop(MinerStoppingReason.NO_FUEL);
return;
} }
}); });
@ -268,8 +267,8 @@ class MiningTask implements Runnable {
if (chest.getType() == Material.CHEST) { if (chest.getType() == Material.CHEST) {
BlockState state = PaperLib.getBlockState(chest, false).getState(); BlockState state = PaperLib.getBlockState(chest, false).getState();
if (state instanceof Chest) { if (state instanceof Chest chest) {
Inventory inv = ((Chest) state).getBlockInventory(); Inventory inv = chest.getBlockInventory();
if (InvUtils.fits(inv, item)) { if (InvUtils.fits(inv, item)) {
inv.addItem(item); inv.addItem(item);
@ -299,7 +298,7 @@ class MiningTask implements Runnable {
if (chest.getType() == Material.CHEST) { if (chest.getType() == Material.CHEST) {
BlockState state = PaperLib.getBlockState(chest, false).getState(); BlockState state = PaperLib.getBlockState(chest, false).getState();
if (state instanceof Chest) { if (state instanceof Chest chest) {
Inventory inv = ((Chest) state).getBlockInventory(); Inventory inv = ((Chest) state).getBlockInventory();
this.fuelLevel = grabFuelFrom(inv); this.fuelLevel = grabFuelFrom(inv);
} }

View File

@ -19,26 +19,17 @@ class OreDictionary14 implements OreDictionary {
@Override @Override
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public @Nonnull ItemStack getDrops(Material material, Random random) { public @Nonnull ItemStack getDrops(Material material, Random random) {
switch (material) { return switch (material) {
case COAL_ORE: case COAL_ORE -> new ItemStack(Material.COAL);
return new ItemStack(Material.COAL); case DIAMOND_ORE -> new ItemStack(Material.DIAMOND);
case DIAMOND_ORE: case EMERALD_ORE -> new ItemStack(Material.EMERALD);
return new ItemStack(Material.DIAMOND); case REDSTONE_ORE -> new ItemStack(Material.REDSTONE, 4 + random.nextInt(2));
case EMERALD_ORE: case LAPIS_ORE -> new ItemStack(Material.LAPIS_LAZULI, 4 + random.nextInt(4));
return new ItemStack(Material.EMERALD); case NETHER_QUARTZ_ORE -> new ItemStack(Material.QUARTZ);
case REDSTONE_ORE: case IRON_ORE -> new ItemStack(Material.IRON_ORE);
return new ItemStack(Material.REDSTONE, 4 + random.nextInt(2)); case GOLD_ORE -> new ItemStack(Material.GOLD_ORE);
case LAPIS_ORE: default -> new ItemStack(material);
return new ItemStack(Material.LAPIS_LAZULI, 4 + random.nextInt(4)); };
case NETHER_QUARTZ_ORE:
return new ItemStack(Material.QUARTZ);
case IRON_ORE:
return new ItemStack(Material.IRON_ORE);
case GOLD_ORE:
return new ItemStack(Material.GOLD_ORE);
default:
return new ItemStack(material);
}
} }
} }

View File

@ -19,15 +19,13 @@ class OreDictionary16 extends OreDictionary14 {
@Override @Override
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public @Nonnull ItemStack getDrops(Material material, Random random) { public @Nonnull ItemStack getDrops(Material material, Random random) {
switch (material) { return switch (material) {
case NETHER_GOLD_ORE: case NETHER_GOLD_ORE ->
// In 1.16, breaking nether gold ores should get gold nuggets // In 1.16, breaking nether gold ores should get gold nuggets
return new ItemStack(Material.GOLD_NUGGET, 2 + random.nextInt(4)); new ItemStack(Material.GOLD_NUGGET, 2 + random.nextInt(4));
case ANCIENT_DEBRIS: case ANCIENT_DEBRIS -> new ItemStack(Material.ANCIENT_DEBRIS);
return new ItemStack(Material.ANCIENT_DEBRIS); default -> super.getDrops(material, random);
default: };
return super.getDrops(material, random);
}
} }
} }

View File

@ -19,34 +19,25 @@ class OreDictionary17 extends OreDictionary16 {
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
public ItemStack getDrops(Material material, Random random) { public ItemStack getDrops(Material material, Random random) {
// In 1.17, breaking metal ores should get raw metals. Also support deepslate ores. // In 1.17, breaking metal ores should get raw metals. Also support deepslate ores.
switch (material) { return switch (material) {
case COAL_ORE: case COAL_ORE,
case DEEPSLATE_COAL_ORE: DEEPSLATE_COAL_ORE -> new ItemStack(Material.COAL);
return new ItemStack(Material.COAL); case DIAMOND_ORE,
case DIAMOND_ORE: DEEPSLATE_DIAMOND_ORE -> new ItemStack(Material.DIAMOND);
case DEEPSLATE_DIAMOND_ORE: case EMERALD_ORE,
return new ItemStack(Material.DIAMOND); DEEPSLATE_EMERALD_ORE -> new ItemStack(Material.EMERALD);
case EMERALD_ORE: case REDSTONE_ORE,
case DEEPSLATE_EMERALD_ORE: DEEPSLATE_REDSTONE_ORE -> new ItemStack(Material.REDSTONE, 4 + random.nextInt(2));
return new ItemStack(Material.EMERALD); case LAPIS_ORE,
case REDSTONE_ORE: DEEPSLATE_LAPIS_ORE -> new ItemStack(Material.LAPIS_LAZULI, 4 + random.nextInt(4));
case DEEPSLATE_REDSTONE_ORE: case COPPER_ORE,
return new ItemStack(Material.REDSTONE, 4 + random.nextInt(2)); DEEPSLATE_COPPER_ORE -> new ItemStack(Material.RAW_COPPER);
case LAPIS_ORE: case IRON_ORE,
case DEEPSLATE_LAPIS_ORE: DEEPSLATE_IRON_ORE -> new ItemStack(Material.RAW_IRON);
return new ItemStack(Material.LAPIS_LAZULI, 4 + random.nextInt(4)); case GOLD_ORE,
case COPPER_ORE: DEEPSLATE_GOLD_ORE -> new ItemStack(Material.RAW_GOLD);
case DEEPSLATE_COPPER_ORE: default -> super.getDrops(material, random);
return new ItemStack(Material.RAW_COPPER); };
case IRON_ORE:
case DEEPSLATE_IRON_ORE:
return new ItemStack(Material.RAW_IRON);
case GOLD_ORE:
case DEEPSLATE_GOLD_ORE:
return new ItemStack(Material.RAW_GOLD);
default:
return super.getDrops(material, random);
}
} }
} }