diff --git a/src/common/buildcraft/api/bptblocks/BptBlockSign.java b/src/common/buildcraft/api/bptblocks/BptBlockSign.java index 934c3e27a..9cf80e3b3 100644 --- a/src/common/buildcraft/api/bptblocks/BptBlockSign.java +++ b/src/common/buildcraft/api/bptblocks/BptBlockSign.java @@ -1,8 +1,8 @@ -/** +/** * Copyright (c) SpaceToad, 2011 * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ @@ -15,7 +15,6 @@ import buildcraft.api.blueprints.BlockSignature; import buildcraft.api.blueprints.BptBlock; import buildcraft.api.blueprints.BptSlotInfo; import buildcraft.api.blueprints.IBptContext; -import buildcraft.api.core.Orientations; import net.minecraft.src.Block; import net.minecraft.src.Item; @@ -46,7 +45,7 @@ public class BptBlockSign extends BptBlock { } slot.meta = (int) (angle / 360.0 * 16.0); } else { - slot.meta = Orientations.values()[slot.meta].rotateLeft().ordinal(); +// slot.meta = ForgeDirection.values()[slot.meta].rotateLeft().ordinal(); } } diff --git a/src/common/buildcraft/api/core/BuildCraftAPI.java b/src/common/buildcraft/api/core/BuildCraftAPI.java index 082ef4a7d..28655581d 100644 --- a/src/common/buildcraft/api/core/BuildCraftAPI.java +++ b/src/common/buildcraft/api/core/BuildCraftAPI.java @@ -1,8 +1,8 @@ -/** +/** * Copyright (c) SpaceToad, 2011 * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ @@ -13,25 +13,23 @@ import net.minecraft.src.Block; import net.minecraft.src.World; public class BuildCraftAPI { - + @Deprecated - // To be removed, see LiquidManager + // To be removed, see LiquidContainerRegistry public static final int BUCKET_VOLUME = 1000; public static final int LAST_ORIGINAL_BLOCK = 122; public static final int LAST_ORIGINAL_ITEM = 126; - public static boolean[] softBlocks = new boolean[Block.blocksList.length]; - /** - * Return true if the block given in parameter is pass through (e.g. air, - * water...) - */ + public static final boolean[] softBlocks = new boolean[Block.blocksList.length]; + + @Deprecated + // To be removed public static boolean softBlock(int blockId) { return blockId == 0 || softBlocks[blockId] || Block.blocksList[blockId] == null; } - /** - * Return true if the block cannot be broken, typically bedrock and lava - */ + @Deprecated + // To be removed public static boolean unbreakableBlock(int blockId) { return blockId == Block.bedrock.blockID || blockId == Block.lavaStill.blockID || blockId == Block.lavaMoving.blockID; } @@ -47,10 +45,4 @@ public class BuildCraftAPI { world.setBlockWithNotify(x, y, z, 0); } - - static { - for (int i = 0; i < softBlocks.length; ++i) { - softBlocks[i] = false; - } - } } diff --git a/src/common/buildcraft/api/core/Orientations.java b/src/common/buildcraft/api/core/Orientations.java deleted file mode 100644 index 6b27a4b0c..000000000 --- a/src/common/buildcraft/api/core/Orientations.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in - * http://www.mod-buildcraft.com/MMPL-1.0.txt - */ - -package buildcraft.api.core; - -import net.minecraftforge.common.ForgeDirection; - -public enum Orientations { - YNeg, // 0 - YPos, // 1 - ZNeg, // 2 - ZPos, // 3 - XNeg, // 4 - XPos, // 5 - Unknown; - - public Orientations reverse() { - switch (this) { - case YPos: - return Orientations.YNeg; - case YNeg: - return Orientations.YPos; - case ZPos: - return Orientations.ZNeg; - case ZNeg: - return Orientations.ZPos; - case XPos: - return Orientations.XNeg; - case XNeg: - return Orientations.XPos; - default: - return Orientations.Unknown; - } - } - - public ForgeDirection toDirection(){ - switch(this){ - case YNeg: - return ForgeDirection.DOWN; - case YPos: - return ForgeDirection.UP; - case ZNeg: - return ForgeDirection.NORTH; - case ZPos: - return ForgeDirection.SOUTH; - case XNeg: - return ForgeDirection.WEST; - case XPos: - return ForgeDirection.EAST; - default: - return ForgeDirection.UNKNOWN; - - } - } - - public Orientations rotateLeft() { - switch (this) { - case XPos: - return ZPos; - case ZNeg: - return XPos; - case XNeg: - return ZNeg; - case ZPos: - return XNeg; - default: - return this; - } - } - - public static Orientations[] dirs() { - return new Orientations[] { YNeg, YPos, ZNeg, ZPos, XNeg, XPos }; - } -} diff --git a/src/common/buildcraft/api/core/Position.java b/src/common/buildcraft/api/core/Position.java index 2ee79d7ec..7b22d81c7 100644 --- a/src/common/buildcraft/api/core/Position.java +++ b/src/common/buildcraft/api/core/Position.java @@ -1,8 +1,8 @@ -/** +/** * Copyright (c) SpaceToad, 2011 * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ @@ -11,20 +11,21 @@ package buildcraft.api.core; import net.minecraft.src.NBTTagCompound; import net.minecraft.src.TileEntity; +import net.minecraftforge.common.ForgeDirection; public class Position { public double x, y, z; - public Orientations orientation; + public ForgeDirection orientation; public Position(double ci, double cj, double ck) { x = ci; y = cj; z = ck; - orientation = Orientations.Unknown; + orientation = ForgeDirection.UNKNOWN; } - public Position(double ci, double cj, double ck, Orientations corientation) { + public Position(double ci, double cj, double ck, ForgeDirection corientation) { x = ci; y = cj; z = ck; @@ -43,7 +44,7 @@ public class Position { y = nbttagcompound.getDouble("j"); z = nbttagcompound.getDouble("k"); - orientation = Orientations.Unknown; + orientation = ForgeDirection.UNKNOWN; } public Position(TileEntity tile) { @@ -54,16 +55,16 @@ public class Position { public void moveRight(double step) { switch (orientation) { - case ZPos: + case SOUTH: x = x - step; break; - case ZNeg: + case NORTH: x = x + step; break; - case XPos: + case EAST: z = z + step; break; - case XNeg: + case WEST: z = z - step; break; default: @@ -76,22 +77,22 @@ public class Position { public void moveForwards(double step) { switch (orientation) { - case YPos: + case UP: y = y + step; break; - case YNeg: + case DOWN: y = y - step; break; - case ZPos: + case SOUTH: z = z + step; break; - case ZNeg: + case NORTH: z = z - step; break; - case XPos: + case EAST: x = x + step; break; - case XNeg: + case WEST: x = x - step; break; default: @@ -104,10 +105,10 @@ public class Position { public void moveUp(double step) { switch (orientation) { - case ZPos: - case ZNeg: - case XPos: - case XNeg: + case SOUTH: + case NORTH: + case EAST: + case WEST: y = y + step; break; default: diff --git a/src/common/buildcraft/api/fuels/IronEngineCoolant.java b/src/common/buildcraft/api/fuels/IronEngineCoolant.java index d8adb4431..0675a2d48 100644 --- a/src/common/buildcraft/api/fuels/IronEngineCoolant.java +++ b/src/common/buildcraft/api/fuels/IronEngineCoolant.java @@ -2,7 +2,8 @@ package buildcraft.api.fuels; import java.util.LinkedList; -import buildcraft.api.liquids.LiquidStack; +import net.minecraftforge.liquids.LiquidStack; + public class IronEngineCoolant { diff --git a/src/common/buildcraft/api/fuels/IronEngineFuel.java b/src/common/buildcraft/api/fuels/IronEngineFuel.java index baf9006a0..1bf333fc5 100644 --- a/src/common/buildcraft/api/fuels/IronEngineFuel.java +++ b/src/common/buildcraft/api/fuels/IronEngineFuel.java @@ -11,8 +11,9 @@ package buildcraft.api.fuels; import java.util.LinkedList; -import buildcraft.api.liquids.LiquidManager; -import buildcraft.api.liquids.LiquidStack; +import net.minecraftforge.liquids.LiquidContainerRegistry; +import net.minecraftforge.liquids.LiquidStack; + public class IronEngineFuel { @@ -37,7 +38,7 @@ public class IronEngineFuel { public final int totalBurningTime; public IronEngineFuel(int liquidId, float powerPerCycle, int totalBurningTime) { - this(new LiquidStack(liquidId, LiquidManager.BUCKET_VOLUME, 0), powerPerCycle, totalBurningTime); + this(new LiquidStack(liquidId, LiquidContainerRegistry.BUCKET_VOLUME, 0), powerPerCycle, totalBurningTime); } public IronEngineFuel(LiquidStack liquid, float powerPerCycle, int totalBurningTime) { this.liquid = liquid; diff --git a/src/common/buildcraft/api/inventory/ISecuredInventory.java b/src/common/buildcraft/api/inventory/ISecuredInventory.java index f673f16f2..8cc854185 100644 --- a/src/common/buildcraft/api/inventory/ISecuredInventory.java +++ b/src/common/buildcraft/api/inventory/ISecuredInventory.java @@ -1,6 +1,6 @@ package buildcraft.api.inventory; -import buildcraft.api.core.Orientations; +import net.minecraftforge.common.ForgeDirection; public interface ISecuredInventory { @@ -15,6 +15,6 @@ public interface ISecuredInventory { * @param orientation Orientation the transaction will be performed from. * @param name Name of the user/player who owns the transaction. */ - void prepareTransaction(Orientations orientation, String name); + void prepareTransaction(ForgeDirection orientation, String name); } diff --git a/src/common/buildcraft/api/inventory/ISelectiveInventory.java b/src/common/buildcraft/api/inventory/ISelectiveInventory.java index 688c4d8ce..243676344 100644 --- a/src/common/buildcraft/api/inventory/ISelectiveInventory.java +++ b/src/common/buildcraft/api/inventory/ISelectiveInventory.java @@ -1,6 +1,6 @@ package buildcraft.api.inventory; -import buildcraft.api.core.Orientations; +import net.minecraftforge.common.ForgeDirection; import net.minecraft.src.ItemStack; public interface ISelectiveInventory extends ISpecialInventory { @@ -13,5 +13,5 @@ public interface ISelectiveInventory extends ISpecialInventory { * @param maxItemCount Maximum amount of items to extract (spread over all returned item stacks) * @return Array of item stacks extracted from the inventory */ - ItemStack[] extractItem(Object[] desired, boolean exclusion, boolean doRemove, Orientations from, int maxItemCount); + ItemStack[] extractItem(Object[] desired, boolean exclusion, boolean doRemove, ForgeDirection from, int maxItemCount); } diff --git a/src/common/buildcraft/api/inventory/ISpecialInventory.java b/src/common/buildcraft/api/inventory/ISpecialInventory.java index e26c85842..658de50ff 100644 --- a/src/common/buildcraft/api/inventory/ISpecialInventory.java +++ b/src/common/buildcraft/api/inventory/ISpecialInventory.java @@ -1,6 +1,6 @@ package buildcraft.api.inventory; -import buildcraft.api.core.Orientations; +import net.minecraftforge.common.ForgeDirection; import net.minecraft.src.IInventory; import net.minecraft.src.ItemStack; @@ -13,7 +13,7 @@ public interface ISpecialInventory extends IInventory { * @param from Orientation the ItemStack is offered from. * @return Amount of items used from the passed stack. */ - int addItem(ItemStack stack, boolean doAdd, Orientations from); + int addItem(ItemStack stack, boolean doAdd, ForgeDirection from); /** * Requests items to be extracted from the inventory * @param doRemove If false no actual extraction may occur. @@ -21,6 +21,6 @@ public interface ISpecialInventory extends IInventory { * @param maxItemCount Maximum amount of items to extract (spread over all returned item stacks) * @return Array of item stacks extracted from the inventory */ - ItemStack[] extractItem(boolean doRemove, Orientations from, int maxItemCount); + ItemStack[] extractItem(boolean doRemove, ForgeDirection from, int maxItemCount); } diff --git a/src/common/buildcraft/api/liquids/ILiquid.java b/src/common/buildcraft/api/liquids/ILiquid.java deleted file mode 100644 index 74d9fbe9b..000000000 --- a/src/common/buildcraft/api/liquids/ILiquid.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in - * http://www.mod-buildcraft.com/MMPL-1.0.txt - */ - -package buildcraft.api.liquids; - -public interface ILiquid { - - public int stillLiquidId(); - - public boolean isMetaSensitive(); - - public int stillLiquidMeta(); - -} diff --git a/src/common/buildcraft/api/liquids/ILiquidTank.java b/src/common/buildcraft/api/liquids/ILiquidTank.java deleted file mode 100644 index d570e16e3..000000000 --- a/src/common/buildcraft/api/liquids/ILiquidTank.java +++ /dev/null @@ -1,27 +0,0 @@ -package buildcraft.api.liquids; - -public interface ILiquidTank { - - /** - * @return LiquidStack representing the liquid contained in the tank, null if empty. - */ - LiquidStack getLiquid(); - void setLiquid(LiquidStack liquid); - void setCapacity(int capacity); - int getCapacity(); - - /** - * - * @param resource - * @param doFill - * @return Amount of liquid used for filling. - */ - int fill(LiquidStack resource, boolean doFill); - /** - * - * @param maxDrain - * @param doDrain - * @return Null if nothing was drained, otherwise a LiquidStack containing the drained. - */ - LiquidStack drain(int maxDrain, boolean doDrain); -} diff --git a/src/common/buildcraft/api/liquids/ITankContainer.java b/src/common/buildcraft/api/liquids/ITankContainer.java deleted file mode 100644 index 51c89126a..000000000 --- a/src/common/buildcraft/api/liquids/ITankContainer.java +++ /dev/null @@ -1,46 +0,0 @@ -package buildcraft.api.liquids; - -import buildcraft.api.core.Orientations; - -public interface ITankContainer { - - /** - * Fills liquid into internal tanks, distribution is left to the ITankContainer. - * @param from Orientation the liquid is pumped in from. - * @param resource LiquidStack representing the maximum amount of liquid filled into the ITankContainer - * @param doFill If false filling will only be simulated. - * @return Amount of resource that was filled into internal tanks. - */ - int fill(Orientations from, LiquidStack resource, boolean doFill); - /** - * Fills liquid into the specified internal tank. - * @param from Orientation the liquid is pumped in from. - * @param resource LiquidStack representing the maximum amount of liquid filled into the ITankContainer - * @param doFill If false filling will only be simulated. - * @return Amount of resource that was filled into internal tanks. - */ - int fill(int tankIndex, LiquidStack resource, boolean doFill); - - /** - * Drains liquid out of internal tanks, distribution is left to the ITankContainer. - * @param from Orientation the liquid is drained to. - * @param maxDrain Maximum amount of liquid to drain. - * @param doDrain If false draining will only be simulated. - * @return LiquidStack representing the liquid and amount actually drained from the ITankContainer - */ - LiquidStack drain(Orientations from, int maxDrain, boolean doDrain); - /** - * Drains liquid out of the specified internal tank. - * @param from Orientation the liquid is drained to. - * @param maxDrain Maximum amount of liquid to drain. - * @param doDrain If false draining will only be simulated. - * @return LiquidStack representing the liquid and amount actually drained from the ITankContainer - */ - LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain); - - /** - * @return Array of {@link LiquidTank}s contained in this ITankContainer - */ - ILiquidTank[] getTanks(); - -} diff --git a/src/common/buildcraft/api/liquids/LiquidData.java b/src/common/buildcraft/api/liquids/LiquidData.java deleted file mode 100644 index 97187772b..000000000 --- a/src/common/buildcraft/api/liquids/LiquidData.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) SpaceToad, 2011 - * http://www.mod-buildcraft.com - * - * BuildCraft is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in - * http://www.mod-buildcraft.com/MMPL-1.0.txt - */ - -package buildcraft.api.liquids; - -import net.minecraft.src.Item; -import net.minecraft.src.ItemStack; - -public class LiquidData { - - public final LiquidStack stillLiquid; - public final LiquidStack movingLiquid; - - public final ItemStack filled; - public final ItemStack container; - - public LiquidData(int stillLiquidId, int movingLiquidId, Item filled) { - this(new LiquidStack(stillLiquidId, LiquidManager.BUCKET_VOLUME), new LiquidStack(movingLiquidId, LiquidManager.BUCKET_VOLUME), new ItemStack(filled, 1), new ItemStack(Item.bucketEmpty)); - } - - public LiquidData(int stillLiquidId, int movingLiquidId, ItemStack filled) { - this(new LiquidStack(stillLiquidId, LiquidManager.BUCKET_VOLUME), new LiquidStack(movingLiquidId, LiquidManager.BUCKET_VOLUME), filled, new ItemStack(Item.bucketEmpty)); - } - - public LiquidData(LiquidStack stillLiquid, ItemStack filled, ItemStack container) { - this(stillLiquid, stillLiquid, filled, container); - } - - public LiquidData(LiquidStack stillLiquid, LiquidStack movingLiquid, ItemStack filled, ItemStack container) { - this.stillLiquid = stillLiquid; - this.movingLiquid = movingLiquid; - this.filled = filled; - this.container = container; - - if(stillLiquid == null || filled == null || container == null) - throw new RuntimeException("stillLiquid, filled, or container is null, this is an error"); - } - -} diff --git a/src/common/buildcraft/api/liquids/LiquidDictionary.java b/src/common/buildcraft/api/liquids/LiquidDictionary.java deleted file mode 100644 index fece9bfab..000000000 --- a/src/common/buildcraft/api/liquids/LiquidDictionary.java +++ /dev/null @@ -1,57 +0,0 @@ -package buildcraft.api.liquids; - -import java.util.HashMap; -import java.util.Map; - -/** - * When creating liquids you should register them with this class. - * - * @author CovertJaguar - */ -public abstract class LiquidDictionary -{ - - private static Map liquids = new HashMap(); - - /** - * When creating liquids you should call this function. - * - * Upon passing it a name and liquid item it will return either - * a preexisting implementation of that liquid or the liquid passed in. - * - * - * @param name the name of the liquid - * @param liquid the liquid to use if one doesn't exist - * @return - */ - public static LiquidStack getOrCreateLiquid(String name, LiquidStack liquid) - { - LiquidStack existing = liquids.get(name); - if(existing != null) { - return existing.copy(); - } - liquids.put(name, liquid.copy()); - return liquid; - } - - /** - * Returns the liquid matching the name, - * if such a liquid exists. - * - * Can return null. - * - * @param name the name of the liquid - * @param amount the amout of liquid - * @return - */ - public static LiquidStack getLiquid(String name, int amount) - { - LiquidStack liquid = liquids.get(name); - if(liquid == null) - return null; - - liquid = liquid.copy(); - liquid.amount = amount; - return liquid; - } -} diff --git a/src/common/buildcraft/api/liquids/LiquidManager.java b/src/common/buildcraft/api/liquids/LiquidManager.java deleted file mode 100644 index a94949514..000000000 --- a/src/common/buildcraft/api/liquids/LiquidManager.java +++ /dev/null @@ -1,64 +0,0 @@ -package buildcraft.api.liquids; - -import java.util.LinkedList; - -import net.minecraft.src.ItemStack; - -public class LiquidManager { - - public static final int BUCKET_VOLUME = 1000; - public static LinkedList liquids = new LinkedList(); - - public static LiquidStack getLiquidForFilledItem(ItemStack filledItem) { - if (filledItem == null) - return null; - - for (LiquidData liquid : liquids) - if (liquid.filled.isItemEqual(filledItem)) - return liquid.stillLiquid; - - return null; - } - - public static int getLiquidIDForFilledItem(ItemStack filledItem) { - LiquidStack liquidForFilledItem = getLiquidForFilledItem(filledItem); - - if (liquidForFilledItem == null) - return 0; - - return liquidForFilledItem.itemID; - } - - public static ItemStack getFilledItemForLiquid(LiquidStack liquid) { - for (LiquidData data : liquids) - if(data.stillLiquid.isLiquidEqual(liquid)) - return data.filled.copy(); - - return null; - } - - public static ItemStack fillLiquidContainer(int liquidId, int quantity, ItemStack emptyContainer) { - return fillLiquidContainer(new LiquidStack(liquidId, quantity, 0), emptyContainer); - } - - public static ItemStack fillLiquidContainer(LiquidStack liquid, ItemStack emptyContainer) { - for(LiquidData data : liquids) - if(liquid.containsLiquid(data.stillLiquid) - && data.container.isItemEqual(emptyContainer)) - return data.filled.copy(); - return null; - } - - public static boolean isLiquid(ItemStack block) { - if (block.itemID == 0) - return false; - - for (LiquidData liquid : liquids) - if (liquid.stillLiquid.isLiquidEqual(block) || liquid.movingLiquid.isLiquidEqual(block)) - return true; - - return false; - } - - -} diff --git a/src/common/buildcraft/api/liquids/LiquidStack.java b/src/common/buildcraft/api/liquids/LiquidStack.java deleted file mode 100644 index 60ec6e062..000000000 --- a/src/common/buildcraft/api/liquids/LiquidStack.java +++ /dev/null @@ -1,109 +0,0 @@ -package buildcraft.api.liquids; - -import net.minecraft.src.Block; -import net.minecraft.src.Item; -import net.minecraft.src.ItemStack; -import net.minecraft.src.NBTTagCompound; - -/** - * ItemStack substitute for liquids - * @author SirSengir - */ -public class LiquidStack { - public int itemID; - public int amount; - public int itemMeta; - - private LiquidStack() { - } - - public LiquidStack(int itemID, int amount) { - this(itemID, amount, 0); - } - - public LiquidStack(Item item, int amount) { - this(item.shiftedIndex, amount, 0); - } - - public LiquidStack(Block block, int amount) { - this(block.blockID, amount, 0); - } - - public LiquidStack(int itemID, int amount, int itemDamage) { - this.itemID = itemID; - this.amount = amount; - this.itemMeta = itemDamage; - } - - public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) { - nbttagcompound.setShort("Id", (short) itemID); - nbttagcompound.setInteger("Amount", amount); - nbttagcompound.setShort("Meta", (short) itemMeta); - return nbttagcompound; - } - - public void readFromNBT(NBTTagCompound nbttagcompound) { - itemID = nbttagcompound.getShort("Id"); - amount = nbttagcompound.getInteger("Amount"); - itemMeta = nbttagcompound.getShort("Meta"); - } - - /** - * @return A copy of this LiquidStack - */ - public LiquidStack copy() { - return new LiquidStack(itemID, amount, itemMeta); - } - - /** - * @param other - * @return true if this LiquidStack contains the same liquid as the one passed in. - */ - public boolean isLiquidEqual(LiquidStack other) { - if(other == null) - return false; - - return itemID == other.itemID && itemMeta == other.itemMeta; - } - - /** - * @param other - * @return true if this LiquidStack contains the other liquid (liquids are equal and amount >= other.amount). - */ - public boolean containsLiquid(LiquidStack other) { - if(!isLiquidEqual(other)) - return false; - - return amount >= other.amount; - } - - /** - * @param other ItemStack containing liquids. - * @return true if this LiquidStack contains the same liquid as the one passed in. - */ - public boolean isLiquidEqual(ItemStack other) { - if(other == null) - return false; - - return itemID == other.itemID && itemMeta == other.getItemDamage(); - } - - /** - * @return ItemStack representation of this LiquidStack - */ - public ItemStack asItemStack() { - return new ItemStack(itemID, 1, itemMeta); - } - - /** - * Reads a liquid stack from the passed nbttagcompound and returns it. - * - * @param nbttagcompound - * @return - */ - public static LiquidStack loadLiquidStackFromNBT(NBTTagCompound nbttagcompound) { - LiquidStack liquidstack = new LiquidStack(); - liquidstack.readFromNBT(nbttagcompound); - return liquidstack.itemID == 0 ? null : liquidstack; - } -} diff --git a/src/common/buildcraft/api/liquids/LiquidTank.java b/src/common/buildcraft/api/liquids/LiquidTank.java deleted file mode 100644 index 62f51755e..000000000 --- a/src/common/buildcraft/api/liquids/LiquidTank.java +++ /dev/null @@ -1,100 +0,0 @@ -package buildcraft.api.liquids; - -/** - * Reference implementation of ILiquidTank. Use this or implement your own. - */ -public class LiquidTank implements ILiquidTank { - private LiquidStack liquid; - private int capacity; - - public LiquidTank(int capacity) { - this(null, capacity); - } - - public LiquidTank(int liquidId, int quantity, int capacity) { - this(new LiquidStack(liquidId, quantity), capacity); - } - public LiquidTank(LiquidStack liquid, int capacity) { - this.liquid = liquid; - this.capacity = capacity; - } - - @Override - public LiquidStack getLiquid() { - return this.liquid; - } - - @Override - public void setLiquid(LiquidStack liquid) { - this.liquid = liquid; - } - - @Override - public void setCapacity(int capacity) { - this.capacity = capacity; - } - - @Override - public int getCapacity() { - return this.capacity; - } - - @Override - public int fill(LiquidStack resource, boolean doFill) { - if(resource == null || resource.itemID <= 0) - return 0; - - if(liquid == null || liquid.itemID <= 0) { - if(resource.amount <= capacity) { - if(doFill) - this.liquid = resource.copy(); - return resource.amount; - } else { - if(doFill) { - this.liquid = resource.copy(); - this.liquid.amount = capacity; - } - return capacity; - } - } - - if(!liquid.isLiquidEqual(resource)) - return 0; - - int space = capacity - liquid.amount; - if(resource.amount <= space) { - if(doFill) - this.liquid.amount += resource.amount; - return resource.amount; - } else { - - if(doFill) - this.liquid.amount = capacity; - return space; - } - - } - @Override - public LiquidStack drain(int maxDrain, boolean doDrain) { - if(liquid == null || liquid.itemID <= 0) - return null; - if(liquid.amount <= 0) - return null; - - int used = maxDrain; - if(liquid.amount < used) - used = liquid.amount; - - if(doDrain) { - liquid.amount -= used; - } - - LiquidStack drained = new LiquidStack(liquid.itemID, used, liquid.itemMeta); - - // Reset liquid if emptied - if(liquid.amount <= 0) - liquid = null; - - return drained; - } -} diff --git a/src/common/buildcraft/api/power/IPowerProvider.java b/src/common/buildcraft/api/power/IPowerProvider.java index 97506496b..ae74209e5 100644 --- a/src/common/buildcraft/api/power/IPowerProvider.java +++ b/src/common/buildcraft/api/power/IPowerProvider.java @@ -1,6 +1,6 @@ package buildcraft.api.power; -import buildcraft.api.core.Orientations; +import net.minecraftforge.common.ForgeDirection; import buildcraft.api.core.SafeTimeTracker; import net.minecraft.src.NBTTagCompound; @@ -32,9 +32,9 @@ public interface IPowerProvider { void writeToNBT(NBTTagCompound nbttagcompound); - void receiveEnergy(float quantity, Orientations from); + void receiveEnergy(float quantity, ForgeDirection from); - boolean isPowerSource(Orientations from); + boolean isPowerSource(ForgeDirection from); SafeTimeTracker getTimeTracker(); diff --git a/src/common/buildcraft/api/power/PowerProvider.java b/src/common/buildcraft/api/power/PowerProvider.java index 54acf3358..6f359f73a 100644 --- a/src/common/buildcraft/api/power/PowerProvider.java +++ b/src/common/buildcraft/api/power/PowerProvider.java @@ -9,7 +9,7 @@ package buildcraft.api.power; -import buildcraft.api.core.Orientations; +import net.minecraftforge.common.ForgeDirection; import buildcraft.api.core.SafeTimeTracker; import net.minecraft.src.NBTTagCompound; import net.minecraft.src.TileEntity; @@ -145,7 +145,7 @@ public abstract class PowerProvider implements IPowerProvider { } @Override - public void receiveEnergy(float quantity, Orientations from) { + public void receiveEnergy(float quantity, ForgeDirection from) { powerSources[from.ordinal()] = 2; energyStored += quantity; @@ -156,7 +156,7 @@ public abstract class PowerProvider implements IPowerProvider { } @Override - public boolean isPowerSource(Orientations from) { + public boolean isPowerSource(ForgeDirection from) { return powerSources[from.ordinal()] != 0; } } diff --git a/src/common/buildcraft/api/recipes/RefineryRecipe.java b/src/common/buildcraft/api/recipes/RefineryRecipe.java index 6b98e5372..3b9caa982 100644 --- a/src/common/buildcraft/api/recipes/RefineryRecipe.java +++ b/src/common/buildcraft/api/recipes/RefineryRecipe.java @@ -9,14 +9,16 @@ package buildcraft.api.recipes; -import java.util.LinkedList; +import java.util.SortedSet; +import java.util.TreeSet; -import buildcraft.api.liquids.LiquidStack; +import net.minecraftforge.liquids.LiquidStack; -public class RefineryRecipe { - private static LinkedList recipes = new LinkedList(); +public class RefineryRecipe implements Comparable { + + private static SortedSet recipes = new TreeSet(); public static void registerRefineryRecipe(RefineryRecipe recipe) { if (!recipes.contains(recipe)) { @@ -44,8 +46,24 @@ public class RefineryRecipe { this(new LiquidStack(ingredientId1, ingredientQty1, 0), new LiquidStack(ingredientId2, ingredientQty2, 0), new LiquidStack(resultId, resultQty, 0), energy, delay); } public RefineryRecipe(LiquidStack ingredient1, LiquidStack ingredient2, LiquidStack result, int energy, int delay) { - this.ingredient1 = ingredient1; - this.ingredient2 = ingredient2; + + // Sort starting materials. + if(ingredient1 != null && ingredient2 != null) { + if( (ingredient1.itemID > ingredient2.itemID) || (ingredient1.itemID == ingredient2.itemID && ingredient1.itemMeta > ingredient2.itemMeta) ) { + this.ingredient1 = ingredient2; + this.ingredient2 = ingredient1; + } else { + this.ingredient1 = ingredient1; + this.ingredient2 = ingredient2; + } + } else if(ingredient2 != null) { + this.ingredient1 = ingredient2; + this.ingredient2 = ingredient1; + } else { + this.ingredient1 = ingredient1; + this.ingredient2 = ingredient2; + } + this.result = result; this.energy = energy; this.delay = delay; @@ -76,4 +94,63 @@ public class RefineryRecipe { return false; } + + // Compares to only the types of source materials. + // We consider non-null < null in order that one-ingredient recipe is checked after + // the failure of matching two-ingredient recipes which include that liquid. + @Override + public int compareTo(RefineryRecipe other) { + + if(other == null) { + return -1; + } else if (ingredient1 == null) { + if(other.ingredient1 == null) { + return 0; + } else { + return 1; + } + } else if(other.ingredient1 == null) { + return -1; + } else if(ingredient1.itemID != other.ingredient1.itemID) { + return ingredient1.itemID - other.ingredient1.itemID; + } else if(ingredient1.itemMeta != other.ingredient1.itemMeta) { + return ingredient1.itemMeta - other.ingredient1.itemMeta; + } else if(ingredient2 == null) { + if(other.ingredient2 == null) { + return 0; + } else { + return 1; + } + } else if(other.ingredient2 == null) { + return -1; + } else if(ingredient2.itemID != other.ingredient2.itemID) { + return ingredient2.itemID - other.ingredient2.itemID; + } else if(ingredient2.itemMeta != other.ingredient2.itemMeta) { + return ingredient2.itemMeta - other.ingredient2.itemMeta; + } + + return 0; + } + + + // equals() should be consistent with compareTo(). + @Override + public boolean equals(Object obj) { + if(obj != null && obj instanceof RefineryRecipe) { + return this.compareTo((RefineryRecipe)obj) == 0; + } + return false; + } + + // hashCode() should be overridden because equals() was overridden. + @Override + public int hashCode() { + if(ingredient1 == null) { + return 0; + } else if(ingredient2 == null) { + return ingredient1.itemID ^ ingredient1.itemMeta; + } + + return ingredient1.itemID ^ ingredient1.itemMeta ^ ingredient2.itemID ^ ingredient2.itemMeta; + } } diff --git a/src/common/buildcraft/api/tools/IToolPipette.java b/src/common/buildcraft/api/tools/IToolPipette.java index 763642e05..0dd54b9ed 100644 --- a/src/common/buildcraft/api/tools/IToolPipette.java +++ b/src/common/buildcraft/api/tools/IToolPipette.java @@ -1,7 +1,7 @@ package buildcraft.api.tools; -import buildcraft.api.liquids.LiquidStack; import net.minecraft.src.ItemStack; +import net.minecraftforge.liquids.LiquidStack; public interface IToolPipette { diff --git a/src/common/buildcraft/api/transport/FacadeManager.java b/src/common/buildcraft/api/transport/FacadeManager.java new file mode 100644 index 000000000..67b5f3d5e --- /dev/null +++ b/src/common/buildcraft/api/transport/FacadeManager.java @@ -0,0 +1,20 @@ +package buildcraft.api.transport; + +import java.lang.reflect.Method; +import net.minecraft.src.ItemStack; + +public class FacadeManager +{ + private static Method addFacade; + + public static void addFacade(ItemStack is) { + try { + if(addFacade == null) { + Class facade = Class.forName("buildcraft.transport.ItemFacade"); + addFacade = facade.getMethod("addFacade", ItemStack.class); + } + addFacade.invoke(null, is); + } catch(Exception ex) { + } + } +} diff --git a/src/common/buildcraft/api/transport/IExtractionHandler.java b/src/common/buildcraft/api/transport/IExtractionHandler.java index 35943853f..3caf80493 100644 --- a/src/common/buildcraft/api/transport/IExtractionHandler.java +++ b/src/common/buildcraft/api/transport/IExtractionHandler.java @@ -1,19 +1,19 @@ -package buildcraft.api.transport; - -import net.minecraft.src.World; - -/** - * Implement and register with the PipeManager if you want to suppress connections from wooden pipes. - */ -public interface IExtractionHandler { - - /** - * Can this pipe extract items from the block located at these coordinates? - */ - boolean canExtractItems(IPipe pipe, World world, int i, int j, int k); - - /** - * Can this pipe extract liquids from the block located at these coordinates? - */ - boolean canExtractLiquids(IPipe pipe, World world, int i, int j, int k); -} +package buildcraft.api.transport; + +import net.minecraft.src.World; + +/** + * Implement and register with the PipeManager if you want to suppress connections from wooden pipes. + */ +public interface IExtractionHandler { + + /** + * Can this pipe extract items from the block located at these coordinates? + */ + boolean canExtractItems(IPipe pipe, World world, int i, int j, int k); + + /** + * Can this pipe extract liquids from the block located at these coordinates? + */ + boolean canExtractLiquids(IPipe pipe, World world, int i, int j, int k); +} diff --git a/src/common/buildcraft/api/transport/IPipeConnection.java b/src/common/buildcraft/api/transport/IPipeConnection.java index 137879f6c..1e78ea26e 100644 --- a/src/common/buildcraft/api/transport/IPipeConnection.java +++ b/src/common/buildcraft/api/transport/IPipeConnection.java @@ -9,9 +9,9 @@ package buildcraft.api.transport; -import buildcraft.api.core.Orientations; +import net.minecraftforge.common.ForgeDirection; public interface IPipeConnection { - public boolean isPipeConnected(Orientations with); + public boolean isPipeConnected(ForgeDirection with); } diff --git a/src/common/buildcraft/api/transport/IPipeEntry.java b/src/common/buildcraft/api/transport/IPipeEntry.java index 02e13acdd..0ae0c8fdf 100644 --- a/src/common/buildcraft/api/transport/IPipeEntry.java +++ b/src/common/buildcraft/api/transport/IPipeEntry.java @@ -10,15 +10,15 @@ package buildcraft.api.transport; import net.minecraft.src.ItemStack; -import buildcraft.api.core.Orientations; +import net.minecraftforge.common.ForgeDirection; /** * Interface used to put objects into pipes, implemented by pipe tile entities. */ public interface IPipeEntry { - void entityEntering(ItemStack payload, Orientations orientation); - void entityEntering(IPipedItem item, Orientations orientation); + void entityEntering(ItemStack payload, ForgeDirection orientation); + void entityEntering(IPipedItem item, ForgeDirection orientation); boolean acceptItems(); diff --git a/src/common/buildcraft/api/transport/IPipedItem.java b/src/common/buildcraft/api/transport/IPipedItem.java index d8e83294b..fb3b3045f 100644 --- a/src/common/buildcraft/api/transport/IPipedItem.java +++ b/src/common/buildcraft/api/transport/IPipedItem.java @@ -1,6 +1,6 @@ package buildcraft.api.transport; -import buildcraft.api.core.Orientations; +import net.minecraftforge.common.ForgeDirection; import buildcraft.api.core.Position; import buildcraft.api.core.SafeTimeTracker; import net.minecraft.src.EntityItem; @@ -89,7 +89,7 @@ public interface IPipedItem { public abstract void writeToNBT(NBTTagCompound nbttagcompound); - public abstract EntityItem toEntityItem(Orientations dir); + public abstract EntityItem toEntityItem(ForgeDirection dir); public abstract float getEntityBrightness(float f); diff --git a/src/common/ic2/api/Direction.java b/src/common/ic2/api/Direction.java index 52381c16e..6d708ad48 100644 --- a/src/common/ic2/api/Direction.java +++ b/src/common/ic2/api/Direction.java @@ -72,7 +72,7 @@ public enum Direction { public Direction getInverse() { int inverseDir = dir - getSign(); - for (Direction direction: Direction.values()) { + for (Direction direction : directions) { if (direction.dir == inverseDir) return direction; } @@ -102,5 +102,6 @@ public enum Direction { } private int dir; + private static final Direction[] directions = Direction.values(); } diff --git a/src/common/ic2/api/IC2Reactor.java b/src/common/ic2/api/IC2Reactor.java new file mode 100644 index 000000000..2faa2dd72 --- /dev/null +++ b/src/common/ic2/api/IC2Reactor.java @@ -0,0 +1,28 @@ +package ic2.api; + +import java.lang.reflect.Field; + +public class IC2Reactor { + private static Field energyGeneratorNuclear; + + public int getEUOutput() { + try { + if (energyGeneratorNuclear == null) energyGeneratorNuclear = Class.forName(getPackage() + ".common.IC2").getDeclaredField("energyGeneratorNuclear"); + + return energyGeneratorNuclear.getInt(null); + } catch (Throwable e) { + throw new RuntimeException(e); + } + } + + /** + * Get the base IC2 package name, used internally. + * + * @return IC2 package name, if unable to be determined defaults to ic2 + */ + private static String getPackage() { + Package pkg = NetworkHelper.class.getPackage(); + if (pkg != null) return pkg.getName().substring(0, pkg.getName().lastIndexOf('.')); + else return "ic2"; + } +} diff --git a/src/common/ic2/api/IEnergyStorage.java b/src/common/ic2/api/IEnergyStorage.java index f67b7afb0..a89bd7dcd 100644 --- a/src/common/ic2/api/IEnergyStorage.java +++ b/src/common/ic2/api/IEnergyStorage.java @@ -23,5 +23,5 @@ public interface IEnergyStorage { * * @return Energy output in EU/t */ - public int getRate(); + public int getOutput(); } diff --git a/src/common/ic2/api/IReactor.java b/src/common/ic2/api/IReactor.java index 8c6a9291c..674b2d4dd 100644 --- a/src/common/ic2/api/IReactor.java +++ b/src/common/ic2/api/IReactor.java @@ -91,9 +91,9 @@ public interface IReactor { public int addOutput(int energy); /** - * Get's the EU worth of a single basic Uranium pulse - * Please use this variable to alter energy output, as it represents the config modifiers as well. + * Replaced by IC2Reactor.getEUOutput() - stays at the universal output value of 1 for compatibility */ + @Deprecated public int getPulsePower(); /** diff --git a/src/common/ic2/api/NetworkHelper.java b/src/common/ic2/api/NetworkHelper.java index 5287671bc..df0247b0e 100644 --- a/src/common/ic2/api/NetworkHelper.java +++ b/src/common/ic2/api/NetworkHelper.java @@ -81,7 +81,7 @@ public final class NetworkHelper { if (NetworkManager_initiateTileEntityEvent == null) NetworkManager_initiateTileEntityEvent = Class.forName(getPackage() + ".common.NetworkManager").getMethod("initiateTileEntityEvent", TileEntity.class, Integer.TYPE, Boolean.TYPE); if (instance == null) instance = getInstance(); - NetworkManager_initiateTileEntityEvent.invoke(null, te, event, limitRange); + NetworkManager_initiateTileEntityEvent.invoke(instance, te, event, limitRange); } catch (Exception e) { throw new RuntimeException(e); } @@ -126,8 +126,9 @@ public final class NetworkHelper { public static void announceBlockUpdate(World world, int x, int y, int z) { try { if (NetworkManager_announceBlockUpdate == null) NetworkManager_announceBlockUpdate = Class.forName(getPackage() + ".common.NetworkManager").getMethod("announceBlockUpdate", World.class, Integer.TYPE, Integer.TYPE, Integer.TYPE); + if (instance == null) instance = getInstance(); - NetworkManager_announceBlockUpdate.invoke(null, world, x, y, z); + NetworkManager_announceBlockUpdate.invoke(instance, world, x, y, z); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/src/common/mekanism/api/IElectricMachine.java b/src/common/mekanism/api/IElectricMachine.java index 1e6fbe3ab..6e029cd95 100644 --- a/src/common/mekanism/api/IElectricMachine.java +++ b/src/common/mekanism/api/IElectricMachine.java @@ -4,9 +4,6 @@ import java.util.List; import buildcraft.api.power.IPowerReceptor; -import universalelectricity.implement.IElectricityReceiver; -import universalelectricity.implement.IJouleStorage; - import dan200.computer.api.IPeripheral; import ic2.api.IEnergySink; diff --git a/src/common/mekanism/common/BlockAdvancedSolarGenerator.java b/src/common/mekanism/common/BlockAdvancedSolarGenerator.java index 1a66407f8..15337aca1 100644 --- a/src/common/mekanism/common/BlockAdvancedSolarGenerator.java +++ b/src/common/mekanism/common/BlockAdvancedSolarGenerator.java @@ -3,7 +3,7 @@ package mekanism.common; import java.util.List; import java.util.Random; -import universalelectricity.core.Vector3; +import universalelectricity.core.vector.Vector3; import universalelectricity.prefab.multiblock.IMultiBlock; import cpw.mods.fml.common.Side; diff --git a/src/common/mekanism/common/BlockBasic.java b/src/common/mekanism/common/BlockBasic.java index 9a1ef8872..a3ea242ea 100644 --- a/src/common/mekanism/common/BlockBasic.java +++ b/src/common/mekanism/common/BlockBasic.java @@ -142,7 +142,7 @@ public class BlockBasic extends Block @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving entityliving) { - world.markBlockAsNeedsUpdate(x, y, z); + world.markBlockForRenderUpdate(x, y, z); world.updateAllLightTypes(x, y, z); } diff --git a/src/common/mekanism/common/ContainerAdvancedElectricMachine.java b/src/common/mekanism/common/ContainerAdvancedElectricMachine.java index b15e3c405..c4cb05635 100644 --- a/src/common/mekanism/common/ContainerAdvancedElectricMachine.java +++ b/src/common/mekanism/common/ContainerAdvancedElectricMachine.java @@ -1,7 +1,7 @@ package mekanism.common; import ic2.api.IElectricItem; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import mekanism.api.IEnergizedItem; import mekanism.api.ItemMachineUpgrade; import net.minecraft.src.*; diff --git a/src/common/mekanism/common/ContainerBioGenerator.java b/src/common/mekanism/common/ContainerBioGenerator.java index 2099376c5..778e5f1ce 100644 --- a/src/common/mekanism/common/ContainerBioGenerator.java +++ b/src/common/mekanism/common/ContainerBioGenerator.java @@ -1,7 +1,7 @@ package mekanism.common; import ic2.api.IElectricItem; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import mekanism.api.IEnergizedItem; import net.minecraft.src.*; diff --git a/src/common/mekanism/common/ContainerElectricMachine.java b/src/common/mekanism/common/ContainerElectricMachine.java index 1c32b1992..23748c673 100644 --- a/src/common/mekanism/common/ContainerElectricMachine.java +++ b/src/common/mekanism/common/ContainerElectricMachine.java @@ -1,7 +1,7 @@ package mekanism.common; import ic2.api.IElectricItem; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import mekanism.api.IEnergizedItem; import mekanism.api.ItemMachineUpgrade; import net.minecraft.src.*; diff --git a/src/common/mekanism/common/ContainerElectrolyticSeparator.java b/src/common/mekanism/common/ContainerElectrolyticSeparator.java index 155240300..64640ad3b 100644 --- a/src/common/mekanism/common/ContainerElectrolyticSeparator.java +++ b/src/common/mekanism/common/ContainerElectrolyticSeparator.java @@ -1,7 +1,7 @@ package mekanism.common; import ic2.api.IElectricItem; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import mekanism.api.IEnergizedItem; import mekanism.api.IStorageTank.EnumGas; import mekanism.api.IStorageTank; diff --git a/src/common/mekanism/common/ContainerGasTank.java b/src/common/mekanism/common/ContainerGasTank.java index 67bbf1502..9c4fb6a4f 100644 --- a/src/common/mekanism/common/ContainerGasTank.java +++ b/src/common/mekanism/common/ContainerGasTank.java @@ -1,7 +1,7 @@ package mekanism.common; import ic2.api.IElectricItem; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import mekanism.api.*; import mekanism.api.IStorageTank.EnumGas; import net.minecraft.src.*; diff --git a/src/common/mekanism/common/ContainerHeatGenerator.java b/src/common/mekanism/common/ContainerHeatGenerator.java index 146c5699a..7c3a8fbbc 100644 --- a/src/common/mekanism/common/ContainerHeatGenerator.java +++ b/src/common/mekanism/common/ContainerHeatGenerator.java @@ -1,7 +1,7 @@ package mekanism.common; import ic2.api.IElectricItem; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import mekanism.api.IEnergizedItem; import net.minecraft.src.*; diff --git a/src/common/mekanism/common/ContainerHydrogenGenerator.java b/src/common/mekanism/common/ContainerHydrogenGenerator.java index 6d298c900..ff6b33fee 100644 --- a/src/common/mekanism/common/ContainerHydrogenGenerator.java +++ b/src/common/mekanism/common/ContainerHydrogenGenerator.java @@ -1,7 +1,7 @@ package mekanism.common; import ic2.api.IElectricItem; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import mekanism.api.IEnergizedItem; import mekanism.api.IStorageTank; import mekanism.api.IStorageTank.EnumGas; diff --git a/src/common/mekanism/common/ContainerPowerUnit.java b/src/common/mekanism/common/ContainerPowerUnit.java index 5825738e7..169528f15 100644 --- a/src/common/mekanism/common/ContainerPowerUnit.java +++ b/src/common/mekanism/common/ContainerPowerUnit.java @@ -1,7 +1,7 @@ package mekanism.common; import ic2.api.IElectricItem; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import mekanism.api.*; import net.minecraft.src.*; diff --git a/src/common/mekanism/common/ContainerSolarGenerator.java b/src/common/mekanism/common/ContainerSolarGenerator.java index 330672afe..f825589cd 100644 --- a/src/common/mekanism/common/ContainerSolarGenerator.java +++ b/src/common/mekanism/common/ContainerSolarGenerator.java @@ -1,7 +1,7 @@ package mekanism.common; import ic2.api.IElectricItem; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import mekanism.api.IEnergizedItem; import net.minecraft.src.*; diff --git a/src/common/mekanism/common/ItemEnergized.java b/src/common/mekanism/common/ItemEnergized.java index 1ff56cfb2..d22285ac1 100644 --- a/src/common/mekanism/common/ItemEnergized.java +++ b/src/common/mekanism/common/ItemEnergized.java @@ -3,8 +3,8 @@ package mekanism.common; import java.util.List; import universalelectricity.core.UniversalElectricity; -import universalelectricity.electricity.ElectricInfo; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.electricity.ElectricInfo; +import universalelectricity.core.implement.IItemElectric; import ic2.api.IElectricItem; import mekanism.api.IEnergizedItem; @@ -150,7 +150,7 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, IItem } @Override - public double getMaxJoules() + public double getMaxJoules(Object... data) { return MAX_ENERGY*UniversalElectricity.IC2_RATIO; } diff --git a/src/common/mekanism/common/ItemMekanismHoe.java b/src/common/mekanism/common/ItemMekanismHoe.java index b8055b22a..0cffb55e3 100644 --- a/src/common/mekanism/common/ItemMekanismHoe.java +++ b/src/common/mekanism/common/ItemMekanismHoe.java @@ -2,59 +2,89 @@ package mekanism.common; import java.util.List; +import cpw.mods.fml.common.Side; +import cpw.mods.fml.common.asm.SideOnly; + import net.minecraft.src.*; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.Event.Result; +import net.minecraftforge.event.entity.player.UseHoeEvent; public class ItemMekanismHoe extends ItemMekanism { - public ItemMekanismHoe(int par1, EnumToolMaterial par2EnumToolMaterial) + protected EnumToolMaterial theToolMaterial; + + public ItemMekanismHoe(int id, EnumToolMaterial par2EnumToolMaterial) { - super(par1); + super(id); + theToolMaterial = par2EnumToolMaterial; maxStackSize = 1; setMaxDamage(par2EnumToolMaterial.getMaxUses()); + setCreativeTab(CreativeTabs.tabTools); } - @Override + /** + * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return + * True if something happen and false if it don't. This is for ITEMS, not BLOCKS + */ public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { - if (!par2EntityPlayer.func_82247_a(par4, par5, par6, par7, par1ItemStack)) + if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) { return false; } - - int i = par3World.getBlockId(par4, par5, par6); - int j = par3World.getBlockId(par4, par5 + 1, par6); - - if (par7 != 0 && j == 0 && i == Block.grass.blockID || i == Block.dirt.blockID) - { - Block block = Block.tilledField; - par3World.playSoundEffect((float)par4 + 0.5F, (float)par5 + 0.5F, (float)par6 + 0.5F, block.stepSound.getStepSound(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); - - if (par3World.isRemote) - { - return true; - } - else - { - par3World.setBlockWithNotify(par4, par5, par6, block.blockID); - par1ItemStack.damageItem(1, par2EntityPlayer); - return true; - } - } else { - return false; + UseHoeEvent event = new UseHoeEvent(par2EntityPlayer, par1ItemStack, par3World, par4, par5, par6); + if (MinecraftForge.EVENT_BUS.post(event)) + { + return false; + } + + if (event.getResult() == Result.ALLOW) + { + par1ItemStack.damageItem(1, par2EntityPlayer); + return true; + } + + int var11 = par3World.getBlockId(par4, par5, par6); + int var12 = par3World.getBlockId(par4, par5 + 1, par6); + + if ((par7 == 0 || var12 != 0 || var11 != Block.grass.blockID) && var11 != Block.dirt.blockID) + { + return false; + } + else + { + Block var13 = Block.tilledField; + par3World.playSoundEffect((double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), (double)((float)par6 + 0.5F), var13.stepSound.getStepSound(), (var13.stepSound.getVolume() + 1.0F) / 2.0F, var13.stepSound.getPitch() * 0.8F); + + if (par3World.isRemote) + { + return true; + } + else + { + par3World.setBlockWithNotify(par4, par5, par6, var13.blockID); + par1ItemStack.damageItem(1, par2EntityPlayer); + return true; + } + } } } - - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - list.add("HP: " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); - } - @Override + @SideOnly(Side.CLIENT) + + /** + * Returns True is the item is renderer in full 3D when hold. + */ public boolean isFull3D() { return true; } + + public String func_77842_f() + { + return theToolMaterial.toString(); + } } diff --git a/src/common/mekanism/common/Mekanism.java b/src/common/mekanism/common/Mekanism.java index c8a4aa2d5..e15739d1a 100644 --- a/src/common/mekanism/common/Mekanism.java +++ b/src/common/mekanism/common/Mekanism.java @@ -644,7 +644,7 @@ public class Mekanism RecipeHandler.addCrusherRecipe(new ItemStack(Item.melonSeeds), new ItemStack(BioFuel, 1)); RecipeHandler.addCrusherRecipe(new ItemStack(Item.appleRed), new ItemStack(BioFuel, 3)); RecipeHandler.addCrusherRecipe(new ItemStack(Item.bread), new ItemStack(BioFuel, 3)); - RecipeHandler.addCrusherRecipe(new ItemStack(Item.potatoe), new ItemStack(BioFuel, 2)); + RecipeHandler.addCrusherRecipe(new ItemStack(Item.potato), new ItemStack(BioFuel, 2)); for(int i = 0; i < BlockLeaves.LEAF_TYPES.length; i++) { diff --git a/src/common/mekanism/common/SlotEnergy.java b/src/common/mekanism/common/SlotEnergy.java index f1a30bbed..b418f8b86 100644 --- a/src/common/mekanism/common/SlotEnergy.java +++ b/src/common/mekanism/common/SlotEnergy.java @@ -1,6 +1,6 @@ package mekanism.common; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import ic2.api.IElectricItem; import mekanism.api.IEnergizedItem; import net.minecraft.src.*; diff --git a/src/common/mekanism/common/SlotStorageTank.java b/src/common/mekanism/common/SlotStorageTank.java index 653bb3526..40b51194f 100644 --- a/src/common/mekanism/common/SlotStorageTank.java +++ b/src/common/mekanism/common/SlotStorageTank.java @@ -1,6 +1,5 @@ package mekanism.common; -import universalelectricity.implement.IItemElectric; import ic2.api.IElectricItem; import mekanism.api.IEnergizedItem; import mekanism.api.IStorageTank; diff --git a/src/common/mekanism/common/TileEntityAdvancedElectricMachine.java b/src/common/mekanism/common/TileEntityAdvancedElectricMachine.java index 39c5dddc5..3c3572f6d 100644 --- a/src/common/mekanism/common/TileEntityAdvancedElectricMachine.java +++ b/src/common/mekanism/common/TileEntityAdvancedElectricMachine.java @@ -8,8 +8,7 @@ import java.util.List; import mekanism.api.IMachineUpgrade; import universalelectricity.core.UniversalElectricity; -import universalelectricity.electricity.ElectricInfo; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import buildcraft.api.power.IPowerProvider; import buildcraft.api.power.PowerFramework; @@ -320,7 +319,7 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM secondaryEnergyStored = dataStream.readInt(); currentMaxEnergy = dataStream.readInt(); currentTicksRequired = dataStream.readInt(); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } catch (Exception e) { System.out.println("[Mekanism] Error while handling tile entity packet."); diff --git a/src/common/mekanism/common/TileEntityAdvancedSolarGenerator.java b/src/common/mekanism/common/TileEntityAdvancedSolarGenerator.java index 6b0bf572b..8c929b61d 100644 --- a/src/common/mekanism/common/TileEntityAdvancedSolarGenerator.java +++ b/src/common/mekanism/common/TileEntityAdvancedSolarGenerator.java @@ -1,6 +1,6 @@ package mekanism.common; -import universalelectricity.core.Vector3; +import universalelectricity.core.vector.Vector3; import universalelectricity.prefab.multiblock.*; import mekanism.common.BlockGenerator.GeneratorType; import net.minecraft.src.*; diff --git a/src/common/mekanism/common/TileEntityBasicBlock.java b/src/common/mekanism/common/TileEntityBasicBlock.java index 75428ef3f..ef1c531bd 100644 --- a/src/common/mekanism/common/TileEntityBasicBlock.java +++ b/src/common/mekanism/common/TileEntityBasicBlock.java @@ -2,7 +2,7 @@ package mekanism.common; import com.google.common.io.ByteArrayDataInput; -import universalelectricity.prefab.TileEntityDisableable; +import universalelectricity.prefab.tile.TileEntityDisableable; import ic2.api.EnergyNet; import ic2.api.IWrenchable; import mekanism.api.ITileNetwork; diff --git a/src/common/mekanism/common/TileEntityBasicMachine.java b/src/common/mekanism/common/TileEntityBasicMachine.java index 57099bfdf..edcff59e3 100644 --- a/src/common/mekanism/common/TileEntityBasicMachine.java +++ b/src/common/mekanism/common/TileEntityBasicMachine.java @@ -1,12 +1,9 @@ package mekanism.common; import universalelectricity.core.UniversalElectricity; -import universalelectricity.electricity.ElectricInfo; -import universalelectricity.electricity.ElectricityManager; -import universalelectricity.implement.IElectricityReceiver; -import universalelectricity.implement.IJouleStorage; -import universalelectricity.prefab.TileEntityDisableable; - +import universalelectricity.core.electricity.ElectricInfo; +import universalelectricity.core.implement.IElectricityReceiver; +import universalelectricity.core.implement.IJouleStorage; import buildcraft.api.power.IPowerProvider; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerFramework; @@ -209,7 +206,7 @@ public abstract class TileEntityBasicMachine extends TileEntityElectricBlock imp } @Override - public double getMaxJoules() + public double getMaxJoules(Object... data) { return currentMaxEnergy*UniversalElectricity.IC2_RATIO; } diff --git a/src/common/mekanism/common/TileEntityBioGenerator.java b/src/common/mekanism/common/TileEntityBioGenerator.java index f8e02d77d..7f80e57dc 100644 --- a/src/common/mekanism/common/TileEntityBioGenerator.java +++ b/src/common/mekanism/common/TileEntityBioGenerator.java @@ -3,13 +3,8 @@ package mekanism.common; import ic2.api.ElectricItem; import ic2.api.IElectricItem; import universalelectricity.core.UniversalElectricity; -import universalelectricity.electricity.ElectricInfo; -import universalelectricity.implement.IItemElectric; -import buildcraft.api.core.Orientations; -import buildcraft.api.liquids.ILiquidTank; -import buildcraft.api.liquids.ITankContainer; -import buildcraft.api.liquids.LiquidStack; -import buildcraft.api.liquids.LiquidTank; +import universalelectricity.core.electricity.ElectricInfo; +import universalelectricity.core.implement.IItemElectric; import com.google.common.io.ByteArrayDataInput; @@ -17,6 +12,10 @@ import dan200.computer.api.IComputerAccess; import mekanism.api.IEnergizedItem; import net.minecraft.src.*; import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.liquids.ILiquidTank; +import net.minecraftforge.liquids.ITankContainer; +import net.minecraftforge.liquids.LiquidStack; +import net.minecraftforge.liquids.LiquidTank; public class TileEntityBioGenerator extends TileEntityGenerator implements ITankContainer { @@ -166,7 +165,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank energyStored = dataStream.readInt(); isActive = dataStream.readBoolean(); bioFuelSlot.liquidStored = dataStream.readInt(); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } catch (Exception e) { System.out.println("[Mekanism] Error while handling tile entity packet."); @@ -216,9 +215,9 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank } @Override - public int fill(Orientations from, LiquidStack resource, boolean doFill) + public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) { - if(from.toDirection() != ForgeDirection.getOrientation(facing)) + if(from != ForgeDirection.getOrientation(facing)) { if(resource.itemID == Mekanism.hooks.ForestryBiofuelID) { @@ -253,7 +252,7 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank } @Override - public LiquidStack drain(Orientations from, int maxDrain, boolean doDrain) + public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { return null; } @@ -265,8 +264,14 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements ITank } @Override - public ILiquidTank[] getTanks() + public ILiquidTank[] getTanks(ForgeDirection direction) { return new ILiquidTank[] {new LiquidTank(bioFuelSlot.liquidID, bioFuelSlot.liquidStored, bioFuelSlot.MAX_LIQUID)}; } + + @Override + public ILiquidTank getTank(ForgeDirection direction, LiquidStack type) + { + return null; + } } diff --git a/src/common/mekanism/common/TileEntityElectricBlock.java b/src/common/mekanism/common/TileEntityElectricBlock.java index 6bb00fb2a..3e9d098ff 100644 --- a/src/common/mekanism/common/TileEntityElectricBlock.java +++ b/src/common/mekanism/common/TileEntityElectricBlock.java @@ -5,7 +5,6 @@ import com.google.common.io.ByteArrayDataInput; import buildcraft.api.power.IPowerProvider; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerFramework; -import universalelectricity.prefab.TileEntityDisableable; import ic2.api.EnergyNet; import ic2.api.IWrenchable; import mekanism.api.ITileNetwork; diff --git a/src/common/mekanism/common/TileEntityElectricMachine.java b/src/common/mekanism/common/TileEntityElectricMachine.java index dbc961af1..5f50dbac8 100644 --- a/src/common/mekanism/common/TileEntityElectricMachine.java +++ b/src/common/mekanism/common/TileEntityElectricMachine.java @@ -7,8 +7,7 @@ import java.util.List; import universalelectricity.core.UniversalElectricity; -import universalelectricity.electricity.ElectricInfo; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import buildcraft.api.power.IPowerProvider; import buildcraft.api.power.PowerFramework; @@ -273,7 +272,7 @@ public abstract class TileEntityElectricMachine extends TileEntityBasicMachine energyStored = dataStream.readInt(); currentMaxEnergy = dataStream.readInt(); currentTicksRequired = dataStream.readInt(); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } catch (Exception e) { System.out.println("[Mekanism] Error while handling tile entity packet."); diff --git a/src/common/mekanism/common/TileEntityElectrolyticSeparator.java b/src/common/mekanism/common/TileEntityElectrolyticSeparator.java index 838ca833a..a494fa142 100644 --- a/src/common/mekanism/common/TileEntityElectrolyticSeparator.java +++ b/src/common/mekanism/common/TileEntityElectrolyticSeparator.java @@ -5,17 +5,10 @@ import ic2.api.ElectricItem; import ic2.api.IElectricItem; import ic2.api.IEnergySink; import universalelectricity.core.UniversalElectricity; -import universalelectricity.core.Vector3; -import universalelectricity.electricity.ElectricInfo; -import universalelectricity.implement.IElectricityReceiver; -import universalelectricity.implement.IItemElectric; -import universalelectricity.implement.IJouleStorage; - -import buildcraft.api.core.Orientations; -import buildcraft.api.liquids.ILiquidTank; -import buildcraft.api.liquids.ITankContainer; -import buildcraft.api.liquids.LiquidStack; -import buildcraft.api.liquids.LiquidTank; +import universalelectricity.core.electricity.ElectricInfo; +import universalelectricity.core.implement.IElectricityReceiver; +import universalelectricity.core.implement.IJouleStorage; +import universalelectricity.core.vector.Vector3; import com.google.common.io.ByteArrayDataInput; @@ -30,6 +23,10 @@ import mekanism.api.IStorageTank.EnumGas; import mekanism.api.ITileNetwork; import net.minecraft.src.*; import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.liquids.ILiquidTank; +import net.minecraftforge.liquids.ITankContainer; +import net.minecraftforge.liquids.LiquidStack; +import net.minecraftforge.liquids.LiquidTank; public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IGasStorage, IEnergySink, IJouleStorage, IElectricityReceiver, IEnergyAcceptor, ITankContainer, IPeripheral { @@ -254,7 +251,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp waterSlot.liquidStored = dataStream.readInt(); oxygenStored = dataStream.readInt(); hydrogenStored = dataStream.readInt(); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } catch (Exception e) { System.out.println("[Mekanism] Error while handling tile entity packet."); @@ -336,7 +333,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } @Override - public double getMaxJoules() + public double getMaxJoules(Object... data) { return MAX_ENERGY*UniversalElectricity.IC2_RATIO; } @@ -426,9 +423,9 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } @Override - public int fill(Orientations from, LiquidStack resource, boolean doFill) + public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) { - if(from.toDirection() != ForgeDirection.getOrientation(facing)) + if(from != ForgeDirection.getOrientation(facing)) { if(resource.itemID == Block.waterStill.blockID) { @@ -463,7 +460,7 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } @Override - public LiquidStack drain(Orientations from, int maxDrain, boolean doDrain) + public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { return null; } @@ -475,11 +472,17 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } @Override - public ILiquidTank[] getTanks() + public ILiquidTank[] getTanks(ForgeDirection direction) { return new ILiquidTank[] {new LiquidTank(waterSlot.liquidID, waterSlot.liquidStored, waterSlot.MAX_LIQUID)}; } + @Override + public ILiquidTank getTank(ForgeDirection direction, LiquidStack type) + { + return null; + } + @Override public void readFromNBT(NBTTagCompound nbtTags) { diff --git a/src/common/mekanism/common/TileEntityGasTank.java b/src/common/mekanism/common/TileEntityGasTank.java index 89ffd3c47..23b3c897f 100644 --- a/src/common/mekanism/common/TileEntityGasTank.java +++ b/src/common/mekanism/common/TileEntityGasTank.java @@ -1,6 +1,6 @@ package mekanism.common; -import universalelectricity.core.Vector3; +import universalelectricity.core.vector.Vector3; import com.google.common.io.ByteArrayDataInput; @@ -181,7 +181,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasS facing = dataStream.readInt(); gasStored = dataStream.readInt(); gasType = EnumGas.getFromName(dataStream.readUTF()); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } catch (Exception e) { System.out.println("[Mekanism] Error while handling tile entity packet."); diff --git a/src/common/mekanism/common/TileEntityGenerator.java b/src/common/mekanism/common/TileEntityGenerator.java index f8d56370d..efa1af688 100644 --- a/src/common/mekanism/common/TileEntityGenerator.java +++ b/src/common/mekanism/common/TileEntityGenerator.java @@ -1,6 +1,5 @@ package mekanism.common; -import buildcraft.api.core.Orientations; import buildcraft.api.power.IPowerProvider; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerFramework; @@ -18,14 +17,13 @@ import ic2.api.IElectricItem; import ic2.api.IEnergySource; import ic2.api.IEnergyStorage; import universalelectricity.core.UniversalElectricity; -import universalelectricity.core.Vector3; -import universalelectricity.electricity.ElectricInfo; -import universalelectricity.electricity.ElectricityManager; -import universalelectricity.implement.IConductor; -import universalelectricity.implement.IElectricityReceiver; -import universalelectricity.implement.IItemElectric; -import universalelectricity.implement.IJouleStorage; -import universalelectricity.prefab.TileEntityConductor; +import universalelectricity.core.electricity.ElectricInfo; +import universalelectricity.core.electricity.ElectricityManager; +import universalelectricity.core.implement.IConductor; +import universalelectricity.core.implement.IElectricityReceiver; +import universalelectricity.core.implement.IJouleStorage; +import universalelectricity.core.vector.Vector3; +import universalelectricity.prefab.tile.TileEntityConductor; import mekanism.api.IEnergizedItem; import mekanism.api.IEnergyAcceptor; import net.minecraft.src.*; @@ -87,7 +85,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem IPowerReceptor receptor = (IPowerReceptor)tileEntity; int energyNeeded = Math.min(receptor.getPowerProvider().getMinEnergyReceived(), receptor.getPowerProvider().getMaxEnergyReceived())*10; float transferEnergy = Math.max(Math.min(Math.min(energyNeeded, energyStored), 54000), 0); - receptor.getPowerProvider().receiveEnergy((float)(transferEnergy/10), Orientations.dirs()[ForgeDirection.getOrientation(facing).getOpposite().ordinal()]); + receptor.getPowerProvider().receiveEnergy((float)(transferEnergy/10), ForgeDirection.getOrientation(facing).getOpposite()); setEnergy(energyStored - (int)transferEnergy); } else if(tileEntity instanceof TileEntityConductor) @@ -238,7 +236,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem } @Override - public double getMaxJoules() + public double getMaxJoules(Object... data) { return MAX_ENERGY*UniversalElectricity.IC2_RATIO; } @@ -274,7 +272,7 @@ public abstract class TileEntityGenerator extends TileEntityElectricBlock implem } @Override - public int getRate() + public int getOutput() { return output; } diff --git a/src/common/mekanism/common/TileEntityHeatGenerator.java b/src/common/mekanism/common/TileEntityHeatGenerator.java index 9fe901f34..2d4d40709 100644 --- a/src/common/mekanism/common/TileEntityHeatGenerator.java +++ b/src/common/mekanism/common/TileEntityHeatGenerator.java @@ -5,13 +5,8 @@ import java.io.DataOutputStream; import ic2.api.ElectricItem; import ic2.api.IElectricItem; import universalelectricity.core.UniversalElectricity; -import universalelectricity.electricity.ElectricInfo; -import universalelectricity.implement.IItemElectric; -import buildcraft.api.core.Orientations; -import buildcraft.api.liquids.ILiquidTank; -import buildcraft.api.liquids.ITankContainer; -import buildcraft.api.liquids.LiquidStack; -import buildcraft.api.liquids.LiquidTank; +import universalelectricity.core.electricity.ElectricInfo; +import universalelectricity.core.implement.IItemElectric; import buildcraft.api.power.PowerFramework; import com.google.common.io.ByteArrayDataInput; @@ -21,6 +16,10 @@ import dan200.computer.api.IComputerAccess; import mekanism.api.IEnergizedItem; import net.minecraft.src.*; import net.minecraftforge.common.ForgeDirection; +import net.minecraftforge.liquids.ILiquidTank; +import net.minecraftforge.liquids.ITankContainer; +import net.minecraftforge.liquids.LiquidStack; +import net.minecraftforge.liquids.LiquidTank; public class TileEntityHeatGenerator extends TileEntityGenerator implements ITankContainer { @@ -187,7 +186,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan energyStored = dataStream.readInt(); isActive = dataStream.readBoolean(); fuelSlot.liquidStored = dataStream.readInt(); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } catch (Exception e) { System.out.println("[Mekanism] Error while handling tile entity packet."); @@ -237,9 +236,9 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan } @Override - public int fill(Orientations from, LiquidStack resource, boolean doFill) + public int fill(ForgeDirection from, LiquidStack resource, boolean doFill) { - if(from.toDirection() != ForgeDirection.getOrientation(facing)) + if(from != ForgeDirection.getOrientation(facing)) { if(resource.itemID == Mekanism.hooks.BuildCraftFuelID) { @@ -274,7 +273,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan } @Override - public LiquidStack drain(Orientations from, int maxDrain, boolean doDrain) + public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { return null; } @@ -286,8 +285,14 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements ITan } @Override - public ILiquidTank[] getTanks() + public ILiquidTank[] getTanks(ForgeDirection direction) { return new ILiquidTank[] {new LiquidTank(fuelSlot.liquidID, fuelSlot.liquidStored, fuelSlot.MAX_LIQUID)}; } + + @Override + public ILiquidTank getTank(ForgeDirection direction, LiquidStack type) + { + return null; + } } diff --git a/src/common/mekanism/common/TileEntityHydrogenGenerator.java b/src/common/mekanism/common/TileEntityHydrogenGenerator.java index d530d7f97..923760778 100644 --- a/src/common/mekanism/common/TileEntityHydrogenGenerator.java +++ b/src/common/mekanism/common/TileEntityHydrogenGenerator.java @@ -3,8 +3,8 @@ package mekanism.common; import ic2.api.ElectricItem; import ic2.api.IElectricItem; import universalelectricity.core.UniversalElectricity; -import universalelectricity.electricity.ElectricInfo; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.electricity.ElectricInfo; +import universalelectricity.core.implement.IItemElectric; import com.google.common.io.ByteArrayDataInput; @@ -188,7 +188,7 @@ public class TileEntityHydrogenGenerator extends TileEntityGenerator implements energyStored = dataStream.readInt(); hydrogenStored = dataStream.readInt(); isActive = dataStream.readBoolean(); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } catch (Exception e) { System.out.println("[Mekanism] Error while handling tile entity packet."); diff --git a/src/common/mekanism/common/TileEntityPowerUnit.java b/src/common/mekanism/common/TileEntityPowerUnit.java index 5e9c0100a..4f6d79d11 100644 --- a/src/common/mekanism/common/TileEntityPowerUnit.java +++ b/src/common/mekanism/common/TileEntityPowerUnit.java @@ -4,23 +4,20 @@ import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; - import universalelectricity.core.UniversalElectricity; -import universalelectricity.core.Vector3; -import universalelectricity.electricity.ElectricInfo; -import universalelectricity.electricity.ElectricityManager; -import universalelectricity.implement.IConductor; -import universalelectricity.implement.IElectricityReceiver; -import universalelectricity.implement.IItemElectric; -import universalelectricity.implement.IJouleStorage; -import universalelectricity.prefab.TileEntityConductor; -import universalelectricity.prefab.TileEntityDisableable; +import universalelectricity.core.electricity.ElectricInfo; +import universalelectricity.core.electricity.ElectricityManager; +import universalelectricity.core.implement.IConductor; +import universalelectricity.core.implement.IElectricityReceiver; +import universalelectricity.core.implement.IItemElectric; +import universalelectricity.core.implement.IJouleStorage; +import universalelectricity.prefab.tile.TileEntityConductor; +import universalelectricity.core.vector.Vector3; import buildcraft.api.power.IPowerProvider; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerFramework; import buildcraft.api.power.PowerProvider; -import buildcraft.api.core.Orientations; import com.google.common.io.ByteArrayDataInput; @@ -193,7 +190,7 @@ public class TileEntityPowerUnit extends TileEntityElectricBlock implements IEne IPowerReceptor receptor = (IPowerReceptor)tileEntity; int energyNeeded = Math.min(receptor.getPowerProvider().getMinEnergyReceived(), receptor.getPowerProvider().getMaxEnergyReceived())*10; float transferEnergy = Math.max(Math.min(Math.min(energyNeeded, energyStored), 54000), 0); - receptor.getPowerProvider().receiveEnergy((float)(transferEnergy/10), Orientations.dirs()[ForgeDirection.getOrientation(facing).getOpposite().ordinal()]); + receptor.getPowerProvider().receiveEnergy((float)(transferEnergy/10), ForgeDirection.getOrientation(facing).getOpposite()); setEnergy(energyStored - (int)transferEnergy); } else if(tileEntity instanceof TileEntityConductor) @@ -257,7 +254,7 @@ public class TileEntityPowerUnit extends TileEntityElectricBlock implements IEne } @Override - public int getRate() + public int getOutput() { return output; } @@ -311,7 +308,7 @@ public class TileEntityPowerUnit extends TileEntityElectricBlock implements IEne } @Override - public double getMaxJoules() + public double getMaxJoules(Object... data) { return MAX_ENERGY*UniversalElectricity.IC2_RATIO; } @@ -468,7 +465,7 @@ public class TileEntityPowerUnit extends TileEntityElectricBlock implements IEne try { facing = dataStream.readInt(); energyStored = dataStream.readInt(); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } catch (Exception e) { System.out.println("[Mekanism] Error while handling tile entity packet."); diff --git a/src/common/mekanism/common/TileEntitySolarGenerator.java b/src/common/mekanism/common/TileEntitySolarGenerator.java index 31efb4073..bba00ba6b 100644 --- a/src/common/mekanism/common/TileEntitySolarGenerator.java +++ b/src/common/mekanism/common/TileEntitySolarGenerator.java @@ -3,8 +3,8 @@ package mekanism.common; import ic2.api.ElectricItem; import ic2.api.IElectricItem; import universalelectricity.core.UniversalElectricity; -import universalelectricity.electricity.ElectricInfo; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.electricity.ElectricInfo; +import universalelectricity.core.implement.IItemElectric; import com.google.common.io.ByteArrayDataInput; @@ -134,7 +134,7 @@ public class TileEntitySolarGenerator extends TileEntityGenerator energyStored = dataStream.readInt(); isActive = dataStream.readBoolean(); seesSun = dataStream.readBoolean(); - worldObj.markBlockAsNeedsUpdate(xCoord, yCoord, zCoord); + worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord); } catch (Exception e) { System.out.println("[Mekanism] Error while handling tile entity packet."); diff --git a/src/common/railcraft/common/api/carts/CartBase.java b/src/common/railcraft/common/api/carts/CartBase.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/carts/CartTools.java b/src/common/railcraft/common/api/carts/CartTools.java old mode 100755 new mode 100644 index c889872dd..22ee3fd36 --- a/src/common/railcraft/common/api/carts/CartTools.java +++ b/src/common/railcraft/common/api/carts/CartTools.java @@ -1,6 +1,5 @@ package railcraft.common.api.carts; -import railcraft.common.api.core.items.IMinecartItem; import cpw.mods.fml.common.registry.EntityRegistry; import java.util.ArrayList; import java.util.List; @@ -12,6 +11,7 @@ import net.minecraft.src.ItemMinecart; import net.minecraft.src.ItemStack; import net.minecraft.src.World; import net.minecraftforge.common.ForgeDirection; +import railcraft.common.api.core.items.IMinecartItem; public abstract class CartTools { diff --git a/src/common/railcraft/common/api/carts/ICartRenderInterface.java b/src/common/railcraft/common/api/carts/ICartRenderInterface.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/carts/IEnergyTransfer.java b/src/common/railcraft/common/api/carts/IEnergyTransfer.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/carts/IExplosiveCart.java b/src/common/railcraft/common/api/carts/IExplosiveCart.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/carts/IItemTransfer.java b/src/common/railcraft/common/api/carts/IItemTransfer.java old mode 100755 new mode 100644 index a5af647d5..1876ad389 --- a/src/common/railcraft/common/api/carts/IItemTransfer.java +++ b/src/common/railcraft/common/api/carts/IItemTransfer.java @@ -1,7 +1,7 @@ package railcraft.common.api.carts; import net.minecraft.src.ItemStack; -import railcraft.common.api.core.items.EnumItemType; +import railcraft.common.api.core.items.IItemType; /** * This interface allows items to be passed around with out needing @@ -55,11 +55,11 @@ public interface IItemTransfer * determine which ItemStack to return, or none at all. * However, if the return value is not null * it should fulfill the following condition:
- * EnumItemType.isItemType(it.requestItem(this,request), request) == true + * IItemType.isItemType(it.requestItem(this,request), request) == true * * @param source The Object submitting the request * @param request The type of item requested * @return An ItemStack to fulfill the request or null if refused. */ - public ItemStack requestItem(Object source, EnumItemType request); + public ItemStack requestItem(Object source, IItemType request); } diff --git a/src/common/railcraft/common/api/carts/ILinkableCart.java b/src/common/railcraft/common/api/carts/ILinkableCart.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/carts/ILinkageManager.java b/src/common/railcraft/common/api/carts/ILinkageManager.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/carts/ILiquidTransfer.java b/src/common/railcraft/common/api/carts/ILiquidTransfer.java old mode 100755 new mode 100644 index 8d72e7348..b587ddd52 --- a/src/common/railcraft/common/api/carts/ILiquidTransfer.java +++ b/src/common/railcraft/common/api/carts/ILiquidTransfer.java @@ -1,23 +1,23 @@ package railcraft.common.api.carts; -import buildcraft.api.liquids.LiquidStack; +import net.minecraftforge.liquids.LiquidStack; /** - * This interface allows carts to transfer liquid between each other - * as well as adding a couple other functions related to liquids. + * This interface allows carts to transfer liquid between each other as well as + * adding a couple other functions related to liquids. * * @author CovertJaguar */ -public interface ILiquidTransfer -{ +public interface ILiquidTransfer { /** * Offers liquid to this object. * - * Is not used by the Liquid Loader to load carts, - * the traditional ILiquidContainer is used for that. + * Is not used by the Liquid Loader to load carts, the traditional + * ILiquidContainer is used for that. * - * @param source The Object offering the liquid, used to prevent request loops in trains + * @param source The Object offering the liquid, used to prevent request + * loops in trains * @param quantity The quantity offered * @param id The liquid id offered * @return the liquid used @@ -27,10 +27,11 @@ public interface ILiquidTransfer /** * Requests liquid from this object. * - * Is not used by the Liquid Unloader to drain carts, - * the traditional ILiquidContainer is used for that. + * Is not used by the Liquid Unloader to drain carts, the traditional + * ILiquidContainer is used for that. * - * @param source The Object requesting the liquid, used to prevent request loops in trains + * @param source The Object requesting the liquid, used to prevent request + * loops in trains * @param quantity The quantity requested * @param id The liquid type requested * @return the liquid provided @@ -38,9 +39,9 @@ public interface ILiquidTransfer public int requestLiquid(Object source, LiquidStack request); /** - * Set by the Liquid Loader while filling, - * primarily used for rendering a visible - * change while being filled. + * Set by the Liquid Loader while filling, primarily used for rendering a + * visible change while being filled. + * * @param filling */ public void setFilling(boolean filling); diff --git a/src/common/railcraft/common/api/carts/IMinecart.java b/src/common/railcraft/common/api/carts/IMinecart.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/carts/TransferCartBase.java b/src/common/railcraft/common/api/carts/TransferCartBase.java old mode 100755 new mode 100644 index d623308eb..6577ca495 --- a/src/common/railcraft/common/api/carts/TransferCartBase.java +++ b/src/common/railcraft/common/api/carts/TransferCartBase.java @@ -4,7 +4,7 @@ import net.minecraft.src.EntityMinecart; import net.minecraft.src.IInventory; import net.minecraft.src.ItemStack; import net.minecraft.src.World; -import railcraft.common.api.core.items.EnumItemType; +import railcraft.common.api.core.items.IItemType; /** * Abstract minecart class that implements the IItemTransfer @@ -124,7 +124,7 @@ public abstract class TransferCartBase extends CartBase implements IItemTransfer } @Override - public ItemStack requestItem(Object source, EnumItemType request) + public ItemStack requestItem(Object source, IItemType request) { ItemStack result = null; if(!passThrough && getSizeInventory() > 0) { @@ -192,7 +192,7 @@ public abstract class TransferCartBase extends CartBase implements IItemTransfer * @param filter EnumItemType to match against * @return An ItemStack */ - protected final ItemStack removeOneItem(IInventory inv, EnumItemType filter) + protected final ItemStack removeOneItem(IInventory inv, IItemType filter) { for(int i = 0; i < inv.getSizeInventory(); i++) { ItemStack slot = inv.getStackInSlot(i); diff --git a/src/common/railcraft/common/api/carts/bore/IBoreHead.java b/src/common/railcraft/common/api/carts/bore/IBoreHead.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/carts/bore/IMineable.java b/src/common/railcraft/common/api/carts/bore/IMineable.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/core/INetworkedObject.java b/src/common/railcraft/common/api/core/INetworkedObject.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/core/IPostConnection.java b/src/common/railcraft/common/api/core/IPostConnection.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/core/WorldCoordinate.java b/src/common/railcraft/common/api/core/WorldCoordinate.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/core/items/BallastRegistry.java b/src/common/railcraft/common/api/core/items/BallastRegistry.java deleted file mode 100755 index dcc724f1a..000000000 --- a/src/common/railcraft/common/api/core/items/BallastRegistry.java +++ /dev/null @@ -1,93 +0,0 @@ -package railcraft.common.api.core.items; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import net.minecraft.src.Block; -import net.minecraft.src.ItemBlock; -import net.minecraft.src.ItemStack; - -/** - * Register an item here to designate it as a possible - * ballast that can be used in the Bore. - * - * It is expected that ballast is affected by gravity. - * - * @author CovertJaguar - */ -public abstract class BallastRegistry -{ - - private static Set ballastRegistry = new HashSet(); - - private static class ItemWrapper - { - - public int itemID; - public int itemDamage; - public ItemStack stack; - - public ItemWrapper(ItemStack stack) - { - itemID = stack.itemID; - itemDamage = stack.getItemDamage(); - this.stack = stack; - } - - @Override - public boolean equals(Object obj) - { - if(obj == null) { - return false; - } - if(getClass() != obj.getClass()) { - return false; - } - final ItemWrapper other = (ItemWrapper)obj; - if(this.itemID != other.itemID) { - return false; - } - if(this.itemDamage != other.itemDamage) { - return false; - } - return true; - } - - @Override - public int hashCode() - { - int hash = 3; - hash = 47 * hash + this.itemID; - hash = 47 * hash + this.itemDamage; - return hash; - } - } - - static { - registerBallast(new ItemStack(Block.gravel)); - } - - public static void registerBallast(ItemStack ballast) - { - if(ballast.getItem() instanceof ItemBlock) { - ballastRegistry.add(new ItemWrapper(ballast)); - } else { - throw new RuntimeException("Attempted to register an invalid ballast, must be an ItemBlock item."); - } - } - - public static boolean isItemBallast(ItemStack ballast) - { - return ballastRegistry.contains(new ItemWrapper(ballast)); - } - - public static List getRegisteredBallasts() - { - List list = new ArrayList(); - for(ItemWrapper item : ballastRegistry) { - list.add(item.stack); - } - return list; - } -} diff --git a/src/common/railcraft/common/api/core/items/EnumItemType.java b/src/common/railcraft/common/api/core/items/EnumItemType.java deleted file mode 100755 index 00a7a2aca..000000000 --- a/src/common/railcraft/common/api/core/items/EnumItemType.java +++ /dev/null @@ -1,47 +0,0 @@ -package railcraft.common.api.core.items; - -import net.minecraft.src.BlockRail; -import net.minecraft.src.Item; -import net.minecraft.src.ItemBlock; -import net.minecraft.src.ItemFood; -import net.minecraft.src.ItemStack; -import net.minecraft.src.TileEntityFurnace; -import net.minecraftforge.common.MinecartRegistry; - -/** - * This interface is used with several of the functions in IItemTransfer - * to provide a convenient means of dealing with entire classes of items without - * having to specify each item individually. - * @author CovertJaguar - */ -public enum EnumItemType -{ - - FUEL, RAIL, MINECART, BALLAST, FOOD; - - public static boolean isItemType(ItemStack stack, EnumItemType filter) - { - return filter.isItemType(stack); - } - - public boolean isItemType(ItemStack stack) - { - if(stack == null) { - return false; - } - switch (this) { - case FUEL: - return TileEntityFurnace.isItemFuel(stack); - case RAIL: - return stack.getItem() instanceof ITrackItem || (stack.getItem() instanceof ItemBlock && BlockRail.isRailBlock(stack.itemID)); - case MINECART: - return MinecartRegistry.getCartClassForItem(stack) != null || stack.getItem() instanceof IMinecartItem; - case BALLAST: - return BallastRegistry.isItemBallast(stack); - case FOOD: - return stack.getItem() instanceof ItemFood || stack.itemID == Item.wheat.shiftedIndex; - default: - return false; - } - } -} diff --git a/src/common/railcraft/common/api/core/items/ICrowbar.java b/src/common/railcraft/common/api/core/items/ICrowbar.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/core/items/IItemType.java b/src/common/railcraft/common/api/core/items/IItemType.java new file mode 100644 index 000000000..5b1ca29b5 --- /dev/null +++ b/src/common/railcraft/common/api/core/items/IItemType.java @@ -0,0 +1,23 @@ +package railcraft.common.api.core.items; + +import java.util.HashMap; +import java.util.Map; +import net.minecraft.src.ItemStack; + +/** + * This interface is used with several of the functions in IItemTransfer + * to provide a convenient means of dealing with entire classes of items without + * having to specify each item individually. + * @author CovertJaguar + */ +public interface IItemType +{ + /** + * Railcraft adds the following IItemTypes during preInit: FUEL, TRACK, MINECART, BALLAST, FEED + * + * Feel free to grab them from here or define your own. + */ + public static final Map types = new HashMap(); + + public boolean isItemType(ItemStack stack); +} diff --git a/src/common/railcraft/common/api/core/items/IMinecartItem.java b/src/common/railcraft/common/api/core/items/IMinecartItem.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/core/items/ITrackItem.java b/src/common/railcraft/common/api/core/items/ITrackItem.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/core/items/ItemRegistry.java b/src/common/railcraft/common/api/core/items/ItemRegistry.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/crafting/IBlastFurnaceCraftingManager.java b/src/common/railcraft/common/api/crafting/IBlastFurnaceCraftingManager.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/crafting/IBlastFurnaceRecipe.java b/src/common/railcraft/common/api/crafting/IBlastFurnaceRecipe.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/crafting/ICokeOvenCraftingManager.java b/src/common/railcraft/common/api/crafting/ICokeOvenCraftingManager.java old mode 100755 new mode 100644 index a6e5b73f3..0c2d810ff --- a/src/common/railcraft/common/api/crafting/ICokeOvenCraftingManager.java +++ b/src/common/railcraft/common/api/crafting/ICokeOvenCraftingManager.java @@ -1,15 +1,14 @@ package railcraft.common.api.crafting; -import buildcraft.api.liquids.LiquidStack; import java.util.List; import net.minecraft.src.ItemStack; +import net.minecraftforge.liquids.LiquidStack; /** * * @author CovertJaguar */ -public interface ICokeOvenCraftingManager -{ +public interface ICokeOvenCraftingManager { void addRecipe(ItemStack input, ItemStack output, LiquidStack liquidOutput, int cookTime); @@ -22,5 +21,4 @@ public interface ICokeOvenCraftingManager ICokeOvenRecipe getRecipe(int inputId, int inputDamage); List getRecipes(); - } diff --git a/src/common/railcraft/common/api/crafting/ICokeOvenRecipe.java b/src/common/railcraft/common/api/crafting/ICokeOvenRecipe.java old mode 100755 new mode 100644 index f2e9e29f5..844c24256 --- a/src/common/railcraft/common/api/crafting/ICokeOvenRecipe.java +++ b/src/common/railcraft/common/api/crafting/ICokeOvenRecipe.java @@ -1,7 +1,7 @@ package railcraft.common.api.crafting; -import buildcraft.api.liquids.LiquidStack; import net.minecraft.src.ItemStack; +import net.minecraftforge.liquids.LiquidStack; /** * diff --git a/src/common/railcraft/common/api/crafting/IRockCrusherCraftingManager.java b/src/common/railcraft/common/api/crafting/IRockCrusherCraftingManager.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/crafting/IRockCrusherRecipe.java b/src/common/railcraft/common/api/crafting/IRockCrusherRecipe.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/crafting/IRollingMachineCraftingManager.java b/src/common/railcraft/common/api/crafting/IRollingMachineCraftingManager.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/crafting/RailcraftCraftingManager.java b/src/common/railcraft/common/api/crafting/RailcraftCraftingManager.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/fuel/FuelManager.java b/src/common/railcraft/common/api/fuel/FuelManager.java new file mode 100644 index 000000000..aa4246adf --- /dev/null +++ b/src/common/railcraft/common/api/fuel/FuelManager.java @@ -0,0 +1,35 @@ +package railcraft.common.api.fuel; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import net.minecraftforge.liquids.LiquidStack; + +/** + * + * @author CovertJaguar + */ +public class FuelManager +{ + + public static final Map boilerFuel = new HashMap(); + + /** + * Register the amount of heat in a bucket of liquid fuel. + * + * @param liquid + * @param heatValuePerBucket + */ + public static void addBoilerFuel(LiquidStack liquid, int heatValuePerBucket) { + boilerFuel.put(liquid, heatValuePerBucket); + } + + public static int getBoilerFuelValue(LiquidStack liquid) { + for(Entry entry : boilerFuel.entrySet()) { + if(entry.getKey().isLiquidEqual(liquid)) { + return entry.getValue(); + } + } + return 0; + } +} diff --git a/src/common/railcraft/common/api/signals/EnumSignalAspect.java b/src/common/railcraft/common/api/signals/EnumSignalAspect.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/signals/IBlockSignal.java b/src/common/railcraft/common/api/signals/IBlockSignal.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/signals/ISignalController.java b/src/common/railcraft/common/api/signals/ISignalController.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/signals/ISignalReceiver.java b/src/common/railcraft/common/api/signals/ISignalReceiver.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/signals/SignalTools.java b/src/common/railcraft/common/api/signals/SignalTools.java old mode 100755 new mode 100644 index 2c2b272c6..46b689d24 --- a/src/common/railcraft/common/api/signals/SignalTools.java +++ b/src/common/railcraft/common/api/signals/SignalTools.java @@ -7,8 +7,8 @@ import net.minecraft.src.EntityPlayer; import net.minecraft.src.ItemStack; import net.minecraft.src.TileEntity; import net.minecraft.src.World; -import railcraft.common.api.tracks.RailTools; import railcraft.common.api.core.WorldCoordinate; +import railcraft.common.api.tracks.RailTools; /** * This is not documented and needs some reworking to simplify usage. diff --git a/src/common/railcraft/common/api/tracks/ITrackCustomPlaced.java b/src/common/railcraft/common/api/tracks/ITrackCustomPlaced.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/tracks/ITrackCustomShape.java b/src/common/railcraft/common/api/tracks/ITrackCustomShape.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/tracks/ITrackEmitter.java b/src/common/railcraft/common/api/tracks/ITrackEmitter.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/tracks/ITrackInstance.java b/src/common/railcraft/common/api/tracks/ITrackInstance.java old mode 100755 new mode 100644 index 460959fa6..b3a3f5efd --- a/src/common/railcraft/common/api/tracks/ITrackInstance.java +++ b/src/common/railcraft/common/api/tracks/ITrackInstance.java @@ -79,7 +79,7 @@ public interface ITrackInstance extends INetworkedObject public boolean blockActivated(EntityPlayer player); - public void onBlockPlaced(int side); + public void onBlockPlaced(); public void onBlockPlacedBy(EntityLiving entity); diff --git a/src/common/railcraft/common/api/tracks/ITrackLockdown.java b/src/common/railcraft/common/api/tracks/ITrackLockdown.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/tracks/ITrackPowered.java b/src/common/railcraft/common/api/tracks/ITrackPowered.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/tracks/ITrackReversable.java b/src/common/railcraft/common/api/tracks/ITrackReversable.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/tracks/ITrackSwitch.java b/src/common/railcraft/common/api/tracks/ITrackSwitch.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/tracks/ITrackTile.java b/src/common/railcraft/common/api/tracks/ITrackTile.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/tracks/RailTools.java b/src/common/railcraft/common/api/tracks/RailTools.java old mode 100755 new mode 100644 index 393530202..c6ad39555 --- a/src/common/railcraft/common/api/tracks/RailTools.java +++ b/src/common/railcraft/common/api/tracks/RailTools.java @@ -1,6 +1,5 @@ package railcraft.common.api.tracks; -import railcraft.common.api.core.items.ITrackItem; import net.minecraft.src.Block; import net.minecraft.src.BlockRail; import net.minecraft.src.EntityMinecart; @@ -9,6 +8,7 @@ import net.minecraft.src.ItemStack; import net.minecraft.src.MathHelper; import net.minecraft.src.TileEntity; import net.minecraft.src.World; +import railcraft.common.api.core.items.ITrackItem; /** * A number of utility functions related to rails. diff --git a/src/common/railcraft/common/api/tracks/TrackInstanceBase.java b/src/common/railcraft/common/api/tracks/TrackInstanceBase.java old mode 100755 new mode 100644 index 35d04573e..74d6dc6ee --- a/src/common/railcraft/common/api/tracks/TrackInstanceBase.java +++ b/src/common/railcraft/common/api/tracks/TrackInstanceBase.java @@ -79,7 +79,7 @@ public abstract class TrackInstanceBase implements ITrackInstance } @Override - public void onBlockPlaced(int side) + public void onBlockPlaced() { switchTrack(true); testPower(); @@ -101,7 +101,7 @@ public abstract class TrackInstanceBase implements ITrackInstance public void markBlockNeedsUpdate() { - getWorld().markBlockNeedsUpdate(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); + getWorld().markBlockForRenderUpdate(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); } protected boolean isRailValid(World world, int i, int j, int k, int meta) diff --git a/src/common/railcraft/common/api/tracks/TrackRegistry.java b/src/common/railcraft/common/api/tracks/TrackRegistry.java old mode 100755 new mode 100644 diff --git a/src/common/railcraft/common/api/tracks/TrackSpec.java b/src/common/railcraft/common/api/tracks/TrackSpec.java old mode 100755 new mode 100644 index 68608a63a..1997c315b --- a/src/common/railcraft/common/api/tracks/TrackSpec.java +++ b/src/common/railcraft/common/api/tracks/TrackSpec.java @@ -1,7 +1,6 @@ package railcraft.common.api.tracks; import net.minecraft.src.ItemStack; -import railcraft.common.api.core.items.ItemRegistry; /** * Each type of Track has a single instance of TrackSpec diff --git a/src/common/universalelectricity/core/UEConfig.java b/src/common/universalelectricity/core/UEConfig.java old mode 100755 new mode 100644 diff --git a/src/common/universalelectricity/core/UELoader.java b/src/common/universalelectricity/core/UELoader.java old mode 100755 new mode 100644 index e0dbde41f..dc3d6415a --- a/src/common/universalelectricity/core/UELoader.java +++ b/src/common/universalelectricity/core/UELoader.java @@ -4,8 +4,8 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.world.WorldEvent.Load; import net.minecraftforge.event.world.WorldEvent.Unload; -import universalelectricity.electricity.ElectricityManager; -import universalelectricity.electricity.ElectricityManagerTicker; +import universalelectricity.core.electricity.ElectricityManager; +import universalelectricity.core.electricity.ElectricityManagerTicker; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Side; @@ -13,8 +13,9 @@ import cpw.mods.fml.common.registry.TickRegistry; /** * A class used to load Universal Electricity and make it work. + * * @author Calclavia - * + * */ public class UELoader { diff --git a/src/common/universalelectricity/core/UniversalElectricity.java b/src/common/universalelectricity/core/UniversalElectricity.java old mode 100755 new mode 100644 index abc082bd2..7f2b62b06 --- a/src/common/universalelectricity/core/UniversalElectricity.java +++ b/src/common/universalelectricity/core/UniversalElectricity.java @@ -14,12 +14,10 @@ import cpw.mods.fml.common.Loader; /** * Instructions for using the Universal Electricity API. * - * The less you include of the API, the more compatible your - * mod will be for future releases of Universal Electricity. + * The less you include of the API, the more compatible your mod will be for future releases of + * Universal Electricity. * - * REQUIRED PACKAGES: - * "universalelectricity" - * "universalelectricity.electricity" + * REQUIRED PACKAGES: "universalelectricity" "universalelectricity.electricity" * "universalelectricity.implements" - Some interfaces can be removed if not needed. * * The rest of the classes should be removed if you are not going to use them. @@ -33,8 +31,8 @@ public class UniversalElectricity * The version of the Universal Electricity API. */ public static final int MAJOR_VERSION = 1; - public static final int MINOR_VERSION = 0; - public static final int REVISION_VERSION = 0; + public static final int MINOR_VERSION = 1; + public static final int REVISION_VERSION = 2; public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVISION_VERSION; /** @@ -53,16 +51,15 @@ public class UniversalElectricity public static final float TO_BC_RATIO = 1 / BC3_RATIO; /** - * Use this material for all your machine blocks. It can be breakable by - * hand. + * Use this material for all your machine blocks. It can be breakable by hand. */ public static final Material machine = new Material(MapColor.ironColor); public static final List mods = new ArrayList(); /** - * You must register your mod with Universal Electricity. Call this in your - * mod's pre-initialization stage. + * You must register your mod with Universal Electricity. Call this in your mod's + * pre-initialization stage. */ public static void register(Object mod, int major, int minor, int revision, boolean strict) { @@ -83,15 +80,14 @@ public class UniversalElectricity } mods.add(mod); - - FMLLog.fine(mod.getClass().getSimpleName()+" has been registered to Universal Electricity."); - + + FMLLog.fine(mod.getClass().getSimpleName() + " has been registered to Universal Electricity."); + UELoader.INSTANCE.initiate(); } /** - * A function that allows you to lock your mod to a specific version of - * Forge. + * A function that allows you to lock your mod to a specific version of Forge. */ public static void forgeLock(int major, int minor, int revision, boolean strict) { diff --git a/src/common/universalelectricity/electricity/ElectricInfo.java b/src/common/universalelectricity/core/electricity/ElectricInfo.java old mode 100755 new mode 100644 similarity index 95% rename from src/common/universalelectricity/electricity/ElectricInfo.java rename to src/common/universalelectricity/core/electricity/ElectricInfo.java index 55722bf9e..94ea3c28a --- a/src/common/universalelectricity/electricity/ElectricInfo.java +++ b/src/common/universalelectricity/core/electricity/ElectricInfo.java @@ -1,203 +1,203 @@ -package universalelectricity.electricity; - -/** - * An easy way to display information on electricity. - * - * @author Calclavia - */ - -public class ElectricInfo -{ - public static enum ElectricUnit - { - AMPERE("Amp", "I"), AMP_HOUR("Amp Hour", "Ah"), VOLTAGE("Volt", "V"), WATT("Watt", "W"), WATT_HOUR("Watt Hour", "Wh"), RESISTANCE("Ohm", "R"), CONDUCTANCE("Siemen", "S"), JOULES("Joule", "J"); - - public String name; - public String symbol; - - private ElectricUnit(String name, String symbol) - { - this.name = name; - this.symbol = symbol; - } - - public String getPlural() - { - return this.name + "s"; - } - } - - public static enum MeasurementUnit - { - MICRO("Micro", "mi", 0.000001), MILLI("Milli", "m", 0.001), KILO("Kilo", "k", 1000), MEGA("Mega", "M", 1000000); - - public String name; - public String symbol; - public double process; - - private MeasurementUnit(String name, String symbol, double process) - { - this.name = name; - this.symbol = symbol; - this.process = process; - } - - public String getName(boolean isSymbol) - { - if (isSymbol) - { - return symbol; - } - else - { - return name; - } - } - - public double process(double value) - { - return value / this.process; - } - } - - public static double getJoules(double watts, double seconds) - { - return watts * seconds; - } - - public static double getJoules(double amps, double voltage, double seconds) - { - return amps * voltage * seconds; - } - - public static double getWattsFromJoules(double joules, double seconds) - { - return joules / seconds; - } - - public static double getAmps(double watts, double voltage) - { - return watts / voltage; - } - - public static double getAmps(double ampHours) - { - return ampHours * 3600; - } - - public static double getAmpsFromWattHours(double wattHours, double voltage) - { - return getWatts(wattHours) / voltage; - } - - public static double getWattHoursFromAmpHours(double ampHours, double voltage) - { - return ampHours * voltage; - } - - public static double getAmpHours(double amps) - { - return amps / 3600; - } - - public static double getWatts(double amps, double voltage) - { - return amps * voltage; - } - - public static double getWatts(double wattHours) - { - return wattHours * 3600; - } - - public static double getWattHours(double watts) - { - return watts / 3600; - } - - public static double getWattHours(double amps, double voltage) - { - return getWattHours(getWatts(amps, voltage)); - } - - public static double getResistance(double amps, double voltage) - { - return voltage / amps; - } - - public static double getConductance(double amps, double voltage) - { - return amps / voltage; - } - - /** - * Displays the unit as text. Works only for positive numbers. - */ - public static String getDisplay(double value, ElectricUnit unit, int significantFigures, boolean isShort) - { - String unitName = unit.name; - - if (isShort) - { - unitName = unit.symbol; - } - else if (value > 1) - { - unitName = unit.getPlural(); - } - - if (value == 0) { return value + " " + unitName; } - - if (value <= MeasurementUnit.MILLI.process) { return roundDecimals(MeasurementUnit.MICRO.process(value), significantFigures) + " " + MeasurementUnit.MICRO.getName(isShort) + unitName; } - - if (value < 1) { return roundDecimals(MeasurementUnit.MILLI.process(value), significantFigures) + " " + MeasurementUnit.MILLI.getName(isShort) + unitName; } - - if (value > MeasurementUnit.KILO.process) { return roundDecimals(MeasurementUnit.KILO.process(value), significantFigures) + " " + MeasurementUnit.KILO.getName(isShort) + unitName; } - - if (value > MeasurementUnit.MEGA.process) { return roundDecimals(MeasurementUnit.MEGA.process(value), significantFigures) + " " + MeasurementUnit.MEGA.getName(isShort) + unitName; } - - return roundDecimals(value, significantFigures) + " " + unitName; - } - - public static String getDisplayShort(double value, ElectricUnit unit) - { - return getDisplay(value, unit, 2, true); - } - - public static String getDisplay(double value, ElectricUnit unit) - { - return getDisplay(value, unit, 2, false); - } - - public static String getDisplaySimple(double value, ElectricUnit unit, int significantFigures) - { - if (value > 1) - { - if (significantFigures < 1) { return (int) value + " " + unit.getPlural(); } - - return roundDecimals(value, significantFigures) + " " + unit.getPlural(); - } - - if (significantFigures < 1) { return (int) value + " " + unit.name; } - - return roundDecimals(value, significantFigures) + " " + unit.name; - } - - /** - * Rounds a number to a specific number place places - * - * @param The - * number - * @return The rounded number - */ - public static double roundDecimals(double d, int significantFigures) - { - int j = (int) (d * Math.pow(10, significantFigures)); - return j / (double) Math.pow(10, significantFigures); - } - - public static double roundDecimals(double d) - { - return roundDecimals(d, 2); - } -} +package universalelectricity.core.electricity; + +/** + * An easy way to display information on electricity. + * + * @author Calclavia + */ + +public class ElectricInfo +{ + public static enum ElectricUnit + { + AMPERE("Amp", "I"), AMP_HOUR("Amp Hour", "Ah"), VOLTAGE("Volt", "V"), WATT("Watt", "W"), WATT_HOUR("Watt Hour", "Wh"), RESISTANCE("Ohm", "R"), CONDUCTANCE("Siemen", "S"), JOULES("Joule", "J"); + + public String name; + public String symbol; + + private ElectricUnit(String name, String symbol) + { + this.name = name; + this.symbol = symbol; + } + + public String getPlural() + { + return this.name + "s"; + } + } + + public static enum MeasurementUnit + { + MICRO("Micro", "mi", 0.000001), MILLI("Milli", "m", 0.001), KILO("Kilo", "k", 1000), MEGA("Mega", "M", 1000000); + + public String name; + public String symbol; + public double process; + + private MeasurementUnit(String name, String symbol, double process) + { + this.name = name; + this.symbol = symbol; + this.process = process; + } + + public String getName(boolean isSymbol) + { + if (isSymbol) + { + return symbol; + } + else + { + return name; + } + } + + public double process(double value) + { + return value / this.process; + } + } + + public static double getJoules(double watts, double seconds) + { + return watts * seconds; + } + + public static double getJoules(double amps, double voltage, double seconds) + { + return amps * voltage * seconds; + } + + public static double getWattsFromJoules(double joules, double seconds) + { + return joules / seconds; + } + + public static double getAmps(double watts, double voltage) + { + return watts / voltage; + } + + public static double getAmps(double ampHours) + { + return ampHours * 3600; + } + + public static double getAmpsFromWattHours(double wattHours, double voltage) + { + return getWatts(wattHours) / voltage; + } + + public static double getWattHoursFromAmpHours(double ampHours, double voltage) + { + return ampHours * voltage; + } + + public static double getAmpHours(double amps) + { + return amps / 3600; + } + + public static double getWatts(double amps, double voltage) + { + return amps * voltage; + } + + public static double getWatts(double wattHours) + { + return wattHours * 3600; + } + + public static double getWattHours(double watts) + { + return watts / 3600; + } + + public static double getWattHours(double amps, double voltage) + { + return getWattHours(getWatts(amps, voltage)); + } + + public static double getResistance(double amps, double voltage) + { + return voltage / amps; + } + + public static double getConductance(double amps, double voltage) + { + return amps / voltage; + } + + /** + * Displays the unit as text. Works only for positive numbers. + */ + public static String getDisplay(double value, ElectricUnit unit, int significantFigures, boolean isShort) + { + String unitName = unit.name; + + if (isShort) + { + unitName = unit.symbol; + } + else if (value > 1) + { + unitName = unit.getPlural(); + } + + if (value == 0) { return value + " " + unitName; } + + if (value <= MeasurementUnit.MILLI.process) { return roundDecimals(MeasurementUnit.MICRO.process(value), significantFigures) + " " + MeasurementUnit.MICRO.getName(isShort) + unitName; } + + if (value < 1) { return roundDecimals(MeasurementUnit.MILLI.process(value), significantFigures) + " " + MeasurementUnit.MILLI.getName(isShort) + unitName; } + + if (value > MeasurementUnit.KILO.process) { return roundDecimals(MeasurementUnit.KILO.process(value), significantFigures) + " " + MeasurementUnit.KILO.getName(isShort) + unitName; } + + if (value > MeasurementUnit.MEGA.process) { return roundDecimals(MeasurementUnit.MEGA.process(value), significantFigures) + " " + MeasurementUnit.MEGA.getName(isShort) + unitName; } + + return roundDecimals(value, significantFigures) + " " + unitName; + } + + public static String getDisplayShort(double value, ElectricUnit unit) + { + return getDisplay(value, unit, 2, true); + } + + public static String getDisplay(double value, ElectricUnit unit) + { + return getDisplay(value, unit, 2, false); + } + + public static String getDisplaySimple(double value, ElectricUnit unit, int significantFigures) + { + if (value > 1) + { + if (significantFigures < 1) { return (int) value + " " + unit.getPlural(); } + + return roundDecimals(value, significantFigures) + " " + unit.getPlural(); + } + + if (significantFigures < 1) { return (int) value + " " + unit.name; } + + return roundDecimals(value, significantFigures) + " " + unit.name; + } + + /** + * Rounds a number to a specific number place places + * + * @param The + * number + * @return The rounded number + */ + public static double roundDecimals(double d, int significantFigures) + { + int j = (int) (d * Math.pow(10, significantFigures)); + return j / (double) Math.pow(10, significantFigures); + } + + public static double roundDecimals(double d) + { + return roundDecimals(d, 2); + } +} diff --git a/src/common/universalelectricity/electricity/ElectricityManager.java b/src/common/universalelectricity/core/electricity/ElectricityManager.java old mode 100755 new mode 100644 similarity index 80% rename from src/common/universalelectricity/electricity/ElectricityManager.java rename to src/common/universalelectricity/core/electricity/ElectricityManager.java index 6807e4971..b1d035888 --- a/src/common/universalelectricity/electricity/ElectricityManager.java +++ b/src/common/universalelectricity/core/electricity/ElectricityManager.java @@ -1,4 +1,4 @@ -package universalelectricity.electricity; +package universalelectricity.core.electricity; import java.util.ArrayList; import java.util.EnumSet; @@ -9,16 +9,15 @@ import java.util.Map; import net.minecraft.src.TileEntity; import net.minecraftforge.common.ForgeDirection; -import universalelectricity.core.Vector3; -import universalelectricity.implement.IConductor; -import universalelectricity.implement.IElectricityReceiver; +import universalelectricity.core.implement.IConductor; +import universalelectricity.core.implement.IElectricityReceiver; +import universalelectricity.core.vector.Vector3; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.TickType; /** - * This class is used to manage electricity - * transferring and flow. It is also used to call - * updates on UE tile entities. + * This class is used to manage electricity transferring and flow. It is also used to call updates + * on UE tile entities. * * @author Calclavia * @@ -26,10 +25,8 @@ import cpw.mods.fml.common.TickType; public class ElectricityManager { /** - * ElectricityManager exists on both client - * and server side. Rely on the server side - * one as it is more accurate! Client side - * only simulates. + * ElectricityManager exists on both client and server side. Rely on the server side one as it + * is more accurate! Client side only simulates. */ public static ElectricityManager instance; @@ -42,8 +39,7 @@ public class ElectricityManager } /** - * Registers a the conductor into the UE - * electricity net. + * Registers a the conductor into the UE electricity net. * * @param conductor * - The IConductor tile entity. @@ -55,15 +51,12 @@ public class ElectricityManager } /** - * Merges two connection lines together into - * one. + * Merges two connection lines together into one. * * @param networkA - * - The network to be merged into. - * This network will be kept. + * - The network to be merged into. This network will be kept. * @param networkB - * - The network to be merged. This - * network will be deleted. + * - The network to be merged. This network will be deleted. */ public void mergeConnection(ElectricityNetwork networkA, ElectricityNetwork networkB) { @@ -84,11 +77,8 @@ public class ElectricityManager } /** - * Separate one connection line into two - * different ones between two conductors. This - * function does this by resetting all wires - * in the connection line and making them each - * reconnect. + * Separate one connection line into two different ones between two conductors. This function + * does this by resetting all wires in the connection line and making them each reconnect. * * @param conductorA * - existing conductor @@ -123,8 +113,7 @@ public class ElectricityManager } /** - * Clean up and remove all useless and invalid - * connections. + * Clean up and remove all useless and invalid connections. */ public void cleanUpConnections() { @@ -147,23 +136,17 @@ public class ElectricityManager } /** - * Produces electricity into a specific wire - * which will be distributed across the - * electricity network. + * Produces electricity into a specific wire which will be distributed across the electricity + * network. * * @param sender - * The machine sending the - * electricity. + * The machine sending the electricity. * @param targetConductor - * The conductor receiving the - * electricity (or connected to the - * machine). + * The conductor receiving the electricity (or connected to the machine). * @param amps - * The amount of amps this machine - * is sending. + * The amount of amps this machine is sending. * @param voltage - * The amount of volts this machine - * is sending. + * The amount of volts this machine is sending. */ public void produceElectricity(TileEntity sender, IConductor targetConductor, double amps, double voltage) { @@ -219,8 +202,7 @@ public class ElectricityManager } /** - * Gets the actual watt request of an electric - * receiver accounting all current electricity + * Gets the actual watt request of an electric receiver accounting all current electricity * packets qued up for it. * * @return - The amount of watts requested. @@ -254,11 +236,9 @@ public class ElectricityManager } /** - * Checks if the current connection line needs - * electricity + * Checks if the current connection line needs electricity * - * @return - The amount of joules this - * connection line needs + * @return - The amount of joules this connection line needs */ public double getElectricityRequired(ElectricityNetwork network) { @@ -323,8 +303,7 @@ public class ElectricityManager } /** - * This function is called to refresh all - * conductors in the world. + * This function is called to refresh all conductors in the world. */ public void refreshConductors() { diff --git a/src/common/universalelectricity/electricity/ElectricityManagerTicker.java b/src/common/universalelectricity/core/electricity/ElectricityManagerTicker.java old mode 100755 new mode 100644 similarity index 89% rename from src/common/universalelectricity/electricity/ElectricityManagerTicker.java rename to src/common/universalelectricity/core/electricity/ElectricityManagerTicker.java index a00634b29..14dff7740 --- a/src/common/universalelectricity/electricity/ElectricityManagerTicker.java +++ b/src/common/universalelectricity/core/electricity/ElectricityManagerTicker.java @@ -1,4 +1,4 @@ -package universalelectricity.electricity; +package universalelectricity.core.electricity; import java.util.EnumSet; @@ -28,7 +28,7 @@ public class ElectricityManagerTicker implements ITickHandler @Override public void tickEnd(EnumSet type, Object... tickData) { - + } @Override diff --git a/src/common/universalelectricity/electricity/ElectricityNetwork.java b/src/common/universalelectricity/core/electricity/ElectricityNetwork.java old mode 100755 new mode 100644 similarity index 88% rename from src/common/universalelectricity/electricity/ElectricityNetwork.java rename to src/common/universalelectricity/core/electricity/ElectricityNetwork.java index 0d4bed0c3..2c6e194bf --- a/src/common/universalelectricity/electricity/ElectricityNetwork.java +++ b/src/common/universalelectricity/core/electricity/ElectricityNetwork.java @@ -1,12 +1,12 @@ -package universalelectricity.electricity; +package universalelectricity.core.electricity; import java.util.ArrayList; import java.util.List; import net.minecraft.src.TileEntity; import net.minecraftforge.common.ForgeDirection; -import universalelectricity.implement.IConductor; -import universalelectricity.implement.IElectricityReceiver; +import universalelectricity.core.implement.IConductor; +import universalelectricity.core.implement.IElectricityReceiver; public class ElectricityNetwork { @@ -29,8 +29,7 @@ public class ElectricityNetwork } /** - * Get only the electric units that can receive electricity from the given - * side. + * Get only the electric units that can receive electricity from the given side. */ public List getConnectedReceivers() { @@ -108,7 +107,7 @@ public class ElectricityNetwork return lowestAmp; } - + /** * This function is called to refresh all conductors in this network */ diff --git a/src/common/universalelectricity/electricity/ElectricityTransferData.java b/src/common/universalelectricity/core/electricity/ElectricityTransferData.java old mode 100755 new mode 100644 similarity index 88% rename from src/common/universalelectricity/electricity/ElectricityTransferData.java rename to src/common/universalelectricity/core/electricity/ElectricityTransferData.java index 5ab909959..85a7f1553 --- a/src/common/universalelectricity/electricity/ElectricityTransferData.java +++ b/src/common/universalelectricity/core/electricity/ElectricityTransferData.java @@ -1,42 +1,42 @@ -package universalelectricity.electricity; - -import net.minecraft.src.TileEntity; -import net.minecraftforge.common.ForgeDirection; -import universalelectricity.implement.IElectricityReceiver; - -public class ElectricityTransferData -{ - public TileEntity sender; - public IElectricityReceiver receiver; - public ElectricityNetwork network; - public double amps; - public double voltage; - public ForgeDirection side; - - /** - * @param sender - * - Tile that's sending electricity. - * @param receiver - * - Receiver that's receiving electricity - * @param conductor - * - Conductor that is conducting the electricity - * @param side - * - - * @param amps - * @param voltage - */ - public ElectricityTransferData(TileEntity sender, IElectricityReceiver receiver, ElectricityNetwork network, ForgeDirection side, double amps, double voltage) - { - this.sender = sender; - this.receiver = receiver; - this.network = network; - this.side = side; - this.amps = amps; - this.voltage = voltage; - } - - public boolean isValid() - { - return this.sender != null && this.receiver != null && this.network != null && this.amps > 0 && this.voltage > 0; - } -} +package universalelectricity.core.electricity; + +import net.minecraft.src.TileEntity; +import net.minecraftforge.common.ForgeDirection; +import universalelectricity.core.implement.IElectricityReceiver; + +public class ElectricityTransferData +{ + public TileEntity sender; + public IElectricityReceiver receiver; + public ElectricityNetwork network; + public double amps; + public double voltage; + public ForgeDirection side; + + /** + * @param sender + * - Tile that's sending electricity. + * @param receiver + * - Receiver that's receiving electricity + * @param conductor + * - Conductor that is conducting the electricity + * @param side + * - + * @param amps + * @param voltage + */ + public ElectricityTransferData(TileEntity sender, IElectricityReceiver receiver, ElectricityNetwork network, ForgeDirection side, double amps, double voltage) + { + this.sender = sender; + this.receiver = receiver; + this.network = network; + this.side = side; + this.amps = amps; + this.voltage = voltage; + } + + public boolean isValid() + { + return this.sender != null && this.receiver != null && this.network != null && this.amps > 0 && this.voltage > 0; + } +} diff --git a/src/common/universalelectricity/implement/IConductor.java b/src/common/universalelectricity/core/implement/IConductor.java old mode 100755 new mode 100644 similarity index 84% rename from src/common/universalelectricity/implement/IConductor.java rename to src/common/universalelectricity/core/implement/IConductor.java index 5c495cbb7..6ec514c18 --- a/src/common/universalelectricity/implement/IConductor.java +++ b/src/common/universalelectricity/core/implement/IConductor.java @@ -1,9 +1,9 @@ -package universalelectricity.implement; +package universalelectricity.core.implement; import net.minecraft.src.TileEntity; import net.minecraft.src.World; import net.minecraftforge.common.ForgeDirection; -import universalelectricity.electricity.ElectricityNetwork; +import universalelectricity.core.electricity.ElectricityNetwork; /** * Must be applied to all tile entities that are conductors. @@ -28,16 +28,16 @@ public interface IConductor extends IConnector public TileEntity[] getConnectedBlocks(); /** - * Gets the resistance of the conductor. Used to calculate energy loss. A - * higher resistance means a higher energy loss. + * Gets the resistance of the conductor. Used to calculate energy loss. A higher resistance + * means a higher energy loss. * * @return The amount of Ohm's of resistance. */ public double getResistance(); /** - * The maximum amount of amps this conductor can handle before melting down. - * This is calculating PER TICK! + * The maximum amount of amps this conductor can handle before melting down. This is calculating + * PER TICK! * * @return The amount of amps in volts */ diff --git a/src/common/universalelectricity/implement/IConnector.java b/src/common/universalelectricity/core/implement/IConnector.java old mode 100755 new mode 100644 similarity index 59% rename from src/common/universalelectricity/implement/IConnector.java rename to src/common/universalelectricity/core/implement/IConnector.java index ddc2cb126..ed1e841da --- a/src/common/universalelectricity/implement/IConnector.java +++ b/src/common/universalelectricity/core/implement/IConnector.java @@ -1,9 +1,9 @@ -package universalelectricity.implement; +package universalelectricity.core.implement; import net.minecraftforge.common.ForgeDirection; /** - * Applied to TileEntities that can connect to UE wires. + * Applied to a TileEntity that can connect to UE wires. * * @author Calclavia * @@ -11,7 +11,7 @@ import net.minecraftforge.common.ForgeDirection; public interface IConnector { /** - * Can this tile entity visually connect to a wire on this specific side? + * Can this TileEntity visually connect to a wire on this specific side? * * @param side * - The side in which the connection is coming from. diff --git a/src/common/universalelectricity/implement/IDisableable.java b/src/common/universalelectricity/core/implement/IDisableable.java old mode 100755 new mode 100644 similarity index 76% rename from src/common/universalelectricity/implement/IDisableable.java rename to src/common/universalelectricity/core/implement/IDisableable.java index 30597cc25..5ab627c0c --- a/src/common/universalelectricity/implement/IDisableable.java +++ b/src/common/universalelectricity/core/implement/IDisableable.java @@ -1,8 +1,8 @@ -package universalelectricity.implement; +package universalelectricity.core.implement; /** - * This class should be applied to all tile entities (mainly machines) that can - * be disabled (by things like EMP, short circuit etc.). + * This class should be applied to all tile entities (mainly machines) that can be disabled (by + * things like EMP, short circuit etc.). * * @author Calclavia * diff --git a/src/common/universalelectricity/core/implement/IElectricityProducer.java b/src/common/universalelectricity/core/implement/IElectricityProducer.java new file mode 100644 index 000000000..ec81951c4 --- /dev/null +++ b/src/common/universalelectricity/core/implement/IElectricityProducer.java @@ -0,0 +1,12 @@ +package universalelectricity.core.implement; + +/** + * Applied to TileEntities that can produces electricity. Of course, you will still need to call + * ElectricityManager.instance.produce() to actually output the electricity. + * + * @author Calclavia + */ +public interface IElectricityProducer extends IConnector, IDisableable, IVoltage +{ + +} diff --git a/src/common/universalelectricity/implement/IElectricityReceiver.java b/src/common/universalelectricity/core/implement/IElectricityReceiver.java old mode 100755 new mode 100644 similarity index 69% rename from src/common/universalelectricity/implement/IElectricityReceiver.java rename to src/common/universalelectricity/core/implement/IElectricityReceiver.java index 9e9b81ed5..90ceda273 --- a/src/common/universalelectricity/implement/IElectricityReceiver.java +++ b/src/common/universalelectricity/core/implement/IElectricityReceiver.java @@ -1,11 +1,11 @@ -package universalelectricity.implement; +package universalelectricity.core.implement; import net.minecraft.src.TileEntity; import net.minecraftforge.common.ForgeDirection; /** - * The IElectricityReceiver interface is an interface that must be applied to - * all tile entities that can input or output electricity. + * The IElectricityReceiver interface is an interface that must be applied to all tile entities that + * can receive electricity. * * @author Calclavia * @@ -18,19 +18,16 @@ public interface IElectricityReceiver extends IDisableable, IConnector, IVoltage * @param amps * - Amount of amps this electric unit is receiving. * @param voltage - * - The voltage of the electricity sent. If more than one packet - * is being sent to you in this update, the highest voltage will - * override. + * - The voltage of the electricity sent. If more than one packet is being sent to + * you in this update, the highest voltage will override. * @param side - * - The side of the block in which the electricity is coming - * from. + * - The side of the block in which the electricity is coming from. */ public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side); /** - * How many watts does this electrical unit need this tick? Recommended for - * you to return the max electricity storage of this machine (if there is - * one). + * How many watts does this electrical unit need this tick? Recommended for you to return the + * max electricity storage of this machine (if there is one). */ public double wattRequest(); diff --git a/src/common/universalelectricity/implement/IItemElectric.java b/src/common/universalelectricity/core/implement/IItemElectric.java old mode 100755 new mode 100644 similarity index 74% rename from src/common/universalelectricity/implement/IItemElectric.java rename to src/common/universalelectricity/core/implement/IItemElectric.java index 3d312a2ce..95d70e153 --- a/src/common/universalelectricity/implement/IItemElectric.java +++ b/src/common/universalelectricity/core/implement/IItemElectric.java @@ -1,4 +1,4 @@ -package universalelectricity.implement; +package universalelectricity.core.implement; import net.minecraft.src.ItemStack; @@ -17,15 +17,14 @@ public interface IItemElectric extends IJouleStorage, IVoltage public double onUse(double joulesNeeded, ItemStack itemStack); /** - * @return Returns true or false if this consumer can receive electricity at - * this given tick or moment. + * @return Returns true or false if this consumer can receive electricity at this given tick or + * moment. */ public boolean canReceiveElectricity(); /** - * Can this item give out electricity when placed in an tile entity? - * Electric items like batteries should be able to produce electricity (if - * they are rechargeable). + * Can this item give out electricity when placed in an tile entity? Electric items like + * batteries should be able to produce electricity (if they are rechargeable). * * @return - True or False. */ diff --git a/src/common/universalelectricity/implement/IJouleStorage.java b/src/common/universalelectricity/core/implement/IJouleStorage.java old mode 100755 new mode 100644 similarity index 77% rename from src/common/universalelectricity/implement/IJouleStorage.java rename to src/common/universalelectricity/core/implement/IJouleStorage.java index ebb89ebb3..5638f2673 --- a/src/common/universalelectricity/implement/IJouleStorage.java +++ b/src/common/universalelectricity/core/implement/IJouleStorage.java @@ -1,25 +1,24 @@ -package universalelectricity.implement; - -/** - * This interface is to be applied to all tile entities which stores energy - * within them. - * - * @author Calclavia - */ -public interface IJouleStorage -{ - /** - * Returns the amount of joules this unit has stored. - */ - public double getJoules(Object... data); - - /** - * Sets the amount of joules this unit has stored. - */ - public void setJoules(double wattHours, Object... data); - - /** - * Gets the maximum amount of joules this unit can store. - */ - public double getMaxJoules(); -} +package universalelectricity.core.implement; + +/** + * This interface is to be applied to all tile entities which stores energy within them. + * + * @author Calclavia + */ +public interface IJouleStorage +{ + /** + * Returns the amount of joules this unit has stored. + */ + public double getJoules(Object... data); + + /** + * Sets the amount of joules this unit has stored. + */ + public void setJoules(double wattHours, Object... data); + + /** + * Gets the maximum amount of joules this unit can store. + */ + public double getMaxJoules(Object... data); +} diff --git a/src/common/universalelectricity/implement/IVoltage.java b/src/common/universalelectricity/core/implement/IVoltage.java old mode 100755 new mode 100644 similarity index 75% rename from src/common/universalelectricity/implement/IVoltage.java rename to src/common/universalelectricity/core/implement/IVoltage.java index d4c6b9879..95981d016 --- a/src/common/universalelectricity/implement/IVoltage.java +++ b/src/common/universalelectricity/core/implement/IVoltage.java @@ -1,14 +1,16 @@ -package universalelectricity.implement; +package universalelectricity.core.implement; /** * Applies to all objects that has a voltage. + * * @author Calclavia - * + * */ public interface IVoltage { /** * Gets the voltage of this object. + * * @return The amount of volts. E.g 120v or 240v */ public double getVoltage(); diff --git a/src/common/universalelectricity/core/vector/Region2.java b/src/common/universalelectricity/core/vector/Region2.java new file mode 100644 index 000000000..6e0d54c89 --- /dev/null +++ b/src/common/universalelectricity/core/vector/Region2.java @@ -0,0 +1,34 @@ +package universalelectricity.core.vector; + +public class Region2 +{ + public Vector2 min; + public Vector2 max; + + public Region2() + { + this(new Vector2(), new Vector2()); + } + + public Region2(Vector2 min, Vector2 max) + { + this.min = min; + this.max = max; + } + + /** + * Checks if a point is located inside a region + */ + public boolean isIn(Vector2 point) + { + return (point.x > this.min.x && point.x < this.max.x) && (point.y > this.min.y && point.y < this.max.y); + } + + /** + * Returns whether the given region intersects with this one. + */ + public boolean isIn(Region2 region) + { + return region.max.x > this.min.x && region.min.x < this.max.x ? (region.max.y > this.min.y && region.min.y < this.max.y ? true : false) : false; + } +} diff --git a/src/common/universalelectricity/core/vector/Region3.java b/src/common/universalelectricity/core/vector/Region3.java new file mode 100644 index 000000000..e23596215 --- /dev/null +++ b/src/common/universalelectricity/core/vector/Region3.java @@ -0,0 +1,129 @@ +package universalelectricity.core.vector; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.src.AxisAlignedBB; +import net.minecraft.src.Entity; +import net.minecraft.src.World; + +/** + * A cubical region class. + * + * @author Calclavia + */ +public class Region3 +{ + public Vector3 min; + public Vector3 max; + + public Region3() + { + this(new Vector3(), new Vector3()); + } + + public Region3(Vector3 min, Vector3 max) + { + this.min = min; + this.max = max; + } + + public Region3 get(AxisAlignedBB aabb) + { + return new Region3(new Vector3(aabb.minX, aabb.minY, aabb.minZ), new Vector3(aabb.maxX, aabb.maxY, aabb.maxZ)); + } + + public AxisAlignedBB toAABB() + { + return AxisAlignedBB.getBoundingBox(this.min.x, this.min.y, this.min.z, this.max.x, this.max.y, this.max.z); + } + + public Region2 toRegion2() + { + return new Region2(this.min.toVector2(), this.max.toVector2()); + } + + /** + * Checks if a point is located inside a region + */ + public boolean isIn(Vector3 point) + { + return (point.x > this.min.x && point.x < this.max.x) && (point.y > this.min.y && point.y < this.max.y) && (point.z > this.min.z && point.z < this.max.z); + } + + /** + * Returns whether the given region intersects with this one. + */ + public boolean isIn(Region3 region) + { + return region.max.x > this.min.x && region.min.x < this.max.x ? (region.max.y > this.min.y && region.min.y < this.max.y ? region.max.z > this.min.z && region.min.z < this.max.z : false) : false; + } + + public void expand(Vector3 difference) + { + this.min.subtract(difference); + this.max.add(difference); + } + + /** + * @return List of vectors within this region. + */ + public List getVectors() + { + List vectors = new ArrayList(); + + for (int x = this.min.intX(); x < this.max.intX(); x++) + { + for (int y = this.min.intY(); x < this.max.intY(); y++) + { + for (int z = this.min.intZ(); x < this.max.intZ(); z++) + { + vectors.add(new Vector3(x, y, z)); + } + } + } + + return vectors; + } + + public List getVectors(Vector3 center, int radius) + { + List vectors = new ArrayList(); + + for (int x = this.min.intX(); x < this.max.intX(); x++) + { + for (int y = this.min.intY(); x < this.max.intY(); y++) + { + for (int z = this.min.intZ(); x < this.max.intZ(); z++) + { + Vector3 vector3 = new Vector3(x, y, z); + + if (center.distanceTo(vector3) <= radius) + { + vectors.add(vector3); + } + } + } + } + + return vectors; + } + + /** + * Returns all entities in this region. + */ + public List getEntities(World world, Class entityClass) + { + return world.getEntitiesWithinAABB(entityClass, this.toAABB()); + } + + public List getEntitiesExlude(World world, Entity entity) + { + return world.getEntitiesWithinAABBExcludingEntity(entity, this.toAABB()); + } + + public List getEntities(World world) + { + return this.getEntities(world, Entity.class); + } +} diff --git a/src/common/universalelectricity/core/Vector2.java b/src/common/universalelectricity/core/vector/Vector2.java old mode 100755 new mode 100644 similarity index 70% rename from src/common/universalelectricity/core/Vector2.java rename to src/common/universalelectricity/core/vector/Vector2.java index 079c99827..b570b40d2 --- a/src/common/universalelectricity/core/Vector2.java +++ b/src/common/universalelectricity/core/vector/Vector2.java @@ -1,12 +1,11 @@ -package universalelectricity.core; +package universalelectricity.core.vector; import net.minecraft.src.MathHelper; /** - * Vector2 Class is used for defining objects in a 2D space. Vector2 makes it - * easier to handle the coordinates of objects. Instead of fumbling with x and y - * variables, all x and y variables are stored in one class. Vector3.x, - * Vector3.y. + * Vector2 Class is used for defining objects in a 2D space. Vector2 makes it easier to handle the + * coordinates of objects. Instead of fumbling with x and y variables, all x and y variables are + * stored in one class. Vector3.x, Vector3.y. * * @author Calclavia */ @@ -53,11 +52,6 @@ public class Vector2 implements Cloneable return new Vector2(this.x, this.y); } - public static boolean isPointInRegion(Vector2 point, Vector2 minPoint, Vector2 maxPoint) - { - return (point.x > minPoint.x && point.x < maxPoint.x) && (point.y > minPoint.y && point.y < maxPoint.y); - } - public static double distance(Vector2 par1, Vector2 par2) { double var2 = par1.x - par2.x; @@ -84,6 +78,18 @@ public class Vector2 implements Cloneable this.y += par1; } + public void substract(Vector2 par1) + { + this.x -= par1.x; + this.y -= par1.y; + } + + public void substract(double par1) + { + this.x -= par1; + this.y -= par1; + } + public Vector2 round() { return new Vector2(Math.round(this.x), Math.round(this.y)); @@ -94,13 +100,9 @@ public class Vector2 implements Cloneable return new Vector2(Math.floor(this.x), Math.floor(this.y)); } - public String output() + @Override + public String toString() { return "Vector2: " + this.x + "," + this.y; } - - public void printVector() - { - System.out.println(output()); - } } \ No newline at end of file diff --git a/src/common/universalelectricity/core/Vector3.java b/src/common/universalelectricity/core/vector/Vector3.java old mode 100755 new mode 100644 similarity index 85% rename from src/common/universalelectricity/core/Vector3.java rename to src/common/universalelectricity/core/vector/Vector3.java index 480f9f860..de5618ded --- a/src/common/universalelectricity/core/Vector3.java +++ b/src/common/universalelectricity/core/vector/Vector3.java @@ -1,7 +1,8 @@ -package universalelectricity.core; +package universalelectricity.core.vector; import net.minecraft.src.ChunkCoordinates; import net.minecraft.src.Entity; +import net.minecraft.src.IBlockAccess; import net.minecraft.src.MathHelper; import net.minecraft.src.MovingObjectPosition; import net.minecraft.src.NBTTagCompound; @@ -9,13 +10,12 @@ import net.minecraft.src.TileEntity; import net.minecraft.src.Vec3; import net.minecraft.src.World; import net.minecraftforge.common.ForgeDirection; -import universalelectricity.implement.IConnector; +import universalelectricity.core.implement.IConnector; /** - * Vector3 Class is used for defining objects in a 3D space. Vector3 makes it - * easier to handle the coordinates of objects. Instead of fumbling with x, y - * and z variables, all x, y and z variables are stored in one class. Vector3.x, - * Vector3.y, Vector3.z. + * Vector3 Class is used for defining objects in a 3D space. Vector3 makes it easier to handle the + * coordinates of objects. Instead of fumbling with x, y and z variables, all x, y and z variables + * are stored in one class. Vector3.x, Vector3.y, Vector3.z. * * @author Calclavia */ @@ -71,56 +71,45 @@ public class Vector3 extends Vector2 implements Cloneable } /** - * Converts a TileEntity's position into Vector3 + * Vector3 Shortcut Functions */ + public static Vector3 get(Entity par1) { return new Vector3(par1.posX, par1.posY, par1.posZ); } - /** - * Converts an entity's position into Vector3 - */ public static Vector3 get(TileEntity par1) { return new Vector3(par1.xCoord, par1.yCoord, par1.zCoord); } - /** - * Converts from Vec3 into a Vector3 - */ public static Vector3 get(Vec3 par1) { return new Vector3(par1.xCoord, par1.yCoord, par1.zCoord); } - /** - * Converts a MovingObjectPosition to Vector3 - */ public static Vector3 get(MovingObjectPosition par1) { return new Vector3(par1.blockX, par1.blockY, par1.blockZ); } - /** - * Converts a MovingObjectPosition to Vector3 - */ public static Vector3 get(ChunkCoordinates par1) { return new Vector3(par1.posX, par1.posY, par1.posZ); } - public int getBlockID(World world) + public int getBlockID(IBlockAccess world) { return world.getBlockId(this.intX(), this.intY(), this.intZ()); } - public int getBlockMetadata(World world) + public int getBlockMetadata(IBlockAccess world) { return world.getBlockMetadata(this.intX(), this.intY(), this.intZ()); } - public TileEntity getTileEntity(World world) + public TileEntity getTileEntity(IBlockAccess world) { return world.getBlockTileEntity(this.intX(), this.intY(), this.intZ()); } @@ -161,14 +150,6 @@ public class Vector3 extends Vector2 implements Cloneable return Vec3.createVectorHelper(this.x, this.y, this.z); } - /** - * Checks if a Vector3 point is located inside a region - */ - public static boolean isPointInRegion(Vector3 point, Vector3 minPoint, Vector3 maxPoint) - { - return (point.x > minPoint.x && point.x < maxPoint.x) && (point.y > minPoint.y && point.y < maxPoint.y) && (point.z > minPoint.z && point.z < maxPoint.z); - } - /** * Compares two vectors and see if they are equal. True if so. */ @@ -228,6 +209,13 @@ public class Vector3 extends Vector2 implements Cloneable this.z += par1; } + public void subtract(Vector3 amount) + { + this.x -= amount.x; + this.y -= amount.y; + this.z -= amount.z; + } + public static Vector3 multiply(Vector3 par1, Vector3 par2) { return new Vector3(par1.x * par2.x, par1.y * par2.y, par1.z * par2.z); @@ -274,12 +262,6 @@ public class Vector3 extends Vector2 implements Cloneable return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z)); } - @Override - public String output() - { - return "Vector3: " + this.x + "," + this.y + "," + this.z; - } - /** * Gets a position relative to another position's side * @@ -336,15 +318,14 @@ public class Vector3 extends Vector2 implements Cloneable } /** - * Finds the side of a block depending on it's facing direction from the - * given side. The side numbers are compatible with the - * function"getBlockTextureFromSideAndMetadata". + * Finds the side of a block depending on it's facing direction from the given side. The side + * numbers are compatible with the function "getBlockTextureFromSideAndMetadata". * * Bottom: 0; Top: 1; Back: 2; Front: 3; Left: 4; Right: 5; * * @param front - * - The direction in which this block is facing/front. Use a - * number between 0 and 5. Default is 3. + * - The direction in which this block is facing/front. Use a number between 0 and 5. + * Default is 3. * @param side * - The side you are trying to find. A number between 0 and 5. * @return The side relative to the facing direction. @@ -445,4 +426,10 @@ public class Vector3 extends Vector2 implements Cloneable return ForgeDirection.UNKNOWN; } + + @Override + public String toString() + { + return "Vector3: " + this.x + "," + this.y + "," + this.z; + } } \ No newline at end of file diff --git a/src/common/universalelectricity/implement/IElectricityProducer.java b/src/common/universalelectricity/implement/IElectricityProducer.java deleted file mode 100755 index 65a7b2be9..000000000 --- a/src/common/universalelectricity/implement/IElectricityProducer.java +++ /dev/null @@ -1,20 +0,0 @@ -package universalelectricity.implement; - -import net.minecraftforge.common.ForgeDirection; - -/** - * Applied to tile entities that can produce electricity - * - * @author Calclavia - */ -public interface IElectricityProducer extends IConnector, IDisableable, IVoltage -{ - /** - * Can this machine visually connect to a wire on this specific side? - * - * @param side - * . 0-5 byte - * @return - True if so. - */ - public boolean canConnect(ForgeDirection side); -} diff --git a/src/common/universalelectricity/implement/IRedstoneProvider.java b/src/common/universalelectricity/implement/IRedstoneProvider.java deleted file mode 100755 index ac9108ceb..000000000 --- a/src/common/universalelectricity/implement/IRedstoneProvider.java +++ /dev/null @@ -1,14 +0,0 @@ -package universalelectricity.implement; - -/** - * This should be applied on tile entities that can provide redstone power - * - * @author Henry - * - */ -public interface IRedstoneProvider -{ - public boolean isPoweringTo(byte side); - - public boolean isIndirectlyPoweringTo(byte side); -} diff --git a/src/common/universalelectricity/prefab/BlockConductor.java b/src/common/universalelectricity/prefab/BlockConductor.java old mode 100755 new mode 100644 index 7522d4cb7..c4a5daf94 --- a/src/common/universalelectricity/prefab/BlockConductor.java +++ b/src/common/universalelectricity/prefab/BlockConductor.java @@ -4,7 +4,7 @@ import net.minecraft.src.BlockContainer; import net.minecraft.src.Material; import net.minecraft.src.TileEntity; import net.minecraft.src.World; -import universalelectricity.implement.IConductor; +import universalelectricity.core.implement.IConductor; public abstract class BlockConductor extends BlockContainer { @@ -20,36 +20,35 @@ public abstract class BlockConductor extends BlockContainer public void onBlockAdded(World world, int x, int y, int z) { super.onBlockAdded(world, x, y, z); - + TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - - if(tileEntity != null) + + if (tileEntity != null) { - if(tileEntity instanceof IConductor) + if (tileEntity instanceof IConductor) { - ((IConductor)tileEntity).refreshConnectedBlocks(); + ((IConductor) tileEntity).refreshConnectedBlocks(); } } } /** - * Lets the block know when one of its neighbor changes. Doesn't know which - * neighbor changed (coordinates passed are their own) Args: x, y, z, - * neighbor blockID + * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed + * (coordinates passed are their own) Args: x, y, z, neighbor blockID */ @Override public void onNeighborBlockChange(World world, int x, int y, int z, int blockID) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); - - if(tileEntity != null) + + if (tileEntity != null) { - if(tileEntity instanceof IConductor) + if (tileEntity instanceof IConductor) { - ((IConductor)tileEntity).refreshConnectedBlocks(); + ((IConductor) tileEntity).refreshConnectedBlocks(); } } - - world.markBlockNeedsUpdate(x, y, z); + + world.markBlockForUpdate(x, y, z); } } diff --git a/src/common/universalelectricity/prefab/BlockMachine.java b/src/common/universalelectricity/prefab/BlockMachine.java old mode 100755 new mode 100644 index ea05c0bc5..cdc9f7d9d --- a/src/common/universalelectricity/prefab/BlockMachine.java +++ b/src/common/universalelectricity/prefab/BlockMachine.java @@ -12,13 +12,13 @@ import net.minecraft.src.Material; import net.minecraft.src.NBTTagCompound; import net.minecraft.src.TileEntity; import net.minecraft.src.World; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; import buildcraft.api.tools.IToolWrench; /** - * A block you may extend from to create your machine blocks! You do not have to - * extend from this block if you do not want to. It's optional but it comes with - * some useful functions that will make coding easier for you. + * A block you may extend from to create your machine blocks! You do not have to extend from this + * block if you do not want to. It's optional but it comes with some useful functions that will make + * coding easier for you. */ public abstract class BlockMachine extends BlockContainer { @@ -60,10 +60,9 @@ public abstract class BlockMachine extends BlockContainer } /** - * DO NOT OVERRIDE THIS FUNCTION! 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) + * DO NOT OVERRIDE THIS FUNCTION! 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) @@ -71,8 +70,7 @@ public abstract class BlockMachine extends BlockContainer int metadata = par1World.getBlockMetadata(x, y, z); /** - * Check if the player is holding a wrench or an electric item. If so, - * do not open the GUI. + * Check if the player is holding a wrench or an electric item. If so, do not open the GUI. */ if (par5EntityPlayer.inventory.getCurrentItem() != null) { @@ -117,8 +115,7 @@ public abstract class BlockMachine extends BlockContainer } /** - * Called when the machine is right clicked by the player while sneaking - * (shift clicking) + * Called when the machine is right clicked by the player while sneaking (shift clicking) * * @return True if something happens */ @@ -158,8 +155,8 @@ public abstract class BlockMachine extends BlockContainer } /** - * Returns the TileEntity used by this block. You should use the metadata - * sensitive version of this to get the maximum optimization! + * Returns the TileEntity used by this block. You should use the metadata sensitive version of + * this to get the maximum optimization! */ @Override public TileEntity createNewTileEntity(World var1) @@ -168,8 +165,8 @@ public abstract class BlockMachine extends BlockContainer } /** - * Override this if you don't need it. This will eject all items out of this - * machine if it has an inventory + * Override this if you don't need it. This will eject all items out of this machine if it has + * an inventory */ @Override public void breakBlock(World par1World, int x, int y, int z, int par5, int par6) diff --git a/src/common/universalelectricity/prefab/ItemElectric.java b/src/common/universalelectricity/prefab/ItemElectric.java old mode 100755 new mode 100644 index 5451bdf71..b29786920 --- a/src/common/universalelectricity/prefab/ItemElectric.java +++ b/src/common/universalelectricity/prefab/ItemElectric.java @@ -10,37 +10,31 @@ import net.minecraft.src.ItemStack; import net.minecraft.src.NBTTagCompound; import net.minecraft.src.NBTTagFloat; import net.minecraft.src.World; -import universalelectricity.electricity.ElectricInfo; -import universalelectricity.electricity.ElectricInfo.ElectricUnit; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.electricity.ElectricInfo; +import universalelectricity.core.electricity.ElectricInfo.ElectricUnit; +import universalelectricity.core.implement.IItemElectric; /** - * Extend from this class if your item requires electricity or to be charged. - * Optionally, you can implement IItemElectric instead. + * Extend from this class if your item requires electricity or to be charged. Optionally, you can + * implement IItemElectric instead. * * @author Calclavia * */ public abstract class ItemElectric extends Item implements IItemElectric { - public ItemElectric(int id, CreativeTabs tabs) + public ItemElectric(int id) { super(id); this.setMaxStackSize(1); this.setMaxDamage((int) this.getMaxJoules()); this.setNoRepair(); - this.setCreativeTab(tabs); - } - - public ItemElectric(int id) - { - this(id, CreativeTabs.tabTools); } /** - * Allows items to add custom lines of information to the mouseover - * description. If you want to add more information to your item, you can - * super.addInformation() to keep the electiricty info in the item info bar. + * Allows items to add custom lines of information to the mouseover description. If you want to + * add more information to your item, you can super.addInformation() to keep the electiricty + * info in the item info bar. */ @Override public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) @@ -70,14 +64,15 @@ public abstract class ItemElectric extends Item implements IItemElectric @Override public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) { - // Makes sure the damage is set correctly for this electric item! + // Makes sure the damage is set correctly + // for this electric item! ItemElectric item = ((ItemElectric) par1ItemStack.getItem()); item.setJoules(item.getJoules(par1ItemStack), par1ItemStack); } /** - * Makes sure the item is uncharged when it is crafted and not charged. - * Change this if you do not want this to happen! + * Makes sure the item is uncharged when it is crafted and not charged. Change this if you do + * not want this to happen! */ @Override public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) @@ -112,8 +107,8 @@ public abstract class ItemElectric extends Item implements IItemElectric } /** - * This function sets the electriicty. Do not directly call this function. - * Try to use onReceiveElectricity or onUseElectricity instead. + * This function sets the electriicty. Do not directly call this function. Try to use + * onReceiveElectricity or onUseElectricity instead. * * @param wattHours * - The amount of electricity in joules @@ -125,7 +120,8 @@ public abstract class ItemElectric extends Item implements IItemElectric { ItemStack itemStack = (ItemStack) data[0]; - // Saves the frequency in the itemstack + // Saves the frequency in the + // itemstack if (itemStack.stackTagCompound == null) { itemStack.setTagCompound(new NBTTagCompound()); @@ -167,9 +163,9 @@ public abstract class ItemElectric extends Item implements IItemElectric } /** - * Returns an uncharged version of the electric item. Use this if you want - * the crafting recipe to use a charged version of the electric item instead - * of an empty version of the electric item + * Returns an uncharged version of the electric item. Use this if you want the crafting recipe + * to use a charged version of the electric item instead of an empty version of the electric + * item * * @return The ItemStack of a fully charged electric item */ @@ -179,27 +175,29 @@ public abstract class ItemElectric extends Item implements IItemElectric chargedItem.setItemDamage((int) this.getMaxJoules()); return chargedItem; } - + public static ItemStack getUncharged(ItemStack itemStack) { - if(itemStack.getItem() instanceof IItemElectric) + if (itemStack.getItem() instanceof IItemElectric) { ItemStack chargedItem = itemStack.copy(); - chargedItem.setItemDamage((int)((IItemElectric)itemStack.getItem()).getMaxJoules()); + chargedItem.setItemDamage((int) ((IItemElectric) itemStack.getItem()).getMaxJoules()); return chargedItem; } - + return null; } @Override public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List) { - // Add an uncharged version of the electric item + // Add an uncharged version of the + // electric item ItemStack unchargedItem = new ItemStack(this, 1); unchargedItem.setItemDamage((int) this.getMaxJoules()); par3List.add(unchargedItem); - // Add an electric item to the creative list that is fully charged + // Add an electric item to the creative + // list that is fully charged ItemStack chargedItem = new ItemStack(this, 1); this.setJoules(((IItemElectric) chargedItem.getItem()).getMaxJoules(), chargedItem); par3List.add(chargedItem); diff --git a/src/common/universalelectricity/prefab/RecipeHelper.java b/src/common/universalelectricity/prefab/RecipeHelper.java old mode 100755 new mode 100644 index 366ab3ef6..9fbcedd97 --- a/src/common/universalelectricity/prefab/RecipeHelper.java +++ b/src/common/universalelectricity/prefab/RecipeHelper.java @@ -1,96 +1,188 @@ -package universalelectricity.prefab; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.src.CraftingManager; -import net.minecraft.src.IRecipe; -import net.minecraft.src.ItemStack; -import net.minecraftforge.common.Configuration; -import universalelectricity.core.UEConfig; -import cpw.mods.fml.common.registry.GameRegistry; - -/** - * This class is used to replace recipes that are already added in the existing - * recipe pool for crafting and smelting. All recipe functions take account of - * the Forge Ore Dictionary. It also includes some recipe helper functions to - * shorten some of your function calls. - * - * @author Calclavia - * - */ -public class RecipeHelper -{ - public static List getRecipesByOutput(ItemStack output) - { - List list = new ArrayList(); - - for (Object obj : CraftingManager.getInstance().getRecipeList()) - { - if (obj instanceof IRecipe) - { - if (((IRecipe) obj).getRecipeOutput() == output) - { - list.add((IRecipe)obj); - } - } - } - - return list; - } - - public static boolean replaceRecipe(IRecipe recipe, IRecipe newRecipe) - { - for (Object obj : CraftingManager.getInstance().getRecipeList()) - { - if (obj instanceof IRecipe) - { - if (((IRecipe) obj).equals(recipe) || obj == recipe) - { - CraftingManager.getInstance().getRecipeList().remove(obj); - CraftingManager.getInstance().getRecipeList().add(newRecipe); - return true; - } - } - } - - return false; - } - - public static boolean removeRecipe(IRecipe recipe) - { - for (Object obj : CraftingManager.getInstance().getRecipeList()) - { - if (obj instanceof IRecipe) - { - if (((IRecipe) obj).equals(recipe) || obj == recipe) - { - CraftingManager.getInstance().getRecipeList().remove(obj); - return true; - } - } - } - - return false; - } - - /** - * Use this function if you want to check if the recipe is allowed in the - * configuration file. - */ - public static void addRecipe(IRecipe recipe, String name, Configuration config, boolean defaultBoolean) - { - if (config != null) - { - if (UEConfig.getConfigData(config, "Allow " + name + " Crafting", defaultBoolean)) - { - GameRegistry.addRecipe(recipe); - } - } - } - - public static void addRecipe(IRecipe recipe, Configuration config, boolean defaultBoolean) - { - addRecipe(recipe, recipe.getRecipeOutput().getItemName(), config, defaultBoolean); - } -} +package universalelectricity.prefab; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import net.minecraft.src.CraftingManager; +import net.minecraft.src.IRecipe; +import net.minecraft.src.ItemStack; +import net.minecraftforge.common.Configuration; +import universalelectricity.core.UEConfig; +import cpw.mods.fml.common.registry.GameRegistry; + +/** + * This class is used to replace recipes that are already added in the existing recipe pool for + * crafting and smelting. All recipe functions take account of the Forge Ore Dictionary. It also + * includes some recipe helper functions to shorten some of your function calls. + * + * @author Calclavia + * + */ +public class RecipeHelper +{ + public static List getRecipesByOutput(ItemStack output) + { + List list = new ArrayList(); + + for (Object obj : CraftingManager.getInstance().getRecipeList()) + { + if (obj instanceof IRecipe) + { + if (((IRecipe) obj).getRecipeOutput() == output) + { + list.add((IRecipe) obj); + } + } + } + + return list; + } + + /** + * Replaces a recipe with a new IRecipe. + * + * @return True if successful + */ + public static boolean replaceRecipe(IRecipe recipe, IRecipe newRecipe) + { + for (Object obj : CraftingManager.getInstance().getRecipeList()) + { + if (obj instanceof IRecipe) + { + if (((IRecipe) obj).equals(recipe) || obj == recipe) + { + CraftingManager.getInstance().getRecipeList().remove(obj); + CraftingManager.getInstance().getRecipeList().add(newRecipe); + return true; + } + } + } + + return false; + } + + /** + * Replaces a recipe with the resulting ItemStack with a new IRecipe. + * + * @return True if successful + */ + public static boolean replaceRecipe(ItemStack recipe, IRecipe newRecipe) + { + if (removeRecipe(recipe)) + { + CraftingManager.getInstance().getRecipeList().add(newRecipe); + return true; + } + + return false; + } + + /** + * Removes a recipe by its IRecipe class. + * + * @return True if successful + */ + public static boolean removeRecipe(IRecipe recipe) + { + for (Object obj : CraftingManager.getInstance().getRecipeList()) + { + if (obj != null) + { + if (obj instanceof IRecipe) + { + if (((IRecipe) obj).equals(recipe) || obj == recipe) + { + CraftingManager.getInstance().getRecipeList().remove(obj); + return true; + } + } + } + } + + return false; + } + + /** + * Removes the first recipe found by its output. + * + * @return True if successful + */ + public static boolean removeRecipe(ItemStack stack) + { + for (Object obj : CraftingManager.getInstance().getRecipeList()) + { + if (obj != null) + { + if (obj instanceof IRecipe) + { + if (((IRecipe) obj).getRecipeOutput() != null) + { + if (((IRecipe) obj).getRecipeOutput().isItemEqual(stack)) + { + CraftingManager.getInstance().getRecipeList().remove(obj); + return true; + } + } + } + } + } + + return false; + } + + /** + * Removes all recipes found that has this output. + * + * @return True if successful + */ + public static boolean removeRecipes(ItemStack... itemStacks) + { + boolean didRemove = false; + + for (Iterator itr = CraftingManager.getInstance().getRecipeList().iterator(); itr.hasNext();) + { + Object obj = itr.next(); + + if (obj != null) + { + if (obj instanceof IRecipe) + { + if (((IRecipe) obj).getRecipeOutput() != null) + { + for (ItemStack itemStack : itemStacks) + { + if (((IRecipe) obj).getRecipeOutput().isItemEqual(itemStack)) + { + itr.remove(); + didRemove = true; + break; + } + } + } + } + } + } + + return didRemove; + } + + /** + * Use this function if you want to check if the recipe is allowed in the configuration file. + */ + public static void addRecipe(IRecipe recipe, String name, Configuration config, boolean defaultBoolean) + { + if (config != null) + { + if (UEConfig.getConfigData(config, "Allow " + name + " Crafting", defaultBoolean)) + { + GameRegistry.addRecipe(recipe); + } + } + } + + public static void addRecipe(IRecipe recipe, Configuration config, boolean defaultBoolean) + { + addRecipe(recipe, recipe.getRecipeOutput().getItemName(), config, defaultBoolean); + } +} diff --git a/src/common/universalelectricity/prefab/SlotElectricItem.java b/src/common/universalelectricity/prefab/SlotElectricItem.java old mode 100755 new mode 100644 index c4e4570b6..00e31ade9 --- a/src/common/universalelectricity/prefab/SlotElectricItem.java +++ b/src/common/universalelectricity/prefab/SlotElectricItem.java @@ -3,11 +3,10 @@ package universalelectricity.prefab; import net.minecraft.src.IInventory; import net.minecraft.src.ItemStack; import net.minecraft.src.Slot; -import universalelectricity.implement.IItemElectric; +import universalelectricity.core.implement.IItemElectric; /** - * This slot should be used by any container that needs the slot for an electric - * items only. + * This slot should be used by any container that needs the slot for an electric items only. * * @author Calclavia * @@ -20,8 +19,7 @@ public class SlotElectricItem extends Slot } /** - * Check if the stack is a valid item for this slot. Always true beside for - * the armor slots. + * Check if the stack is a valid item for this slot. Always true beside for the armor slots. */ @Override public boolean isItemValid(ItemStack par1ItemStack) diff --git a/src/common/universalelectricity/implement/UEDamageSource.java b/src/common/universalelectricity/prefab/UEDamageSource.java old mode 100755 new mode 100644 similarity index 93% rename from src/common/universalelectricity/implement/UEDamageSource.java rename to src/common/universalelectricity/prefab/UEDamageSource.java index ac17957b7..479528c06 --- a/src/common/universalelectricity/implement/UEDamageSource.java +++ b/src/common/universalelectricity/prefab/UEDamageSource.java @@ -1,4 +1,4 @@ -package universalelectricity.implement; +package universalelectricity.prefab; import java.util.ArrayList; import java.util.List; diff --git a/src/common/universalelectricity/prefab/UETab.java b/src/common/universalelectricity/prefab/UETab.java new file mode 100644 index 000000000..05dc647a1 --- /dev/null +++ b/src/common/universalelectricity/prefab/UETab.java @@ -0,0 +1,34 @@ +package universalelectricity.prefab; + +import net.minecraft.src.Block; +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.ItemStack; +import cpw.mods.fml.common.registry.LanguageRegistry; + +public class UETab extends CreativeTabs +{ + public static final UETab INSTANCE = new UETab("UniversalElectricity"); + private static ItemStack itemStack; + + public UETab(String par2Str) + { + super(CreativeTabs.getNextID(), par2Str); + LanguageRegistry.instance().addStringLocalization("itemGroup.UniversalElectricity", "en_US", "Universal Electricity"); + } + + public static void setItemStack(ItemStack newItemStack) + { + if (itemStack == null) + { + itemStack = newItemStack; + } + } + + @Override + public ItemStack getIconItemStack() + { + if (itemStack == null) { return new ItemStack(Block.blocksList[this.getTabIconItemIndex()]); } + + return itemStack; + } +} diff --git a/src/common/universalelectricity/prefab/implement/IRedstoneProvider.java b/src/common/universalelectricity/prefab/implement/IRedstoneProvider.java new file mode 100644 index 000000000..e1f93c44e --- /dev/null +++ b/src/common/universalelectricity/prefab/implement/IRedstoneProvider.java @@ -0,0 +1,16 @@ +package universalelectricity.prefab.implement; + +import net.minecraftforge.common.ForgeDirection; + +/** + * This should be applied on tile entities that can provide redstone power + * + * @author Calclavia + * + */ +public interface IRedstoneProvider +{ + public boolean isPoweringTo(ForgeDirection side); + + public boolean isIndirectlyPoweringTo(ForgeDirection side); +} diff --git a/src/common/universalelectricity/implement/IRedstoneReceptor.java b/src/common/universalelectricity/prefab/implement/IRedstoneReceptor.java old mode 100755 new mode 100644 similarity index 54% rename from src/common/universalelectricity/implement/IRedstoneReceptor.java rename to src/common/universalelectricity/prefab/implement/IRedstoneReceptor.java index 053fd8ff8..489680088 --- a/src/common/universalelectricity/implement/IRedstoneReceptor.java +++ b/src/common/universalelectricity/prefab/implement/IRedstoneReceptor.java @@ -1,8 +1,8 @@ -package universalelectricity.implement; +package universalelectricity.prefab.implement; /** - * OPTIONAL This interface should be applied onto all tile entities that needs - * to receive redstone power. Look at TileEntityBatteryBox for reference. + * This interface should be applied onto all tile entities that needs to receive redstone power. + * Look at TileEntityBatteryBox for reference. * * @author Calclavia * diff --git a/src/common/universalelectricity/implement/IRotatable.java b/src/common/universalelectricity/prefab/implement/IRotatable.java old mode 100755 new mode 100644 similarity index 57% rename from src/common/universalelectricity/implement/IRotatable.java rename to src/common/universalelectricity/prefab/implement/IRotatable.java index feb1fc301..0bddcf684 --- a/src/common/universalelectricity/implement/IRotatable.java +++ b/src/common/universalelectricity/prefab/implement/IRotatable.java @@ -1,11 +1,11 @@ -package universalelectricity.implement; +package universalelectricity.prefab.implement; import net.minecraftforge.common.ForgeDirection; /** - * This interface should be applied onto all tile entities that are - * rotatable. This interface however is optional and you do not need it for your - * add-on to function. It just makes things easier for you to code. + * This interface should be applied onto all tile entities that are rotatable. This interface + * however is optional and you do not need it for your add-on to function. It just makes things + * easier for you to code. * * @author Calclavia * @@ -14,11 +14,11 @@ import net.minecraftforge.common.ForgeDirection; public interface IRotatable { /** - * Gets the facing direction of the tile entity. Always returns the front - * side of the tile entity. + * Gets the facing direction of the tile entity. Always returns the front side of the tile + * entity. * - * @return The facing side from 0-5 The full list of which side the number - * represents is in the UniversalElectricity class. + * @return The facing side from 0-5 The full list of which side the number represents is in the + * UniversalElectricity class. */ public ForgeDirection getDirection(); @@ -26,8 +26,8 @@ public interface IRotatable * Sets the facing direction of the tile entity. * * @param facingDirection - * - A direction from 0-5. The full list of which side the number - * represents is in the UniversalElectricity class. + * - A direction from 0-5. The full list of which side the number represents is in + * the UniversalElectricity class. */ public void setDirection(ForgeDirection facingDirection); } diff --git a/src/common/universalelectricity/implement/ITier.java b/src/common/universalelectricity/prefab/implement/ITier.java old mode 100755 new mode 100644 similarity index 83% rename from src/common/universalelectricity/implement/ITier.java rename to src/common/universalelectricity/prefab/implement/ITier.java index 5030f2c0b..f67de2a55 --- a/src/common/universalelectricity/implement/ITier.java +++ b/src/common/universalelectricity/prefab/implement/ITier.java @@ -1,4 +1,4 @@ -package universalelectricity.implement; +package universalelectricity.prefab.implement; /** * This interface should be applied to all things that has a tier/level. diff --git a/src/common/universalelectricity/prefab/multiblock/BlockMulti.java b/src/common/universalelectricity/prefab/multiblock/BlockMulti.java old mode 100755 new mode 100644 index 73f29f3f7..acc5be5fb --- a/src/common/universalelectricity/prefab/multiblock/BlockMulti.java +++ b/src/common/universalelectricity/prefab/multiblock/BlockMulti.java @@ -1,99 +1,98 @@ -package universalelectricity.prefab.multiblock; - -import java.util.Random; - -import net.minecraft.src.Block; -import net.minecraft.src.BlockContainer; -import net.minecraft.src.EntityPlayer; -import net.minecraft.src.ItemStack; -import net.minecraft.src.MovingObjectPosition; -import net.minecraft.src.TileEntity; -import net.minecraft.src.World; -import universalelectricity.core.UniversalElectricity; -import universalelectricity.core.Vector3; - -public class BlockMulti extends BlockContainer -{ - public BlockMulti(int id) - { - super(id, UniversalElectricity.machine); - this.setHardness(0.8F); - this.setBlockName("MultiBlock"); - } - - public void makeFakeBlock(World worldObj, Vector3 position, Vector3 mainBlock) - { - worldObj.setBlockWithNotify(position.intX(), position.intY(), position.intZ(), this.blockID); - ((TileEntityMulti) worldObj.getBlockTileEntity(position.intX(), position.intY(), position.intZ())).setMainBlock(mainBlock); - } - - @Override - public void breakBlock(World par1World, int x, int y, int z, int par5, int par6) - { - TileEntityMulti tileEntity = (TileEntityMulti) par1World.getBlockTileEntity(x, y, z); - tileEntity.onBlockRemoval(); - super.breakBlock(par1World, 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(); - } - - @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; - } +package universalelectricity.prefab.multiblock; + +import java.util.Random; + +import net.minecraft.src.Block; +import net.minecraft.src.BlockContainer; +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.ItemStack; +import net.minecraft.src.MovingObjectPosition; +import net.minecraft.src.TileEntity; +import net.minecraft.src.World; +import universalelectricity.core.UniversalElectricity; +import universalelectricity.core.vector.Vector3; + +public class BlockMulti extends BlockContainer +{ + public BlockMulti(int id) + { + super(id, UniversalElectricity.machine); + this.setHardness(0.8F); + this.setBlockName("MultiBlock"); + } + + public void makeFakeBlock(World worldObj, Vector3 position, Vector3 mainBlock) + { + worldObj.setBlockWithNotify(position.intX(), position.intY(), position.intZ(), this.blockID); + ((TileEntityMulti) worldObj.getBlockTileEntity(position.intX(), position.intY(), position.intZ())).setMainBlock(mainBlock); + } + + @Override + public void breakBlock(World par1World, int x, int y, int z, int par5, int par6) + { + TileEntityMulti tileEntity = (TileEntityMulti) par1World.getBlockTileEntity(x, y, z); + tileEntity.onBlockRemoval(); + super.breakBlock(par1World, 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(); + } + + @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; + } } \ No newline at end of file diff --git a/src/common/universalelectricity/prefab/multiblock/IBlockActivate.java b/src/common/universalelectricity/prefab/multiblock/IBlockActivate.java old mode 100755 new mode 100644 index 1eaa350a7..bbac0a969 --- a/src/common/universalelectricity/prefab/multiblock/IBlockActivate.java +++ b/src/common/universalelectricity/prefab/multiblock/IBlockActivate.java @@ -1,17 +1,17 @@ -package universalelectricity.prefab.multiblock; - -import net.minecraft.src.EntityPlayer; - -/** - * A general interface to be implemented by anything that needs it. - * - * @author Calclavia - * - */ -public interface IBlockActivate -{ - /** - * Called when activated - */ - public boolean onActivated(EntityPlayer entityPlayer); +package universalelectricity.prefab.multiblock; + +import net.minecraft.src.EntityPlayer; + +/** + * A general interface to be implemented by anything that needs it. + * + * @author Calclavia + * + */ +public interface IBlockActivate +{ + /** + * Called when activated + */ + public boolean onActivated(EntityPlayer entityPlayer); } \ No newline at end of file diff --git a/src/common/universalelectricity/prefab/multiblock/IMultiBlock.java b/src/common/universalelectricity/prefab/multiblock/IMultiBlock.java old mode 100755 new mode 100644 index 1e05c3777..52d786ceb --- a/src/common/universalelectricity/prefab/multiblock/IMultiBlock.java +++ b/src/common/universalelectricity/prefab/multiblock/IMultiBlock.java @@ -1,30 +1,30 @@ -package universalelectricity.prefab.multiblock; - -import net.minecraft.src.TileEntity; -import universalelectricity.core.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 IBlockActivate -{ - /** - * 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); -} +package universalelectricity.prefab.multiblock; + +import net.minecraft.src.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 IBlockActivate +{ + /** + * 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/common/universalelectricity/prefab/multiblock/TileEntityMulti.java b/src/common/universalelectricity/prefab/multiblock/TileEntityMulti.java old mode 100755 new mode 100644 index c840de016..efe5152a3 --- a/src/common/universalelectricity/prefab/multiblock/TileEntityMulti.java +++ b/src/common/universalelectricity/prefab/multiblock/TileEntityMulti.java @@ -1,120 +1,120 @@ -package universalelectricity.prefab.multiblock; - -import net.minecraft.src.EntityPlayer; -import net.minecraft.src.INetworkManager; -import net.minecraft.src.NBTTagCompound; -import net.minecraft.src.Packet; -import net.minecraft.src.Packet250CustomPayload; -import net.minecraft.src.TileEntity; -import net.minecraft.src.World; -import universalelectricity.core.Vector3; -import universalelectricity.prefab.network.IPacketReceiver; -import universalelectricity.prefab.network.PacketManager; - -import com.google.common.io.ByteArrayDataInput; - -/** - * 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 void setMainBlock(Vector3 mainBlock) - { - this.mainBlockPosition = mainBlock; - - if (!this.worldObj.isRemote) - { - PacketManager.sendPacketToClients(this.getDescriptionPacket()); - } - } - - @Override - public Packet getDescriptionPacket() - { - return PacketManager.getPacket("BasicComponents", this, this.mainBlockPosition.x, this.mainBlockPosition.y, this.mainBlockPosition.z); - } - - public void onBlockRemoval() - { - if (mainBlockPosition != null) - { - TileEntity tileEntity = this.worldObj.getBlockTileEntity((int) mainBlockPosition.x, (int) mainBlockPosition.y, (int) mainBlockPosition.z); - - 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 (mainBlockPosition != null) - { - TileEntity tileEntity = this.worldObj.getBlockTileEntity((int) mainBlockPosition.x, (int) mainBlockPosition.y, (int) mainBlockPosition.z); - - 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 par1NBTTagCompound) - { - super.readFromNBT(par1NBTTagCompound); - - this.mainBlockPosition = Vector3.readFromNBT("mainBlockPosition", par1NBTTagCompound); - } - - /** - * Writes a tile entity to NBT. - */ - @Override - public void writeToNBT(NBTTagCompound par1NBTTagCompound) - { - super.writeToNBT(par1NBTTagCompound); - - this.mainBlockPosition.writeToNBT("mainBlockPosition", par1NBTTagCompound); - } - - /** - * Determines if this TileEntity requires update calls. - * - * @return True if you want updateEntity() to be called, false if not - */ - 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.readDouble(), dataStream.readDouble(), dataStream.readDouble()); - } - catch (Exception e) - { - e.printStackTrace(); - } - } +package universalelectricity.prefab.multiblock; + +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.INetworkManager; +import net.minecraft.src.NBTTagCompound; +import net.minecraft.src.Packet; +import net.minecraft.src.Packet250CustomPayload; +import net.minecraft.src.TileEntity; +import net.minecraft.src.World; +import universalelectricity.core.vector.Vector3; +import universalelectricity.prefab.network.IPacketReceiver; +import universalelectricity.prefab.network.PacketManager; + +import com.google.common.io.ByteArrayDataInput; + +/** + * 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 void setMainBlock(Vector3 mainBlock) + { + this.mainBlockPosition = mainBlock; + + if (!this.worldObj.isRemote) + { + PacketManager.sendPacketToClients(this.getDescriptionPacket()); + } + } + + @Override + public Packet getDescriptionPacket() + { + return PacketManager.getPacket("BasicComponents", this, this.mainBlockPosition.x, this.mainBlockPosition.y, this.mainBlockPosition.z); + } + + public void onBlockRemoval() + { + if (mainBlockPosition != null) + { + TileEntity tileEntity = this.worldObj.getBlockTileEntity((int) mainBlockPosition.x, (int) mainBlockPosition.y, (int) mainBlockPosition.z); + + 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 (mainBlockPosition != null) + { + TileEntity tileEntity = this.worldObj.getBlockTileEntity((int) mainBlockPosition.x, (int) mainBlockPosition.y, (int) mainBlockPosition.z); + + 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 par1NBTTagCompound) + { + super.readFromNBT(par1NBTTagCompound); + + this.mainBlockPosition = Vector3.readFromNBT("mainBlockPosition", par1NBTTagCompound); + } + + /** + * Writes a tile entity to NBT. + */ + @Override + public void writeToNBT(NBTTagCompound par1NBTTagCompound) + { + super.writeToNBT(par1NBTTagCompound); + + this.mainBlockPosition.writeToNBT("mainBlockPosition", par1NBTTagCompound); + } + + /** + * Determines if this TileEntity requires update calls. + * + * @return True if you want updateEntity() to be called, false if not + */ + 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.readDouble(), dataStream.readDouble(), dataStream.readDouble()); + } + catch (Exception e) + { + e.printStackTrace(); + } + } } \ No newline at end of file diff --git a/src/common/universalelectricity/prefab/network/ConnectionHandler.java b/src/common/universalelectricity/prefab/network/ConnectionHandler.java old mode 100755 new mode 100644 diff --git a/src/common/universalelectricity/prefab/network/IPacketReceiver.java b/src/common/universalelectricity/prefab/network/IPacketReceiver.java old mode 100755 new mode 100644 index cac1133cd..bf39ea4dd --- a/src/common/universalelectricity/prefab/network/IPacketReceiver.java +++ b/src/common/universalelectricity/prefab/network/IPacketReceiver.java @@ -1,15 +1,15 @@ -package universalelectricity.prefab.network; - -import net.minecraft.src.EntityPlayer; -import net.minecraft.src.INetworkManager; -import net.minecraft.src.Packet250CustomPayload; - -import com.google.common.io.ByteArrayDataInput; - -public interface IPacketReceiver -{ - /** - * Sends some data to the tile entity. - */ - public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream); -} +package universalelectricity.prefab.network; + +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.INetworkManager; +import net.minecraft.src.Packet250CustomPayload; + +import com.google.common.io.ByteArrayDataInput; + +public interface IPacketReceiver +{ + /** + * Sends some data to the tile entity. + */ + public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream); +} diff --git a/src/common/universalelectricity/prefab/network/ISimpleConnectionHandler.java b/src/common/universalelectricity/prefab/network/ISimpleConnectionHandler.java old mode 100755 new mode 100644 index a07979975..45972983a --- a/src/common/universalelectricity/prefab/network/ISimpleConnectionHandler.java +++ b/src/common/universalelectricity/prefab/network/ISimpleConnectionHandler.java @@ -5,8 +5,7 @@ import universalelectricity.prefab.network.ConnectionHandler.ConnectionType; public interface ISimpleConnectionHandler { /** - * Called when a player logs in. Use this to reset some tile entities - * variables if you need to. + * Called when a player logs in. Use this to reset some tile entities variables if you need to. * * @param player */ diff --git a/src/common/universalelectricity/prefab/network/PacketManager.java b/src/common/universalelectricity/prefab/network/PacketManager.java old mode 100755 new mode 100644 index 217172815..4fb4f9c5f --- a/src/common/universalelectricity/prefab/network/PacketManager.java +++ b/src/common/universalelectricity/prefab/network/PacketManager.java @@ -10,7 +10,7 @@ import net.minecraft.src.Packet; import net.minecraft.src.Packet250CustomPayload; import net.minecraft.src.TileEntity; import net.minecraft.src.World; -import universalelectricity.core.Vector3; +import universalelectricity.core.vector.Vector3; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteStreams; @@ -21,13 +21,11 @@ import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player; /** - * This class is used for sending and receiving packets between the server and - * the client. You can directly use this by registering this packet manager with - * NetworkMod. Example: + * This class is used for sending and receiving packets between the server and the client. You can + * directly use this by registering this packet manager with NetworkMod. Example: * - * @NetworkMod(channels = { "BasicComponents" }, clientSideRequired = true, - * serverSideRequired = false, packetHandler = - * PacketManager.class) + * @NetworkMod(channels = { "BasicComponents" }, clientSideRequired = true, serverSideRequired = + * false, packetHandler = PacketManager.class) * * Check out {@link #BasicComponents} for better reference. * @@ -46,6 +44,7 @@ public class PacketManager implements IPacketHandler, IPacketReceiver } } + @SuppressWarnings("resource") public static Packet getPacketWithID(String channelName, int id, Object... sendData) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); @@ -83,6 +82,7 @@ public class PacketManager implements IPacketHandler, IPacketReceiver * * @return */ + @SuppressWarnings("resource") public static Packet getPacket(String channelName, TileEntity sender, Object... sendData) { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); @@ -114,9 +114,8 @@ public class PacketManager implements IPacketHandler, IPacketReceiver } /** - * Sends packets to clients around a specific coordinate. A wrapper using - * Vector3. See {@PacketDispatcher} for detailed - * information. + * Sends packets to clients around a specific coordinate. A wrapper using Vector3. See + * {@PacketDispatcher} for detailed information. */ public static void sendPacketToClients(Packet packet, World worldObj, Vector3 position, double range) { diff --git a/src/common/universalelectricity/prefab/ore/OreGenBase.java b/src/common/universalelectricity/prefab/ore/OreGenBase.java old mode 100755 new mode 100644 index f2b4b7a29..863eff47a --- a/src/common/universalelectricity/prefab/ore/OreGenBase.java +++ b/src/common/universalelectricity/prefab/ore/OreGenBase.java @@ -12,10 +12,9 @@ import universalelectricity.core.UEConfig; import universalelectricity.core.UniversalElectricity; /** - * This class is used for storing ore generation data. If you are too lazy to - * generate your own ores, you can do - * {@link #OreGenerator.ORES_TO_GENERATE.add()} to add your ore to the list of - * ores to generate. + * This class is used for storing ore generation data. If you are too lazy to generate your own + * ores, you can do {@link #OreGenerator.ORES_TO_GENERATE.add()} to add your ore to the list of ores + * to generate. * * @author Calclavia * @@ -42,8 +41,8 @@ public abstract class OreGenBase public int harvestLevel; /** - * The predefined tool classes are "pickaxe", "shovel", "axe". You can add - * others for custom tools. + * The predefined tool classes are "pickaxe", "shovel", "axe". You can add others for custom + * tools. */ public String harvestTool; @@ -59,9 +58,8 @@ public abstract class OreGenBase * @param amountPerChunk * - The amount of ores to generate per chunk * @param amountPerBranch - * - The amount of ores to generate in a clutter. E.g coal - * generates with a lot of other coal next to it. How much do you - * want? + * - The amount of ores to generate in a clutter. E.g coal generates with a lot of + * other coal next to it. How much do you want? */ public OreGenBase(String name, String oreDiectionaryName, ItemStack stack, String harvestTool, int harvestLevel) { @@ -84,14 +82,16 @@ public abstract class OreGenBase return this; } - // You may inherit from this class and change this function if you want a + // You may inherit from this class and change + // this function if you want a // custom texture render for your ore. public int getBlockTextureFromSide(int side) { return this.blockIndexTexture; } - // Checks the config file and see if Universal Electricity should generate + // Checks the config file and see if Universal + // Electricity should generate // this ore private static boolean shouldGenerateOre(String oreName) { diff --git a/src/common/universalelectricity/prefab/ore/OreGenReplace.java b/src/common/universalelectricity/prefab/ore/OreGenReplace.java old mode 100755 new mode 100644 index c9bbbedc1..d4a646d00 --- a/src/common/universalelectricity/prefab/ore/OreGenReplace.java +++ b/src/common/universalelectricity/prefab/ore/OreGenReplace.java @@ -11,10 +11,9 @@ import net.minecraft.src.MathHelper; import net.minecraft.src.World; /** - * This class is used for storing ore generation data. If you are too lazy to - * generate your own ores, you can do - * {@link #OreGenerator.ORES_TO_GENERATE.add()} to add your ore to the list of - * ores to generate. + * This class is used for storing ore generation data. If you are too lazy to generate your own + * ores, you can do {@link #OreGenerator.ORES_TO_GENERATE.add()} to add your ore to the list of ores + * to generate. * * @author Calclavia * @@ -44,9 +43,8 @@ public class OreGenReplace extends OreGenBase * @param amountPerChunk * - The amount of ores to generate per chunk * @param amountPerBranch - * - The amount of ores to generate in a clutter. E.g coal - * generates with a lot of other coal next to it. How much do you - * want? + * - The amount of ores to generate in a clutter. E.g coal generates with a lot of + * other coal next to it. How much do you want? */ public OreGenReplace(String name, String oreDiectionaryName, ItemStack stack, int replaceID, int minGenerateLevel, int maxGenerateLevel, int amountPerChunk, int amountPerBranch, String harvestTool, int harvestLevel) { diff --git a/src/common/universalelectricity/prefab/ore/OreGenReplaceStone.java b/src/common/universalelectricity/prefab/ore/OreGenReplaceStone.java old mode 100755 new mode 100644 diff --git a/src/common/universalelectricity/prefab/ore/OreGenerator.java b/src/common/universalelectricity/prefab/ore/OreGenerator.java old mode 100755 new mode 100644 index f51a52674..3c94519d3 --- a/src/common/universalelectricity/prefab/ore/OreGenerator.java +++ b/src/common/universalelectricity/prefab/ore/OreGenerator.java @@ -14,8 +14,7 @@ public class OreGenerator implements IWorldGenerator public static boolean isInitiated = false; /** - * Add your ore data to this list of ores for it to automatically generate! - * No hassle indeed! + * Add your ore data to this list of ores for it to automatically generate! No hassle indeed! */ private static final List ORES_TO_GENERATE = new ArrayList(); @@ -62,7 +61,8 @@ public class OreGenerator implements IWorldGenerator chunkX = chunkX << 4; chunkZ = chunkZ << 4; - // Checks to make sure this is the normal world + // Checks to make sure this is the normal + // world for (OreGenBase oreData : ORES_TO_GENERATE) { if (oreData.shouldGenerate && oreData.isOreGeneratedInWorld(world, chunkGenerator)) diff --git a/src/common/universalelectricity/prefab/potion/CustomPotion.java b/src/common/universalelectricity/prefab/potion/CustomPotion.java old mode 100755 new mode 100644 index 90a5fa8e5..fc13deb97 --- a/src/common/universalelectricity/prefab/potion/CustomPotion.java +++ b/src/common/universalelectricity/prefab/potion/CustomPotion.java @@ -1,41 +1,41 @@ -package universalelectricity.prefab.potion; - -import net.minecraft.src.Potion; -import cpw.mods.fml.common.registry.LanguageRegistry; - -public abstract class CustomPotion extends Potion -{ - /** - * Creates a new type of potion - * - * @param id - * - The ID of this potion. Make it greater than 20. - * @param isBadEffect - * - Is this potion a good potion or a bad one? - * @param color - * - The color of this potion. - * @param name - * - The name of this potion. - */ - public CustomPotion(int id, boolean isBadEffect, int color, String name) - { - super(id, isBadEffect, color); - this.setPotionName("potion." + name); - LanguageRegistry.instance().addStringLocalization(this.getName(), name); - } - - @Override - public Potion setIconIndex(int par1, int par2) - { - super.setIconIndex(par1, par2); - return this; - } - - /** - * You must register all your potion effects during mod initialization! - */ - public void register() - { - Potion.potionTypes[this.getId()] = this; - } -} +package universalelectricity.prefab.potion; + +import net.minecraft.src.Potion; +import cpw.mods.fml.common.registry.LanguageRegistry; + +public abstract class CustomPotion extends Potion +{ + /** + * Creates a new type of potion + * + * @param id + * - The ID of this potion. Make it greater than 20. + * @param isBadEffect + * - Is this potion a good potion or a bad one? + * @param color + * - The color of this potion. + * @param name + * - The name of this potion. + */ + public CustomPotion(int id, boolean isBadEffect, int color, String name) + { + super(id, isBadEffect, color); + this.setPotionName("potion." + name); + LanguageRegistry.instance().addStringLocalization(this.getName(), name); + } + + @Override + public Potion setIconIndex(int par1, int par2) + { + super.setIconIndex(par1, par2); + return this; + } + + /** + * You must register all your potion effects during mod initialization! + */ + public void register() + { + Potion.potionTypes[this.getId()] = this; + } +} diff --git a/src/common/universalelectricity/prefab/potion/CustomPotionEffect.java b/src/common/universalelectricity/prefab/potion/CustomPotionEffect.java old mode 100755 new mode 100644 index 401359d4d..fedd88ccc --- a/src/common/universalelectricity/prefab/potion/CustomPotionEffect.java +++ b/src/common/universalelectricity/prefab/potion/CustomPotionEffect.java @@ -1,41 +1,41 @@ -package universalelectricity.prefab.potion; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.src.ItemStack; -import net.minecraft.src.Potion; -import net.minecraft.src.PotionEffect; - -public class CustomPotionEffect extends PotionEffect -{ - public CustomPotionEffect(int potionID, int duration, int amplifier) - { - super(potionID, duration, amplifier); - } - - public CustomPotionEffect(Potion potion, int duration, int amplifier) - { - this(potion.getId(), duration, amplifier); - } - - /** - * Creates a potion effect with custom curable items. - * - * @param curativeItems - * - ItemStacks that can cure this potion effect - */ - public CustomPotionEffect(int potionID, int duration, int amplifier, List curativeItems) - { - super(potionID, duration, amplifier); - - if (curativeItems == null) - { - this.setCurativeItems(new ArrayList()); - } - else - { - this.setCurativeItems(curativeItems); - } - } -} +package universalelectricity.prefab.potion; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.src.ItemStack; +import net.minecraft.src.Potion; +import net.minecraft.src.PotionEffect; + +public class CustomPotionEffect extends PotionEffect +{ + public CustomPotionEffect(int potionID, int duration, int amplifier) + { + super(potionID, duration, amplifier); + } + + public CustomPotionEffect(Potion potion, int duration, int amplifier) + { + this(potion.getId(), duration, amplifier); + } + + /** + * Creates a potion effect with custom curable items. + * + * @param curativeItems + * - ItemStacks that can cure this potion effect + */ + public CustomPotionEffect(int potionID, int duration, int amplifier, List curativeItems) + { + super(potionID, duration, amplifier); + + if (curativeItems == null) + { + this.setCurativeItems(new ArrayList()); + } + else + { + this.setCurativeItems(curativeItems); + } + } +} diff --git a/src/common/universalelectricity/prefab/TileEntityAdvanced.java b/src/common/universalelectricity/prefab/tile/TileEntityAdvanced.java old mode 100755 new mode 100644 similarity index 90% rename from src/common/universalelectricity/prefab/TileEntityAdvanced.java rename to src/common/universalelectricity/prefab/tile/TileEntityAdvanced.java index 214829362..c005fa532 --- a/src/common/universalelectricity/prefab/TileEntityAdvanced.java +++ b/src/common/universalelectricity/prefab/tile/TileEntityAdvanced.java @@ -1,60 +1,60 @@ -package universalelectricity.prefab; - -import net.minecraft.src.Block; -import net.minecraft.src.TileEntity; - -/** - * A TileEntity with some pre-added functionalities. - * - * @author Calclavia - * - */ -public abstract class TileEntityAdvanced extends TileEntity -{ - protected long ticks = 0; - - @Override - public void updateEntity() - { - if (this.ticks == 0) - { - this.initiate(); - } - - if (this.ticks >= Long.MAX_VALUE) - { - this.ticks = 1; - } - - this.ticks++; - } - - /** - * Called on the TileEntity's first tick. - */ - protected void initiate() - { - } - - @Override - public int getBlockMetadata() - { - if (this.blockMetadata == -1) - { - this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord); - } - - return this.blockMetadata; - } - - @Override - public Block getBlockType() - { - if (this.blockType == null) - { - this.blockType = Block.blocksList[this.worldObj.getBlockId(this.xCoord, this.yCoord, this.zCoord)]; - } - - return this.blockType; - } -} +package universalelectricity.prefab.tile; + +import net.minecraft.src.Block; +import net.minecraft.src.TileEntity; + +/** + * A TileEntity with some pre-added functionalities. + * + * @author Calclavia + * + */ +public abstract class TileEntityAdvanced extends TileEntity +{ + protected long ticks = 0; + + @Override + public void updateEntity() + { + if (this.ticks == 0) + { + this.initiate(); + } + + if (this.ticks >= Long.MAX_VALUE) + { + this.ticks = 1; + } + + this.ticks++; + } + + /** + * Called on the TileEntity's first tick. + */ + protected void initiate() + { + } + + @Override + public int getBlockMetadata() + { + if (this.blockMetadata == -1) + { + this.blockMetadata = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord); + } + + return this.blockMetadata; + } + + @Override + public Block getBlockType() + { + if (this.blockType == null) + { + this.blockType = Block.blocksList[this.worldObj.getBlockId(this.xCoord, this.yCoord, this.zCoord)]; + } + + return this.blockType; + } +} diff --git a/src/common/universalelectricity/prefab/TileEntityConductor.java b/src/common/universalelectricity/prefab/tile/TileEntityConductor.java old mode 100755 new mode 100644 similarity index 80% rename from src/common/universalelectricity/prefab/TileEntityConductor.java rename to src/common/universalelectricity/prefab/tile/TileEntityConductor.java index e199ba551..3d33dfc49 --- a/src/common/universalelectricity/prefab/TileEntityConductor.java +++ b/src/common/universalelectricity/prefab/tile/TileEntityConductor.java @@ -1,4 +1,4 @@ -package universalelectricity.prefab; +package universalelectricity.prefab.tile; import net.minecraft.src.EntityPlayer; import net.minecraft.src.INetworkManager; @@ -6,18 +6,17 @@ import net.minecraft.src.Packet250CustomPayload; import net.minecraft.src.TileEntity; import net.minecraft.src.World; import net.minecraftforge.common.ForgeDirection; -import universalelectricity.core.Vector3; -import universalelectricity.electricity.ElectricityManager; -import universalelectricity.electricity.ElectricityNetwork; -import universalelectricity.implement.IConductor; -import universalelectricity.implement.IConnector; +import universalelectricity.core.electricity.ElectricityManager; +import universalelectricity.core.electricity.ElectricityNetwork; +import universalelectricity.core.implement.IConductor; +import universalelectricity.core.implement.IConnector; +import universalelectricity.core.vector.Vector3; import universalelectricity.prefab.network.IPacketReceiver; import com.google.common.io.ByteArrayDataInput; /** - * This tile entity pre-fabricated for all - * conductors. + * This tile entity pre-fabricated for all conductors. * * @author Calclavia * @@ -27,8 +26,7 @@ public abstract class TileEntityConductor extends TileEntityAdvanced implements private ElectricityNetwork network; /** - * Stores information on the blocks that this - * conductor is connected to + * Stores information on the blocks that this conductor is connected to */ public TileEntity[] connectedBlocks = { null, null, null, null, null, null }; @@ -122,11 +120,9 @@ public abstract class TileEntityConductor extends TileEntityAdvanced implements } /** - * Determines if this TileEntity requires - * update calls. + * Determines if this TileEntity requires update calls. * - * @return True if you want updateEntity() to - * be called, false if not + * @return True if you want updateEntity() to be called, false if not */ @Override public boolean canUpdate() diff --git a/src/common/universalelectricity/prefab/TileEntityDisableable.java b/src/common/universalelectricity/prefab/tile/TileEntityDisableable.java old mode 100755 new mode 100644 similarity index 79% rename from src/common/universalelectricity/prefab/TileEntityDisableable.java rename to src/common/universalelectricity/prefab/tile/TileEntityDisableable.java index 55e51e521..8554ae532 --- a/src/common/universalelectricity/prefab/TileEntityDisableable.java +++ b/src/common/universalelectricity/prefab/tile/TileEntityDisableable.java @@ -1,10 +1,9 @@ -package universalelectricity.prefab; +package universalelectricity.prefab.tile; -import universalelectricity.implement.IDisableable; +import universalelectricity.core.implement.IDisableable; /** - * An easier way to implement the methods from IElectricityDisableable with - * default values set. + * An easier way to implement the methods from IElectricityDisableable with default values set. * * @author Calclavia */ diff --git a/src/common/universalelectricity/prefab/TileEntityElectricityReceiver.java b/src/common/universalelectricity/prefab/tile/TileEntityElectricityReceiver.java old mode 100755 new mode 100644 similarity index 76% rename from src/common/universalelectricity/prefab/TileEntityElectricityReceiver.java rename to src/common/universalelectricity/prefab/tile/TileEntityElectricityReceiver.java index 598cdac8c..38e422755 --- a/src/common/universalelectricity/prefab/TileEntityElectricityReceiver.java +++ b/src/common/universalelectricity/prefab/tile/TileEntityElectricityReceiver.java @@ -1,11 +1,10 @@ -package universalelectricity.prefab; +package universalelectricity.prefab.tile; import net.minecraftforge.common.ForgeDirection; -import universalelectricity.implement.IElectricityReceiver; +import universalelectricity.core.implement.IElectricityReceiver; /** - * An easier way to implement the methods from IElectricityReceiver with default - * values set. + * An easier way to implement the methods from IElectricityReceiver with default values set. * * @author Calclavia */