Fixed #250 - Conveyor belts not sending packets

This commit is contained in:
Calclavia 2014-02-21 22:33:48 +08:00
parent cbaf9884e6
commit 8352961a94
3 changed files with 22 additions and 27 deletions

View file

@ -30,7 +30,7 @@ import cpw.mods.fml.common.network.PacketDispatcher;
*
* @author DarkGuardsman
*/
public class TileConveyorBelt extends TileMechanical implements IBelt, IRotatable, IPacketReceiverWithID
public class TileConveyorBelt extends TileMechanical implements IBelt, IRotatable
{
public enum SlantType
{
@ -108,7 +108,6 @@ public class TileConveyorBelt extends TileMechanical implements IBelt, IRotatabl
markRefresh = false;
}
}
}
@Override
@ -127,29 +126,15 @@ public class TileConveyorBelt extends TileMechanical implements IBelt, IRotatabl
}
@Override
public boolean onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
public void onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
if (this.worldObj.isRemote)
{
try
{
if (id == PACKET_SLANT)
{
this.slantType = SlantType.values()[data.readInt()];
return true;
}
else if (id == PACKET_REFRESH)
{
refresh();
return true;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
return false;
super.onReceivePacket(id, data, player, extra);
if (id == PACKET_SLANT)
this.slantType = SlantType.values()[data.readInt()];
else if (id == PACKET_REFRESH)
refresh();
}
public SlantType getSlant()

View file

@ -189,7 +189,8 @@ public class PartPipe extends PartFramedConnection<EnumPipeMaterial, IFluidPipe,
protected IFluidPipe getConnector(TileEntity tile)
{
if (tile instanceof IFluidPipe)
return (IFluidPipe) ((IFluidPipe) tile).getInstance(ForgeDirection.UNKNOWN);
if (((IFluidPipe) tile).getInstance(ForgeDirection.UNKNOWN) instanceof IFluidPipe)
return (IFluidPipe) ((IFluidPipe) tile).getInstance(ForgeDirection.UNKNOWN);
return null;
}

View file

@ -7,6 +7,7 @@ import net.minecraftforge.common.ForgeDirection;
import resonantinduction.api.mechanical.IMechanical;
import resonantinduction.api.mechanical.IMechanicalNetwork;
import resonantinduction.core.ResonantInduction;
import resonantinduction.mechanical.Mechanical;
import resonantinduction.mechanical.gear.PartGearShaft;
import universalelectricity.api.vector.Vector3;
import calclavia.lib.network.IPacketReceiver;
@ -17,6 +18,8 @@ import com.google.common.io.ByteArrayDataInput;
public abstract class TileMechanical extends TileAdvanced implements IMechanical, IPacketReceiver
{
protected static final int PACKET_VELOCITY = Mechanical.contentRegistry.getNextPacketID();
/** The mechanical connections this connector has made */
protected Object[] connections = new Object[6];
private IMechanicalNetwork network;
@ -59,13 +62,19 @@ public abstract class TileMechanical extends TileAdvanced implements IMechanical
private void sendRotationPacket()
{
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, angularVelocity), worldObj, new Vector3(this), 20);
PacketHandler.sendPacketToClients(ResonantInduction.PACKET_TILE.getPacket(this, PACKET_VELOCITY, angularVelocity), worldObj, new Vector3(this), 20);
}
@Override
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
angularVelocity = data.readFloat();
onReceivePacket(data.readInt(), data, player, extra);
}
public void onReceivePacket(int id, ByteArrayDataInput data, EntityPlayer player, Object... extra)
{
if (id == PACKET_VELOCITY)
angularVelocity = data.readFloat();
}
@Override