Massive cleanup to manipulator
This commit is contained in:
parent
d7576fa983
commit
edb4234ad0
20 changed files with 318 additions and 436 deletions
|
@ -3,9 +3,9 @@ package assemblyline;
|
|||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import assemblyline.gui.GuiEjectorSettings;
|
||||
import assemblyline.interaction.ContainerEjector;
|
||||
import assemblyline.interaction.TileEntitySorter;
|
||||
import assemblyline.gui.GuiSorter;
|
||||
import assemblyline.machines.ContainerSorter;
|
||||
import assemblyline.machines.TileEntitySorter;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
public class ALCommonProxy implements IGuiHandler
|
||||
|
@ -32,7 +32,7 @@ public class ALCommonProxy implements IGuiHandler
|
|||
{
|
||||
switch(ID)
|
||||
{
|
||||
case 0: return new GuiEjectorSettings(player.inventory, ((TileEntitySorter)tileEntity));
|
||||
case 0: return new GuiSorter(player.inventory, ((TileEntitySorter)tileEntity));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class ALCommonProxy implements IGuiHandler
|
|||
{
|
||||
switch(ID)
|
||||
{
|
||||
case 0: return new ContainerEjector(player.inventory, ((TileEntitySorter)tileEntity));
|
||||
case 0: return new ContainerSorter(player.inventory, ((TileEntitySorter)tileEntity));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@ import universalelectricity.core.UEConfig;
|
|||
import universalelectricity.prefab.network.PacketManager;
|
||||
import assemblyline.belts.BlockConveyorBelt;
|
||||
import assemblyline.belts.TileEntityConveyorBelt;
|
||||
import assemblyline.interaction.BlockInteraction;
|
||||
import assemblyline.interaction.BlockInteraction.MachineType;
|
||||
import assemblyline.interaction.ItemBlockInteraction;
|
||||
import assemblyline.interaction.TileEntitySorter;
|
||||
import assemblyline.interaction.TileEntityManipulator;
|
||||
import assemblyline.machines.BlockInteraction;
|
||||
import assemblyline.machines.ItemBlockInteraction;
|
||||
import assemblyline.machines.TileEntityManipulator;
|
||||
import assemblyline.machines.TileEntitySorter;
|
||||
import assemblyline.machines.BlockInteraction.MachineType;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
|
|
|
@ -35,7 +35,7 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
|
|||
*/
|
||||
public double wattsReceived = 0;
|
||||
|
||||
private float speed = -0.05F;
|
||||
private float speed = -0.045F;
|
||||
public float wheelRotation = 0;
|
||||
public boolean running = false;
|
||||
public boolean flip = false;
|
||||
|
@ -43,12 +43,11 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
|
|||
{ null, null, null, null };
|
||||
|
||||
public int clearCount = 0;
|
||||
public int range = 0;
|
||||
public int powerTransferRange = 0;
|
||||
public List<Entity> entityIgnoreList = new ArrayList<Entity>();
|
||||
|
||||
/**
|
||||
* Powers nearby conveyor belts.
|
||||
*
|
||||
* Steal power from nearby belts.
|
||||
* @return
|
||||
*/
|
||||
public boolean searchNeighborBelts()
|
||||
|
@ -74,13 +73,14 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
|
|||
if (adjBelts[b] instanceof TileEntityConveyorBelt)
|
||||
{
|
||||
TileEntityConveyorBelt belt = (TileEntityConveyorBelt) adjBelts[b];
|
||||
if (belt.range > rr)
|
||||
if (belt.powerTransferRange > rr)
|
||||
{
|
||||
rr = belt.range;
|
||||
rr = belt.powerTransferRange;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.range = rr - 1;
|
||||
|
||||
this.powerTransferRange = rr - 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -98,12 +98,12 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
|
|||
|
||||
if (this.wattsReceived >= JOULES_REQUIRED)
|
||||
{
|
||||
this.wattsReceived = Math.max(this.wattsReceived - JOULES_REQUIRED, 0);
|
||||
this.range = 20;
|
||||
this.wattsReceived = 0;
|
||||
this.powerTransferRange = 20;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.range = 0;
|
||||
this.powerTransferRange = 0;
|
||||
}
|
||||
|
||||
if (!(worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord) instanceof IConductor))
|
||||
|
@ -111,7 +111,7 @@ public class TileEntityConveyorBelt extends TileEntityElectricityReceiver implem
|
|||
searchNeighborBelts();
|
||||
}
|
||||
|
||||
if (this.range > 0)
|
||||
if (this.powerTransferRange > 0)
|
||||
{
|
||||
this.running = true;
|
||||
}
|
||||
|
|
|
@ -1,342 +0,0 @@
|
|||
package assemblyline.interaction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.src.AxisAlignedBB;
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.INetworkManager;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.NBTTagList;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.TileEntityChest;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.prefab.TileEntityElectricityReceiver;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityManipulator extends TileEntityElectricityReceiver implements IPacketReceiver, IInventory
|
||||
{
|
||||
public float energyReq = .1f;
|
||||
public float energyMax = 10f;
|
||||
public float energyStor = 0f;
|
||||
private ItemStack[] containingItems = new ItemStack[1];
|
||||
public ForgeDirection dir = ForgeDirection.DOWN;
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public double wattRequest()
|
||||
{
|
||||
return energyMax - energyStor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if (count++ >= 10)
|
||||
{
|
||||
count = 0;
|
||||
if (!isDisabled())
|
||||
{
|
||||
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
ForgeDirection searchPosition = ForgeDirection.getOrientation(this.getBeltDirection());
|
||||
dir = searchPosition;
|
||||
try
|
||||
{
|
||||
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(xCoord + searchPosition.offsetX, yCoord + searchPosition.offsetY, zCoord + searchPosition.offsetZ, xCoord + searchPosition.offsetX + 1, yCoord + searchPosition.offsetY + 1, zCoord + searchPosition.offsetZ + 1);
|
||||
TileEntity bEnt = worldObj.getBlockTileEntity(xCoord + searchPosition.getOpposite().offsetX, yCoord + searchPosition.getOpposite().offsetY, zCoord + searchPosition.getOpposite().offsetZ);
|
||||
List<EntityItem> itemsBehind = worldObj.getEntitiesWithinAABB(EntityItem.class, bounds);
|
||||
ItemStack tItem = this.containingItems[0];
|
||||
if (itemsBehind.size() > 0 && this.energyStor > this.energyReq && bEnt instanceof IInventory)
|
||||
{
|
||||
energyStor -= energyReq;
|
||||
|
||||
for (EntityItem entity : itemsBehind)
|
||||
{
|
||||
ItemStack eStack = entity.item;
|
||||
int ite = eStack.stackSize;
|
||||
if (bEnt instanceof TileEntityChest)
|
||||
{
|
||||
TileEntityChest bEntChest2 = null;
|
||||
TileEntityChest bEntChest = (TileEntityChest) bEnt;
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
ForgeDirection si = ForgeDirection.getOrientation(i);
|
||||
if (worldObj.getBlockTileEntity(xCoord + dir.getOpposite().offsetX + si.offsetX, yCoord + dir.getOpposite().offsetY + si.offsetY, zCoord + dir.getOpposite().offsetZ + si.offsetZ) instanceof TileEntityChest)
|
||||
{
|
||||
bEntChest2 = (TileEntityChest) worldObj.getBlockTileEntity(xCoord + dir.getOpposite().offsetX + si.offsetX, yCoord + dir.getOpposite().offsetY + si.offsetY, zCoord + dir.getOpposite().offsetZ + si.offsetZ);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (eStack != null && eStack.stackSize > 0)
|
||||
{
|
||||
for (int i = 0; i < bEntChest.getSizeInventory(); i++)
|
||||
{
|
||||
|
||||
ItemStack stack = bEntChest.getStackInSlot(i);
|
||||
if (stack == null)
|
||||
{
|
||||
bEntChest.setInventorySlotContents(i, eStack);
|
||||
entity.setDead();
|
||||
eStack = null;
|
||||
break;
|
||||
}
|
||||
else if (stack.getItem().equals(eStack.getItem()) && stack.getItemDamage() == eStack.getItemDamage())
|
||||
{
|
||||
int rej = Math.max((stack.stackSize + eStack.stackSize) - stack.getItem().getItemStackLimit(), 0);
|
||||
stack.stackSize = Math.min(Math.max((stack.stackSize + eStack.stackSize - rej), 0), stack.getItem().getItemStackLimit());
|
||||
eStack.stackSize = rej;
|
||||
bEntChest.setInventorySlotContents(i, stack);
|
||||
if (eStack.stackSize <= 0)
|
||||
{
|
||||
entity.setDead();
|
||||
eStack = null;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (bEntChest2 != null && eStack != null && eStack.stackSize > 0)
|
||||
{
|
||||
for (int i = 0; i < bEntChest2.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack stack = bEntChest2.getStackInSlot(i);
|
||||
if (stack == null)
|
||||
{
|
||||
bEntChest2.setInventorySlotContents(i, eStack);
|
||||
entity.setDead();
|
||||
eStack = null;
|
||||
break;
|
||||
}
|
||||
else if (stack.getItem().equals(eStack.getItem()) && stack.getItemDamage() == eStack.getItemDamage())
|
||||
{
|
||||
int rej = Math.max((stack.stackSize + eStack.stackSize) - stack.getItem().getItemStackLimit(), 0);
|
||||
stack.stackSize = Math.min(Math.max((stack.stackSize + eStack.stackSize - rej), 0), stack.getItem().getItemStackLimit());
|
||||
eStack.stackSize = rej;
|
||||
bEntChest2.setInventorySlotContents(i, stack);
|
||||
if (eStack.stackSize <= 0)
|
||||
{
|
||||
entity.setDead();
|
||||
eStack = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (entity != null && eStack != null)
|
||||
{
|
||||
if (eStack != null && eStack.stackSize <= 0)
|
||||
{
|
||||
entity.setDead();
|
||||
eStack = null;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.setDead();
|
||||
EntityItem var23 = new EntityItem(worldObj, entity.posX, entity.posY + 0.1D, entity.posZ, eStack);
|
||||
worldObj.spawnEntityInWorld(var23);
|
||||
}
|
||||
}
|
||||
|
||||
}// end chest trade
|
||||
// TODO setup for
|
||||
// ISideInventory
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getBeltDirection()
|
||||
{
|
||||
int meta = worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord);
|
||||
if (meta >= 4 && meta < 8)
|
||||
{
|
||||
switch (meta)
|
||||
{
|
||||
case 4:
|
||||
return 2;
|
||||
case 5:
|
||||
return 5;
|
||||
case 6:
|
||||
return 3;
|
||||
case 7:
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveFromSide(ForgeDirection side)
|
||||
{
|
||||
if (side == dir || side == dir.getOpposite()) { return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
NBTTagList var2 = par1NBTTagCompound.getTagList("Items");
|
||||
this.containingItems = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
|
||||
{
|
||||
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
|
||||
byte var5 = var4.getByte("Slot");
|
||||
|
||||
if (var5 >= 0 && var5 < this.containingItems.length)
|
||||
{
|
||||
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
NBTTagList var2 = new NBTTagList();
|
||||
|
||||
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
|
||||
{
|
||||
if (this.containingItems[var3] != null)
|
||||
{
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var4.setByte("Slot", (byte) var3);
|
||||
this.containingItems[var3].writeToNBT(var4);
|
||||
var2.appendTag(var4);
|
||||
}
|
||||
}
|
||||
|
||||
par1NBTTagCompound.setTag("Items", var2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.containingItems.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int par1)
|
||||
{
|
||||
return this.containingItems[par1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int par1, int par2)
|
||||
{
|
||||
if (this.containingItems[par1] != null)
|
||||
{
|
||||
ItemStack var3;
|
||||
|
||||
if (this.containingItems[par1].stackSize <= par2)
|
||||
{
|
||||
var3 = this.containingItems[par1];
|
||||
this.containingItems[par1] = null;
|
||||
return var3;
|
||||
}
|
||||
else
|
||||
{
|
||||
var3 = this.containingItems[par1].splitStack(par2);
|
||||
|
||||
if (this.containingItems[par1].stackSize == 0)
|
||||
{
|
||||
this.containingItems[par1] = null;
|
||||
}
|
||||
|
||||
return var3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int par1)
|
||||
{
|
||||
if (this.containingItems[par1] != null)
|
||||
{
|
||||
ItemStack var2 = this.containingItems[par1];
|
||||
this.containingItems[par1] = null;
|
||||
return var2;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
|
||||
{
|
||||
this.containingItems[par1] = par2ItemStack;
|
||||
|
||||
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
|
||||
{
|
||||
par2ItemStack.stackSize = this.getInventoryStackLimit();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return "Ejector";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
// TODO change
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChest()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side)
|
||||
{
|
||||
this.energyStor += (amps * voltage);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.interaction;
|
||||
package assemblyline.machines;
|
||||
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.EntityPlayer;
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.interaction;
|
||||
package assemblyline.machines;
|
||||
|
||||
import net.minecraft.src.Container;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
|
@ -7,11 +7,11 @@ import net.minecraft.src.Item;
|
|||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.Slot;
|
||||
|
||||
public class ContainerEjector extends Container
|
||||
public class ContainerSorter extends Container
|
||||
{
|
||||
private TileEntitySorter tileEntity;
|
||||
|
||||
public ContainerEjector(InventoryPlayer par1InventoryPlayer, TileEntitySorter tileEntity)
|
||||
public ContainerSorter(InventoryPlayer par1InventoryPlayer, TileEntitySorter tileEntity)
|
||||
{
|
||||
this.tileEntity = tileEntity;
|
||||
for(int i = 0; i < 4; i++)
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.interaction;
|
||||
package assemblyline.machines;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import net.minecraft.src.ItemStack;
|
|||
import net.minecraft.src.MathHelper;
|
||||
import net.minecraft.src.World;
|
||||
import assemblyline.AssemblyLine;
|
||||
import assemblyline.interaction.BlockInteraction.MachineType;
|
||||
import assemblyline.machines.BlockInteraction.MachineType;
|
||||
|
||||
public class ItemBlockInteraction extends ItemBlock
|
||||
{
|
184
src/common/assemblyline/machines/TileEntityManipulator.java
Normal file
184
src/common/assemblyline/machines/TileEntityManipulator.java
Normal file
|
@ -0,0 +1,184 @@
|
|||
package assemblyline.machines;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.src.AxisAlignedBB;
|
||||
import net.minecraft.src.EntityItem;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.IInventory;
|
||||
import net.minecraft.src.INetworkManager;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.TileEntityChest;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.Vector3;
|
||||
import universalelectricity.prefab.TileEntityElectricityReceiver;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
|
||||
import assemblyline.machines.BlockInteraction.MachineType;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
public class TileEntityManipulator extends TileEntityElectricityReceiver
|
||||
{
|
||||
/**
|
||||
* Joules required to run this thing.
|
||||
*/
|
||||
public static final int JOULES_REQUIRED = 15;
|
||||
|
||||
/**
|
||||
* The amount of watts received.
|
||||
*/
|
||||
public double wattsReceived = 0;
|
||||
|
||||
@Override
|
||||
public double wattRequest()
|
||||
{
|
||||
return JOULES_REQUIRED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
if (!this.isDisabled())
|
||||
{
|
||||
if (!this.isOutput())
|
||||
{
|
||||
/**
|
||||
* Find items going into the
|
||||
* manipulator and input them
|
||||
* into an inventory behind
|
||||
* this manipulator.
|
||||
*/
|
||||
Vector3 inputPosition = Vector3.get(this);
|
||||
inputPosition.modifyPositionFromSide(this.getBeltDirection());
|
||||
|
||||
Vector3 outputPosition = Vector3.get(this);
|
||||
outputPosition.modifyPositionFromSide(this.getBeltDirection().getOpposite());
|
||||
|
||||
AxisAlignedBB bounds = AxisAlignedBB.getBoundingBox(inputPosition.x, inputPosition.y, inputPosition.z, inputPosition.x + 1, inputPosition.y + 1, inputPosition.z + 1);
|
||||
List<EntityItem> itemsInBound = this.worldObj.getEntitiesWithinAABB(EntityItem.class, bounds);
|
||||
|
||||
for (EntityItem entity : itemsInBound)
|
||||
{
|
||||
ItemStack remainingStack = this.tryPlaceInPosition(entity.item.copy(), outputPosition);
|
||||
|
||||
if (remainingStack != null)
|
||||
{
|
||||
if (remainingStack.stackSize > 0)
|
||||
{
|
||||
EntityItem var23 = new EntityItem(worldObj, entity.posX, entity.posY + 0.1D, entity.posZ, remainingStack);
|
||||
worldObj.spawnEntityInWorld(var23);
|
||||
}
|
||||
}
|
||||
|
||||
entity.setDead();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to place an itemStack in a specific
|
||||
* position if it is an inventory.
|
||||
*
|
||||
* @return The ItemStack remained after place
|
||||
* attempt
|
||||
*/
|
||||
private ItemStack tryPlaceInPosition(ItemStack itemStack, Vector3 position)
|
||||
{
|
||||
TileEntity tileEntity = position.getTileEntity(this.worldObj);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
/**
|
||||
* Try to put items into a chest.
|
||||
*/
|
||||
if (tileEntity instanceof TileEntityChest)
|
||||
{
|
||||
TileEntityChest[] chests =
|
||||
{ (TileEntityChest) tileEntity, null };
|
||||
|
||||
/**
|
||||
* Try to find a double chest.
|
||||
*/
|
||||
for (int i = 2; i < 6; i++)
|
||||
{
|
||||
ForgeDirection searchDirection = ForgeDirection.getOrientation(i);
|
||||
Vector3 searchPosition = position.clone();
|
||||
searchPosition.modifyPositionFromSide(searchDirection);
|
||||
|
||||
if (searchPosition.getTileEntity(this.worldObj) instanceof TileEntityChest)
|
||||
{
|
||||
chests[1] = (TileEntityChest) searchPosition.getTileEntity(this.worldObj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (TileEntityChest chest : chests)
|
||||
{
|
||||
if (itemStack != null && itemStack.stackSize > 0)
|
||||
{
|
||||
for (int i = 0; i < chest.getSizeInventory(); i++)
|
||||
{
|
||||
ItemStack stackInChest = chest.getStackInSlot(i);
|
||||
|
||||
if (stackInChest == null)
|
||||
{
|
||||
chest.setInventorySlotContents(i, itemStack);
|
||||
return null;
|
||||
}
|
||||
else if (stackInChest.getItem().equals(itemStack.getItem()) && stackInChest.getItemDamage() == itemStack.getItemDamage())
|
||||
{
|
||||
int rejectedAmount = Math.max((stackInChest.stackSize + itemStack.stackSize) - stackInChest.getItem().getItemStackLimit(), 0);
|
||||
stackInChest.stackSize = Math.min(Math.max((stackInChest.stackSize + itemStack.stackSize - rejectedAmount), 0), stackInChest.getItem().getItemStackLimit());
|
||||
itemStack.stackSize = rejectedAmount;
|
||||
chest.setInventorySlotContents(i, stackInChest);
|
||||
|
||||
if (itemStack.stackSize <= 0) { return null; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (itemStack.stackSize <= 0) { return null; }
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the manipulator is powered, it will
|
||||
* output items instead of input.
|
||||
*/
|
||||
public boolean isOutput()
|
||||
{
|
||||
return this.worldObj.isBlockIndirectlyGettingPowered(this.xCoord, this.yCoord, this.zCoord) || this.worldObj.isBlockGettingPowered(this.xCoord, this.yCoord, this.zCoord);
|
||||
}
|
||||
|
||||
public ForgeDirection getBeltDirection()
|
||||
{
|
||||
return ForgeDirection.getOrientation(MachineType.getDirection(this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord)) + 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveFromSide(ForgeDirection side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side)
|
||||
{
|
||||
this.wattsReceived += (amps * voltage);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.interaction;
|
||||
package assemblyline.machines;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.crafting;
|
||||
package assemblyline.machines.crafter;
|
||||
|
||||
import net.minecraft.src.BlockContainer;
|
||||
import net.minecraft.src.CreativeTabs;
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.crafting;
|
||||
package assemblyline.machines.crafter;
|
||||
|
||||
import net.minecraft.src.Entity;
|
||||
import net.minecraft.src.NBTTagCompound;
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.crafting;
|
||||
package assemblyline.machines.crafter;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.INetworkManager;
|
|
@ -1,4 +1,4 @@
|
|||
package assemblyline.crafting;
|
||||
package assemblyline.machines.crafter;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
|
|
@ -4,8 +4,8 @@ import net.minecraftforge.client.MinecraftForgeClient;
|
|||
import assemblyline.AssemblyLine;
|
||||
import assemblyline.ALCommonProxy;
|
||||
import assemblyline.belts.TileEntityConveyorBelt;
|
||||
import assemblyline.interaction.TileEntitySorter;
|
||||
import assemblyline.interaction.TileEntityManipulator;
|
||||
import assemblyline.machines.TileEntityManipulator;
|
||||
import assemblyline.machines.TileEntitySorter;
|
||||
import assemblyline.render.RenderSorter;
|
||||
import assemblyline.render.RenderHelper;
|
||||
import assemblyline.render.RenderConveyorBelt;
|
||||
|
|
|
@ -7,19 +7,19 @@ import net.minecraft.src.StatCollector;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import assemblyline.AssemblyLine;
|
||||
import assemblyline.interaction.ContainerEjector;
|
||||
import assemblyline.interaction.TileEntitySorter;
|
||||
import assemblyline.machines.ContainerSorter;
|
||||
import assemblyline.machines.TileEntitySorter;
|
||||
|
||||
public class GuiEjectorSettings extends GuiContainer
|
||||
public class GuiSorter extends GuiContainer
|
||||
{
|
||||
private TileEntitySorter tileEntity;
|
||||
|
||||
private int containerWidth;
|
||||
private int containerHeight;
|
||||
|
||||
public GuiEjectorSettings(InventoryPlayer par1InventoryPlayer, TileEntitySorter tileEntity)
|
||||
public GuiSorter(InventoryPlayer par1InventoryPlayer, TileEntitySorter tileEntity)
|
||||
{
|
||||
super(new ContainerEjector(par1InventoryPlayer, tileEntity));
|
||||
super(new ContainerSorter(par1InventoryPlayer, tileEntity));
|
||||
this.tileEntity = tileEntity;
|
||||
}
|
||||
|
|
@ -164,7 +164,7 @@ public class ModelConveyorBelt extends ModelBase
|
|||
setRotation(c1, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
public void render(float f5, int pos, boolean front, boolean back, boolean above)
|
||||
public void render(float f5, float radians, boolean front, boolean back, boolean above)
|
||||
{
|
||||
boolean mid = front && back ? true : false;
|
||||
boolean leftCap = !front && back ? true : false;
|
||||
|
@ -214,9 +214,9 @@ public class ModelConveyorBelt extends ModelBase
|
|||
}
|
||||
|
||||
// rollers
|
||||
MRoller.rotateAngleX = 0.7853982F * pos;
|
||||
BRoller.rotateAngleX = 0.7853982F * pos;
|
||||
FRoller.rotateAngleX = 0.7853982F * pos;
|
||||
MRoller.rotateAngleX = radians;
|
||||
BRoller.rotateAngleX = radians;
|
||||
FRoller.rotateAngleX = radians;
|
||||
MRoller.render(f5);
|
||||
BRoller.render(f5);
|
||||
FRoller.render(f5);
|
||||
|
|
|
@ -15,7 +15,8 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer
|
|||
|
||||
public void renderAModelAt(TileEntityConveyorBelt tileEntity, double x, double y, double z, float f)
|
||||
{
|
||||
String flip = "";//if(tileEntity.flip){flip = "F";}
|
||||
String flip = "";// if(tileEntity.flip){flip
|
||||
// = "F";}
|
||||
boolean mid = tileEntity.middleBelt();
|
||||
int face = tileEntity.getBeltDirection();
|
||||
|
||||
|
@ -23,15 +24,25 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer
|
|||
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
|
||||
int pos = 0;
|
||||
bindTextureByName(AssemblyLine.TEXTURE_PATH+"BeltTexture"+flip+".png");
|
||||
if(face==2){ GL11.glRotatef(180f, 0f, 1f, 0f);}
|
||||
if(face==3){ GL11.glRotatef(0f, 0f, 1f, 0f);}
|
||||
if(face==4){ GL11.glRotatef(90f, 0f, 1f, 0f);}
|
||||
if(face==5){ GL11.glRotatef(270f, 0f, 1f, 0f);}
|
||||
int ent = tileEntity.worldObj.getBlockId(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
|
||||
model.render(0.0625F,pos,tileEntity.BackCap(),tileEntity.FrontCap(), false);
|
||||
|
||||
bindTextureByName(AssemblyLine.TEXTURE_PATH + "BeltTexture" + flip + ".png");
|
||||
if (face == 2)
|
||||
{
|
||||
GL11.glRotatef(180f, 0f, 1f, 0f);
|
||||
}
|
||||
if (face == 3)
|
||||
{
|
||||
GL11.glRotatef(0f, 0f, 1f, 0f);
|
||||
}
|
||||
if (face == 4)
|
||||
{
|
||||
GL11.glRotatef(90f, 0f, 1f, 0f);
|
||||
}
|
||||
if (face == 5)
|
||||
{
|
||||
GL11.glRotatef(270f, 0f, 1f, 0f);
|
||||
}
|
||||
int ent = tileEntity.worldObj.getBlockId(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
|
||||
model.render(0.0625F, (float) Math.toRadians(tileEntity.wheelRotation), tileEntity.BackCap(), tileEntity.FrontCap(), false);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
|
@ -40,7 +51,7 @@ public class RenderConveyorBelt extends TileEntitySpecialRenderer
|
|||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
|
||||
{
|
||||
this.renderAModelAt((TileEntityConveyorBelt)tileEntity, var2, var4, var6, var8);
|
||||
this.renderAModelAt((TileEntityConveyorBelt) tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
}
|
|
@ -7,7 +7,7 @@ import net.minecraft.src.RenderBlocks;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import assemblyline.AssemblyLine;
|
||||
import assemblyline.interaction.BlockInteraction.MachineType;
|
||||
import assemblyline.machines.BlockInteraction.MachineType;
|
||||
import assemblyline.model.ModelConveyorBelt;
|
||||
import assemblyline.model.ModelSorter;
|
||||
import assemblyline.model.ModelManipulator;
|
||||
|
@ -31,15 +31,15 @@ public class RenderHelper implements ISimpleBlockRenderingHandler
|
|||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) 0.0F, (float) 1.5F, (float) 0.0F);
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH+"BeltTexture.png"));
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "BeltTexture.png"));
|
||||
modelConveyorBelt.render(0.0625F, 0, false, false, false);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if (block.blockID == AssemblyLine.blockInteraction.blockID)
|
||||
{
|
||||
if(metadata == MachineType.SORTER.metadata)
|
||||
if (metadata == MachineType.SORTER.metadata)
|
||||
{
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH+"ejector.png"));
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "ejector.png"));
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) 0.6F, (float) 1.5F, (float) 0.6F);
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
|
@ -48,9 +48,9 @@ public class RenderHelper implements ISimpleBlockRenderingHandler
|
|||
modelEjector.renderPiston(0.0625F, 1);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else if(metadata == MachineType.MANIPULATOR.metadata)
|
||||
else if (metadata == MachineType.MANIPULATOR.metadata)
|
||||
{
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH+"injector.png"));
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "injector.png"));
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) 0.6F, (float) 1.5F, (float) 0.6F);
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
import assemblyline.AssemblyLine;
|
||||
import assemblyline.belts.TileEntityConveyorBelt;
|
||||
import assemblyline.interaction.TileEntityManipulator;
|
||||
import assemblyline.machines.TileEntityManipulator;
|
||||
import assemblyline.model.ModelManipulator;
|
||||
|
||||
public class RenderManipulator extends TileEntitySpecialRenderer
|
||||
|
@ -16,23 +16,37 @@ public class RenderManipulator extends TileEntitySpecialRenderer
|
|||
|
||||
public void renderAModelAt(TileEntityManipulator tileEntity, double x, double y, double z, float f)
|
||||
{
|
||||
String flip = "";//if(tileEntity.flip){flip = "F";}
|
||||
int face = tileEntity.getBeltDirection();
|
||||
String flip = "";// if(tileEntity.flip){flip
|
||||
// = "F";}
|
||||
int face = tileEntity.getBeltDirection().ordinal();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
|
||||
GL11.glRotatef(180f, 0f, 0f, 1f);
|
||||
|
||||
this.bindTextureByName(AssemblyLine.TEXTURE_PATH+"injector.png");
|
||||
this.bindTextureByName(AssemblyLine.TEXTURE_PATH + "injector.png");
|
||||
|
||||
if (face == 2)
|
||||
{
|
||||
GL11.glRotatef(0f, 0f, 1f, 0f);
|
||||
}
|
||||
if (face == 3)
|
||||
{
|
||||
GL11.glRotatef(180f, 0f, 1f, 0f);
|
||||
}
|
||||
if (face == 4)
|
||||
{
|
||||
GL11.glRotatef(270f, 0f, 1f, 0f);
|
||||
}
|
||||
if (face == 5)
|
||||
{
|
||||
GL11.glRotatef(90f, 0f, 1f, 0f);
|
||||
}
|
||||
|
||||
if(face==2){ GL11.glRotatef(0f, 0f, 1f, 0f);}
|
||||
if(face==3){ GL11.glRotatef(180f, 0f, 1f, 0f);}
|
||||
if(face==4){ GL11.glRotatef(270f, 0f, 1f, 0f);}
|
||||
if(face==5){ GL11.glRotatef(90f, 0f, 1f, 0f);}
|
||||
int ent = tileEntity.worldObj.getBlockId(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
|
||||
model.render(0.0625F, true, 0);
|
||||
//TODO change the true part to check if there is a TE on the input side
|
||||
model.render(0.0625F, true, 0);
|
||||
|
||||
// TODO change the true part to check if
|
||||
// there is a TE on the input side
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
@ -40,7 +54,7 @@ public class RenderManipulator extends TileEntitySpecialRenderer
|
|||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
|
||||
{
|
||||
this.renderAModelAt((TileEntityManipulator)tileEntity, var2, var4, var6, var8);
|
||||
this.renderAModelAt((TileEntityManipulator) tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
}
|
|
@ -6,7 +6,7 @@ import net.minecraft.src.TileEntitySpecialRenderer;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import assemblyline.AssemblyLine;
|
||||
import assemblyline.interaction.TileEntitySorter;
|
||||
import assemblyline.machines.TileEntitySorter;
|
||||
import assemblyline.model.ModelSorter;
|
||||
|
||||
public class RenderSorter extends TileEntitySpecialRenderer
|
||||
|
@ -18,15 +18,30 @@ public class RenderSorter extends TileEntitySpecialRenderer
|
|||
boolean fire = tileEntity.firePiston;
|
||||
int face = tileEntity.getDirection(tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
||||
int pos = 0;
|
||||
if(fire){pos = 8;}
|
||||
bindTextureByName(AssemblyLine.TEXTURE_PATH+"ejector.png");
|
||||
if (fire)
|
||||
{
|
||||
pos = 8;
|
||||
}
|
||||
bindTextureByName(AssemblyLine.TEXTURE_PATH + "ejector.png");
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
if(face==2){ GL11.glRotatef(180f, 0f, 1f, 0f);}
|
||||
if(face==3){ GL11.glRotatef(0f, 0f, 1f, 0f);}
|
||||
if(face==4){ GL11.glRotatef(90f, 0f, 1f, 0f);}
|
||||
if(face==5){ GL11.glRotatef(270f, 0f, 1f, 0f);}
|
||||
if (face == 2)
|
||||
{
|
||||
GL11.glRotatef(180f, 0f, 1f, 0f);
|
||||
}
|
||||
if (face == 3)
|
||||
{
|
||||
GL11.glRotatef(0f, 0f, 1f, 0f);
|
||||
}
|
||||
if (face == 4)
|
||||
{
|
||||
GL11.glRotatef(90f, 0f, 1f, 0f);
|
||||
}
|
||||
if (face == 5)
|
||||
{
|
||||
GL11.glRotatef(270f, 0f, 1f, 0f);
|
||||
}
|
||||
model.renderMain(0.0625F);
|
||||
model.renderPiston(0.0625F, pos);
|
||||
GL11.glPopMatrix();
|
||||
|
@ -36,7 +51,7 @@ public class RenderSorter extends TileEntitySpecialRenderer
|
|||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
|
||||
{
|
||||
this.renderAModelAt((TileEntitySorter)tileEntity, var2, var4, var6, var8);
|
||||
this.renderAModelAt((TileEntitySorter) tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue