Added packet
This commit is contained in:
parent
410e2c1c27
commit
6d8edae19f
|
@ -21,8 +21,11 @@ import net.minecraft.world.World;
|
|||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.common.network.PacketDispatcher;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.TranslationHelper;
|
||||
import universalelectricity.prefab.network.PacketManager;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.machine.encoder.ContainerEncoder;
|
||||
import assemblyline.common.machine.encoder.IInventoryWatcher;
|
||||
|
@ -92,22 +95,24 @@ public class GuiEncoder extends GuiContainer implements IInventoryWatcher
|
|||
{
|
||||
case 0: // add
|
||||
{
|
||||
if (!commandField.getText().equals(""))
|
||||
if (!this.commandField.getText().equals(""))
|
||||
{
|
||||
if (tileEntity != null)
|
||||
if (this.tileEntity != null)
|
||||
{
|
||||
ItemStack disk = tileEntity.getStackInSlot(0);
|
||||
ItemStack disk = this.tileEntity.getStackInSlot(0);
|
||||
if (disk != null)
|
||||
{
|
||||
ArrayList<String> tempCmds = ItemDisk.getCommands(disk);
|
||||
tempCmds.add(commandField.getText());
|
||||
ItemDisk.setCommands(disk, tempCmds);
|
||||
tileEntity.setInventorySlotContents(0, disk);
|
||||
// TODO: Make the client send the server the new command to be added
|
||||
this.tileEntity.setInventorySlotContents(0, disk);
|
||||
// TODO: Change command ID to corresponding ones.
|
||||
int commandID = 0;
|
||||
PacketDispatcher.sendPacketToServer(PacketManager.getPacket(AssemblyLine.CHANNEL, this.tileEntity, (int) commandID));
|
||||
}
|
||||
}
|
||||
|
||||
commandField.setText("");
|
||||
this.commandField.setText("");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
package assemblyline.common.machine.encoder;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.ISidedInventory;
|
||||
import universalelectricity.prefab.network.IPacketReceiver;
|
||||
import universalelectricity.prefab.tile.TileEntityAdvanced;
|
||||
|
||||
public class TileEntityEncoder extends TileEntityAdvanced implements ISidedInventory
|
||||
public class TileEntityEncoder extends TileEntityAdvanced implements IPacketReceiver, ISidedInventory
|
||||
{
|
||||
|
||||
private ItemStack disk;
|
||||
private IInventoryWatcher watcher;
|
||||
|
||||
|
@ -127,9 +131,12 @@ public class TileEntityEncoder extends TileEntityAdvanced implements ISidedInven
|
|||
{
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
NBTTagCompound diskNBT = new NBTTagCompound();
|
||||
disk.writeToNBT(diskNBT);
|
||||
nbt.setCompoundTag("disk", diskNBT);
|
||||
if (this.disk != null)
|
||||
{
|
||||
NBTTagCompound diskNBT = new NBTTagCompound();
|
||||
this.disk.writeToNBT(diskNBT);
|
||||
nbt.setCompoundTag("disk", diskNBT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -138,9 +145,24 @@ public class TileEntityEncoder extends TileEntityAdvanced implements ISidedInven
|
|||
super.readFromNBT(nbt);
|
||||
|
||||
NBTTagCompound diskNBT = nbt.getCompoundTag("disk");
|
||||
|
||||
if (diskNBT != null)
|
||||
{
|
||||
disk = ItemStack.loadItemStackFromNBT(diskNBT);
|
||||
this.disk = ItemStack.loadItemStackFromNBT(diskNBT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO: Get this to work and add commands to the stack
|
||||
int newAddCommandID = dataStream.readInt();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue