From b0500332bcb6194462add44e9bd91a7cc35d4073 Mon Sep 17 00:00:00 2001 From: Glitchfinder Date: Tue, 8 Jan 2013 15:14:12 -0800 Subject: [PATCH] Finishing up backwards compatibility for dye colors. --- .../nossr50/skills/gathering/Fishing.java | 9 +++++-- .../nossr50/skills/gathering/Herbalism.java | 24 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java index f32705a5a..2252cd48f 100755 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Fishing.java @@ -404,8 +404,13 @@ public class Fishing { break; case SQUID: - ItemStack item = new ItemStack(Material.INK_SACK, 1, (short) 0); - item.setData(new MaterialData(Material.INK_SACK, DyeColor.BLACK.getDyeData())); + ItemStack item; + try { + item = (new MaterialData(Material.INK_SACK, DyeColor.BLACK.getDyeData())).toItemStack(1); + } + catch(Exception e) { + item = (new MaterialData(Material.INK_SACK, (byte) 0)).toItemStack(1); + } Misc.dropItem(location, item); break; 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 ed04198c7..5736a90f5 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Herbalism.java @@ -269,7 +269,12 @@ public class Herbalism { } else { if (mat == Material.COCOA) { - is = new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData()); + try { + is = new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData()); + } + catch (Exception e) { + is = new ItemStack(Material.INK_SACK, 1, (short) 3); + } } else if (mat == Material.CARROT) { is = new ItemStack(Material.CARROT_ITEM, 1, (short) 0); @@ -422,7 +427,12 @@ public class Herbalism { break; case COCOA: // Broken: Requires an update to bukkit to enable seaching for variable-sized ItemStacks. - hasSeeds = inventory.contains(new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData()), 1); + try { + hasSeeds = inventory.contains(new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData()), 1); + } + catch(Exception e) { + hasSeeds = inventory.contains(new ItemStack(Material.INK_SACK, 1, (short) 3), 1); + } break; case CARROT: hasSeeds = inventory.contains(Material.CARROT_ITEM); @@ -456,8 +466,14 @@ public class Herbalism { inventory.removeItem(new ItemStack(Material.SEEDS)); break; case COCOA: - Misc.dropItem(location, new ItemStack(Material.INK_SACK, 3, DyeColor.BROWN.getDyeData())); - inventory.removeItem(new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData())); + try { + Misc.dropItem(location, new ItemStack(Material.INK_SACK, 3, DyeColor.BROWN.getDyeData())); + inventory.removeItem(new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData())); + } + catch(Exception e) { + Misc.dropItem(location, new ItemStack(Material.INK_SACK, 3, (short) 3)); + inventory.removeItem(new ItemStack(Material.INK_SACK, 1, (short) 3)); + } break; case CARROT: Misc.dropItem(location, new ItemStack(Material.CARROT_ITEM));