Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Battlesigns now properly reflect all projectiles, not just arrows.
- Loading branch information
Showing
3 changed files
with
104 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/main/java/tconstruct/util/network/MovementUpdatePacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters