diff --git a/src/dark/api/ISentryGun.java b/src/dark/api/ISentryGun.java deleted file mode 100644 index 2b7ac82bf..000000000 --- a/src/dark/api/ISentryGun.java +++ /dev/null @@ -1,29 +0,0 @@ -package dark.api; - -import com.dark.interfaces.IBlockActivated; -import com.dark.interfaces.IControlReceiver; - -import net.minecraft.tileentity.TileEntity; -import dark.core.interfaces.IDamageableTile; - -/** Applied to tile entities that are sentry guns - * - * @author DarkGuardsman */ -public interface ISentryGun extends IAimable, IDamageableTile, IControlReceiver, IBlockActivated -{ - /** Gets the type of sentry */ - public SentryType getType(); - - /** Gets the tileEntity this sentry is attached too. Null if its self supporting */ - public TileEntity getPlatform(); - - public static enum SentryType - { - /** Sentry guns that act like entities and are self moving */ - AUTOMATED(), - /** Sentry guns that are manually moved by assisted input and are basically blocks */ - AIMED(), - /** Sentry guns that are mounted by entities like players and are an extension of that entity */ - MOUNTED(); - } -} diff --git a/src/dark/api/events/AutoCraftEvent.java b/src/dark/api/events/AutoCraftEvent.java deleted file mode 100644 index d4a4c0c77..000000000 --- a/src/dark/api/events/AutoCraftEvent.java +++ /dev/null @@ -1,39 +0,0 @@ -package dark.api.events; - -import com.dark.helpers.AutoCraftingManager.IAutoCrafter; - -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; -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; - Vector3 spot; - IAutoCrafter crafter; - ItemStack craftingResult; - - public AutoCraftEvent(World world, Vector3 spot, IAutoCrafter craft, ItemStack stack) - { - this.world = world; - this.spot = spot; - this.crafter = craft; - this.craftingResult = stack; - } - - @Cancelable - /** Called before a crafter checks if it can craft. Use this to cancel crafting */ - public static class PreCraft extends AutoCraftEvent - { - public PreCraft(World world, Vector3 spot, IAutoCrafter craft, ItemStack stack) - { - super(world, spot, craft, stack); - } - } - -} diff --git a/src/dark/api/reciepes/AssemblyObjectManager.java b/src/dark/api/reciepes/AssemblyObjectManager.java deleted file mode 100644 index a62fee4e0..000000000 --- a/src/dark/api/reciepes/AssemblyObjectManager.java +++ /dev/null @@ -1,45 +0,0 @@ -package dark.api.reciepes; - -import java.util.HashMap; - -import net.minecraft.item.ItemStack; - -import com.builtbroken.common.Pair; - -public class AssemblyObjectManager -{ - /** Generic item or block based recipes. Entity recipes are handled by the entity */ - private HashMap, IAssemblyRecipe> itemRecipes = new HashMap(); - - private static AssemblyObjectManager instance; - - public static AssemblyObjectManager instance() - { - if (instance == null) - { - instance = new AssemblyObjectManager(); - } - return instance; - } - - public IAssemblyRecipe getRecipeFor(Object object) - { - IAssemblyRecipe re = null; - - if (re instanceof IAssemblyObject) - { - re = ((IAssemblyObject) object).getRecipe(object); - } - - if (re == null && object instanceof ItemStack) - { - re = itemRecipes.get(new Pair(((ItemStack) object).itemID, ((ItemStack) object).getItemDamage())); - if (re == null && ((ItemStack) object).getItem() instanceof IAssemblyObject) - { - re = ((IAssemblyObject) ((ItemStack) object).getItem()).getRecipe(object); - } - } - - return re; - } -} diff --git a/src/dark/api/reciepes/IAssemblier.java b/src/dark/api/reciepes/IAssemblier.java deleted file mode 100644 index 3b61f7b72..000000000 --- a/src/dark/api/reciepes/IAssemblier.java +++ /dev/null @@ -1,38 +0,0 @@ -package dark.api.reciepes; - -/** Machine or entity that is creating a AssemblyObject. Avoid actually storing the recipe item if - * there is one. Instead do what a few other mods do an give the illusion of the recipe being - * imprinted into the machine while letting the player keep the item - * - * @author DarkGuardsman */ -public interface IAssemblier -{ - /** @param assembler - this, used in the case that an item is the assembler, or even a block - * without a tileEntiy. Eg a Workbench is an example of this as it has no tileEntiy but supports - * crafting - * @return current recipe */ - public IAssemblyRecipe getCurrentRecipe(Object object); - - /** @param assembler - this, used in the case that an item is the assembler, or even a block - * without a tileEntiy. Eg a Workbench is an example of this as it has no tileEntiy but supports - * crafting - * @return true if the recipe was set correctly */ - public boolean setCurrentRecipe(Object assembler, IAssemblyRecipe recipe); - - /** @param assembler - this, used in the case that an item is the assembler, or even a block - * without a tileEntiy. Eg a Workbench is an example of this as it has no tileEntiy but supports - * crafting - * @return current work in progress */ - public IAssemblyObject getCurrentWork(Object assembler); - - /** Checks if the recipe can be created by this assembler. Should be used in cases were an - * assembler is designed for one task type - * - * @param assembler - this, used in the case that an item is the assembler, or even a block - * without a tileEntiy. Eg a Workbench is an example of this as it has no tileEntiy but supports - * crafting - * @param recipe - recipe - * @return */ - public boolean canSupportRecipe(Object assembler, IAssemblyRecipe recipe); - -} diff --git a/src/dark/api/reciepes/IAssemblyObject.java b/src/dark/api/reciepes/IAssemblyObject.java deleted file mode 100644 index e3c18a1bc..000000000 --- a/src/dark/api/reciepes/IAssemblyObject.java +++ /dev/null @@ -1,19 +0,0 @@ -package dark.api.reciepes; - -/** Applied to objects that are not complete and are being constructed from parts slowly. Used mainly - * with assembly line armbots to create large objects like rockets automatically. - * - * @author DarkGuardsman */ -public interface IAssemblyObject -{ - /** Gets the recipe that this object is being build from */ - public IAssemblyRecipe getRecipe(Object object); - - /** Called each time the assembler makes a change to the object. Use this to trigger render - * updates of the object */ - public void onChanged(Object object); - - public void setStep(Object object, int step); - - public int getStep(Object object); -} diff --git a/src/dark/api/reciepes/IAssemblyRecipe.java b/src/dark/api/reciepes/IAssemblyRecipe.java deleted file mode 100644 index 56f1c4ee7..000000000 --- a/src/dark/api/reciepes/IAssemblyRecipe.java +++ /dev/null @@ -1,19 +0,0 @@ -package dark.api.reciepes; - -import net.minecraft.item.ItemStack; - -/** WIP feature to allow an item/block to be slowly built one step at a time. Object can be an - * ItemStack, Entity, or even an object just for this purpose. Though if its not world based you'll - * need to inform the assembler that it exists - * - * @author Darkgaurdsman */ -public interface IAssemblyRecipe -{ - /** Cost in materials(ItemStack) to complete the next step in the build process */ - public ItemStack[] getCostAtStep(Object object, int step); - - /** Number of steps to complete the crafting */ - public int getSteps(Object object); - - public void nextStep(Object Object); -} diff --git a/src/dark/api/reciepes/IBlueprint.java b/src/dark/api/reciepes/IBlueprint.java deleted file mode 100644 index e6f89548c..000000000 --- a/src/dark/api/reciepes/IBlueprint.java +++ /dev/null @@ -1,17 +0,0 @@ -package dark.api.reciepes; - -/** Advanced version of the assemblyRecipe. This is also used to display the recipe like a blueprint - * - * @author DarkGuardsman */ -public interface IBlueprint extends IAssemblyRecipe -{ - /** Check if the blueprint can be used by the object - * - * @param object - player, assembler,drone, entity, block, tileEntity - * @return true if it can be used. This is mainly used for disabling recipes for players */ - public boolean canUseBlueprint(Object object); - - /** Should a blueprint item be created for this blueprint. */ - public boolean createItemFor(); - -} diff --git a/src/dark/api/reciepes/IInjectorMold.java b/src/dark/api/reciepes/IInjectorMold.java deleted file mode 100644 index 4de0cf469..000000000 --- a/src/dark/api/reciepes/IInjectorMold.java +++ /dev/null @@ -1,15 +0,0 @@ -package dark.api.reciepes; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -/** Items that are used as molds by the mold-injector to create items from liquid materials. Eg iron - * armor from molten iron fluid - * - * @author Darkguardsman */ -public interface IInjectorMold -{ - public ItemStack getOutput(FluidStack fluid, ItemStack mold); - - public FluidStack getRequirement(ItemStack mold); -} diff --git a/src/dark/api/reciepes/IProcessable.java b/src/dark/api/reciepes/IProcessable.java deleted file mode 100644 index b8473a587..000000000 --- a/src/dark/api/reciepes/IProcessable.java +++ /dev/null @@ -1,22 +0,0 @@ -package dark.api.reciepes; - -import net.minecraft.item.ItemStack; - -/** Simple interface that allows an item to control how its salvaged, processed, or refined by a - * processor. This is 100% optional as the processor by default can break down most items. The only - * reason to use this is for more complex processing or were the item was created with NBT. - * - * @author Darkgaurdsman */ -public interface IProcessable -{ - /** Can this item be Processed by the machine */ - public boolean canProcess(ProcessorType type, ItemStack stack); - - /** Gets the output array of items when this item is processed by a processor machine - * - * @param type - type of machine see ProcessorTypes enum for info - * @param stack - ItemStack of this item or block - * @return Array of all item outputed, Make sure to return less than or equal to the amount of - * items it takes to craft only one of this item */ - public ItemStack[] getProcesserOutput(ProcessorType type, ItemStack stack); -} diff --git a/src/dark/api/reciepes/MachineRecipeHandler.java b/src/dark/api/reciepes/MachineRecipeHandler.java deleted file mode 100644 index 951818d47..000000000 --- a/src/dark/api/reciepes/MachineRecipeHandler.java +++ /dev/null @@ -1,390 +0,0 @@ -package dark.api.reciepes; - -import java.util.List; -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemArmor; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTool; -import net.minecraft.item.crafting.FurnaceRecipes; -import net.minecraftforge.common.Configuration; -import net.minecraftforge.oredict.OreDictionary; - -import com.builtbroken.common.Pair; -import com.dark.helpers.AutoCraftingManager; - -import cpw.mods.fml.common.registry.GameRegistry; -import dark.api.ColorCode; -import dark.core.basics.EnumMaterial; -import dark.core.basics.EnumOrePart; -import dark.machines.CoreRecipeLoader; - -/** Recipes for ore processor machines - * - * @author DarkGuardsman */ -public class MachineRecipeHandler -{ - private static Random random = new Random(); - private static boolean loadedOres = false; - - static - { - newProcessorRecipe(ProcessorType.CRUSHER, Block.stone, Block.cobblestone); - newProcessorRecipe(ProcessorType.CRUSHER, Block.oreDiamond, Item.diamond); - newProcessorRecipe(ProcessorType.CRUSHER, Block.oreLapis, new ItemStack(Item.dyePowder.itemID, 4, ColorCode.BLUE.ordinal())); - newProcessorRecipe(ProcessorType.CRUSHER, Block.oreRedstone, new ItemStack(Item.redstone.itemID, 4, 0)); - newProcessorRecipe(ProcessorType.CRUSHER, Block.oreEmerald, new ItemStack(Item.redstone.itemID, 4, 0)); - - newProcessorRecipe(ProcessorType.GRINDER, new ItemStack(Block.cobblestone.blockID, 1, 0), new ItemStack(Block.sand.blockID, 1, 0)); - newProcessorRecipe(ProcessorType.GRINDER, Block.glass, Block.sand); - - MachineRecipeHandler.newAltProcessorOutput(ProcessorType.GRINDER, Block.stone, Block.cobblestone); - MachineRecipeHandler.newAltProcessorOutput(ProcessorType.GRINDER, Block.cobblestoneMossy, Block.cobblestone); - MachineRecipeHandler.newAltProcessorOutput(ProcessorType.GRINDER, Block.glass, Block.sand); - MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Item.stick, null); - - MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Block.stone, Block.cobblestone); - MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Block.cobblestoneMossy, Block.cobblestone); - MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Item.stick, null); - - //TODO replace these with ItemOreDirv glass shards - MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, Block.glass, Block.sand); - } - - /** Creates a new recipe for the type of processor machine - * - * @param type - machine type - * @param in - input item, stacksize is ignored - * @param out - output item */ - public static void newProcessorRecipe(ProcessorType type, Object in, Object out) - { - newProcessorRecipe(type, in, out, -1, -1); - } - - /** Creates a new recipe for the type of processor machine - * - * @param type - machine type - * @param in - input item, stacksize is ignored - * @param out - output item - * @param min - min stacksize to return as output - * @param max- max stacksize to return as output */ - public static void newProcessorRecipe(ProcessorType type, Object in, Object out, int min, int max) - { - newProcessorRecipe(type, in, out, min, max, false); - } - - /** Creates a new recipe for the type of processor machine - * - * @param type - machine type - * @param in - input item, stacksize is ignored - * @param out - output item - * @param min - min stacksize to return as output - * @param max- max stacksize to return as output - * @param ignoreNBT - only use this if your item's nbt doesn't play a factor in what items were - * used to craft it */ - public static void newProcessorRecipe(ProcessorType type, Object in, Object out, int min, int max, boolean ignoreNBT) - { - if (in != null && out != null && type != null) - { - ItemStack input = convertToItemStack(in); - ItemStack output = convertToItemStack(out); - if (input != null && output != null && type.recipes != null) - { - if (!ignoreNBT && (input.getTagCompound() != null || input.isItemEnchanted())) - { - System.out.println("[MachineRecipeHandler]Error: NBT or Enchanted Items must use the IProccesable interface to properlly handle recipe outputs."); - System.out.println("[MachineRecipeHandler]Item>> Data: " + input.toString() + " Name: " + input.getItem().getUnlocalizedName()); - return; - } - if (min == -1) - { - min = output.stackSize; - } - if (max == -1 || max < min) - { - max = output.stackSize; - } - type.recipes.put(new Pair(input.itemID, input.getItemDamage()), new ProcessorRecipe(output, min, max)); - } - } - } - - /** Used to track items that should be converted to different items during salvaging. */ - public static void newAltProcessorOutput(ProcessorType type, Object in, Object out) - { - if (in != null && out != null && type != null) - { - ItemStack input = convertToItemStack(in); - ItemStack output = convertToItemStack(out); - if (input != null && output != null && type.altOutput != null) - { - type.altOutput.put(new Pair(input.itemID, input.getItemDamage()), output); - } - } - } - - /** Marks an itemstack as unsalvagable by all processors */ - public static void banProcessingOfItem(ItemStack stack) - { - if (stack != null) - { - for (ProcessorType type : ProcessorType.values()) - { - banProcessingOfItem(type, stack); - } - } - } - - /** Marks an itemstack as unusable by processors. This will jam the processor if the item enters - * it */ - public static void banProcessingOfItem(ProcessorType type, ItemStack stack) - { - if (type != null && stack != null) - { - type.banList.add(new Pair(stack.itemID, stack.getItemDamage())); - } - } - - /** Converts an object input into an itemstack for use */ - private static ItemStack convertToItemStack(Object object) - { - if (object instanceof ItemStack) - { - ItemStack stack = (ItemStack) object; - if (stack.getItemDamage() < 0) - { - stack.setItemDamage(0); - } - return stack; - } - if (object instanceof Block) - { - return new ItemStack(((Block) object).blockID, 1, -1); - } - if (object instanceof Item) - { - return new ItemStack(((Item) object).itemID, 1, -1); - } - return null; - } - - /** Gets the lit of items that are created from the input item stack. General this will be an - * array of one item. However, in salavaging cases it can be up to 8 items. - * - * @param type - Processor type - * @param inputStack - item stack input ignores stacksize - * @return array of itemStacks */ - public static ItemStack[] getProcessorOutput(ProcessorType type, ItemStack inputStack) - { - if (inputStack != null && type != null) - { - ItemStack[] reList = null; - if (inputStack.getItem() instanceof IProcessable) - { - if (!((IProcessable) inputStack.getItem()).canProcess(type, inputStack)) - { - return null; - } - reList = ((IProcessable) inputStack.getItem()).getProcesserOutput(type, inputStack); - } - if (reList == null) - { - reList = getOuputNormal(type, inputStack); - } - if (reList == null) - { - //TODO Disabled due to bug and needs to be fixed to make the processors more functional - //reList = salvageItem(type, inputStack); - } - return reList; - } - return null; - } - - /** Salvages an itemStack for the items used to craft it - * - * @param type - processor type used to determine damage results - * @param stack - itemStack being salvaged - * @return Array of all items salvaged */ - public static ItemStack[] salvageItem(ProcessorType type, ItemStack stack) - { - return salvageItem(type, stack, true); - } - - /** Salvages an itemStack for the items used to craft it - * - * @param type - processor type used to determine damage results - * @param stack - itemStack being salvaged - * @param damage - damage the output items. Eg ironIngot becomes ironDust, or ironScraps - * @return Array of all items salvaged */ - public static ItemStack[] salvageItem(ProcessorType type, ItemStack stack, boolean damage) - { - float bar = 0.1f; - //Allow tools and armor to be salvaged but at a very low rate - if ((stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemTool) && stack.isItemDamaged()) - { - bar = (stack.getItemDamage() / stack.getMaxDamage()); - } - ItemStack[] reList = salvageItem(stack, bar); - if (damage && reList != null && type.altOutput != null) - { - for (int i = 0; i < reList.length; i++) - { - if (type.altOutput.containsKey(new Pair(reList[i].itemID, reList[i].getItemDamage()))) - { - reList[i] = convertToItemStack(type.altOutput.get(new Pair(reList[i].itemID, reList[i].getItemDamage()))); - } - } - } - return reList; - } - - /** Salvages an itemStack for the items used to craft it - * - * @param stack - itemStack being salvaged - * @param bar - chance per item that the random must be above inorder to salvage the output - * @return Array of all items salvaged */ - public static ItemStack[] salvageItem(ItemStack stack, float bar) - { - //TODO find a way around having to force recipe to be the same stack size of the salvage. Maybe percentage based salvaging or min stacksize from machine? - ItemStack[] recipeList = AutoCraftingManager.getReverseRecipe(stack.copy(), stack.stackSize); - if (recipeList != null) - { - ItemStack[] reList = new ItemStack[recipeList.length]; - boolean items = false; - for (int i = 0; i < recipeList.length; i++) - { - if (random.nextFloat() >= bar) - { - reList[i] = recipeList[i].copy(); - items = true; - if (recipeList[i].itemID < Block.blocksList.length && Block.blocksList[recipeList[i].itemID] != null && recipeList[i].getItemDamage() > 16) - { - reList[i].setItemDamage(0); - } - - } - } - return items ? reList : null; - } - return null; - } - - public static ItemStack[] getOuputNormal(ProcessorType type, ItemStack stack) - { - if (type.recipes != null) - { - ProcessorRecipe re = type.recipes.get(new Pair(stack.itemID, -1)); - if (re == null || re.output == null) - { - re = type.recipes.get(new Pair(stack.itemID, stack.getItemDamage())); - } - if (type.altOutput != null && (re == null || re.output == null)) - { - return new ItemStack[] { type.altOutput.get(new Pair(stack.itemID, stack.getItemDamage())) }; - } - if (re != null && re.output != null) - { - ItemStack output = re.output.copy(); - output.stackSize = Math.min(re.maxItemsOut, re.minItemsOut + random.nextInt(re.minItemsOut)); - if (re.chancePerItem < 1.0f) - { - - } - return new ItemStack[] { output }; - } - } - - return null; - } - - public static void parseOreNames(Configuration config) - { - if (!loadedOres && CoreRecipeLoader.itemMetals != null && config.get("Ore", "processOreDictionary", true, "Scans the ore dictionary and adds other mods ore to the machine recipes").getBoolean(true)) - { - for (EnumMaterial mat : EnumMaterial.values()) - { //Ingots - List ingots = OreDictionary.getOres("ingot" + mat.simpleName); - ingots.addAll(OreDictionary.getOres(mat.simpleName + "ingot")); - //plate - List plates = OreDictionary.getOres("plate" + mat.simpleName); - plates.addAll(OreDictionary.getOres(mat.simpleName + "plate")); - //ore - List ores = OreDictionary.getOres("ore" + mat.simpleName); - ores.addAll(OreDictionary.getOres(mat.simpleName + "ore")); - //dust - List dusts = OreDictionary.getOres("dust" + mat.simpleName); - dusts.addAll(OreDictionary.getOres(mat.simpleName + "dust")); - for (ItemStack du : dusts) - { - if (mat.shouldCreateItem(EnumOrePart.INGOTS) && config.get("Ore", "OverrideDustSmelthing", true, "Overrides other mods dust smelting so the ingots smelt as the same item.").getBoolean(true)) - { - FurnaceRecipes.smelting().addSmelting(du.itemID, du.getItemDamage(), mat.getStack(EnumOrePart.INGOTS, 1), 0.6f); - } - } - - for (ItemStack ing : ingots) - { - if (mat.shouldCreateItem(EnumOrePart.DUST)) - { - MachineRecipeHandler.newProcessorRecipe(ProcessorType.GRINDER, ing, mat.getStack(EnumOrePart.DUST, 1)); - MachineRecipeHandler.newAltProcessorOutput(ProcessorType.GRINDER, ing, mat.getStack(EnumOrePart.DUST, 1)); - } - if (mat.shouldCreateItem(EnumOrePart.SCRAPS)) - { - MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, ing, mat.getStack(EnumOrePart.SCRAPS, 1)); - MachineRecipeHandler.newProcessorRecipe(ProcessorType.CRUSHER, ing, mat.getStack(EnumOrePart.SCRAPS, 1)); - } - if (mat.shouldCreateItem(EnumOrePart.INGOTS)) - { - GameRegistry.addShapelessRecipe(mat.getStack(EnumOrePart.INGOTS, 1), new Object[] { ing }); - } - } - for (ItemStack pla : plates) - { - if (mat.shouldCreateItem(EnumOrePart.DUST)) - { - - MachineRecipeHandler.newProcessorRecipe(ProcessorType.GRINDER, pla, mat.getStack(EnumOrePart.DUST, 1)); - MachineRecipeHandler.newAltProcessorOutput(ProcessorType.GRINDER, pla, mat.getStack(EnumOrePart.DUST, 1)); - - } - if (mat.shouldCreateItem(EnumOrePart.SCRAPS)) - { - - MachineRecipeHandler.newProcessorRecipe(ProcessorType.CRUSHER, pla, mat.getStack(EnumOrePart.SCRAPS, 1)); - MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, pla, mat.getStack(EnumOrePart.SCRAPS, 1)); - - } - if (mat.shouldCreateItem(EnumOrePart.PLATES)) - { - GameRegistry.addShapelessRecipe(mat.getStack(EnumOrePart.PLATES, 1), new Object[] { pla }); - if (config.get("Ore", "OverridePlateCrafting", true, "Overrides other mods metal plate crafting. As well creates new recipes for mod ingots without plate crafting.").getBoolean(true)) - { - GameRegistry.addShapelessRecipe(mat.getStack(EnumOrePart.INGOTS, 4), new Object[] { pla }); - } - } - } - for (ItemStack ore : ores) - { - if (mat.shouldCreateItem(EnumOrePart.RUBBLE)) - { - MachineRecipeHandler.newProcessorRecipe(ProcessorType.CRUSHER, ore, mat.getStack(EnumOrePart.RUBBLE, 1), 1, 2); - } - if (mat.shouldCreateItem(EnumOrePart.DUST)) - { - MachineRecipeHandler.newProcessorRecipe(ProcessorType.GRINDER, ore, mat.getStack(EnumOrePart.DUST, 1), 1, 3); - } - if (mat.shouldCreateItem(EnumOrePart.INGOTS) && config.get("Ore", "OverrideOreSmelthing", true, "Overrides other mods smelting recipes for ingots").getBoolean(true)) - { - FurnaceRecipes.smelting().addSmelting(ore.itemID, ore.getItemDamage(), mat.getStack(EnumOrePart.INGOTS, 1), 0.6f); - } - } - - } - loadedOres = true; - } - } -} diff --git a/src/dark/api/reciepes/ProcessorRecipe.java b/src/dark/api/reciepes/ProcessorRecipe.java deleted file mode 100644 index 38db8e16d..000000000 --- a/src/dark/api/reciepes/ProcessorRecipe.java +++ /dev/null @@ -1,23 +0,0 @@ -package dark.api.reciepes; - -import net.minecraft.item.ItemStack; - -/** Processor Recipe output Container. Input is controlled by the processor recipes class. */ -public class ProcessorRecipe -{ - /** Output of the recipe */ - public ItemStack output; - /** Chance per item after the stack size has been calculated from min and max size */ - public float chancePerItem = 1.0f; - /** Min the recipe can output */ - public int minItemsOut = -1; - /** Max the recipe can output */ - public int maxItemsOut = -1; - - public ProcessorRecipe(ItemStack output, int min, int max) - { - this.output = output; - this.minItemsOut = min; - this.maxItemsOut = max; - } -} diff --git a/src/dark/api/reciepes/ProcessorType.java b/src/dark/api/reciepes/ProcessorType.java deleted file mode 100644 index 26fd0b240..000000000 --- a/src/dark/api/reciepes/ProcessorType.java +++ /dev/null @@ -1,28 +0,0 @@ -package dark.api.reciepes; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import net.minecraft.item.ItemStack; - -import com.builtbroken.common.Pair; - -/** Enum of machines that support a simple A -> B processor recipe format. More complex machine will - * have there own recipe handlers - * - * @author Darkguardsman */ -public enum ProcessorType -{ - /** Pistons that smash the object */ - CRUSHER(), - /** Several disks that shred the item up */ - GRINDER(), - /** Grinds the edge or surface of the item sharpening it */ - SHARPENING_STONE(), - /** Breaks down an item carefully giving an almost complete output of item used to craft it */ - SALVAGER(); - public HashMap, ProcessorRecipe> recipes = new HashMap(); - public HashMap, ItemStack> altOutput = new HashMap(); - public List> banList = new ArrayList(); -} diff --git a/src/dark/core/interfaces/IDamageableTile.java b/src/dark/core/interfaces/IDamageableTile.java deleted file mode 100644 index fe0f59f3c..000000000 --- a/src/dark/core/interfaces/IDamageableTile.java +++ /dev/null @@ -1,40 +0,0 @@ -package dark.core.interfaces; - -import com.dark.interfaces.IBlockActivated; - -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.DamageSource; - -/** Used by tiles that want to pretend to be living objects. Will require the use of this interface - * as well spawning a EntityTileDamage entity as its location. Then entity if larger than the tile - * will pass all interaction events to the block - * - * @author DarkGuardsman */ -public interface IDamageableTile extends IBlockActivated -{ - /** Same as attackEntityFrom in Entity.class - * - * @param source - DamageSource/DamageType - * @param ammount - amount of damage - * @return */ - public boolean onDamageTaken(DamageSource source, float ammount); - - /** Is this tile considered too still be alive. Allows for the tile to remain while being - * considered dead */ - public boolean isAlive(); - - /** Current health of the tile */ - public float getDamage(); - - /** Sets the tiles heath - * - * @param health - amount hit points - * @param increase - increase instead of replace */ - public void setDamage(float health); - - /** Max hit points of the object */ - public float getMaxHealth(); - - /** Can the potion be used on the Entity that is translating damage for the TileEntity */ - public boolean canApplyPotion(PotionEffect par1PotionEffect); -} diff --git a/src/dark/core/interfaces/IMultiBlock.java b/src/dark/core/interfaces/IMultiBlock.java deleted file mode 100644 index dcd57e9a2..000000000 --- a/src/dark/core/interfaces/IMultiBlock.java +++ /dev/null @@ -1,23 +0,0 @@ -package dark.core.interfaces; - -import com.dark.interfaces.IBlockActivated; - -import net.minecraft.tileentity.TileEntity; -import universalelectricity.core.vector.Vector3; - -/** Interface to be applied to tile entity blocks that occupies more than one block space. Useful for - * large machines. - * - * @author Calclavia */ -public interface IMultiBlock extends IBlockActivated -{ - /** Called when this multiblock is created - * - * @param placedPosition - The position the block was placed at */ - public void onCreate(Vector3 placedPosition); - - /** Called when one of the multiblocks of this block is destroyed - * - * @param callingBlock - The tile entity who called the onDestroy function */ - public void onDestroy(TileEntity callingBlock); -} diff --git a/src/dark/core/prefab/ModPrefab.java b/src/dark/core/prefab/ModPrefab.java index 7cde6d13d..b82618636 100644 --- a/src/dark/core/prefab/ModPrefab.java +++ b/src/dark/core/prefab/ModPrefab.java @@ -24,10 +24,7 @@ public abstract class ModPrefab public String DOMAIN = this.getDomain(); public String PREFIX = DOMAIN + ":"; - public String DIRECTORY_NO_SLASH = "assets/" + DOMAIN + "/"; - public String DIRECTORY = "/" + DIRECTORY_NO_SLASH; - public String LANGUAGE_PATH = DIRECTORY + "languages/"; - public String SOUND_PATH = DIRECTORY + "audio/"; + private static Triple date; diff --git a/src/dark/core/prefab/RecipeLoader.java b/src/dark/core/prefab/RecipeLoader.java deleted file mode 100644 index 537e99988..000000000 --- a/src/dark/core/prefab/RecipeLoader.java +++ /dev/null @@ -1,92 +0,0 @@ -package dark.core.prefab; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - -/** Recipe system to make it easier to load recipes for a mod - * - * @author DarkGuardsman */ -public abstract class RecipeLoader -{ - protected static Object circuit; - protected static Object circuit2; - protected static Object circuit3; - protected static Object steel; - protected static Object steelPlate; - protected static Object motor; - protected static Object bronze; - protected static Object bronzePlate; - protected static Object copper; - protected static Object copperPlate; - - static boolean loaded = false; - - /** Should be called to load recipes. The main class only loads ore name items to decrease - * chances of missing items in recipes */ - public void loadRecipes() - { - if (!loaded) - { - /* Vinalla items load first */ - circuit = Item.redstoneRepeater; - circuit2 = Item.comparator; - steel = Item.ingotIron; - steelPlate = Item.ingotGold; - copper = Item.ingotIron; - copperPlate = Item.ingotGold; - motor = Block.pistonBase; - bronze = Item.ingotIron; - bronzePlate = Item.ingotGold; - /* Ore directory items load over the vinalla ones if they are present */ - if (OreDictionary.getOres("basicCircuit").size() > 0) - { - circuit = "basicCircuit"; - } - if (OreDictionary.getOres("advancedCircuit").size() > 0) - { - circuit = "advancedCircuit"; - } - if (OreDictionary.getOres("ingotSteel").size() > 0) - { - steel = "ingotSteel"; - } - if (OreDictionary.getOres("plateSteel").size() > 0) - { - steelPlate = "plateSteel"; - } - if (OreDictionary.getOres("motor").size() > 0) - { - motor = "motor"; - } - if (OreDictionary.getOres("ingotBronze").size() > 0) - { - bronze = "ingotBronze"; - } - if (OreDictionary.getOres("plateBronze").size() > 0) - { - bronzePlate = "plateBronze"; - } - if (OreDictionary.getOres("copperBronze").size() > 0) - { - bronze = "copperBronze"; - } - if (OreDictionary.getOres("copperBronze").size() > 0) - { - bronzePlate = "copperBronze"; - } - } - } - - public ItemStack setStackSize(ItemStack stack, int amount) - { - if (stack != null) - { - ItemStack itemStack = stack.copy(); - itemStack.stackSize = amount; - return itemStack; - } - return stack; - } -} diff --git a/src/dark/core/prefab/entities/EntityTileDamage.java b/src/dark/core/prefab/entities/EntityTileDamage.java deleted file mode 100644 index 7e1522542..000000000 --- a/src/dark/core/prefab/entities/EntityTileDamage.java +++ /dev/null @@ -1,230 +0,0 @@ -package dark.core.prefab.entities; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.PotionEffect; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import net.minecraft.util.Vec3; -import net.minecraft.world.World; -import universalelectricity.core.vector.Vector3; - -import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; - -import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import dark.core.interfaces.IDamageableTile; - -/** Entity designed to take damage and apply it to the tile from an Entity. Simulates the tile is - * alive and can be harmed by normal AIs without additional code. - * - * @author DarkGuardsman */ -public class EntityTileDamage extends EntityLiving implements IEntityAdditionalSpawnData -{ - - public TileEntity host; - int hp = 100; - - public EntityTileDamage(World par1World) - { - super(par1World); - this.isImmuneToFire = true; - this.setSize(1.1F, 1.1F); - } - - public EntityTileDamage(TileEntity c) - { - this(c.worldObj); - this.setPosition(c.xCoord + 0.5, c.yCoord, c.zCoord + 0.5); - this.host = c; - } - - public EntityTileDamage(Vector3 v, TileEntity c) - { - this(c.worldObj); - this.setPosition(v); - this.host = c; - } - - public void setPosition(Vector3 vec) - { - this.setPosition(vec.x, vec.y, vec.z); - } - - @Override - public boolean attackEntityFrom(DamageSource source, float ammount) - { - if (this.host instanceof IDamageableTile) - { - return ((IDamageableTile) this.host).onDamageTaken(source, ammount); - } - else - { - if ((hp -= ammount) <= 0) - { - if (this.host != null) - { - Vector3 vec = new Vector3(this.host.xCoord, this.host.yCoord, this.host.zCoord); - int id = vec.getBlockID(this.worldObj); - int meta = vec.getBlockID(this.worldObj); - Block block = Block.blocksList[id]; - if (block != null) - { - block.breakBlock(this.worldObj, this.host.xCoord, this.host.yCoord, this.host.zCoord, id, meta); - } - vec.setBlock(this.worldObj, 0); - } - this.setDead(); - - } - return true; - } - } - - @Override - public boolean isPotionApplicable(PotionEffect par1PotionEffect) - { - if (par1PotionEffect != null && this.host instanceof IDamageableTile) - { - return ((IDamageableTile) this.host).canApplyPotion(par1PotionEffect); - } - return false; - } - - @Override - public String getEntityName() - { - return "EntityTileTarget"; - } - - @Override - public void writeSpawnData(ByteArrayDataOutput data) - { - if (this.host != null) - { - data.writeInt(this.host.xCoord); - data.writeInt(this.host.yCoord); - data.writeInt(this.host.zCoord); - } - } - - @Override - public void readSpawnData(ByteArrayDataInput data) - { - try - { - this.host = this.worldObj.getBlockTileEntity(data.readInt(), data.readInt(), data.readInt()); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - @Override - public void onUpdate() - { - if (!this.worldObj.isRemote) - { - if (this.host == null || this.host.isInvalid()) - { - this.setDead(); - } - else if (this.host instanceof IDamageableTile && !((IDamageableTile) this.host).isAlive()) - { - this.setDead(); - } - else - { - this.updatePotionEffects(); - this.setPosition(this.host.xCoord + 0.5, this.host.yCoord, this.host.zCoord + 0.5); - } - } - } - - @Override - public void readEntityFromNBT(NBTTagCompound nbttagcompound) - { - // TODO Auto-generated method stub - - } - - @Override - public void moveEntity(double par1, double par3, double par5) - { - - } - - @Override - public void writeEntityToNBT(NBTTagCompound nbttagcompound) - { - // TODO Auto-generated method stub - - } - - @Override - protected boolean canTriggerWalking() - { - return false; - } - - @Override - public AxisAlignedBB getCollisionBox(Entity par1Entity) - { - return AxisAlignedBB.getBoundingBox(this.posX - .6, this.posY - .6, this.posZ - .6, this.posX + .6, this.posY + .6, this.posZ + .6); - - } - - @Override - public boolean canBeCollidedWith() - { - return true; - } - - @SideOnly(Side.CLIENT) - @Override - public boolean isInRangeToRenderVec3D(Vec3 par1Vec3) - { - return false; - } - - @SideOnly(Side.CLIENT) - @Override - public boolean isInRangeToRenderDist(double par1) - { - return false; - } - - @Override - public void setVelocity(double par1, double par3, double par5) - { - - } - - @Override - public boolean isInsideOfMaterial(Material par1Material) - { - return false; - } - - @Override - public boolean interact(EntityPlayer player) - { - if (this.host != null && player != null) - { - Block block = Block.blocksList[this.worldObj.getBlockId(this.host.xCoord, this.host.yCoord, this.host.zCoord)]; - if (block != null) - { - return block.onBlockActivated(this.worldObj, this.host.xCoord, this.host.yCoord, this.host.zCoord, player, 0, 0, 0, 0); - } - } - return false; - } -} diff --git a/src/dark/core/prefab/machine/BlockMulti.java b/src/dark/core/prefab/machine/BlockMulti.java deleted file mode 100644 index 6f6e18eb6..000000000 --- a/src/dark/core/prefab/machine/BlockMulti.java +++ /dev/null @@ -1,181 +0,0 @@ -package dark.core.prefab.machine; - -import java.util.List; -import java.util.Random; -import java.util.Set; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.world.World; -import net.minecraftforge.common.Configuration; -import universalelectricity.core.UniversalElectricity; -import universalelectricity.core.vector.Vector3; - -import com.builtbroken.common.Pair; -import com.dark.DarkCore; -import com.dark.IExtraInfo.IExtraBlockInfo; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import dark.machines.CoreMachine; - -public class BlockMulti extends BlockContainer implements IExtraBlockInfo -{ - public String textureName = null; - public String channel = ""; - - public BlockMulti() - { - super(CoreMachine.CONFIGURATION.getBlock("MultiBlock", DarkCore.getNextID()).getInt(), UniversalElectricity.machine); - this.setHardness(0.8F); - this.setUnlocalizedName("multiBlock"); - this.setChannel(CoreMachine.CHANNEL); - } - - public BlockMulti setChannel(String channel) - { - this.channel = channel; - return this; - } - - @Override - public BlockMulti setTextureName(String name) - { - this.textureName = name; - return this; - } - - public void makeFakeBlock(World worldObj, Vector3 position, Vector3 mainBlock) - { - worldObj.setBlock(position.intX(), position.intY(), position.intZ(), this.blockID); - ((TileEntityMulti) worldObj.getBlockTileEntity(position.intX(), position.intY(), position.intZ())).setMainBlock(mainBlock); - } - - @SideOnly(Side.CLIENT) - @Override - public void registerIcons(IconRegister iconRegister) - { - if (this.textureName != null) - { - this.blockIcon = iconRegister.registerIcon(this.textureName); - } - else - { - super.registerIcons(iconRegister); - } - } - - @Override - public void breakBlock(World world, int x, int y, int z, int par5, int par6) - { - TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - - if (tileEntity instanceof TileEntityMulti) - { - ((TileEntityMulti) tileEntity).onBlockRemoval(); - } - - super.breakBlock(world, x, y, z, par5, par6); - } - - /** Called when the block is right clicked by the player. This modified version detects electric - * items and wrench actions on your machine block. Do not override this function. Use - * machineActivated instead! (It does the same thing) */ - @Override - public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) - { - TileEntityMulti tileEntity = (TileEntityMulti) par1World.getBlockTileEntity(x, y, z); - return tileEntity.onBlockActivated(par1World, x, y, z, par5EntityPlayer); - } - - /** Returns the quantity of items to drop on block destruction. */ - @Override - public int quantityDropped(Random par1Random) - { - return 0; - } - - @Override - public int getRenderType() - { - return -1; - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - @Override - public TileEntity createNewTileEntity(World var1) - { - return new TileEntityMulti(this.channel); - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World par1World, int x, int y, int z) - { - TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z); - Vector3 mainBlockPosition = ((TileEntityMulti) tileEntity).mainBlockPosition; - - if (mainBlockPosition != null) - { - int mainBlockID = par1World.getBlockId(mainBlockPosition.intX(), mainBlockPosition.intY(), mainBlockPosition.intZ()); - - if (mainBlockID > 0) - { - return Block.blocksList[mainBlockID].getPickBlock(target, par1World, mainBlockPosition.intX(), mainBlockPosition.intY(), mainBlockPosition.intZ()); - } - } - - return null; - } - - @Override - public void getTileEntities(int blockID, Set>> list) - { - list.add(new Pair>("DMMultiBlock", TileEntityMulti.class)); - - } - - @Override - @SideOnly(Side.CLIENT) - public void getClientTileEntityRenderers(List, TileEntitySpecialRenderer>> list) - { - - } - - @Override - public boolean hasExtraConfigs() - { - // TODO Auto-generated method stub - return false; - } - - @Override - public void loadExtraConfigs(Configuration config) - { - // TODO Auto-generated method stub - - } - - @Override - public void loadOreNames() - { - // TODO Auto-generated method stub - - } -} \ No newline at end of file diff --git a/src/dark/core/prefab/machine/EnergyHelper.java b/src/dark/core/prefab/machine/EnergyHelper.java deleted file mode 100644 index 9c5a1c839..000000000 --- a/src/dark/core/prefab/machine/EnergyHelper.java +++ /dev/null @@ -1,82 +0,0 @@ -package dark.core.prefab.machine; - -import com.dark.prefab.TileEntityEnergyMachine; - -import ic2.api.item.IElectricItemManager; -import ic2.api.item.ISpecialElectricItem; -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; -import universalelectricity.compatibility.Compatibility; -import universalelectricity.core.item.ElectricItemHelper; -import universalelectricity.core.item.IItemElectric; - -public class EnergyHelper -{ - - /** Recharges electric item. */ - public static void recharge(ItemStack itemStack, TileEntityEnergyMachine machine) - { - if (itemStack != null) - { - if (itemStack.getItem() instanceof IItemElectric) - { - machine.setEnergyStored(machine.getEnergyStored() - ElectricItemHelper.chargeItem(itemStack, machine.getProvide(ForgeDirection.UNKNOWN))); - - } - else if (itemStack.getItem() instanceof ISpecialElectricItem) - { - ISpecialElectricItem electricItem = (ISpecialElectricItem) itemStack.getItem(); - IElectricItemManager manager = electricItem.getManager(itemStack); - float energy = Math.max(machine.getProvide(ForgeDirection.UNKNOWN) * Compatibility.IC2_RATIO, 0); - energy = manager.charge(itemStack, (int) (energy * Compatibility.TO_IC2_RATIO), 0, false, false) * Compatibility.IC2_RATIO; - machine.provideElectricity(energy, true); - } - } - } - - /** Discharges electric item. */ - public static void discharge(ItemStack itemStack, TileEntityEnergyMachine machine) - { - if (itemStack != null) - { - if (itemStack.getItem() instanceof IItemElectric) - { - machine.setEnergyStored(machine.getEnergyStored() + ElectricItemHelper.dischargeItem(itemStack, machine.getRequest(ForgeDirection.UNKNOWN))); - - } - else if (itemStack.getItem() instanceof ISpecialElectricItem) - { - ISpecialElectricItem electricItem = (ISpecialElectricItem) itemStack.getItem(); - - if (electricItem.canProvideEnergy(itemStack)) - { - IElectricItemManager manager = electricItem.getManager(itemStack); - float energy = Math.max(machine.getRequest(ForgeDirection.UNKNOWN) * Compatibility.IC2_RATIO, 0); - energy = manager.discharge(itemStack, (int) (energy * Compatibility.TO_IC2_RATIO), 0, false, false); - machine.receiveElectricity(energy, true); - } - } - } - } - - public static boolean isBatteryItem(ItemStack itemStack) - { - if (itemStack != null) - { - if (itemStack.getItem() instanceof IItemElectric) - { - return true; - } - else if (itemStack.getItem() instanceof ISpecialElectricItem) - { - ISpecialElectricItem electricItem = (ISpecialElectricItem) itemStack.getItem(); - - if (electricItem.canProvideEnergy(itemStack)) - { - return true; - } - } - } - return false; - } -} diff --git a/src/dark/core/prefab/machine/TileEntityMulti.java b/src/dark/core/prefab/machine/TileEntityMulti.java deleted file mode 100644 index a9ab82844..000000000 --- a/src/dark/core/prefab/machine/TileEntityMulti.java +++ /dev/null @@ -1,141 +0,0 @@ -package dark.core.prefab.machine; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.INetworkManager; -import net.minecraft.network.packet.Packet; -import net.minecraft.network.packet.Packet250CustomPayload; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import universalelectricity.core.vector.Vector3; -import universalelectricity.prefab.network.IPacketReceiver; - -import com.dark.network.PacketHandler; -import com.google.common.io.ByteArrayDataInput; - -import dark.core.interfaces.IMultiBlock; - -/** This is a multiblock to be used for blocks that are bigger than one block. - * - * @author Calclavia */ -public class TileEntityMulti extends TileEntity implements IPacketReceiver -{ - // The the position of the main block - public Vector3 mainBlockPosition; - public String channel; - - public TileEntityMulti() - { - - } - - public TileEntityMulti(String channel) - { - this.channel = channel; - } - - public void setMainBlock(Vector3 mainBlock) - { - this.mainBlockPosition = mainBlock; - - if (!this.worldObj.isRemote) - { - this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); - } - } - - @Override - public Packet getDescriptionPacket() - { - if (this.mainBlockPosition != null) - { - if (this.channel == null || this.channel == "" && this.getBlockType() instanceof BlockMulti) - { - this.channel = ((BlockMulti) this.getBlockType()).channel; - } - - return PacketHandler.instance().getTilePacket(this.channel, this, this.mainBlockPosition.intX(), this.mainBlockPosition.intY(), this.mainBlockPosition.intZ()); - - } - - return null; - } - - public void onBlockRemoval() - { - if (this.mainBlockPosition != null) - { - TileEntity tileEntity = this.worldObj.getBlockTileEntity(this.mainBlockPosition.intX(), this.mainBlockPosition.intY(), this.mainBlockPosition.intZ()); - - if (tileEntity != null && tileEntity instanceof IMultiBlock) - { - IMultiBlock mainBlock = (IMultiBlock) tileEntity; - - if (mainBlock != null) - { - mainBlock.onDestroy(this); - } - } - } - } - - public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer) - { - if (this.mainBlockPosition != null) - { - TileEntity tileEntity = this.worldObj.getBlockTileEntity(this.mainBlockPosition.intX(), this.mainBlockPosition.intY(), this.mainBlockPosition.intZ()); - - if (tileEntity != null) - { - if (tileEntity instanceof IMultiBlock) - { - return ((IMultiBlock) tileEntity).onActivated(par5EntityPlayer); - } - } - } - - return false; - } - - /** Reads a tile entity from NBT. */ - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - this.mainBlockPosition = new Vector3(nbt.getCompoundTag("mainBlockPosition")); - } - - /** Writes a tile entity to NBT. */ - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - - if (this.mainBlockPosition != null) - { - nbt.setCompoundTag("mainBlockPosition", this.mainBlockPosition.writeToNBT(new NBTTagCompound())); - } - } - - /** Determines if this TileEntity requires update calls. - * - * @return True if you want updateEntity() to be called, false if not */ - @Override - public boolean canUpdate() - { - return false; - } - - @Override - public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream) - { - try - { - this.mainBlockPosition = new Vector3(dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - } - catch (Exception e) - { - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/src/dark/core/prefab/sentry/BlockSentryGun.java b/src/dark/core/prefab/sentry/BlockSentryGun.java deleted file mode 100644 index 0e28193de..000000000 --- a/src/dark/core/prefab/sentry/BlockSentryGun.java +++ /dev/null @@ -1,120 +0,0 @@ -package dark.core.prefab.sentry; - -import java.util.Set; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.tileentity.TileEntity; - -import com.builtbroken.common.Pair; -import com.dark.CoreRegistry; -import com.dark.prefab.BlockMachine; -import com.dark.prefab.ItemBlockHolder; - -import dark.machines.CoreMachine; - -/** Actual block that is the sentry gun. Mainly a place holder as the sentry guns need something to - * exist threw that is not an entity. Renders need to still be handled by the respective mod. - * Especial item renders as this just creates the block and reservers the meta slot - * - * @author DarkGuardsman */ -public class BlockSentryGun extends BlockMachine -{ - static TileEntitySentry[] sentryGuns = new TileEntitySentry[16]; - static String[] sentryGunNames = new String[16]; - static int registeredGuns = 0; - static int[] sentryBlockIds = new int[1]; - - public BlockSentryGun(int v) - { - super(CoreMachine.CONFIGURATION, "DMSentryGun" + v, Material.iron); - this.setResistance(100); - this.setHardness(100); - } - - /** Make sure to let others know your claimed IDs or add configs so we don't run into issues. As - * well the slot is the meta data value the gun will be created with. Any number over 15 will - * create another block then use its 16 meta values. */ - public static void registerSentry(int slot, String name, Class clazz) - { - try - { - //Expands the sentry gun list as needed; - if (slot > sentryGuns.length) - { - int b = (slot / 16) + 1; - sentryBlockIds = new int[b]; - TileEntitySentry[] guns = new TileEntitySentry[b * 16]; - for (int s = 0; s < sentryGuns.length; s++) - { - guns[s] = sentryGuns[s]; - } - sentryGuns = guns; - } - if (clazz != null && sentryGuns[slot] == null) - { - int b = (slot / 16); - sentryBlockIds[b] = -1; - sentryGuns[slot] = clazz.newInstance(); - sentryGunNames[slot] = name; - registeredGuns++; - } - else if (sentryGuns[slot] != null) - { - throw new IllegalArgumentException("Sentry gun slot " + slot + " is already occupied by " + sentryGuns[slot] + " when adding " + clazz); - } - - } - catch (InstantiationException e) - { - e.printStackTrace(); - } - catch (IllegalAccessException e) - { - e.printStackTrace(); - } - catch (IllegalArgumentException e) - { - throw e; - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - /** Called by the core when this block is about to be created. If there are no registered sentry - * guns then this block doesn't exist. */ - public static void createAndRegister() - { - if (registeredGuns > 0) - { - for (int b = 0; b < sentryBlockIds.length; b++) - { - if (sentryBlockIds[b] == -1) - { - Block block = new BlockSentryGun(b); - if (block != null) - { - CoreRegistry.registredBlocks.put(block, "DMSentryGun" + b); - CoreRegistry.proxy.registerBlock(block, ItemBlockHolder.class, "DMSentryGun" + b, CoreMachine.MOD_ID); - CoreRegistry.finishCreation(block); - sentryBlockIds[b] = block.blockID; - } - } - } - } - } - - @Override - public void getTileEntities(int blockID, Set>> list) - { - for (int t = 0; t < sentryGuns.length; t++) - { - if (sentryGuns[t] != null) - { - list.add(new Pair("DMSentry_" + sentryGunNames[t], sentryGuns[t].getClass())); - } - } - } -} diff --git a/src/dark/core/prefab/sentry/BlockSentryPlatform.java b/src/dark/core/prefab/sentry/BlockSentryPlatform.java deleted file mode 100644 index 6ed722622..000000000 --- a/src/dark/core/prefab/sentry/BlockSentryPlatform.java +++ /dev/null @@ -1,22 +0,0 @@ -package dark.core.prefab.sentry; - -import com.dark.prefab.BlockMachine; - -import net.minecraft.block.material.Material; -import dark.machines.CoreMachine; - -/** Base platform for all sentry and turret's created to use for power, logic, and inventory - * connections to the world. - * - * @author DarkGuardsman */ -public class BlockSentryPlatform extends BlockMachine -{ - - public BlockSentryPlatform() - { - super(CoreMachine.CONFIGURATION, "DMSentryPlatform", Material.iron); - this.setResistance(100); - this.setHardness(100); - } - -} diff --git a/src/dark/core/prefab/sentry/TileEntityAutoSentry.java b/src/dark/core/prefab/sentry/TileEntityAutoSentry.java deleted file mode 100644 index 32ae08588..000000000 --- a/src/dark/core/prefab/sentry/TileEntityAutoSentry.java +++ /dev/null @@ -1,15 +0,0 @@ -package dark.core.prefab.sentry; - -public class TileEntityAutoSentry extends TileEntitySentry -{ - public TileEntityAutoSentry(float maxDamage) - { - super(maxDamage); - } - - @Override - public SentryType getType() - { - return SentryType.AUTOMATED; - } -} diff --git a/src/dark/core/prefab/sentry/TileEntityGunPlatform.java b/src/dark/core/prefab/sentry/TileEntityGunPlatform.java deleted file mode 100644 index 07ede2854..000000000 --- a/src/dark/core/prefab/sentry/TileEntityGunPlatform.java +++ /dev/null @@ -1,21 +0,0 @@ -package dark.core.prefab.sentry; - -import com.dark.terminal.TileEntityTerminal; - -public class TileEntityGunPlatform extends TileEntityTerminal -{ - public TileEntityGunPlatform() - { - super(0, 0); - } - - public TileEntityGunPlatform(float wattsPerTick) - { - super(wattsPerTick); - } - - public TileEntityGunPlatform(float wattsPerTick, float maxEnergy) - { - super(wattsPerTick, maxEnergy); - } -} diff --git a/src/dark/core/prefab/sentry/TileEntityMountedSentry.java b/src/dark/core/prefab/sentry/TileEntityMountedSentry.java deleted file mode 100644 index 926c04409..000000000 --- a/src/dark/core/prefab/sentry/TileEntityMountedSentry.java +++ /dev/null @@ -1,15 +0,0 @@ -package dark.core.prefab.sentry; - -public class TileEntityMountedSentry extends TileEntitySentry -{ - public TileEntityMountedSentry(float maxDamage) - { - super(maxDamage); - } - - @Override - public SentryType getType() - { - return SentryType.MOUNTED; - } -} diff --git a/src/dark/core/prefab/sentry/TileEntitySentry.java b/src/dark/core/prefab/sentry/TileEntitySentry.java deleted file mode 100644 index 0d1d5c396..000000000 --- a/src/dark/core/prefab/sentry/TileEntitySentry.java +++ /dev/null @@ -1,322 +0,0 @@ -package dark.core.prefab.sentry; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.packet.Packet; -import net.minecraft.potion.PotionEffect; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import net.minecraftforge.common.ForgeDirection; -import universalelectricity.core.vector.Vector3; - -import com.dark.helpers.MathHelper; -import com.dark.helpers.RayTraceHelper; -import com.dark.network.PacketHandler; -import com.dark.prefab.TileEntityMachine; -import com.google.common.io.ByteArrayDataInput; - -import cpw.mods.fml.common.network.Player; -import dark.api.ISentryGun; -import dark.core.prefab.entities.EntityTileDamage; -import dark.machines.CoreMachine; - -/** Prefab tileEntity for creating senty guns that can be of type aimed, mounted, or automated. - * Contains most of the code for a sentry gun to operate short of aiming and operating logic. This - * means the classes that extend this still need to tell the sentry were to aim. As well this - * doesn't handle any firing events or damage events. This is only a shell for the sentry to be - * created. Everything else is up to the sub classes of this class. - * - * @author DarkGuardsman */ -public abstract class TileEntitySentry extends TileEntityMachine implements ISentryGun -{ - protected EntityTileDamage entitySentry = null; - protected TileEntityGunPlatform platform; - protected ForgeDirection mountingSide = ForgeDirection.DOWN; - - protected boolean isAlive = true, isRunning = false, requiresPlatform = true; - private float damage = 0.0f; - private final float maxDamage; - - private Vector3 rotation = new Vector3(), targetRotation = new Vector3(), prevRotation = new Vector3(); - protected float roationSpeed = 10f, minPitch = -30, maxPitch = 30, minYaw = -180, maxYaw = 180, size = 1.0f; - - public TileEntitySentry(float maxDamage) - { - this.maxDamage = maxDamage; - } - - /* ****************************************************** - * Logic code - * ****************************************************** */ - @Override - public void updateEntity() - { - super.updateEntity(); - if (this.isFunctioning()) - { - if (this.entitySentry == null) - { - this.getDamageEntity(true); - } - this.updateRotation(); - } - } - - @Override - public boolean canFunction() - { - return super.canFunction() && this.isAlive() && (!this.requiresPlatform || this.requiresPlatform && this.getPlatform() != null); - } - - /* ****************************************************** - * Sentry code - * ****************************************************** */ - - @Override - public SentryType getType() - { - return SentryType.AIMED; - } - - @Override - public TileEntity getPlatform() - { - Vector3 mountVec = new Vector3(this).modifyPositionFromSide(mountingSide); - if (platform == null || platform.isInvalid() || !new Vector3(platform).equals(mountVec)) - { - TileEntity entity = mountVec.getTileEntity(this.worldObj); - if (entity instanceof TileEntityGunPlatform) - { - this.platform = (TileEntityGunPlatform) entity; - } - } - return platform; - } - - /* ****************************************************** - * Rotation code - * ****************************************************** */ - public void updateRotation() - { - this.prevRotation = this.getRotation(); - this.rotation.x = MathHelper.clamp((float) MathHelper.updateRotation(this.rotation.x, this.targetRotation.x, this.roationSpeed), this.minPitch, this.maxPitch); - this.rotation.y = MathHelper.clamp((float) MathHelper.updateRotation(this.rotation.y, this.targetRotation.y, this.roationSpeed), this.minYaw, this.maxYaw); - } - - @Override - public Vector3 getLook() - { - //TODO store this value so a new vector is not created each call - return new Vector3(RayTraceHelper.getLook(this.getRotation().floatX(), this.getRotation().floatY(), this.size)); - } - - @Override - public Vector3 getRotation() - { - if (this.rotation == null) - { - this.rotation = new Vector3(); - } - return rotation; - } - - @Override - public void updateRotation(float pitch, float yaw, float roll) - { - if (this.targetRotation == null) - { - this.targetRotation = this.getRotation(); - } - this.targetRotation.x += pitch; - this.targetRotation.y += yaw; - this.targetRotation.z += roll; - } - - @Override - public void setRotation(float pitch, float yaw, float roll) - { - this.getRotation().x = pitch; - this.getRotation().y = yaw; - this.getRotation().z = roll; - } - - /* ****************************************************** - * Damage Code - * ****************************************************** */ - - @Override - public boolean onDamageTaken(DamageSource source, float ammount) - { - if (source != null && ammount > 0) - { - if (source.equals(DamageSource.onFire)) - { - //TODO cause heat damage slowly but not right away - //TODO check for heat sources around the sentry - //TODO mess with the sentries abilities when over heated - return false; - } - else - { - this.setDamage(this.getDamage() - ammount); - - if (this.getDamage() <= 0) - { - this.isAlive = false; - if (this.entitySentry != null) - { - this.entitySentry.setDead(); - } - this.entitySentry = null; - } - return true; - } - } - return false; - } - - @Override - public boolean isAlive() - { - return this.isAlive; - } - - @Override - public float getDamage() - { - return this.damage; - } - - @Override - public void setDamage(float health) - { - this.damage = health; - } - - @Override - public float getMaxHealth() - { - return this.maxDamage; - } - - @Override - public boolean canApplyPotion(PotionEffect par1PotionEffect) - { - return false; - } - - public EntityTileDamage getDamageEntity() - { - return this.getDamageEntity(isAlive); - } - - public EntityTileDamage getDamageEntity(boolean create) - { - if (entitySentry == null || entitySentry.isDead && create) - { - AxisAlignedBB box = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1); - List list = this.worldObj.getEntitiesWithinAABB(EntityTileDamage.class, box); - for (EntityTileDamage entity : list) - { - if (!entity.isDead && (entity.host == null || entity.host == this)) - { - entity.host = this; - this.entitySentry = entity; - } - else - { - this.entitySentry = new EntityTileDamage(this); - } - } - } - return entitySentry; - } - - /* ****************************************************** - * Player interaction - * ****************************************************** */ - - @Override - public boolean onActivated(EntityPlayer entityPlayer) - { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean keyTyped(EntityPlayer player, int keycode) - { - // TODO Auto-generated method stub - return false; - } - - /* ****************************************************** - * Save/Load/PacketHandling - * ****************************************************** */ - - @Override - public void writeToNBT(NBTTagCompound nbt) - { - super.writeToNBT(nbt); - if (this.getRotation() != null) - { - nbt.setFloat("pitch", this.getRotation().floatX()); - nbt.setFloat("yaw", this.getRotation().floatY()); - nbt.setFloat("roll", this.getRotation().floatZ()); - } - if (this.targetRotation != null) - { - nbt.setFloat("npitch", this.targetRotation.floatX()); - nbt.setFloat("nyaw", this.targetRotation.floatY()); - nbt.setFloat("nroll", this.targetRotation.floatZ()); - } - nbt.setFloat("damage", this.getDamage()); - nbt.setByte("mountSide", (byte) this.mountingSide.ordinal()); - } - - @Override - public void readFromNBT(NBTTagCompound nbt) - { - super.readFromNBT(nbt); - this.getRotation().x = nbt.getFloat("pitch"); - this.getRotation().y = nbt.getFloat("yaw"); - this.getRotation().z = nbt.getFloat("roll"); - this.targetRotation = new Vector3(); - this.targetRotation.x = nbt.getFloat("pitch"); - this.targetRotation.y = nbt.getFloat("yaw"); - this.targetRotation.z = nbt.getFloat("roll"); - this.setDamage(nbt.getFloat("damage")); - this.mountingSide = ForgeDirection.getOrientation(nbt.getByte("mountSide")); - } - - @Override - public Packet getDescriptionPacket() - { - return PacketHandler.instance().getTilePacket(CoreMachine.CHANNEL, this, "Desc", this.isRunning, this.rotation); - } - - @Override - public boolean simplePacket(String id, ByteArrayDataInput dis, Player player) - { - try - { - if (this.worldObj.isRemote && !super.simplePacket(id, dis, player)) - { - if (id.equalsIgnoreCase("Desc")) - { - this.functioning = dis.readBoolean(); - this.rotation = PacketHandler.readVector3(dis); - return true; - } - } - } - catch (Exception e) - { - e.printStackTrace(); - } - return false; - } -} diff --git a/src/dark/machines/CoreMachine.java b/src/dark/machines/CoreMachine.java index 5d07a3302..364f4d1ec 100644 --- a/src/dark/machines/CoreMachine.java +++ b/src/dark/machines/CoreMachine.java @@ -22,6 +22,7 @@ import com.dark.IndustryTabs; import com.dark.fluid.EnumGas; import com.dark.network.PacketDataWatcher; import com.dark.network.PacketHandler; +import com.dark.prefab.BlockMulti; import com.dark.prefab.ItemBlockHolder; import cpw.mods.fml.common.FMLCommonHandler; @@ -57,7 +58,6 @@ import dark.core.basics.ItemParts.Parts; import dark.core.prefab.ModPrefab; import dark.core.prefab.entities.EntityTestCar; import dark.core.prefab.entities.ItemVehicleSpawn; -import dark.core.prefab.machine.BlockMulti; import dark.machines.deco.BlockBasalt; import dark.machines.deco.BlockColorGlass; import dark.machines.deco.BlockColorGlowGlass; @@ -106,16 +106,11 @@ public class CoreMachine extends ModPrefab /** Can over pressure of devices do area damage */ public static boolean overPressureDamage, zeroRendering, zeroAnimation, zeroGraphics; - public static BlockMulti blockMulti; - @Instance(MOD_ID) private static CoreMachine instance; public static CoreRecipeLoader recipeLoader; - - public static final String[] dyeColorNames = new String[] { "Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "Silver", "Gray", "Pink", "Lime", "Yellow", "LightBlue", "Magenta", "Orange", "White" }; - public static final Color[] dyeColors = new Color[] { Color.black, Color.red, Color.green, new Color(139, 69, 19), Color.BLUE, new Color(75, 0, 130), Color.cyan, new Color(192, 192, 192), Color.gray, Color.pink, new Color(0, 255, 0), Color.yellow, new Color(135, 206, 250), Color.magenta, Color.orange, Color.white }; - + public static CoreMachine getInstance() { if (instance == null) @@ -181,7 +176,7 @@ public class CoreMachine extends ModPrefab { MinecraftForge.EVENT_BUS.register(CoreRecipeLoader.itemMetals); } - FMLLog.info(" Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages."); + FMLLog.info(" Loaded: " + TranslationHelper.loadLanguages(DarkCore.LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages."); proxy.init(); } @@ -197,9 +192,10 @@ public class CoreMachine extends ModPrefab } if (CoreRecipeLoader.itemMetals instanceof ItemOreDirv) { - IndustryTabs.tabIndustrial().itemStack = EnumMaterial.getStack(EnumMaterial.IRON, EnumOrePart.GEARS, 1); + IndustryTabs.tabIndustrial().itemStack = EnumMaterial.getStack(EnumMaterial.IRON, EnumOrePart.GEARS, 1); + CoreRecipeLoader.parseOreNames(CONFIGURATION); } - MachineRecipeHandler.parseOreNames(CONFIGURATION); + CONFIGURATION.save(); } @@ -219,12 +215,7 @@ public class CoreMachine extends ModPrefab CoreMachine.zeroRendering = CONFIGURATION.get("Graphics", "DisableAllRendering", false, "Replaces all model renderers with single block forms").getBoolean(false); CoreMachine.zeroGraphics = CONFIGURATION.get("Graphics", "DisableAllGraphics", false, "Disables extra effects that models and renders have. Such as particles, and text").getBoolean(false); } - /* BLOCKS */ - Block m = CoreRegistry.createNewBlock("DMBlockMulti", CoreMachine.MOD_ID, BlockMulti.class, false); - if (m instanceof BlockMulti) - { - blockMulti = (BlockMulti) m; - } + /* BLOCKS */ CoreRecipeLoader.blockSteamGen = CoreRegistry.createNewBlock("DMBlockSteamMachine", CoreMachine.MOD_ID, BlockSmallSteamGen.class, ItemBlockHolder.class); CoreRecipeLoader.blockOre = CoreRegistry.createNewBlock("DMBlockOre", CoreMachine.MOD_ID, BlockOre.class, ItemBlockOre.class); CoreRecipeLoader.blockWire = CoreRegistry.createNewBlock("DMBlockWire", CoreMachine.MOD_ID, BlockWire.class, ItemBlockWire.class); diff --git a/src/dark/machines/CoreRecipeLoader.java b/src/dark/machines/CoreRecipeLoader.java index 5ea10b886..8b09ca08f 100644 --- a/src/dark/machines/CoreRecipeLoader.java +++ b/src/dark/machines/CoreRecipeLoader.java @@ -1,9 +1,15 @@ package dark.machines; +import java.util.List; + +import com.dark.prefab.RecipeLoader; + import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; +import net.minecraftforge.common.Configuration; +import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; import cpw.mods.fml.common.registry.GameRegistry; import dark.api.ColorCode; @@ -19,7 +25,6 @@ import dark.core.basics.ItemCommonTool; import dark.core.basics.ItemOreDirv; import dark.core.basics.ItemParts; import dark.core.basics.ItemParts.Parts; -import dark.core.prefab.RecipeLoader; import dark.machines.deco.BlockBasalt; import dark.machines.generators.BlockSolarPanel; import dark.machines.items.ItemReadoutTools; @@ -294,4 +299,91 @@ public class CoreRecipeLoader extends RecipeLoader } } + + public static void parseOreNames(Configuration config) + { + if (config.get("Ore", "processOreDictionary", true, "Scans the ore dictionary and adds other mods ore to the machine recipes").getBoolean(true)) + { + for (EnumMaterial mat : EnumMaterial.values()) + { //Ingots + List ingots = OreDictionary.getOres("ingot" + mat.simpleName); + ingots.addAll(OreDictionary.getOres(mat.simpleName + "ingot")); + //plate + List plates = OreDictionary.getOres("plate" + mat.simpleName); + plates.addAll(OreDictionary.getOres(mat.simpleName + "plate")); + //ore + List ores = OreDictionary.getOres("ore" + mat.simpleName); + ores.addAll(OreDictionary.getOres(mat.simpleName + "ore")); + //dust + List dusts = OreDictionary.getOres("dust" + mat.simpleName); + dusts.addAll(OreDictionary.getOres(mat.simpleName + "dust")); + for (ItemStack du : dusts) + { + if (mat.shouldCreateItem(EnumOrePart.INGOTS) && config.get("Ore", "OverrideDustSmelthing", true, "Overrides other mods dust smelting so the ingots smelt as the same item.").getBoolean(true)) + { + FurnaceRecipes.smelting().addSmelting(du.itemID, du.getItemDamage(), mat.getStack(EnumOrePart.INGOTS, 1), 0.6f); + } + } + + for (ItemStack ing : ingots) + { + if (mat.shouldCreateItem(EnumOrePart.DUST)) + { + MachineRecipeHandler.newProcessorRecipe(ProcessorType.GRINDER, ing, mat.getStack(EnumOrePart.DUST, 1)); + MachineRecipeHandler.newAltProcessorOutput(ProcessorType.GRINDER, ing, mat.getStack(EnumOrePart.DUST, 1)); + } + if (mat.shouldCreateItem(EnumOrePart.SCRAPS)) + { + MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, ing, mat.getStack(EnumOrePart.SCRAPS, 1)); + MachineRecipeHandler.newProcessorRecipe(ProcessorType.CRUSHER, ing, mat.getStack(EnumOrePart.SCRAPS, 1)); + } + if (mat.shouldCreateItem(EnumOrePart.INGOTS)) + { + GameRegistry.addShapelessRecipe(mat.getStack(EnumOrePart.INGOTS, 1), new Object[] { ing }); + } + } + for (ItemStack pla : plates) + { + if (mat.shouldCreateItem(EnumOrePart.DUST)) + { + + MachineRecipeHandler.newProcessorRecipe(ProcessorType.GRINDER, pla, mat.getStack(EnumOrePart.DUST, 1)); + MachineRecipeHandler.newAltProcessorOutput(ProcessorType.GRINDER, pla, mat.getStack(EnumOrePart.DUST, 1)); + + } + if (mat.shouldCreateItem(EnumOrePart.SCRAPS)) + { + + MachineRecipeHandler.newProcessorRecipe(ProcessorType.CRUSHER, pla, mat.getStack(EnumOrePart.SCRAPS, 1)); + MachineRecipeHandler.newAltProcessorOutput(ProcessorType.CRUSHER, pla, mat.getStack(EnumOrePart.SCRAPS, 1)); + + } + if (mat.shouldCreateItem(EnumOrePart.PLATES)) + { + GameRegistry.addShapelessRecipe(mat.getStack(EnumOrePart.PLATES, 1), new Object[] { pla }); + if (config.get("Ore", "OverridePlateCrafting", true, "Overrides other mods metal plate crafting. As well creates new recipes for mod ingots without plate crafting.").getBoolean(true)) + { + GameRegistry.addShapelessRecipe(mat.getStack(EnumOrePart.INGOTS, 4), new Object[] { pla }); + } + } + } + for (ItemStack ore : ores) + { + if (mat.shouldCreateItem(EnumOrePart.RUBBLE)) + { + MachineRecipeHandler.newProcessorRecipe(ProcessorType.CRUSHER, ore, mat.getStack(EnumOrePart.RUBBLE, 1), 1, 2); + } + if (mat.shouldCreateItem(EnumOrePart.DUST)) + { + MachineRecipeHandler.newProcessorRecipe(ProcessorType.GRINDER, ore, mat.getStack(EnumOrePart.DUST, 1), 1, 3); + } + if (mat.shouldCreateItem(EnumOrePart.INGOTS) && config.get("Ore", "OverrideOreSmelthing", true, "Overrides other mods smelting recipes for ingots").getBoolean(true)) + { + FurnaceRecipes.smelting().addSmelting(ore.itemID, ore.getItemDamage(), mat.getStack(EnumOrePart.INGOTS, 1), 0.6f); + } + } + + } + } + } } diff --git a/src/dark/machines/client/gui/GuiInvMachineBase.java b/src/dark/machines/client/gui/GuiInvMachineBase.java deleted file mode 100644 index 4da18d35b..000000000 --- a/src/dark/machines/client/gui/GuiInvMachineBase.java +++ /dev/null @@ -1,9 +0,0 @@ -package dark.machines.client.gui; - -/** Same as the GuiMachineBase but supports inventory pages - * - * @author DarkGuardsman */ -public class GuiInvMachineBase -{ - -} diff --git a/src/dark/machines/client/gui/GuiMachineBase.java b/src/dark/machines/client/gui/GuiMachineBase.java deleted file mode 100644 index 858986e50..000000000 --- a/src/dark/machines/client/gui/GuiMachineBase.java +++ /dev/null @@ -1,193 +0,0 @@ -package dark.machines.client.gui; - -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - -import com.dark.DarkCore; -import com.dark.prefab.TileEntityMachine; -import com.dark.prefab.invgui.GuiBase; -import com.dark.prefab.invgui.GuiButtonImage; -import com.dark.prefab.invgui.GuiButtonImage.ButtonIcon; - -import cpw.mods.fml.client.FMLClientHandler; -import dark.machines.CoreMachine; - -/** To be used with all machine that have a gui to allow generic settings and feature all all devices - * - * @author DarkGuardsman */ -public class GuiMachineBase extends GuiBase -{ - - public static final ResourceLocation TEXTURE = new ResourceLocation(CoreMachine.getInstance().DOMAIN, DarkCore.GUI_DIRECTORY + "gui_grey.png"); - - protected static final int MAX_BUTTON_ID = 3; - protected TileEntityMachine tileEntity; - protected EntityPlayer entityPlayer; - protected Object mod; - protected int guiID = -1, guiID2 = -1, guiID3 = -1; - protected ButtonIcon guiIcon = ButtonIcon.CHEST, guiIcon2 = ButtonIcon.PERSON, guiIcon3 = ButtonIcon.BLANK; - protected String invName = "Home", invName2 = "2", invName3 = "3"; - - public GuiMachineBase(Object mod, EntityPlayer player, TileEntityMachine tileEntity) - { - this.tileEntity = tileEntity; - this.entityPlayer = player; - this.guiSize.y = 380 / 2; - this.mod = mod; - } - - @SuppressWarnings("unchecked") - @Override - public void initGui() - { - super.initGui(); - this.buttonList.clear(); - - // Inventory, Should be the Gui the machine opens to unless it has no inventory - if (guiID != -1) - this.buttonList.add(new GuiButtonImage(0, (this.width - this.guiSize.intX()) / 2 - 22, (this.height - this.guiSize.intY()) / 2 + 0, guiIcon)); - - // Machine settings - if (guiID2 != -1) - this.buttonList.add(new GuiButtonImage(1, (this.width - this.guiSize.intX()) / 2 - 22, (this.height - this.guiSize.intY()) / 2 + 22, guiIcon2)); - - if (guiID3 != -1) - this.buttonList.add(new GuiButtonImage(2, (this.width - this.guiSize.intX()) / 2 - 22, (this.height - this.guiSize.intY()) / 2 + 44, guiIcon3)); - - } - - @Override - protected void actionPerformed(GuiButton button) - { - switch (button.id) - { - case 0: - { - if (guiID != -1) - entityPlayer.openGui(mod, guiID, tileEntity.worldObj, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); - break; - } - case 1: - { - if (guiID2 != -1) - entityPlayer.openGui(mod, guiID2, tileEntity.worldObj, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); - break; - } - case 2: - { - if (guiID3 != -1) - entityPlayer.openGui(mod, guiID3, tileEntity.worldObj, tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); - break; - } - } - } - - /** Draw the foreground layer for the GuiContainer (everything in front of the items) */ - @Override - protected void drawForegroundLayer(int x, int y, float var1) - { - this.fontRenderer.drawString("\u00a77" + tileEntity.getInvName(), (int) (this.guiSize.intX() / 2 - 7 * 2.5), 4, 4210752); - /** Render Tool Tips */ - if (((GuiButtonImage) this.buttonList.get(0)).isIntersect(x, y) && guiID != -1) - { - this.drawTooltip(x - this.c.intX(), y - this.c.intY() + 10, invName); - } - else if (((GuiButtonImage) this.buttonList.get(1)).isIntersect(x, y) && guiID2 != -1) - { - this.drawTooltip(x - this.c.intX(), y - this.c.intY() + 10, invName2); - } - else if (((GuiButtonImage) this.buttonList.get(2)).isIntersect(x, y) && guiID3 != -1) - { - this.drawTooltip(x - this.c.intX(), y - this.c.intY() + 10, invName3); - } - } - - /** Draw the background layer for the GuiContainer (everything behind the items) */ - @Override - protected void drawBackgroundLayer(int x, int y, float var1) - { - FMLClientHandler.instance().getClient().renderEngine.bindTexture(TEXTURE); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - int containerWidth = (this.width - this.guiSize.intX()) / 2; - int containerHeight = (this.height - this.guiSize.intY()) / 2; - this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.guiSize.intX(), this.guiSize.intY()); - } - - @Override - public void drawTooltip(int x, int y, String... toolTips) - { - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - if (toolTips != null) - { - int var5 = 0; - int var6; - int var7; - - for (var6 = 0; var6 < toolTips.length; ++var6) - { - var7 = this.fontRenderer.getStringWidth(toolTips[var6]); - - if (var7 > var5) - { - var5 = var7; - } - } - - var6 = x + 12; - var7 = y - 12; - int var9 = 8; - - if (toolTips.length > 1) - { - var9 += 2 + (toolTips.length - 1) * 10; - } - - if (this.c.intY() + var7 + var9 + 6 > this.height) - { - var7 = this.height - var9 - this.c.intY() - 6; - } - - this.zLevel = 300.0F; - int var10 = -267386864; - this.drawGradientRect(var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3, var10, var10); - this.drawGradientRect(var6 - 3, var7 + var9 + 3, var6 + var5 + 3, var7 + var9 + 4, var10, var10); - this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 + var9 + 3, var10, var10); - this.drawGradientRect(var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3, var10, var10); - this.drawGradientRect(var6 + var5 + 3, var7 - 3, var6 + var5 + 4, var7 + var9 + 3, var10, var10); - int var11 = 1347420415; - int var12 = (var11 & 16711422) >> 1 | var11 & -16777216; - this.drawGradientRect(var6 - 3, var7 - 3 + 1, var6 - 3 + 1, var7 + var9 + 3 - 1, var11, var12); - this.drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3, var7 + var9 + 3 - 1, var11, var12); - this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1, var11, var11); - this.drawGradientRect(var6 - 3, var7 + var9 + 2, var6 + var5 + 3, var7 + var9 + 3, var12, var12); - - for (int var13 = 0; var13 < toolTips.length; ++var13) - { - String var14 = "\u00a77" + toolTips[var13]; - - this.fontRenderer.drawStringWithShadow(var14, var6, var7, -1); - - if (var13 == 0) - { - var7 += 2; - } - - var7 += 10; - } - - this.zLevel = 0.0F; - } - } - -} diff --git a/src/dark/machines/client/gui/GuiMachineContainer.java b/src/dark/machines/client/gui/GuiMachineContainer.java deleted file mode 100644 index 325f8e064..000000000 --- a/src/dark/machines/client/gui/GuiMachineContainer.java +++ /dev/null @@ -1,206 +0,0 @@ -package dark.machines.client.gui; - -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.tileentity.TileEntity; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - -import com.dark.prefab.TileEntityMachine; -import com.dark.prefab.invgui.GuiButtonImage; -import com.dark.prefab.invgui.GuiButtonImage.ButtonIcon; - -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -@SideOnly(Side.CLIENT) -public abstract class GuiMachineContainer extends GuiContainer -{ - protected static final int MAX_BUTTON_ID = 3; - protected TileEntityMachine tileEntity; - protected EntityPlayer entityPlayer; - protected Object mod; - protected int guiID = -1, guiID2 = -1, guiID3 = -1; - protected ButtonIcon guiIcon = ButtonIcon.CHEST, guiIcon2 = ButtonIcon.PERSON, guiIcon3 = ButtonIcon.BLANK; - protected String invName = "Home", invName2 = "2", invName3 = "3"; - - protected int containerWidth; - protected int containerHeight; - - public GuiMachineContainer(Object mod, Container container, InventoryPlayer inventoryPlayer, TileEntityMachine tileEntity) - { - super(container); - this.tileEntity = tileEntity; - this.entityPlayer = inventoryPlayer.player; - this.ySize = 380 / 2; - this.mod = mod; - } - - @SuppressWarnings("unchecked") - @Override - public void initGui() - { - super.initGui(); - this.buttonList.clear(); - containerWidth = (this.width - this.xSize) / 2; - containerHeight = (this.height - this.ySize) / 2; - if (guiID != -1) - this.buttonList.add(new GuiButtonImage(0, containerWidth - 22, containerHeight + 0, guiIcon)); - if (guiID2 != -1) - this.buttonList.add(new GuiButtonImage(1, containerWidth - 22, containerHeight + 22, guiIcon2)); - if (guiID3 != -1) - this.buttonList.add(new GuiButtonImage(2, containerWidth - 22, containerHeight + 44, guiIcon3)); - - } - - @Override - protected void actionPerformed(GuiButton button) - { - super.actionPerformed(button); - switch (button.id) - { - case 0: - { - if (guiID != -1) - this.entityPlayer.openGui(mod, guiID, this.tileEntity.worldObj, this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord); - break; - } - case 1: - { - if (guiID2 != -1) - this.entityPlayer.openGui(mod, guiID2, this.tileEntity.worldObj, this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord); - break; - } - case 2: - { - if (guiID3 != -1) - this.entityPlayer.openGui(mod, guiID3, this.tileEntity.worldObj, this.tileEntity.xCoord, this.tileEntity.yCoord, this.tileEntity.zCoord); - break; - } - } - } - - /** Draw the foreground layer for the GuiContainer (everything in front of the items) */ - @Override - protected void drawGuiContainerForegroundLayer(int x, int y) - { - this.fontRenderer.drawString("\u00a77" + tileEntity.getInvName(), (int) (this.xSize / 2 - 7 * 2.5), 4, 4210752); - - /** Render Tool Tips */ - if (((GuiButtonImage) this.buttonList.get(0)).isIntersect(x, y)) - { - this.drawTooltip(x - this.guiLeft, y - this.guiTop + 10, invName); - } - else if (((GuiButtonImage) this.buttonList.get(1)).isIntersect(x, y)) - { - this.drawTooltip(x - this.guiLeft, y - this.guiTop + 10, invName2); - } - else if (((GuiButtonImage) this.buttonList.get(2)).isIntersect(x, y)) - { - this.drawTooltip(x - this.guiLeft, y - this.guiTop + 10, invName3); - } - } - - /** Draw the background layer for the GuiContainer (everything behind the items) */ - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int x, int y) - { - FMLClientHandler.instance().getClient().renderEngine.bindTexture(GuiMachineBase.TEXTURE); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - int containerWidth = (this.width - this.xSize) / 2; - int containerHeight = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize); - } - - public void drawTooltip(int x, int y, String... toolTips) - { - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); - - if (toolTips != null) - { - int var5 = 0; - int var6; - int var7; - - for (var6 = 0; var6 < toolTips.length; ++var6) - { - var7 = this.fontRenderer.getStringWidth(toolTips[var6]); - - if (var7 > var5) - { - var5 = var7; - } - } - - var6 = x + 12; - var7 = y - 12; - int var9 = 8; - - if (toolTips.length > 1) - { - var9 += 2 + (toolTips.length - 1) * 10; - } - - if (this.guiTop + var7 + var9 + 6 > this.height) - { - var7 = this.height - var9 - this.guiTop - 6; - } - - this.zLevel = 300.0F; - int var10 = -267386864; - this.drawGradientRect(var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3, var10, var10); - this.drawGradientRect(var6 - 3, var7 + var9 + 3, var6 + var5 + 3, var7 + var9 + 4, var10, var10); - this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 + var9 + 3, var10, var10); - this.drawGradientRect(var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3, var10, var10); - this.drawGradientRect(var6 + var5 + 3, var7 - 3, var6 + var5 + 4, var7 + var9 + 3, var10, var10); - int var11 = 1347420415; - int var12 = (var11 & 16711422) >> 1 | var11 & -16777216; - this.drawGradientRect(var6 - 3, var7 - 3 + 1, var6 - 3 + 1, var7 + var9 + 3 - 1, var11, var12); - this.drawGradientRect(var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3, var7 + var9 + 3 - 1, var11, var12); - this.drawGradientRect(var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1, var11, var11); - this.drawGradientRect(var6 - 3, var7 + var9 + 2, var6 + var5 + 3, var7 + var9 + 3, var12, var12); - - for (int var13 = 0; var13 < toolTips.length; ++var13) - { - String var14 = "\u00a77" + toolTips[var13]; - - this.fontRenderer.drawStringWithShadow(var14, var6, var7, -1); - - if (var13 == 0) - { - var7 += 2; - } - - var7 += 10; - } - - this.zLevel = 0.0F; - } - } - - public int getGuiTop() - { - return this.guiTop; - } - - public int getGuiLeft() - { - return this.guiLeft; - } - - public TileEntity getTile() - { - return this.tileEntity; - } -} diff --git a/src/dark/machines/deco/BlockColored.java b/src/dark/machines/deco/BlockColored.java index 87b21125c..abd71ec54 100644 --- a/src/dark/machines/deco/BlockColored.java +++ b/src/dark/machines/deco/BlockColored.java @@ -11,6 +11,7 @@ import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import dark.api.ColorCode; import dark.machines.CoreMachine; /** Prefab class to make any block have 16 separate color instances similar to wool block @@ -71,7 +72,7 @@ public class BlockColored extends Block for (int i = 0; i < this.icons.length; ++i) { - this.icons[i] = iconReg.registerIcon(CoreMachine.getInstance().PREFIX + CoreMachine.dyeColorNames[~i & 15] + this.getUnlocalizedName().replace("tile.", "")); + this.icons[i] = iconReg.registerIcon(CoreMachine.getInstance().PREFIX + ColorCode.get(~i & 15).name + this.getUnlocalizedName().replace("tile.", "")); } } } @@ -89,7 +90,7 @@ public class BlockColored extends Block { if (this.colorized) { - return CoreMachine.dyeColors[meta & 15].getRGB(); + return ColorCode.get(~meta & 15).color.getRGB(); } return super.getRenderColor(meta); } diff --git a/src/dark/machines/deco/ItemBlockColored.java b/src/dark/machines/deco/ItemBlockColored.java index 20db116e1..fbd660a56 100644 --- a/src/dark/machines/deco/ItemBlockColored.java +++ b/src/dark/machines/deco/ItemBlockColored.java @@ -3,6 +3,7 @@ package dark.machines.deco; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import dark.api.ColorCode; import dark.machines.CoreMachine; public class ItemBlockColored extends ItemBlock @@ -23,7 +24,7 @@ public class ItemBlockColored extends ItemBlock @Override public String getUnlocalizedName(ItemStack par1ItemStack) { - return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + CoreMachine.dyeColorNames[par1ItemStack.getItemDamage()]; + return Block.blocksList[this.getBlockID()].getUnlocalizedName() + "." + ColorCode.get(par1ItemStack.getItemDamage()).name; } @Override diff --git a/src/dark/machines/items/ItemColoredDust.java b/src/dark/machines/items/ItemColoredDust.java index 8a8aeb31c..e958c0897 100644 --- a/src/dark/machines/items/ItemColoredDust.java +++ b/src/dark/machines/items/ItemColoredDust.java @@ -12,6 +12,7 @@ import com.dark.prefab.ItemBasic; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import dark.api.ColorCode; import dark.machines.CoreMachine; public class ItemColoredDust extends ItemBasic @@ -31,7 +32,7 @@ public class ItemColoredDust extends ItemBasic @SideOnly(Side.CLIENT) public int getColorFromItemStack(ItemStack par1ItemStack, int par2) { - return CoreMachine.dyeColors[par1ItemStack.getItemDamage() % 16].getRGB(); + return ColorCode.get(par1ItemStack.getItemDamage() % 16).color.getRGB(); } @Override @@ -58,13 +59,13 @@ public class ItemColoredDust extends ItemBasic @Override public final String getUnlocalizedName(ItemStack par1ItemStack) { - return this.getUnlocalizedName() + "." + CoreMachine.dyeColorNames[par1ItemStack.getItemDamage()]; + return this.getUnlocalizedName() + "." + ColorCode.get(par1ItemStack.getItemDamage()).name; } @Override public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 0; i < CoreMachine.dyeColorNames.length; i++) + for (int i = 0; i < ColorCode.values().length - 1; i++) { par3List.add(new ItemStack(par1, 1, i)); } diff --git a/src/dark/machines/machines/TileEntityBatteryBox.java b/src/dark/machines/machines/TileEntityBatteryBox.java index 32bd2a613..75672eda0 100644 --- a/src/dark/machines/machines/TileEntityBatteryBox.java +++ b/src/dark/machines/machines/TileEntityBatteryBox.java @@ -14,12 +14,12 @@ import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.VectorHelper; import com.dark.network.PacketHandler; +import com.dark.prefab.EnergyHelper; import com.dark.prefab.TileEntityEnergyMachine; import com.google.common.io.ByteArrayDataInput; import cpw.mods.fml.common.network.Player; import cpw.mods.fml.common.registry.LanguageRegistry; -import dark.core.prefab.machine.EnergyHelper; /** Simple in out battery box *