diff --git a/src/main/java/com/gmail/nossr50/config/TreasuresConfig.java b/src/main/java/com/gmail/nossr50/config/TreasuresConfig.java index a00398017..d1caf6a31 100644 --- a/src/main/java/com/gmail/nossr50/config/TreasuresConfig.java +++ b/src/main/java/com/gmail/nossr50/config/TreasuresConfig.java @@ -126,8 +126,7 @@ public class TreasuresConfig extends ConfigLoader{ * Drops From & Max Level */ - ItemStack item = new ItemStack(id, amount, (short) 0); - item.setData(new MaterialData(id, (byte) data)); + ItemStack item = (new MaterialData(id, (byte) data)).toItemStack(amount); if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) { if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) { diff --git a/src/main/java/com/gmail/nossr50/config/mods/CustomBlocksConfig.java b/src/main/java/com/gmail/nossr50/config/mods/CustomBlocksConfig.java index 91c8535b6..ad4deceb7 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomBlocksConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomBlocksConfig.java @@ -79,8 +79,7 @@ public class CustomBlocksConfig extends ConfigLoader { } if (skillType.equals("Ability_Blocks")) { - blockItem = new ItemStack(id, 1, (short) 0); - blockItem.setData(new MaterialData(id, data)); + blockItem = (new MaterialData(id, data)).toItemStack(1); blockList.add(blockItem); continue; @@ -92,17 +91,14 @@ public class CustomBlocksConfig extends ConfigLoader { } if (dropItem) { - itemDrop = new ItemStack(dropID, 1, (short) 0); - itemDrop.setData(new MaterialData(dropID, dropData)); + itemDrop = (new MaterialData(dropID, dropData)).toItemStack(1); } else { - itemDrop = new ItemStack(id, 1, (short) 0); - itemDrop.setData(new MaterialData(id, data)); + itemDrop = (new MaterialData(id, data)).toItemStack(1); } block = new CustomBlock(minimumDropAmount, maxiumDropAmount, itemDrop, tier, xp, data, id); - blockItem = new ItemStack(id, 1, (short) 0); - blockItem.setData(new MaterialData(id, data)); + blockItem = (new MaterialData(id, data)).toItemStack(1); if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) { customOres.add(blockItem); diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java b/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java index a4635191e..28d682090 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Excavation.java @@ -52,8 +52,7 @@ public class Excavation { int xp; - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) { xp = ModChecks.getCustomBlock(block).getXpGain(); diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java index 3bcaee8f5..7cddc3d41 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java @@ -241,8 +241,7 @@ public class Herbalism { break; default: - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) { customPlant = true; diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java b/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java index 2fe813fdb..d389078e8 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java @@ -97,8 +97,7 @@ public class Mining { default: if (ModChecks.isCustomMiningBlock(block)) { - ItemStack dropItem = new ItemStack(block.getTypeId(), 1, (short) 0); - dropItem.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack dropItem = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); Misc.dropItem(location, dropItem); } @@ -121,8 +120,7 @@ public class Mining { switch (type) { case COAL_ORE: if (configInstance.getCoalDoubleDropsEnabled()) { - item = new ItemStack(Material.COAL, 1, (short) 0); - item.setData(new MaterialData(Material.COAL, CoalType.COAL.getData())); + item = (new MaterialData(Material.COAL, CoalType.COAL.getData())).toItemStack(1); Misc.dropItem(location, item); } @@ -172,8 +170,7 @@ public class Mining { case LAPIS_ORE: if (configInstance.getLapisDoubleDropsEnabled()) { - item = new ItemStack(Material.INK_SACK, 1, (short) 0); - item.setData(new MaterialData(Material.INK_SACK, (byte) 0x4)); + item = (new MaterialData(Material.INK_SACK, (byte) 0x4)).toItemStack(1); Misc.dropItems(location, item, 4); Misc.randomDropItems(location, item, 50, 4); diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java index c2c0a4a98..e086e8d52 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java @@ -98,18 +98,14 @@ public class WoodCutting { //Prepare ItemStacks ItemStack item = null; - ItemStack oak = new ItemStack(Material.LOG, 1, (short) 0); - ItemStack spruce = new ItemStack(Material.LOG, 1, (short) 0); - ItemStack birch = new ItemStack(Material.LOG, 1, (short) 0); - ItemStack jungle = new ItemStack(Material.LOG, 1, (short) 0); + ItemStack oak = (new MaterialData(Material.LOG, TreeSpecies.GENERIC.getData())).toItemStack(1); + ItemStack spruce = (new MaterialData(Material.LOG, TreeSpecies.REDWOOD.getData())).toItemStack(1); + ItemStack birch = (new MaterialData(Material.LOG, TreeSpecies.BIRCH.getData())).toItemStack(1); + ItemStack jungle = (new MaterialData(Material.LOG, TreeSpecies.JUNGLE.getData())).toItemStack(1); - oak.setData(new MaterialData(Material.LOG, TreeSpecies.GENERIC.getData())); - spruce.setData(new MaterialData(Material.LOG, TreeSpecies.REDWOOD.getData())); - birch.setData(new MaterialData(Material.LOG, TreeSpecies.BIRCH.getData())); - jungle.setData(new MaterialData(Material.LOG, TreeSpecies.JUNGLE.getData())); for (Block x : toBeFelled) { if (Misc.blockBreakSimulate(x, player, true)) { - if (Config.getInstance().getBlockModsEnabled()) { + if (Config.getInstance().getBlockModsEnabled() && ModChecks.isCustomLogBlock(x)) { if (ModChecks.isCustomLogBlock(x)) { CustomBlock block = ModChecks.getCustomBlock(x); item = block.getItemDrop(); @@ -209,8 +205,8 @@ public class WoodCutting { else if (x.getType() == Material.LEAVES) { final int SAPLING_DROP_CHANCE = 10; - item = new ItemStack(Material.SAPLING, 1, (short) 0); - item.setData(new MaterialData(Material.SAPLING, (byte) (x.getData() & 3))); //Drop the right type of sapling + //Drop the right type of sapling + item = (new MaterialData(Material.SAPLING, (byte) (x.getData() & 3))).toItemStack(1); Misc.randomDropItem(x.getLocation(), item, SAPLING_DROP_CHANCE); @@ -380,8 +376,7 @@ public class WoodCutting { } } else { - item = new ItemStack(mat, 1, (short) 0); - item.setData(new MaterialData(mat, type)); + item = (new MaterialData(mat, type)).toItemStack(1); location = block.getLocation(); diff --git a/src/main/java/com/gmail/nossr50/util/BlockChecks.java b/src/main/java/com/gmail/nossr50/util/BlockChecks.java index ba54d71da..5b328fa94 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockChecks.java +++ b/src/main/java/com/gmail/nossr50/util/BlockChecks.java @@ -60,8 +60,7 @@ public class BlockChecks { return true; default: - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (customBlocksEnabled && CustomBlocksConfig.getInstance().customItems.contains(item)) { return true; @@ -79,8 +78,7 @@ public class BlockChecks { * @return true if the block should allow ability activation, false otherwise */ public static boolean abilityBlockCheck(Block block) { - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (customBlocksEnabled && CustomBlocksConfig.getInstance().customAbilityBlocks.contains(item)) { return false; @@ -205,8 +203,7 @@ public class BlockChecks { } default: - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (customBlocksEnabled && CustomBlocksConfig.getInstance().customHerbalismBlocks.contains(item)) { return true; @@ -243,8 +240,7 @@ public class BlockChecks { return true; default: - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (customBlocksEnabled && CustomBlocksConfig.getInstance().customMiningBlocks.contains(item)) { return true; @@ -273,8 +269,7 @@ public class BlockChecks { return true; default: - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (customBlocksEnabled && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) { return true; @@ -299,8 +294,7 @@ public class BlockChecks { return true; default: - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (customBlocksEnabled && CustomBlocksConfig.getInstance().customWoodcuttingBlocks.contains(item)) { return true; diff --git a/src/main/java/com/gmail/nossr50/util/ModChecks.java b/src/main/java/com/gmail/nossr50/util/ModChecks.java index 4c27facd4..d5549ca8c 100644 --- a/src/main/java/com/gmail/nossr50/util/ModChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ModChecks.java @@ -49,8 +49,7 @@ public class ModChecks { * @return the block if it exists, null otherwise */ public static CustomBlock getCustomBlock(Block block) { - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (!blocksInstance.customItems.contains(item)) { return null; @@ -72,8 +71,7 @@ public class ModChecks { * @return true if the block is custom, false otherwise */ public static boolean isCustomMiningBlock(Block block) { - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (customBlocksEnabled && blocksInstance.customMiningBlocks.contains(item)) { for (CustomBlock b : blocksInstance.customBlocks) { @@ -93,8 +91,7 @@ public class ModChecks { * @return true if the block represents leaves, false otherwise */ public static boolean isCustomLeafBlock(Block block) { - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (blocksInstance.customLeaves.contains(item)) { for (CustomBlock b : blocksInstance.customBlocks) { @@ -114,8 +111,7 @@ public class ModChecks { * @return true if the block represents a log, false otherwise */ public static boolean isCustomLogBlock(Block block) { - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (blocksInstance.customLogs.contains(item)) { for (CustomBlock b : blocksInstance.customBlocks) { @@ -135,8 +131,7 @@ public class ModChecks { * @return true if the block represents an ore, false otherwise */ public static boolean isCustomOreBlock(Block block) { - ItemStack item = new ItemStack(block.getTypeId(), 1, (short) 0); - item.setData(new MaterialData(block.getTypeId(), block.getData())); + ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1); if (blocksInstance.customOres.contains(item)) { for (CustomBlock b : blocksInstance.customBlocks) {