From e8b0e56a801e4c0a46a1d2f04c20a4ccb650ed84 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Sat, 11 Jan 2014 17:28:38 +0800 Subject: [PATCH] Moved more stuff to core --- build.gradle | 2 +- build.properties | 2 +- .../dark/lib/interfaces/IExternalInv.java | 13 - .../java/dark/lib/interfaces/IInvBox.java | 21 -- .../java/dark/lib/interfaces/IPowerLess.java | 16 -- .../dark/lib/interfaces/IRotatableBlock.java | 19 -- .../java/dark/lib/prefab/invgui/InvChest.java | 256 ------------------ .../archaic/blocks/BlockTurntable.java | 2 +- .../archaic/crate/InventoryCrate.java | 4 +- .../archaic/crate/TileCrate.java | 2 +- .../core}/IExtendedStorage.java | 2 +- .../core/prefab}/ContainerFake.java | 2 +- .../prefab/tile/TileEntityEnergyMachine.java | 1 - .../core/prefab/tile/TileEntityInv.java | 8 +- .../core/prefab/tile/TileEntityMachine.java | 4 +- .../prefab/NetworkSharedPower.java | 1 - 16 files changed, 14 insertions(+), 341 deletions(-) delete mode 100644 src/main/java/dark/lib/interfaces/IExternalInv.java delete mode 100644 src/main/java/dark/lib/interfaces/IInvBox.java delete mode 100644 src/main/java/dark/lib/interfaces/IPowerLess.java delete mode 100644 src/main/java/dark/lib/interfaces/IRotatableBlock.java delete mode 100644 src/main/java/dark/lib/prefab/invgui/InvChest.java rename src/main/java/{dark/lib/interfaces => resonantinduction/core}/IExtendedStorage.java (89%) rename src/main/java/{dark/lib/prefab/invgui => resonantinduction/core/prefab}/ContainerFake.java (94%) diff --git a/build.gradle b/build.gradle index 9cc8f2a1e..1ade218e2 100644 --- a/build.gradle +++ b/build.gradle @@ -77,7 +77,7 @@ repositories { } dependencies { compile 'universalelectricity:Universal-Electricity:3.0.+:dev' - compile 'calclaviacore:calclavia-core:+:dev' + compile 'calclaviacore:calclavia-core:1.1.+:dev' compile name: 'CodeChickenLib', version: "1.6.4-1.0.0.49", ext: 'jar' compile name: 'ForgeMultipart', version: "1.6.4-1.0.0.233", ext: 'jar' } diff --git a/build.properties b/build.properties index a6bef0ef5..bddad1055 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ dir.development=./ dir.mcp=${dir.development}forge/mcp version.minecraft=1.6.4 -version.forge=9.11.1.964 +version.forge=9.11.1.965 version.universalelectricity=3.0.0 version.mod.major=0 version.mod.minor=3 diff --git a/src/main/java/dark/lib/interfaces/IExternalInv.java b/src/main/java/dark/lib/interfaces/IExternalInv.java deleted file mode 100644 index abbd3d559..000000000 --- a/src/main/java/dark/lib/interfaces/IExternalInv.java +++ /dev/null @@ -1,13 +0,0 @@ -package dark.lib.interfaces; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.common.ForgeDirection; - -public interface IExternalInv -{ - public IInvBox getInventory(); - - public boolean canStore(ItemStack stack, int slot, ForgeDirection side); - - public boolean canRemove(ItemStack stack, int slot, ForgeDirection side); -} diff --git a/src/main/java/dark/lib/interfaces/IInvBox.java b/src/main/java/dark/lib/interfaces/IInvBox.java deleted file mode 100644 index 56e3a560e..000000000 --- a/src/main/java/dark/lib/interfaces/IInvBox.java +++ /dev/null @@ -1,21 +0,0 @@ -package dark.lib.interfaces; - -import net.minecraft.inventory.ISidedInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -/** @author DarkGuardsman */ -public interface IInvBox extends ISidedInventory -{ - /** Gets the inventory array. ForgeDirection.UNKOWN must return all sides */ - public ItemStack[] getContainedItems(); - - /** Called to save the inventory array */ - public NBTTagCompound saveInv(NBTTagCompound tag); - - /** Called to load the inventory array */ - public void loadInv(NBTTagCompound tag); - - /** Dels all the items in the inventory */ - public void clear(); -} diff --git a/src/main/java/dark/lib/interfaces/IPowerLess.java b/src/main/java/dark/lib/interfaces/IPowerLess.java deleted file mode 100644 index 66deec570..000000000 --- a/src/main/java/dark/lib/interfaces/IPowerLess.java +++ /dev/null @@ -1,16 +0,0 @@ -package dark.lib.interfaces; - -/** - * Applied to devices that have the option to run without power. Normally this option is only shown - * to creative mode players - * - * @author DarkGuardsman - */ -public interface IPowerLess -{ - /** Should this run without power */ - public boolean runPowerLess(); - - /** Set if this should run powerless */ - public void setPowerLess(boolean bool); -} diff --git a/src/main/java/dark/lib/interfaces/IRotatableBlock.java b/src/main/java/dark/lib/interfaces/IRotatableBlock.java deleted file mode 100644 index f998d5688..000000000 --- a/src/main/java/dark/lib/interfaces/IRotatableBlock.java +++ /dev/null @@ -1,19 +0,0 @@ -package dark.lib.interfaces; - -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeDirection; - -/** - * The interface is applied to Blocks that can rotate. - * - * @author DarkGuardsman - */ - -public interface IRotatableBlock -{ - /** @return Gets the facing direction. Always returns the front side of the block. */ - public ForgeDirection getDirection(World world, int x, int y, int z); - - /** @param Sets the facing direction. */ - public void setDirection(World world, int x, int y, int z, ForgeDirection direection); -} diff --git a/src/main/java/dark/lib/prefab/invgui/InvChest.java b/src/main/java/dark/lib/prefab/invgui/InvChest.java deleted file mode 100644 index d59de3321..000000000 --- a/src/main/java/dark/lib/prefab/invgui/InvChest.java +++ /dev/null @@ -1,256 +0,0 @@ -package dark.lib.prefab.invgui; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.ForgeDirection; -import dark.lib.interfaces.IExternalInv; -import dark.lib.interfaces.IInvBox; - -public class InvChest implements IInvBox -{ - /** Access able slots side all */ - protected int[] openSlots; - /** Items contained in this inv */ - protected ItemStack[] containedItems; - /** Host tileEntity */ - protected TileEntity hostTile; - /** Host tileEntity as external inv */ - protected IExternalInv inv; - /** Default slot max count */ - protected final int slots; - - public InvChest(TileEntity chest, IExternalInv inv, int slots) - { - this.hostTile = chest; - this.slots = slots; - this.inv = inv; - } - - public InvChest(TileEntity chest, int slots) - { - this(chest, ((IExternalInv) chest), slots); - } - - public InvChest(Entity entity, int i) - { - this.slots = i; - this.inv = (IExternalInv) entity; - } - - @Override - public int getSizeInventory() - { - return slots; - } - - @Override - public ItemStack getStackInSlot(int slot) - { - return this.getContainedItems()[slot]; - } - - @Override - public ItemStack decrStackSize(int slot, int ammount) - { - if (this.getContainedItems()[slot] != null) - { - ItemStack var3; - - if (this.getContainedItems()[slot].stackSize <= ammount) - { - var3 = this.getContainedItems()[slot]; - this.getContainedItems()[slot] = null; - this.onInventoryChanged(); - return var3; - } - else - { - var3 = this.getContainedItems()[slot].splitStack(ammount); - - if (this.getContainedItems()[slot].stackSize == 0) - { - this.getContainedItems()[slot] = null; - } - - this.onInventoryChanged(); - return var3; - } - } - else - { - return null; - } - } - - @Override - public ItemStack getStackInSlotOnClosing(int par1) - { - if (this.getContainedItems()[par1] != null) - { - ItemStack var2 = this.getContainedItems()[par1]; - this.getContainedItems()[par1] = null; - return var2; - } - else - { - return null; - } - } - - @Override - public void setInventorySlotContents(int par1, ItemStack par2ItemStack) - { - this.getContainedItems()[par1] = par2ItemStack; - - if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) - { - par2ItemStack.stackSize = this.getInventoryStackLimit(); - } - - this.onInventoryChanged(); - } - - @Override - public String getInvName() - { - return "container.chest"; - } - - @Override - public void openChest() - { - - } - - @Override - public void closeChest() - { - - } - - @Override - public boolean isInvNameLocalized() - { - return false; - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) - { - if (i >= this.getSizeInventory()) - { - return false; - } - return true; - } - - @Override - public int[] getAccessibleSlotsFromSide(int var1) - { - if (openSlots == null || openSlots.length != this.getSizeInventory()) - { - this.openSlots = new int[this.getSizeInventory()]; - for (int i = 0; i < this.openSlots.length; i++) - { - openSlots[i] = i; - } - } - return this.openSlots; - } - - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) - { - return this.isItemValidForSlot(i, itemstack) && this.inv.canStore(itemstack, i, ForgeDirection.getOrientation(j)); - } - - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) - { - return this.inv.canRemove(itemstack, i, ForgeDirection.getOrientation(j)); - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - @Override - public void onInventoryChanged() - { - if (this.hostTile != null) - { - this.hostTile.onInventoryChanged(); - } - } - - @Override - public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer) - { - if (this.hostTile != null) - { - return this.hostTile.worldObj.getBlockTileEntity(this.hostTile.xCoord, this.hostTile.yCoord, this.hostTile.zCoord) != this.hostTile ? false : par1EntityPlayer.getDistanceSq(this.hostTile.xCoord + 0.5D, this.hostTile.yCoord + 0.5D, this.hostTile.zCoord + 0.5D) <= 64.0D; - } - return true; - } - - @Override - public ItemStack[] getContainedItems() - { - if (this.containedItems == null) - { - this.containedItems = new ItemStack[this.getSizeInventory()]; - } - return this.containedItems; - } - - @Override - public NBTTagCompound saveInv(NBTTagCompound nbt) - { - NBTTagList itemList = new NBTTagList(); - for (int s = 0; s < this.getContainedItems().length; ++s) - { - if (this.getContainedItems()[s] != null) - { - NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("Slot", (byte) s); - this.getContainedItems()[s].writeToNBT(tag); - itemList.appendTag(tag); - } - } - nbt.setTag("Items", itemList); - return nbt; - } - - @Override - public void loadInv(NBTTagCompound nbt) - { - // chest inv reading - NBTTagList itemList = nbt.getTagList("Items"); - - for (int s = 0; s < itemList.tagCount(); ++s) - { - NBTTagCompound tag = (NBTTagCompound) itemList.tagAt(s); - int slotID = tag.getByte("Slot") & 255; - - if (slotID >= 0 && slotID < this.getContainedItems().length) - { - this.getContainedItems()[slotID] = ItemStack.loadItemStackFromNBT(tag); - } - } - - } - - @Override - public void clear() - { - this.containedItems = null; - this.getContainedItems(); - } - -} diff --git a/src/main/java/resonantinduction/archaic/blocks/BlockTurntable.java b/src/main/java/resonantinduction/archaic/blocks/BlockTurntable.java index 1ae0a0426..856e32b39 100644 --- a/src/main/java/resonantinduction/archaic/blocks/BlockTurntable.java +++ b/src/main/java/resonantinduction/archaic/blocks/BlockTurntable.java @@ -16,10 +16,10 @@ import net.minecraftforge.common.ForgeDirection; import resonantinduction.core.Reference; import resonantinduction.core.prefab.block.BlockRI; import universalelectricity.api.vector.Vector3; +import calclavia.lib.prefab.block.IRotatableBlock; import calclavia.lib.prefab.tile.IRotatable; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -import dark.lib.interfaces.IRotatableBlock; public class BlockTurntable extends BlockRI { diff --git a/src/main/java/resonantinduction/archaic/crate/InventoryCrate.java b/src/main/java/resonantinduction/archaic/crate/InventoryCrate.java index 655226169..e56897102 100644 --- a/src/main/java/resonantinduction/archaic/crate/InventoryCrate.java +++ b/src/main/java/resonantinduction/archaic/crate/InventoryCrate.java @@ -3,9 +3,9 @@ package resonantinduction.archaic.crate; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import dark.lib.prefab.invgui.InvChest; +import calclavia.lib.inventory.TileInventory; -public class InventoryCrate extends InvChest +public class InventoryCrate extends TileInventory { public InventoryCrate(TileEntity crate) { diff --git a/src/main/java/resonantinduction/archaic/crate/TileCrate.java b/src/main/java/resonantinduction/archaic/crate/TileCrate.java index 44964215a..d2548328f 100644 --- a/src/main/java/resonantinduction/archaic/crate/TileCrate.java +++ b/src/main/java/resonantinduction/archaic/crate/TileCrate.java @@ -5,6 +5,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.packet.Packet; import net.minecraftforge.common.ForgeDirection; +import resonantinduction.core.IExtendedStorage; import resonantinduction.core.ResonantInduction; import resonantinduction.core.prefab.tile.TileEntityInv; import calclavia.lib.network.IPacketReceiver; @@ -14,7 +15,6 @@ import com.google.common.io.ByteArrayDataInput; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.relauncher.Side; -import dark.lib.interfaces.IExtendedStorage; /** * Basic single stack inventory diff --git a/src/main/java/dark/lib/interfaces/IExtendedStorage.java b/src/main/java/resonantinduction/core/IExtendedStorage.java similarity index 89% rename from src/main/java/dark/lib/interfaces/IExtendedStorage.java rename to src/main/java/resonantinduction/core/IExtendedStorage.java index 7cce03772..31a2e1fc0 100644 --- a/src/main/java/dark/lib/interfaces/IExtendedStorage.java +++ b/src/main/java/resonantinduction/core/IExtendedStorage.java @@ -1,4 +1,4 @@ -package dark.lib.interfaces; +package resonantinduction.core; import net.minecraft.item.ItemStack; diff --git a/src/main/java/dark/lib/prefab/invgui/ContainerFake.java b/src/main/java/resonantinduction/core/prefab/ContainerFake.java similarity index 94% rename from src/main/java/dark/lib/prefab/invgui/ContainerFake.java rename to src/main/java/resonantinduction/core/prefab/ContainerFake.java index d52ca20b6..349d2af40 100644 --- a/src/main/java/dark/lib/prefab/invgui/ContainerFake.java +++ b/src/main/java/resonantinduction/core/prefab/ContainerFake.java @@ -1,4 +1,4 @@ -package dark.lib.prefab.invgui; +package resonantinduction.core.prefab; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; diff --git a/src/main/java/resonantinduction/core/prefab/tile/TileEntityEnergyMachine.java b/src/main/java/resonantinduction/core/prefab/tile/TileEntityEnergyMachine.java index 5e93b41e9..5d573668e 100644 --- a/src/main/java/resonantinduction/core/prefab/tile/TileEntityEnergyMachine.java +++ b/src/main/java/resonantinduction/core/prefab/tile/TileEntityEnergyMachine.java @@ -18,7 +18,6 @@ import universalelectricity.api.energy.IEnergyContainer; import universalelectricity.api.energy.IEnergyInterface; import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.VectorHelper; -import dark.lib.interfaces.IPowerLess; /** * Basic energy tile that can consume power diff --git a/src/main/java/resonantinduction/core/prefab/tile/TileEntityInv.java b/src/main/java/resonantinduction/core/prefab/tile/TileEntityInv.java index 19cc5ae1a..fd5d2b36b 100644 --- a/src/main/java/resonantinduction/core/prefab/tile/TileEntityInv.java +++ b/src/main/java/resonantinduction/core/prefab/tile/TileEntityInv.java @@ -17,10 +17,10 @@ import calclavia.lib.access.AccessUser; import calclavia.lib.access.GroupRegistry; import calclavia.lib.access.ISpecialAccess; import calclavia.lib.access.Nodes; +import calclavia.lib.inventory.IExternalInv; +import calclavia.lib.inventory.IInvBox; +import calclavia.lib.inventory.TileInventory; import calclavia.lib.prefab.tile.TileAdvanced; -import dark.lib.interfaces.IExternalInv; -import dark.lib.interfaces.IInvBox; -import dark.lib.prefab.invgui.InvChest; /** * Prefab for simple object who only need basic inv support and nothing more @@ -63,7 +63,7 @@ public class TileEntityInv extends TileAdvanced implements IExternalInv, ISidedI { if (inventory == null) { - inventory = new InvChest(this, this.invSlots); + inventory = new TileInventory(this, this.invSlots); } return inventory; } diff --git a/src/main/java/resonantinduction/core/prefab/tile/TileEntityMachine.java b/src/main/java/resonantinduction/core/prefab/tile/TileEntityMachine.java index ec65f680d..71ecafa55 100644 --- a/src/main/java/resonantinduction/core/prefab/tile/TileEntityMachine.java +++ b/src/main/java/resonantinduction/core/prefab/tile/TileEntityMachine.java @@ -13,14 +13,14 @@ import resonantinduction.core.ResonantInduction; import resonantinduction.core.network.ISimplePacketReceiver; import universalelectricity.api.vector.Vector3; import calclavia.lib.content.IExtraInfo.IExtraTileEntityInfo; +import calclavia.lib.inventory.IExternalInv; +import calclavia.lib.inventory.IInvBox; import calclavia.lib.network.PacketHandler; import com.google.common.io.ByteArrayDataInput; import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.Player; -import dark.lib.interfaces.IExternalInv; -import dark.lib.interfaces.IInvBox; public abstract class TileEntityMachine extends TileEntityInv implements ISidedInventory, IExternalInv, ISimplePacketReceiver, IExtraTileEntityInfo { diff --git a/src/main/java/resonantinduction/core/tilenetwork/prefab/NetworkSharedPower.java b/src/main/java/resonantinduction/core/tilenetwork/prefab/NetworkSharedPower.java index 1ba43bb33..903d6c325 100644 --- a/src/main/java/resonantinduction/core/tilenetwork/prefab/NetworkSharedPower.java +++ b/src/main/java/resonantinduction/core/tilenetwork/prefab/NetworkSharedPower.java @@ -3,7 +3,6 @@ package resonantinduction.core.tilenetwork.prefab; import net.minecraft.tileentity.TileEntity; import resonantinduction.core.tilenetwork.INetworkEnergyPart; import resonantinduction.core.tilenetwork.INetworkPart; -import dark.lib.interfaces.IPowerLess; /** * Used for tile networks that only need to share power or act like a group battery that doesn't