Package com.pahimar.ee3.api

Examples of com.pahimar.ee3.api.EnergyValue


    @EventHandler
    public void onServerStarting(FMLServerStartingEvent event)
    {
        event.registerServerCommand(new CommandSetValue());
        event.registerServerCommand(new CommandSetCurrentItemValue());
        event.registerServerCommand(new CommandSyncValues());
    }
View Full Code Here


    }

    @EventHandler
    public void onServerStarting(FMLServerStartingEvent event)
    {
        event.registerServerCommand(new CommandSetValue());
        event.registerServerCommand(new CommandSetCurrentItemValue());
        event.registerServerCommand(new CommandSyncValues());
    }
View Full Code Here

    @EventHandler
    public void onServerStarting(FMLServerStartingEvent event)
    {
        event.registerServerCommand(new CommandSetValue());
        event.registerServerCommand(new CommandSetCurrentItemValue());
        event.registerServerCommand(new CommandSyncValues());
    }
View Full Code Here

        {
            jsonReader = new JsonReader(new FileReader(jsonFile));
            jsonReader.beginArray();
            while (jsonReader.hasNext())
            {
                EnergyValueStackMapping energyValueStackMapping = jsonSerializer.fromJson(jsonReader, EnergyValueStackMapping.class);
                energyValueStackMap.put(energyValueStackMapping.wrappedStack, energyValueStackMapping.energyValue);
            }
            jsonReader.endArray();
            jsonReader.close();
        } catch (FileNotFoundException ignored)
View Full Code Here

            jsonWriter = new JsonWriter(new FileWriter(jsonFile));
            jsonWriter.setIndent("    ");
            jsonWriter.beginArray();
            for (WrappedStack wrappedStack : energyValueMap.keySet())
            {
                jsonSerializer.toJson(new EnergyValueStackMapping(wrappedStack, energyValueMap.get(wrappedStack)), EnergyValueStackMapping.class, jsonWriter);
            }

            jsonWriter.endArray();
            jsonWriter.close();
        }
View Full Code Here

public class EnergyValues
{
    public static void addDefaultEnergyValues()
    {
        // OreDictionary assignment
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.cobblestone))), 1);
        for (int meta = 0; meta < 16; meta++)
        {
            EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Items.dye, 1, meta))), 8);
        }
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.log))), 32);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.diamond_ore))), 8192);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.emerald_ore))), 8192);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.gold_ore))), 2048);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.iron_ore))), 256);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.lapis_ore))), 864);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.quartz_ore))), 256);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.redstone_ore))), 32);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.planks))), 8);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Items.record_11))), 2048);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.wooden_slab))), 4);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.oak_stairs))), 12);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Items.stick))), 4);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.stone))), 1);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.leaves))), 1);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.sapling))), 32);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(new OreStack(new ItemStack(Blocks.sandstone))), 4);

        // Fluids
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(FluidRegistry.WATER), 1);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(FluidRegistry.LAVA), 64);
        EnergyValueRegistryProxy.addPreAssignedEnergyValue(new WrappedStack(FluidRegistry.getFluid("milk")), 64);
View Full Code Here

                return;
            }
        }

        // Wrap the recipe output
        WrappedStack wrappedRecipeOutput = new WrappedStack(recipeOutput);
        List<WrappedStack> wrappedRecipeInputList = new ArrayList<WrappedStack>();
        for (Object recipeInputObject : recipeInputList)
        {
            wrappedRecipeInputList.add(new WrappedStack(recipeInputObject));
        }

        // Add the recipe mapping only if we don't already have it
        if (!recipeMap.get(wrappedRecipeOutput).contains(wrappedRecipeInputList))
        {
View Full Code Here

                    if (itemStack.stackSize > 1)
                    {
                        itemStack.stackSize = 1;
                    }

                    recipeInputs.add(new WrappedStack(itemStack));
                }
            }
        }
        else if (recipe instanceof ShapelessRecipes)
        {
            ShapelessRecipes shapelessRecipe = (ShapelessRecipes) recipe;

            for (Object object : shapelessRecipe.recipeItems)
            {
                if (object instanceof ItemStack)
                {
                    ItemStack itemStack = ((ItemStack) object).copy();

                    if (itemStack.stackSize > 1)
                    {
                        itemStack.stackSize = 1;
                    }

                    recipeInputs.add(new WrappedStack(itemStack));
                }
            }
        }
        else if (recipe instanceof ShapedOreRecipe)
        {
            ShapedOreRecipe shapedOreRecipe = (ShapedOreRecipe) recipe;

            for (int i = 0; i < shapedOreRecipe.getInput().length; i++)
            {
                /*
                 * If the element is a list, then it is an OreStack
                 */
                if (shapedOreRecipe.getInput()[i] instanceof ArrayList)
                {
                    WrappedStack oreStack = new WrappedStack(shapedOreRecipe.getInput()[i]);

                    if (oreStack.getWrappedStack() instanceof OreStack)
                    {
                        recipeInputs.add(oreStack);
                    }
                }
                else if (shapedOreRecipe.getInput()[i] instanceof ItemStack)
                {

                    ItemStack itemStack = ((ItemStack) shapedOreRecipe.getInput()[i]).copy();

                    if (itemStack.stackSize > 1)
                    {
                        itemStack.stackSize = 1;
                    }

                    recipeInputs.add(new WrappedStack(itemStack));
                }
            }
        }
        else if (recipe instanceof ShapelessOreRecipe)
        {
            ShapelessOreRecipe shapelessOreRecipe = (ShapelessOreRecipe) recipe;

            for (Object object : shapelessOreRecipe.getInput())
            {

                if (object instanceof ArrayList)
                {
                    recipeInputs.add(new WrappedStack(object));
                }
                else if (object instanceof ItemStack)
                {

                    ItemStack itemStack = ((ItemStack) object).copy();

                    if (itemStack.stackSize > 1)
                    {
                        itemStack.stackSize = 1;
                    }

                    recipeInputs.add(new WrappedStack(itemStack));
                }
            }
        }

        return collateInputStacks(recipeInputs);
View Full Code Here

     */
    public static List<WrappedStack> collateInputStacks(List<?> uncollatedStacks)
    {
        List<WrappedStack> collatedStacks = new ArrayList<WrappedStack>();

        WrappedStack stack;
        boolean found;

        for (Object object : uncollatedStacks)
        {
            found = false;

            if (WrappedStack.canBeWrapped(object))
            {

                stack = new WrappedStack(object);

                if (collatedStacks.isEmpty())
                {
                    collatedStacks.add(stack);
                }
                else
                {

                    for (WrappedStack collatedStack : collatedStacks)
                    {
                        if (collatedStack.getWrappedStack() != null)
                        {
                            if (stack.getWrappedStack() instanceof ItemStack && collatedStack.getWrappedStack() instanceof ItemStack)
                            {
                                if (ItemHelper.equals((ItemStack) stack.getWrappedStack(), (ItemStack) collatedStack.getWrappedStack()))
                                {
                                    collatedStack.setStackSize(collatedStack.getStackSize() + stack.getStackSize());
                                    found = true;
                                }
                            }
                            else if (stack.getWrappedStack() instanceof OreStack && collatedStack.getWrappedStack() instanceof OreStack)
                            {
                                if (OreStack.compareOreNames((OreStack) stack.getWrappedStack(), (OreStack) collatedStack.getWrappedStack()))
                                {
                                    collatedStack.setStackSize(collatedStack.getStackSize() + stack.getStackSize());
                                    found = true;
                                }
                            }
                        }
                    }
View Full Code Here

    @SubscribeEvent
    public void handleItemTooltipEvent(ItemTooltipEvent event)
    {
        if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
        {
            WrappedStack stack = new WrappedStack(event.itemStack);

            if (EnergyValueRegistry.getInstance().hasEnergyValue(stack))
            {
                EnergyValue energyValue = EnergyValueRegistry.getInstance().getEnergyValue(stack);
                if (stack.getStackSize() > 1)
                {
                    event.toolTip.add("Exchange Energy (Item): " + String.format("%s", energyValueDecimalFormat.format(energyValue.getEnergyValue())));
                    event.toolTip.add("Exchange Energy (Stack): " + String.format("%s", energyValueDecimalFormat.format(stack.getStackSize() * energyValue.getEnergyValue())));
                }
                else
                {
                    event.toolTip.add("Exchange Energy: " + String.format("%s", energyValueDecimalFormat.format(stack.getStackSize() * energyValue.getEnergyValue())));
                }
            }
            else
            {
                event.toolTip.add("No Exchange Energy value");
View Full Code Here

TOP

Related Classes of com.pahimar.ee3.api.EnergyValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.