mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-19 03:49:29 +00:00
Battlesigns now properly reflect all projectiles, not just arrows.
This commit is contained in:
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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user