From 78fb37d51a825bda520bf69b69e26e9d2e5e1286 Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 10 Nov 2013 22:50:24 -0500 Subject: [PATCH] A few things --- src/dark/api/events/AutoCraftEvent.java | 3 ++ src/dark/api/events/LaserEvent.java | 32 +++++++++----- src/dark/core/common/CoreRecipeLoader.java | 11 +++-- src/dark/core/common/DarkMain.java | 1 + src/dark/core/common/items/EnumOrePart.java | 3 +- src/dark/core/common/items/ItemOreDirv.java | 49 +++++++++++++++++++++ src/dark/core/common/items/ItemParts.java | 4 +- 7 files changed, 88 insertions(+), 15 deletions(-) diff --git a/src/dark/api/events/AutoCraftEvent.java b/src/dark/api/events/AutoCraftEvent.java index 44eefcf81..1797265c8 100644 --- a/src/dark/api/events/AutoCraftEvent.java +++ b/src/dark/api/events/AutoCraftEvent.java @@ -7,6 +7,9 @@ import net.minecraftforge.event.Cancelable; import net.minecraftforge.event.Event; import universalelectricity.core.vector.Vector3; +/** Events called when an automated crafter is working on crafting an item + * + * @author DarkGuardsman */ public class AutoCraftEvent extends Event { World world; diff --git a/src/dark/api/events/LaserEvent.java b/src/dark/api/events/LaserEvent.java index ba7a1b26b..22ff27a21 100644 --- a/src/dark/api/events/LaserEvent.java +++ b/src/dark/api/events/LaserEvent.java @@ -1,6 +1,7 @@ package dark.api.events; -import net.minecraft.block.Block; +import java.util.List; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; @@ -8,7 +9,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.Cancelable; import net.minecraftforge.event.Event; -import net.minecraftforge.event.entity.player.PlayerEvent; import universalelectricity.core.vector.Vector3; /** An event triggered by entities or tiles that create lasers @@ -16,9 +16,9 @@ import universalelectricity.core.vector.Vector3; * @author DarkGuardsman */ public class LaserEvent extends Event { - World world; - Vector3 spot; - Vector3 target; + public World world; + public Vector3 spot; + public Vector3 target; public LaserEvent(World world, Vector3 spot, Vector3 target) { @@ -31,7 +31,7 @@ public class LaserEvent extends Event @Cancelable public static class LaserFireEvent extends LaserEvent { - Object shooter; + public Object shooter; public LaserFireEvent(World world, Vector3 spot, Vector3 target, Object shooter) { @@ -44,8 +44,8 @@ public class LaserEvent extends Event @Cancelable public static class LaserFiredPlayerEvent extends LaserFireEvent { - ItemStack laserItem; - MovingObjectPosition hit; + public ItemStack laserItem; + public MovingObjectPosition hit; public LaserFiredPlayerEvent(EntityPlayer player, MovingObjectPosition hit, ItemStack stack) { @@ -58,7 +58,7 @@ public class LaserEvent extends Event /** Called when a laser is heating up a block to be mined */ public static class LaserMeltBlockEvent extends LaserEvent { - Object shooter; + public Object shooter; public LaserMeltBlockEvent(World world, Vector3 spot, Vector3 hit, Object shooter) { @@ -67,11 +67,23 @@ public class LaserEvent extends Event } } + /** Use this to change what drops when the laser finishes mining a block */ + public static class LaserDropItemEvent extends LaserEvent + { + public List items; + + public LaserDropItemEvent(World world, Vector3 spot, Vector3 hit, List items) + { + super(world, spot, hit); + this.items = items; + } + } + /** Called before a laser mines a block */ @Cancelable public static class LaserMineBlockEvent extends LaserEvent { - Object shooter; + public Object shooter; public LaserMineBlockEvent(World world, Vector3 spot, Vector3 hit, Object shooter) { diff --git a/src/dark/core/common/CoreRecipeLoader.java b/src/dark/core/common/CoreRecipeLoader.java index 0b484a8eb..bf18a58c6 100644 --- a/src/dark/core/common/CoreRecipeLoader.java +++ b/src/dark/core/common/CoreRecipeLoader.java @@ -101,9 +101,9 @@ public class CoreRecipeLoader extends RecipeLoader // part valve GameRegistry.addRecipe(new ShapedOreRecipe(valvePart, new Object[] { "PLP", 'P', "ironPipe", 'L', Block.lever })); //Basic Circuit - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemParts, 1, Parts.CircuitBasic.ordinal()), "!#!", "#@#", "!#!", '@', "plateCopper", '#', Block.glass, '!', "copperWire")); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemParts, 1, Parts.CircuitBasic.ordinal()), "!#!", "#@#", "!#!", '@', copperPlate, '#', Block.glass, '!', "copperWire")); //Advanced Circuit - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemParts, 1, Parts.CircuitAdvanced.ordinal()), "!#!", "#@#", "!#!", '@', "plateCopper", '#', Item.redstone, '!', "copperWire")); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemParts, 1, Parts.CircuitAdvanced.ordinal()), "!#!", "#@#", "!#!", '@', copperPlate, '#', Item.redstone, '!', "copperWire")); //Elite Circuit GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemParts, 1, Parts.CircuitElite.ordinal()), "!#!", "#@#", "!#!", '@', "plateGold", '#', Item.redstone, '!', "copperWire")); @@ -111,7 +111,12 @@ public class CoreRecipeLoader extends RecipeLoader GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemParts, 1, Parts.Tank.ordinal()), " # ", "# #", " # ", '#', bronze)); GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemParts, 1, Parts.Tank.ordinal()), " # ", "# #", " # ", '#', steel)); //Motor - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemParts, 1, Parts.Motor.ordinal()), new Object[] { "@!@", "!#!", "@!@", '!', "ingotSteel", '#', Item.ingotIron, '@', "copperWire" })); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemParts, 1, Parts.Motor.ordinal()), new Object[] { "@!@", "!#!", "@!@", '!', steel, '#', Item.ingotIron, '@', new ItemStack(itemParts, 8, Parts.COIL.ordinal()) })); + //Laser Diode + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemParts, 4, Parts.LASER.ordinal()), new Object[] { " G ", "!S!", " C ", '!', "copperWire", 'G', Block.glass, 'S', Block.sand, 'C', RecipeLoader.circuit })); + //Coil + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemParts, 8, Parts.COIL.ordinal()), new Object[] { "WWW", "W W", "WWW", 'W', "copperWire" })); + } if (itemMetals instanceof ItemOreDirv) diff --git a/src/dark/core/common/DarkMain.java b/src/dark/core/common/DarkMain.java index 1d0f4d22f..25cb885ad 100644 --- a/src/dark/core/common/DarkMain.java +++ b/src/dark/core/common/DarkMain.java @@ -176,6 +176,7 @@ public class DarkMain extends ModPrefab } if (CoreRecipeLoader.itemMetals != null) { + MinecraftForge.EVENT_BUS.register(CoreRecipeLoader.itemMetals); //Ore material recipe loop for (EnumMaterial mat : EnumMaterial.values()) { diff --git a/src/dark/core/common/items/EnumOrePart.java b/src/dark/core/common/items/EnumOrePart.java index f882f1776..e54a54eb7 100644 --- a/src/dark/core/common/items/EnumOrePart.java +++ b/src/dark/core/common/items/EnumOrePart.java @@ -10,7 +10,8 @@ public enum EnumOrePart GEARS("Gears"), TUBE("Tube"), ROD("Rod"), - SCRAPS("Scraps"); + SCRAPS("Scraps"), + MOLTEN_SCRAPS("MoltenScraps"); public String simpleName; diff --git a/src/dark/core/common/items/ItemOreDirv.java b/src/dark/core/common/items/ItemOreDirv.java index e83b14df1..8fbefede7 100644 --- a/src/dark/core/common/items/ItemOreDirv.java +++ b/src/dark/core/common/items/ItemOreDirv.java @@ -2,14 +2,17 @@ package dark.core.common.items; import java.util.List; +import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraftforge.common.Configuration; +import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.oredict.OreDictionary; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import dark.api.events.LaserEvent; import dark.core.common.DarkMain; import dark.core.interfaces.IExtraInfo.IExtraItemInfo; import dark.core.prefab.ItemBasic; @@ -109,4 +112,50 @@ public class ItemOreDirv extends ItemBasic implements IExtraItemInfo } + @ForgeSubscribe + public void LaserSmeltEvent(LaserEvent.LaserDropItemEvent event) + { + if (event.items != null) + { + + for (int i = 0; i < event.items.size(); i++) + { + if (event.items.get(i).itemID == Block.blockIron.blockID) + { + event.items.set(i, EnumMaterial.getStack(EnumMaterial.IRON, EnumOrePart.MOLTEN_SCRAPS, event.items.get(i).stackSize * 9)); + } + else if (event.items.get(i).itemID == Block.blockGold.blockID) + { + event.items.set(i, EnumMaterial.getStack(EnumMaterial.GOLD, EnumOrePart.MOLTEN_SCRAPS, event.items.get(i).stackSize * 9)); + } + else if (event.items.get(i).itemID == Block.oreIron.blockID) + { + event.items.set(i, EnumMaterial.getStack(EnumMaterial.IRON, EnumOrePart.MOLTEN_SCRAPS, event.items.get(i).stackSize)); + } + else if (event.items.get(i).itemID == Block.oreGold.blockID) + { + event.items.set(i, EnumMaterial.getStack(EnumMaterial.GOLD, EnumOrePart.MOLTEN_SCRAPS, event.items.get(i).stackSize)); + } + + String oreName = OreDictionary.getOreName(OreDictionary.getOreID(event.items.get(i))); + + if (oreName != null) + { + for (EnumMaterial mat : EnumMaterial.values()) + { + if (oreName.equalsIgnoreCase("ore" + mat.simpleName) || oreName.equalsIgnoreCase(mat.simpleName + "ore")) + { + event.items.set(i, mat.getStack(EnumOrePart.MOLTEN_SCRAPS, event.items.get(i).stackSize + 1 + event.world.rand.nextInt(3))); + break; + } + else if (oreName.equalsIgnoreCase("ingot" + mat.simpleName) || oreName.equalsIgnoreCase(mat.simpleName + "ingot")) + { + event.items.set(i, mat.getStack(EnumOrePart.MOLTEN_SCRAPS, event.items.get(i).stackSize)); + break; + } + } + } + } + } + } } diff --git a/src/dark/core/common/items/ItemParts.java b/src/dark/core/common/items/ItemParts.java index 5467a592b..92753eab4 100644 --- a/src/dark/core/common/items/ItemParts.java +++ b/src/dark/core/common/items/ItemParts.java @@ -91,7 +91,9 @@ public class ItemParts extends ItemBasic implements IExtraItemInfo CircuitAdvanced("circuitAdvanced"), CircuitElite("circuitElite"), Motor("motor"), - IC("IC_Chip"); + IC("IC_Chip"), + COIL("Coil"), + LASER("LaserDiode"); public String name; public Icon icon;