Moved more stuff to core

This commit is contained in:
Calclavia 2014-01-11 17:28:38 +08:00
parent 68e9b95ffb
commit e8b0e56a80
16 changed files with 14 additions and 341 deletions

View file

@ -77,7 +77,7 @@ repositories {
} }
dependencies { dependencies {
compile 'universalelectricity:Universal-Electricity:3.0.+:dev' 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: 'CodeChickenLib', version: "1.6.4-1.0.0.49", ext: 'jar'
compile name: 'ForgeMultipart', version: "1.6.4-1.0.0.233", ext: 'jar' compile name: 'ForgeMultipart', version: "1.6.4-1.0.0.233", ext: 'jar'
} }

View file

@ -1,7 +1,7 @@
dir.development=./ dir.development=./
dir.mcp=${dir.development}forge/mcp dir.mcp=${dir.development}forge/mcp
version.minecraft=1.6.4 version.minecraft=1.6.4
version.forge=9.11.1.964 version.forge=9.11.1.965
version.universalelectricity=3.0.0 version.universalelectricity=3.0.0
version.mod.major=0 version.mod.major=0
version.mod.minor=3 version.mod.minor=3

View file

@ -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);
}

View file

@ -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();
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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();
}
}

View file

@ -16,10 +16,10 @@ import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import resonantinduction.core.prefab.block.BlockRI; import resonantinduction.core.prefab.block.BlockRI;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.prefab.block.IRotatableBlock;
import calclavia.lib.prefab.tile.IRotatable; import calclavia.lib.prefab.tile.IRotatable;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import dark.lib.interfaces.IRotatableBlock;
public class BlockTurntable extends BlockRI public class BlockTurntable extends BlockRI
{ {

View file

@ -3,9 +3,9 @@ package resonantinduction.archaic.crate;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; 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) public InventoryCrate(TileEntity crate)
{ {

View file

@ -5,6 +5,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import resonantinduction.core.IExtendedStorage;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.core.prefab.tile.TileEntityInv; import resonantinduction.core.prefab.tile.TileEntityInv;
import calclavia.lib.network.IPacketReceiver; 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.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import dark.lib.interfaces.IExtendedStorage;
/** /**
* Basic single stack inventory * Basic single stack inventory

View file

@ -1,4 +1,4 @@
package dark.lib.interfaces; package resonantinduction.core;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -1,4 +1,4 @@
package dark.lib.prefab.invgui; package resonantinduction.core.prefab;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;

View file

@ -18,7 +18,6 @@ import universalelectricity.api.energy.IEnergyContainer;
import universalelectricity.api.energy.IEnergyInterface; import universalelectricity.api.energy.IEnergyInterface;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import universalelectricity.api.vector.VectorHelper; import universalelectricity.api.vector.VectorHelper;
import dark.lib.interfaces.IPowerLess;
/** /**
* Basic energy tile that can consume power * Basic energy tile that can consume power

View file

@ -17,10 +17,10 @@ import calclavia.lib.access.AccessUser;
import calclavia.lib.access.GroupRegistry; import calclavia.lib.access.GroupRegistry;
import calclavia.lib.access.ISpecialAccess; import calclavia.lib.access.ISpecialAccess;
import calclavia.lib.access.Nodes; 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 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 * 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) if (inventory == null)
{ {
inventory = new InvChest(this, this.invSlots); inventory = new TileInventory(this, this.invSlots);
} }
return inventory; return inventory;
} }

View file

@ -13,14 +13,14 @@ import resonantinduction.core.ResonantInduction;
import resonantinduction.core.network.ISimplePacketReceiver; import resonantinduction.core.network.ISimplePacketReceiver;
import universalelectricity.api.vector.Vector3; import universalelectricity.api.vector.Vector3;
import calclavia.lib.content.IExtraInfo.IExtraTileEntityInfo; import calclavia.lib.content.IExtraInfo.IExtraTileEntityInfo;
import calclavia.lib.inventory.IExternalInv;
import calclavia.lib.inventory.IInvBox;
import calclavia.lib.network.PacketHandler; import calclavia.lib.network.PacketHandler;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.network.PacketDispatcher; import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player; 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 public abstract class TileEntityMachine extends TileEntityInv implements ISidedInventory, IExternalInv, ISimplePacketReceiver, IExtraTileEntityInfo
{ {

View file

@ -3,7 +3,6 @@ package resonantinduction.core.tilenetwork.prefab;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import resonantinduction.core.tilenetwork.INetworkEnergyPart; import resonantinduction.core.tilenetwork.INetworkEnergyPart;
import resonantinduction.core.tilenetwork.INetworkPart; 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 * Used for tile networks that only need to share power or act like a group battery that doesn't