diff --git a/src/main/java/team/chisel/carving/Carving.java b/src/main/java/team/chisel/carving/Carving.java index d7cb498b..9e6aad01 100644 --- a/src/main/java/team/chisel/carving/Carving.java +++ b/src/main/java/team/chisel/carving/Carving.java @@ -1,9 +1,6 @@ package team.chisel.carving; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; +import java.util.*; import com.cricketcraft.chisel.api.carving.CarvingUtils; import com.cricketcraft.chisel.api.carving.ICarvingGroup; @@ -28,9 +25,11 @@ public class Carving implements ICarvingRegistry { } public static void construct() { + /* do nothing */ } private Carving() { + /* do nothing */ } @Override @@ -50,7 +49,7 @@ public class Carving implements ICarvingRegistry { public List getGroupVariations(Block block, int metadata) { ICarvingGroup group = getGroup(block, metadata); if (group == null) - return null; + return Collections.emptyList(); return group.getVariations(); } @@ -66,12 +65,12 @@ public class Carving implements ICarvingRegistry { @Override public List getItemsForChiseling(ItemStack chiseledItem) { - ArrayList items = new ArrayList(); + ArrayList items = new ArrayList<>(); ICarvingGroup group = null; - int[] oreids = OreDictionary.getOreIDs(chiseledItem); - for (int i : oreids) { + int[] oreIDs = OreDictionary.getOreIDs(chiseledItem); + for (int i : oreIDs) { group = groups.getGroupByOre(OreDictionary.getOreName(i)); if (group != null) { break; @@ -85,33 +84,21 @@ public class Carving implements ICarvingRegistry { if (group == null) return items; - HashMap mapping = new HashMap(); + HashSet mapping = new HashSet<>(); List variations = group.getVariations(); - if (!group.getVariations().isEmpty()) { - for (ICarvingVariation v : variations) { - - String key = Block.getIdFromBlock(v.getBlock()) + "|" + v.getItemMeta(); - if (mapping.containsKey(key)) - continue; - mapping.put(key, 1); - - items.add(new ItemStack(v.getBlock(), 1, v.getItemMeta())); - } + for (ICarvingVariation v : variations) { + String key = Block.getIdFromBlock(v.getBlock()) + "|" + v.getItemMeta(); + if (mapping.add(key)) items.add(new ItemStack(v.getBlock(), 1, v.getItemMeta())); } - ArrayList ores; String oreName = group.getOreName(); - if (oreName != null && ((ores = OreDictionary.getOres(oreName)) != null)) { + if (oreName != null) { + ArrayList ores = OreDictionary.getOres(oreName); for (ItemStack stack : ores) { - String key = Item.getIdFromItem(stack.getItem()) + "|" + stack.getItemDamage(); - if (mapping.containsKey(key)) - continue; - mapping.put(key, 2); - - items.add(stack); + if (mapping.add(key)) items.add(stack); } } @@ -221,8 +208,7 @@ public class Carving implements ICarvingRegistry { @Override public List getSortedGroupNames() { - List names = new ArrayList(); - names.addAll(groups.getNames()); + List names = new ArrayList<>(groups.getNames()); Collections.sort(names); return names; }