Battlesigns now properly reflect all projectiles, not just arrows.

This commit is contained in:
Bernhard Bonigl committed 2014-11-26 22:37:08 +01:00
1 parent 6ea64191e1
commit dc3a2b0ff7
3 files changed
+102 -26

No files matched your search

@@ -0,0 +1,66 @@
package tconstruct.util.network;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import mantle.common.network.AbstractPacket;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.player.EntityPlayer;
public class MovementUpdatePacket extends AbstractPacket {
public int entityID;
public double x;
public double y;
public double z;
public float yaw;
public float pitch;
public MovementUpdatePacket() {
}
public MovementUpdatePacket(Entity entity) {
this.entityID = entity.getEntityId();
this.x = entity.motionX;
this.y = entity.motionY;
this.z = entity.motionZ;
this.yaw = entity.rotationYaw;
this.pitch = entity.rotationPitch;
}
@Override
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
buffer.writeInt(entityID);
buffer.writeDouble(x);
buffer.writeDouble(y);
buffer.writeDouble(z);
buffer.writeFloat(yaw);
buffer.writeFloat(pitch);
}
@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
this.entityID = buffer.readInt();
this.x = buffer.readDouble();
this.y = buffer.readDouble();
this.z = buffer.readDouble();
this.yaw = buffer.readFloat();
this.pitch = buffer.readFloat();
}
@Override
public void handleClientSide(EntityPlayer player) {
Entity entity = player.worldObj.getEntityByID(entityID);
if(entity != null) {
entity.motionX = x;
entity.motionY = y;
entity.motionZ = z;
entity.rotationYaw = yaw;
entity.rotationPitch = pitch;
}
}
@Override
public void handleServerSide(EntityPlayer player) {
// only sent to client
}
}
@@ -133,6 +133,8 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
registerPacket(BeltPacket.class);
registerPacket(GogglePacket.class);
registerPacket(MovementUpdatePacket.class);
}
// Method to call from FMLPostInitializationEvent