Attempt to fix packet issue

This commit is contained in:
Henry Mao 2012-12-29 13:04:51 +08:00
parent 585a2b9599
commit 5c42b9ae6a
4 changed files with 40 additions and 54 deletions

View file

@ -121,7 +121,7 @@ public class AssemblyLine
GameRegistry.addRecipe(new ShapedOreRecipe(blockDetector, new Object[] { "SES", "SCS", "SPS", 'S', "ingotSteel", 'C', "basicCircuit", 'E', Item.eyeOfEnder }));
// Crate
GameRegistry.addRecipe(new ShapedOreRecipe(blockCrate, new Object[] { "SPS", "P P", "SPS", 'P', "plateSteel", 'S', Item.stick }));
GameRegistry.addRecipe(new ShapedOreRecipe(blockCrate, new Object[] { "TST", "S S", "TST", 'S', "ingotSteel", 'T', Item.stick }));
// Conveyor Belt
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConveyorBelt, 4), new Object[] { "III", "WMW", 'I', "ingotSteel", 'W', Block.wood, 'M', "motor" }));

View file

@ -1,5 +1,7 @@
package assemblyline.common.machine;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.electricity.ElectricityConnections;
@ -128,4 +130,18 @@ public abstract class TileEntityAssemblyNetwork extends TileEntityElectricityRec
{
return 20;
}
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setDouble("wattsReceived", this.wattsReceived);
}
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
this.wattsReceived = nbt.getDouble("wattsReceived");
}
}

View file

@ -1,5 +1,8 @@
package assemblyline.common.machine;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@ -9,6 +12,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
@ -181,33 +185,18 @@ public class TileEntityManipulator extends TileEntityFilterable implements IReds
}
}
@Override
public ArrayList getPacketData()
{
ArrayList list = super.getPacketData();
list.add(this.isOutput);
list.add(this.wattsReceived);
return list;
}
@Override
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
{
if (worldObj.isRemote)
{
try
{
super.handlePacketData(network, packetType, packet, player, dataStream);
dataStream.readShort();
this.isOutput = dataStream.readBoolean();
this.wattsReceived = dataStream.readDouble();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
/*
* @Override public ArrayList getPacketData() { ArrayList list = super.getPacketData();
* list.add(this.isOutput); list.add(this.wattsReceived); return list; }
*
* @Override public void handlePacketData(INetworkManager network, int packetType,
* Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream) { if
* (worldObj.isRemote) { ByteArrayInputStream bis = new ByteArrayInputStream(packet.data);
* DataInputStream dis = new DataInputStream(bis); int id, x, y, z; try { id = dis.readInt(); x
* = dis.readInt(); y = dis.readInt(); z = dis.readInt(); NBTTagCompound tag =
* Packet.readNBTTagCompound(dis); readFromNBT(tag); this.wattsReceived = dis.readDouble();
* this.isOutput = dis.readBoolean(); } catch (IOException e) { e.printStackTrace(); } } }
*/
/**
* Throws the items from the manipulator into the world.
@ -432,7 +421,7 @@ public class TileEntityManipulator extends TileEntityFilterable implements IReds
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
this.isOutput = nbt.getBoolean("isWrenchedToOutput");
this.isOutput = nbt.getBoolean("isOutput");
}
/**
@ -442,7 +431,7 @@ public class TileEntityManipulator extends TileEntityFilterable implements IReds
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setBoolean("isWrenchedToOutput", this.isOutput);
nbt.setBoolean("isOutput", this.isOutput);
}
@Override

View file

@ -31,12 +31,6 @@ public class TileEntityRejector extends TileEntityFilterable
* should the piston fire, or be extended
*/
public boolean firePiston = false;
/**
* on/off value for the GUI buttons
*/
public boolean[] guiButtons = new boolean[] { true, true, true, true, true };
private int playerUsing = 0;
@Override
public void onUpdate()
@ -79,26 +73,15 @@ public class TileEntityRejector extends TileEntityFilterable
/**
* If a push happened, send a packet to the client to notify it for an animation.
*
* if (!this.worldObj.isRemote && flag) {
* PacketManager.sendPacketToClients(this.getDescriptionPacket()); }
*/
if (!this.worldObj.isRemote && flag)
{
// Packet packet = PacketManager.getPacket(AssemblyLine.CHANNEL, this,
// this.getPacketData(PacketTypes.ANIMATION));
// PacketManager.sendPacketToClients(packet, this.worldObj, new Vector3(this),
// 30);
PacketManager.sendPacketToClients(getDescriptionPacket());
}
}
catch (Exception e)
{
e.printStackTrace();
}
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER && this.playerUsing > 0)
{
PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj, new Vector3(this), 10);
}
}
}
@ -170,8 +153,7 @@ public class TileEntityRejector extends TileEntityFilterable
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
firePiston = nbt.getBoolean("piston");
this.firePiston = nbt.getBoolean("piston");
}
/**
@ -181,7 +163,6 @@ public class TileEntityRejector extends TileEntityFilterable
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setBoolean("piston", firePiston);
nbt.setBoolean("piston", this.firePiston);
}
}