From caafc88021da5a2c9c0ba20d0766e4f11edf007c Mon Sep 17 00:00:00 2001 From: Tombenpotter Date: Sun, 5 Oct 2014 17:53:00 +0200 Subject: [PATCH] Carvers! --- Changelog.txt | 1 + .../module/vanilla/VanillaItemsRegistry.java | 13 ++++++ .../module/vanilla/VanillaItemstacks.java | 7 +++ .../vanilla/VanillaRecipesRegistry.java | 45 ++++++++++++++++++- .../module/vanilla/items/ItemShardCaver.java | 14 ++++++ .../emt/common/util/EventHandlerEMT.java | 12 +++++ .../assets/electromagictools/lang/en_US.lang | 6 +++ 7 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 src/main/java/tombenpotter/emt/common/module/vanilla/items/ItemShardCaver.java diff --git a/Changelog.txt b/Changelog.txt index 1757a0f..7532e1b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -3,6 +3,7 @@ Changelog of the mod : Electric Magic Tools, a Thaumcraft 4/Industrial-Craft 2 a -------------------------------------------------------------------------------------------------------------------------------------------------------- Version 2.0.0Alpa5: Wild Material Shards have appeared! They are used in the tools' crafting recipes :D. +And here come the carvers! Version 2.0.0Alpha4: Added some items to the vanilla module of the mod: Wooden, Stone, Iron, Golden and Diamond Drills. diff --git a/src/main/java/tombenpotter/emt/common/module/vanilla/VanillaItemsRegistry.java b/src/main/java/tombenpotter/emt/common/module/vanilla/VanillaItemsRegistry.java index df0582a..162d069 100644 --- a/src/main/java/tombenpotter/emt/common/module/vanilla/VanillaItemsRegistry.java +++ b/src/main/java/tombenpotter/emt/common/module/vanilla/VanillaItemsRegistry.java @@ -9,6 +9,7 @@ import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.oredict.OreDictionary; import tombenpotter.emt.ModInformation; import tombenpotter.emt.common.module.vanilla.items.ItemCraftingComponent; +import tombenpotter.emt.common.module.vanilla.items.ItemShardCaver; import tombenpotter.emt.common.module.vanilla.items.tools.ItemVanillaChainsaw; import tombenpotter.emt.common.module.vanilla.items.tools.ItemVanillaDrill; import tombenpotter.emt.common.module.vanilla.items.tools.ItemVanillaOmnitool; @@ -44,6 +45,7 @@ public class VanillaItemsRegistry { public static Item bronzeOmnitool; public static Item craftingComponent; + public static Item woodCarver, stoneCarver, ironCarver, obsidianCarver, diamondCarver; public static Item.ToolMaterial copperMaterial = EnumHelper.addToolMaterial("copperToolMaterial", 2, 300, 6.0F, 2.0F, 14); public static Item.ToolMaterial tinMaterial = EnumHelper.addToolMaterial("tinToolMatierial", 2, 200, 8.0F, 4F, 18); @@ -54,6 +56,17 @@ public class VanillaItemsRegistry { craftingComponent = new ItemCraftingComponent().setUnlocalizedName(ModInformation.modid + ".material"); GameRegistry.registerItem(craftingComponent, "craftingComponents"); + woodCarver = new ItemShardCaver(8).setUnlocalizedName(ModInformation.modid + ".carver.wood"); + GameRegistry.registerItem(woodCarver, "woodCarver"); + stoneCarver = new ItemShardCaver(32).setUnlocalizedName(ModInformation.modid + ".carver.stone"); + GameRegistry.registerItem(stoneCarver, "stoneCarver"); + ironCarver = new ItemShardCaver(128).setUnlocalizedName(ModInformation.modid + ".carver.iron"); + GameRegistry.registerItem(ironCarver, "ironCarver"); + obsidianCarver = new ItemShardCaver(256).setUnlocalizedName(ModInformation.modid + ".carver.obsidian"); + GameRegistry.registerItem(obsidianCarver, "obsidianCarver"); + diamondCarver = new ItemShardCaver(1204).setUnlocalizedName(ModInformation.modid + ".carver.diamond"); + GameRegistry.registerItem(diamondCarver, "diamondCarver"); + woodenDrill = new ItemVanillaDrill(Item.ToolMaterial.WOOD, 75, ":drill_wood", new ItemStack(Item.getItemFromBlock(Blocks.planks))).setUnlocalizedName(ModInformation.modid + ".drill.wood"); GameRegistry.registerItem(woodenDrill, "woodenDrill"); stoneDrill = new ItemVanillaDrill(Item.ToolMaterial.STONE, 165, ":drill_stone", new ItemStack(Item.getItemFromBlock(Blocks.cobblestone))).setUnlocalizedName(ModInformation.modid + ".drill.stone"); diff --git a/src/main/java/tombenpotter/emt/common/module/vanilla/VanillaItemstacks.java b/src/main/java/tombenpotter/emt/common/module/vanilla/VanillaItemstacks.java index 5384a23..381e0d1 100644 --- a/src/main/java/tombenpotter/emt/common/module/vanilla/VanillaItemstacks.java +++ b/src/main/java/tombenpotter/emt/common/module/vanilla/VanillaItemstacks.java @@ -1,6 +1,7 @@ package tombenpotter.emt.common.module.vanilla; import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; public class VanillaItemstacks { public static ItemStack woodenDrill = new ItemStack(VanillaItemsRegistry.woodenDrill); @@ -68,4 +69,10 @@ public class VanillaItemstacks { public static ItemStack tinShard = new ItemStack(VanillaItemsRegistry.craftingComponent, 1, 31); public static ItemStack leadShard = new ItemStack(VanillaItemsRegistry.craftingComponent, 1, 32); public static ItemStack bronzeShard = new ItemStack(VanillaItemsRegistry.craftingComponent, 1, 33); + + public static ItemStack woodenCarver = new ItemStack(VanillaItemsRegistry.woodCarver, 1, OreDictionary.WILDCARD_VALUE); + public static ItemStack stoneCarver = new ItemStack(VanillaItemsRegistry.stoneCarver, 1, OreDictionary.WILDCARD_VALUE); + public static ItemStack ironCarver = new ItemStack(VanillaItemsRegistry.ironCarver, 1, OreDictionary.WILDCARD_VALUE); + public static ItemStack obsidianCarver = new ItemStack(VanillaItemsRegistry.obsidianCarver, 1, OreDictionary.WILDCARD_VALUE); + public static ItemStack diamondCarver = new ItemStack(VanillaItemsRegistry.obsidianCarver, 1, OreDictionary.WILDCARD_VALUE); } diff --git a/src/main/java/tombenpotter/emt/common/module/vanilla/VanillaRecipesRegistry.java b/src/main/java/tombenpotter/emt/common/module/vanilla/VanillaRecipesRegistry.java index 61d373b..ebdf333 100644 --- a/src/main/java/tombenpotter/emt/common/module/vanilla/VanillaRecipesRegistry.java +++ b/src/main/java/tombenpotter/emt/common/module/vanilla/VanillaRecipesRegistry.java @@ -14,9 +14,12 @@ public class VanillaRecipesRegistry { public static IRecipe ironOmnitool, goldenOmnitool, diamondOmnitool, copperOmnitool, tinOmnitool, leadOmnitool, bronzeOmnitool; public static IRecipe woodenDrillTop, stoneDrillTop, ironDrillTop, goldenDrillTop, diamondDrillTop, copperDrillTop, tinDrillTop, leadDrillTop, bronzeDrillTop; public static IRecipe woodenChainsawTop, stoneChainsawTop, ironChainsawTop, goldenChainsawTop, diamondChainsawTop, copperChainsawTop, tinChainsawTop, leadChainsawTop, bronzeChainsawTop; + public static IRecipe woodenCarver, stoneCarver, ironCarver, obsidianCarver, diamondCarver; public static void registerRecipes() { addMiscRecipes(); + addCarversRecipes(); + addShardsRecipes(); addDrillTopRecipes(); addDrillRecipe(); addChainsawTopRecipes(); @@ -26,6 +29,28 @@ public class VanillaRecipesRegistry { public static void addMiscRecipes() { } + public static void addCarversRecipes() { + for (int i = 0; i < OreDictionary.getOres("logWood").size(); i++) { + woodenCarver = GameRegistry.addShapedRecipe(VanillaItemstacks.woodenCarver, " X ", "YYY", 'X', Items.flint, 'Y', OreDictionary.getOres("logWood").get(i)); + } + stoneCarver = GameRegistry.addShapedRecipe(VanillaItemstacks.stoneCarver, " X ", "YYY", 'X', Items.flint, 'Y', Blocks.stone); + ironCarver = GameRegistry.addShapedRecipe(VanillaItemstacks.ironCarver, " X ", "YYY", 'X', VanillaItemstacks.ironShard, 'Y', Blocks.stone); + obsidianCarver = GameRegistry.addShapedRecipe(VanillaItemstacks.obsidianCarver, " X ", "YYY", 'X', VanillaItemstacks.ironShard, 'Y', Blocks.obsidian); + diamondCarver = GameRegistry.addShapedRecipe(VanillaItemstacks.ironCarver, " X ", "YYY", "ZZZ", 'X', VanillaItemstacks.obsidianShard, 'Y', Items.diamond, 'Z', Blocks.obsidian); + } + + public static void addShardsRecipes() { + addCarverRecipe(VanillaItemstacks.woodenShard, "logWood"); + addCarverRecipe(VanillaItemstacks.stoneShard, "stone"); + addCarverRecipe(VanillaItemstacks.ironShard, "ingotIron"); + addCarverRecipe(VanillaItemstacks.goldenShard, "ingotGold"); + addCarverRecipe(VanillaItemstacks.obsidianShard, new ItemStack(Blocks.obsidian)); + addCarverRecipe(VanillaItemstacks.copperShard, "ingotCopper"); + addCarverRecipe(VanillaItemstacks.tinShard, "ingotTin"); + addCarverRecipe(VanillaItemstacks.leadShard, "ingotLead"); + addCarverRecipe(VanillaItemstacks.bronzeShard, "ingotBronze"); + } + public static void addDrillTopRecipes() { woodenDrillTop = drillTopRecipe(VanillaItemstacks.woodenDrillTop, "plankWood", VanillaItemstacks.woodenShard); stoneDrillTop = drillTopRecipe(VanillaItemstacks.stoneDrillTop, "stone", VanillaItemstacks.stoneShard); @@ -47,7 +72,7 @@ public class VanillaRecipesRegistry { copperChainsawTop = chainsawTopRecipe(VanillaItemstacks.copperChainsawTop, "ingotCopper", VanillaItemstacks.copperShard); tinChainsawTop = chainsawTopRecipe(VanillaItemstacks.tinChainsawTop, "ingotTin", VanillaItemstacks.tinShard); leadChainsawTop = chainsawTopRecipe(VanillaItemstacks.leadChainsawTop, "ingotLead", VanillaItemstacks.leadShard); - bronzeDrill = chainsawTopRecipe(VanillaItemstacks.bronzeChainsawTop, "ingotBronze", VanillaItemstacks.bronzeShard); + bronzeChainsawTop = chainsawTopRecipe(VanillaItemstacks.bronzeChainsawTop, "ingotBronze", VanillaItemstacks.bronzeShard); } public static void addDrillRecipe() { @@ -103,4 +128,22 @@ public class VanillaRecipesRegistry { } return null; } + + public static void addCarverRecipe(ItemStack output, ItemStack input) { + GameRegistry.addShapelessRecipe(output, VanillaItemstacks.woodenCarver, input); + GameRegistry.addShapelessRecipe(output, VanillaItemstacks.stoneCarver, input); + GameRegistry.addShapelessRecipe(output, VanillaItemstacks.ironCarver, input); + GameRegistry.addShapelessRecipe(output, VanillaItemstacks.obsidianCarver, input); + GameRegistry.addShapelessRecipe(output, VanillaItemstacks.diamondCarver, input); + } + + public static void addCarverRecipe(ItemStack output, String input) { + for (int i = 0; i < OreDictionary.getOres(input).size(); i++) { + GameRegistry.addShapelessRecipe(output, VanillaItemstacks.woodenCarver, OreDictionary.getOres(input).get(i)); + GameRegistry.addShapelessRecipe(output, VanillaItemstacks.stoneCarver, OreDictionary.getOres(input).get(i)); + GameRegistry.addShapelessRecipe(output, VanillaItemstacks.ironCarver, OreDictionary.getOres(input).get(i)); + GameRegistry.addShapelessRecipe(output, VanillaItemstacks.obsidianCarver, OreDictionary.getOres(input).get(i)); + GameRegistry.addShapelessRecipe(output, VanillaItemstacks.diamondCarver, OreDictionary.getOres(input).get(i)); + } + } } diff --git a/src/main/java/tombenpotter/emt/common/module/vanilla/items/ItemShardCaver.java b/src/main/java/tombenpotter/emt/common/module/vanilla/items/ItemShardCaver.java new file mode 100644 index 0000000..8b969e9 --- /dev/null +++ b/src/main/java/tombenpotter/emt/common/module/vanilla/items/ItemShardCaver.java @@ -0,0 +1,14 @@ +package tombenpotter.emt.common.module.vanilla.items; + +import net.minecraft.item.Item; +import tombenpotter.emt.ElectroMagicTools; + +public class ItemShardCaver extends Item { + + public ItemShardCaver(int maxDamage) { + this.setCreativeTab(ElectroMagicTools.tabEMT); + this.setMaxDamage(maxDamage); + this.setMaxStackSize(1); + this.setNoRepair(); + } +} diff --git a/src/main/java/tombenpotter/emt/common/util/EventHandlerEMT.java b/src/main/java/tombenpotter/emt/common/util/EventHandlerEMT.java index 9d50d98..7e25840 100644 --- a/src/main/java/tombenpotter/emt/common/util/EventHandlerEMT.java +++ b/src/main/java/tombenpotter/emt/common/util/EventHandlerEMT.java @@ -14,6 +14,7 @@ package tombenpotter.emt.common.util; import cpw.mods.fml.client.event.ConfigChangedEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.player.EntityPlayer; @@ -23,6 +24,7 @@ import thaumcraft.common.entities.monster.EntityTaintChicken; import tombenpotter.emt.ElectroMagicTools; import tombenpotter.emt.ModInformation; import tombenpotter.emt.common.module.ic2.IC2ModuleItemRegistry; +import tombenpotter.emt.common.module.vanilla.items.ItemShardCaver; public class EventHandlerEMT { @@ -55,4 +57,14 @@ public class EventHandlerEMT { ElectroMagicTools.logger.info(TextHelper.localize("console.EMT.config.refresh")); } } + + @SubscribeEvent + public void onCraftedEvent(PlayerEvent.ItemCraftedEvent event) { + for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) { + if (event.craftMatrix.getStackInSlot(i) != null && event.craftMatrix.getStackInSlot(i).getItem() instanceof ItemShardCaver && event.player != null) { + event.craftMatrix.getStackInSlot(i).stackSize = 2; + event.craftMatrix.getStackInSlot(i).damageItem(1, event.player); + } + } + } } diff --git a/src/main/resources/assets/electromagictools/lang/en_US.lang b/src/main/resources/assets/electromagictools/lang/en_US.lang index 8713613..d96a6e5 100644 --- a/src/main/resources/assets/electromagictools/lang/en_US.lang +++ b/src/main/resources/assets/electromagictools/lang/en_US.lang @@ -166,6 +166,12 @@ item.EMT.material.shard.tin.name=Tin Shard item.EMT.material.shard.lead.name=Lead Shard item.EMT.material.shard.bronze.name=Bronze Shard +item.EMT.carver.wood.name=Wooden Shard Carver +item.EMT.carver.stone.name=Stone Shard Carver +item.EMT.carver.iron.name=Iron Shard Carver +item.EMT.carver.obsidian.name=Obsidian Shard Carver +item.EMT.carver.diamond.name=Diamond Shard Carver + #=============Block Names============= tile.EMT.shield.name=Shield Block tile.EMT.portablenode.name=Portable Node