again nothing much
Just created some files, and fixed a bug with the rejector. Also renamed the sorter to rejector, since i'm going to create an actual sorter after i finish the belts. If i find tha time i'll finish the elevator belt tonight
This commit is contained in:
parent
859616d353
commit
2dcac2670b
10 changed files with 279 additions and 24 deletions
|
@ -5,7 +5,7 @@ import net.minecraft.src.TileEntity;
|
|||
import net.minecraft.src.World;
|
||||
import assemblyline.gui.GuiSorter;
|
||||
import assemblyline.machines.ContainerSorter;
|
||||
import assemblyline.machines.TileEntitySorter;
|
||||
import assemblyline.machines.TileEntityRejector;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
public class ALCommonProxy implements IGuiHandler
|
||||
|
@ -31,7 +31,7 @@ public class ALCommonProxy implements IGuiHandler
|
|||
switch (ID)
|
||||
{
|
||||
case 0:
|
||||
return new GuiSorter(player.inventory, ((TileEntitySorter) tileEntity));
|
||||
return new GuiSorter(player.inventory, ((TileEntityRejector) tileEntity));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ public class ALCommonProxy implements IGuiHandler
|
|||
switch (ID)
|
||||
{
|
||||
case 0:
|
||||
return new ContainerSorter(player.inventory, ((TileEntitySorter) tileEntity));
|
||||
return new ContainerSorter(player.inventory, ((TileEntityRejector) tileEntity));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ import assemblyline.machines.BlockMulti;
|
|||
import assemblyline.machines.BlockMulti.MachineType;
|
||||
import assemblyline.machines.ItemBlockMulti;
|
||||
import assemblyline.machines.TileEntityManipulator;
|
||||
import assemblyline.machines.TileEntitySorter;
|
||||
import assemblyline.machines.TileEntityRejector;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
|
@ -71,7 +71,7 @@ public class AssemblyLine
|
|||
proxy.init();
|
||||
|
||||
GameRegistry.registerTileEntity(TileEntityConveyorBelt.class, "ConveyorBelt");
|
||||
GameRegistry.registerTileEntity(TileEntitySorter.class, "Sorter");
|
||||
GameRegistry.registerTileEntity(TileEntityRejector.class, "Sorter");
|
||||
GameRegistry.registerTileEntity(TileEntityManipulator.class, "Manipulator");
|
||||
|
||||
// Add Names
|
||||
|
|
|
@ -23,7 +23,7 @@ public class TileEntityElevatorBelt extends TileEntityConveyorBelt
|
|||
* and to prevent items from falling
|
||||
* @return
|
||||
*/
|
||||
public boolean isBlockBellowBelt()
|
||||
public boolean isBellowABelt()
|
||||
{
|
||||
TileEntity ent = worldObj.getBlockTileEntity(xCoord, xCoord-1, zCoord);
|
||||
if(ent instanceof TileEntityElevatorBelt)
|
||||
|
|
|
@ -29,7 +29,7 @@ public class BlockMulti extends BlockMachine
|
|||
{
|
||||
public static enum MachineType
|
||||
{
|
||||
SORTER("Sorter", 0, 0, TileEntitySorter.class), MANIPULATOR("Manipulator", 4, -1, TileEntityManipulator.class), INVALID_1("Invalid", 8, -1, null), INVALID_2("Invalid", 12, -1, null);
|
||||
SORTER("Sorter", 0, 0, TileEntityRejector.class), MANIPULATOR("Manipulator", 4, -1, TileEntityManipulator.class), INVALID_1("Invalid", 8, -1, null), INVALID_2("Invalid", 12, -1, null);
|
||||
|
||||
public String name;
|
||||
public int metadata;
|
||||
|
|
|
@ -9,9 +9,9 @@ import net.minecraft.src.Slot;
|
|||
|
||||
public class ContainerSorter extends Container
|
||||
{
|
||||
private TileEntitySorter tileEntity;
|
||||
private TileEntityRejector tileEntity;
|
||||
|
||||
public ContainerSorter(InventoryPlayer par1InventoryPlayer, TileEntitySorter tileEntity)
|
||||
public ContainerSorter(InventoryPlayer par1InventoryPlayer, TileEntityRejector tileEntity)
|
||||
{
|
||||
this.tileEntity = tileEntity;
|
||||
for (int i = 0; i < 4; i++)
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.google.common.io.ByteArrayDataInput;
|
|||
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
public class TileEntitySorter extends TileEntityElectricityReceiver implements IPacketReceiver, IInventory
|
||||
public class TileEntityRejector extends TileEntityElectricityReceiver implements IPacketReceiver, IInventory
|
||||
{
|
||||
/**
|
||||
* The items this container contains.
|
||||
|
@ -77,7 +77,8 @@ public class TileEntitySorter extends TileEntityElectricityReceiver implements I
|
|||
*/
|
||||
if (this.ticks % 5 == 0 && !this.isDisabled())
|
||||
{
|
||||
|
||||
//TODO remove after testing
|
||||
this.wattsReceived += 100;
|
||||
int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
this.firePiston = false;
|
||||
|
||||
|
@ -156,10 +157,9 @@ public class TileEntitySorter extends TileEntityElectricityReceiver implements I
|
|||
this.beltSide.ignoreEntity(entity);
|
||||
|
||||
}
|
||||
System.out.print(" \n fire ");
|
||||
entity.motionX = (double) side.offsetX * 0.1;
|
||||
entity.motionX = (double) side.offsetX * 0.15;
|
||||
entity.motionY += 0.10000000298023224D;
|
||||
entity.motionZ = (double) side.offsetZ * 0.1;
|
||||
entity.motionZ = (double) side.offsetZ * 0.15;
|
||||
this.wattsReceived -= this.JOULES_REQUIRED;
|
||||
}
|
||||
|
||||
|
@ -243,10 +243,13 @@ public class TileEntitySorter extends TileEntityElectricityReceiver implements I
|
|||
{
|
||||
this.guiButtons[i] = true;
|
||||
}
|
||||
Packet packet = PacketManager.getPacket("asmLine", this, new Object[]{PacketTypes.SETTINGON.ordinal(), i});
|
||||
if (worldObj.isRemote)
|
||||
{
|
||||
Packet packet = PacketManager.getPacket("asmLine", this, PacketTypes.SETTINGON.ordinal(), i);
|
||||
{
|
||||
PacketDispatcher.sendPacketToServer(packet);
|
||||
}else
|
||||
{
|
||||
PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 10);
|
||||
}
|
||||
}
|
||||
|
252
src/common/assemblyline/machines/TileEntityRoboticSorter.java
Normal file
252
src/common/assemblyline/machines/TileEntityRoboticSorter.java
Normal file
|
@ -0,0 +1,252 @@
|
|||
package assemblyline.machines;
|
||||
|
||||
import assemblyline.belts.TileEntityConveyorBelt;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
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.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.prefab.TileEntityElectricityReceiver;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
|
||||
public class TileEntityRoboticSorter extends TileEntityElectricityReceiver implements IPacketReceiver, IInventory {
|
||||
/**
|
||||
* The items this container contains.
|
||||
*/
|
||||
protected ItemStack[] containingItems = new ItemStack[this.getSizeInventory()];
|
||||
|
||||
/**
|
||||
* Used to id the packet types
|
||||
*/
|
||||
private enum PacketTypes
|
||||
{
|
||||
ANIMATION, GUI, SETTINGON
|
||||
}
|
||||
|
||||
/**
|
||||
* Joules required per tick.
|
||||
*/
|
||||
public static final int JOULES_REQUIRED = 10;
|
||||
|
||||
/**
|
||||
* Stored energy
|
||||
*/
|
||||
public double wattsReceived = 0;
|
||||
/**
|
||||
* on/off value for the GUI buttons
|
||||
*/
|
||||
public boolean[] guiButtons = new boolean[]
|
||||
{ true, true, true, true, true };
|
||||
/**
|
||||
* the belt found in the search area
|
||||
*/
|
||||
public TileEntityConveyorBelt[] beltSide = new TileEntityConveyorBelt[6];
|
||||
|
||||
private int playerUsing = 0;
|
||||
@Override
|
||||
public String getInvName()
|
||||
{
|
||||
return "Sorter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* UE methods
|
||||
*/
|
||||
@Override
|
||||
public double getVoltage()
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double wattRequest()
|
||||
{
|
||||
return JOULES_REQUIRED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(TileEntity sender, double amps, double voltage, ForgeDirection side)
|
||||
{
|
||||
this.wattsReceived += (amps * voltage);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Inventory functions.
|
||||
*/
|
||||
@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 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()
|
||||
{
|
||||
this.playerUsing++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeChest()
|
||||
{
|
||||
this.playerUsing--;
|
||||
}
|
||||
|
||||
/**
|
||||
* NBT Data
|
||||
*/
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
for (int i = 0; i < this.guiButtons.length; i++)
|
||||
{
|
||||
this.guiButtons[i] = nbt.getBoolean("guiButton" + i);
|
||||
}
|
||||
|
||||
NBTTagList var2 = nbt.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType,
|
||||
Packet250CustomPayload packet, EntityPlayer player,
|
||||
ByteArrayDataInput dataStream) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
for (int i = 0; i < this.guiButtons.length; i++)
|
||||
{
|
||||
nbt.setBoolean("guiButton" + i, this.guiButtons[i]);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
nbt.setTag("Items", var2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveFromSide(ForgeDirection side) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@ package assemblyline;
|
|||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import assemblyline.belts.TileEntityConveyorBelt;
|
||||
import assemblyline.machines.TileEntityManipulator;
|
||||
import assemblyline.machines.TileEntitySorter;
|
||||
import assemblyline.machines.TileEntityRejector;
|
||||
import assemblyline.render.RenderConveyorBelt;
|
||||
import assemblyline.render.RenderHelper;
|
||||
import assemblyline.render.RenderManipulator;
|
||||
|
@ -26,7 +26,7 @@ public class ALClientProxy extends ALCommonProxy
|
|||
// ClientRegistry.registerTileEntity(TileEntityConveyorBelt.class,
|
||||
// "belt", new RenderConveyorBelt());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConveyorBelt.class, new RenderConveyorBelt());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySorter.class, new RenderSorter());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRejector.class, new RenderSorter());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityManipulator.class, new RenderManipulator());
|
||||
}
|
||||
|
||||
|
|
|
@ -10,16 +10,16 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
import assemblyline.AssemblyLine;
|
||||
import assemblyline.machines.ContainerSorter;
|
||||
import assemblyline.machines.TileEntitySorter;
|
||||
import assemblyline.machines.TileEntityRejector;
|
||||
|
||||
public class GuiSorter extends GuiContainer
|
||||
{
|
||||
private TileEntitySorter tileEntity;
|
||||
private TileEntityRejector tileEntity;
|
||||
|
||||
private int containerWidth;
|
||||
private int containerHeight;
|
||||
|
||||
public GuiSorter(InventoryPlayer par1InventoryPlayer, TileEntitySorter tileEntity)
|
||||
public GuiSorter(InventoryPlayer par1InventoryPlayer, TileEntityRejector tileEntity)
|
||||
{
|
||||
super(new ContainerSorter(par1InventoryPlayer, tileEntity));
|
||||
this.tileEntity = tileEntity;
|
||||
|
|
|
@ -6,14 +6,14 @@ import net.minecraft.src.TileEntitySpecialRenderer;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import assemblyline.AssemblyLine;
|
||||
import assemblyline.machines.TileEntitySorter;
|
||||
import assemblyline.machines.TileEntityRejector;
|
||||
import assemblyline.model.ModelSorter;
|
||||
|
||||
public class RenderSorter extends TileEntitySpecialRenderer
|
||||
{
|
||||
private ModelSorter model = new ModelSorter();
|
||||
|
||||
public void renderAModelAt(TileEntitySorter tileEntity, double x, double y, double z, float f)
|
||||
public void renderAModelAt(TileEntityRejector tileEntity, double x, double y, double z, float f)
|
||||
{
|
||||
boolean fire = tileEntity.firePiston;
|
||||
int face = tileEntity.getDirection(tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
||||
|
@ -51,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((TileEntityRejector) tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue