From c559e7027053f2287e0c4c04a1d4afc3df9fdfb6 Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 17 May 2012 21:57:41 -0400 Subject: [PATCH] Mod support - able to define tiers for custom blocks now. Tier 1 - breaks with wood/gold Tier 2 - breaks with stone Tier 3 - breaks with iron Tier 4 - breaks with diamond --- .../nossr50/config/mods/CustomBlocksConfig.java | 3 ++- .../gmail/nossr50/datatypes/mods/CustomBlock.java | 12 +++++++++++- .../com/gmail/nossr50/skills/gathering/Mining.java | 4 ++++ src/main/resources/blocks.yml | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) 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 33de5673a..fb44334be 100644 --- a/src/main/java/com/gmail/nossr50/config/mods/CustomBlocksConfig.java +++ b/src/main/java/com/gmail/nossr50/config/mods/CustomBlocksConfig.java @@ -71,6 +71,7 @@ public class CustomBlocksConfig extends ModConfigLoader{ int id = config.getInt(skillType + "." + blockName + ".ID", 0); byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0); int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0); + int tier = config.getInt(skillType + "." + blockName + ".Tier", 1); boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false); int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0); byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0); @@ -97,7 +98,7 @@ public class CustomBlocksConfig extends ModConfigLoader{ itemDrop = new ItemStack(id, dropAmount, (short) 0, data); } - block = new CustomBlock(itemDrop, xp, data, id); + block = new CustomBlock(itemDrop, tier, xp, data, id); blockItem = new ItemStack(id, 1, (short) 0, data); if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) { diff --git a/src/main/java/com/gmail/nossr50/datatypes/mods/CustomBlock.java b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomBlock.java index b7fa47229..00f0511e1 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/mods/CustomBlock.java +++ b/src/main/java/com/gmail/nossr50/datatypes/mods/CustomBlock.java @@ -6,12 +6,14 @@ public class CustomBlock { private int itemID; private byte dataValue; private int xpGain; + private int tier; private ItemStack itemDrop; - public CustomBlock(ItemStack itemDrop, int xpGain, byte dataValue, int itemID) { + public CustomBlock(ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) { this.itemID = itemID; this.dataValue = dataValue; this.xpGain = xpGain; + this.tier = tier; this.itemDrop = itemDrop; } @@ -39,6 +41,14 @@ public class CustomBlock { this.xpGain = xpGain; } + public int getTier() { + return tier; + } + + public void setTier(int tier) { + this.tier = tier; + } + public ItemStack getItemDrop() { return itemDrop; } 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 204efb03e..9ed86fe8d 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/Mining.java @@ -251,6 +251,10 @@ public class Mining { FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player); if (Config.getInstance().getBlockModsEnabled() && CustomBlocksConfig.getInstance().customItems.contains(new ItemStack(block.getTypeId(), 1, (short) 0, block.getData()))) { + if (ModChecks.getCustomBlock(block).getTier() < tier) { + return; + } + if (mcMMO.placeStore.isTrue(block)) { return; } diff --git a/src/main/resources/blocks.yml b/src/main/resources/blocks.yml index 844d3e94f..b93b03f93 100644 --- a/src/main/resources/blocks.yml +++ b/src/main/resources/blocks.yml @@ -49,6 +49,7 @@ Mining: Data_Value: 0 XP_Gain: 99 Is_Ore: true + Tier: 1 Drop_Item: false Drop_Item_ID: 999 Drop_Item_Data_Value: 0 @@ -58,6 +59,7 @@ Mining: Data_Value: 0 XP_Gain: 99 Is_Ore: true + Tier: 1 Drop_Item: false Drop_Item_ID: 999 Drop_Item_Data_Value: 0