mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Add ServerPlayerFacingPacket
This commit is contained in:
parent
304c8b73be
commit
d7a39e67df
4 changed files with 98 additions and 1 deletions
|
@ -80,6 +80,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerEntit
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.ServerVehicleMovePacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerAbilitiesPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerChangeHeldItemPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerFacingPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerSetExperiencePacket;
|
||||
|
@ -391,7 +392,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
this.registerIncoming(0x2E, ServerPlayerAbilitiesPacket.class);
|
||||
this.registerIncoming(0x2F, ServerCombatPacket.class);
|
||||
this.registerIncoming(0x30, ServerPlayerListEntryPacket.class);
|
||||
// FIXME: 0x31
|
||||
this.registerIncoming(0x31, ServerPlayerFacingPacket.class);
|
||||
this.registerIncoming(0x32, ServerPlayerPositionRotationPacket.class);
|
||||
this.registerIncoming(0x33, ServerPlayerUseBedPacket.class);
|
||||
this.registerIncoming(0x34, ServerUnlockRecipesPacket.class);
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.github.steveice10.mc.protocol.data.game.advancement.Advancement;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.Effect;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.EntityStatus;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.EquipmentSlot;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.FeetOrEyes;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.attribute.AttributeType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.attribute.ModifierOperation;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.attribute.ModifierType;
|
||||
|
@ -894,6 +895,9 @@ public class MagicValues {
|
|||
register(EquipmentSlot.CHESTPLATE, 4);
|
||||
register(EquipmentSlot.HELMET, 5);
|
||||
|
||||
register(FeetOrEyes.FEET, 0);
|
||||
register(FeetOrEyes.EYES, 1);
|
||||
|
||||
register(SoundCategory.MASTER, 0);
|
||||
register(SoundCategory.MUSIC, 1);
|
||||
register(SoundCategory.RECORD, 2);
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity;
|
||||
|
||||
public enum FeetOrEyes {
|
||||
FEET,
|
||||
EYES;
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.server.entity.player;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.FeetOrEyes;
|
||||
import com.github.steveice10.mc.protocol.packet.MinecraftPacket;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ServerPlayerFacingPacket extends MinecraftPacket {
|
||||
private FeetOrEyes origin; // presumably the origin from which pitch is calculated at
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private Integer targetEntityId;
|
||||
private FeetOrEyes targetEntityFeetOrEyes;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ServerPlayerFacingPacket() {
|
||||
}
|
||||
|
||||
public ServerPlayerFacingPacket(FeetOrEyes origin, double x, double y, double z) {
|
||||
this.origin = origin;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public ServerPlayerFacingPacket(FeetOrEyes origin, int targetEntityId, FeetOrEyes lookAt) {
|
||||
this.origin = origin;
|
||||
this.targetEntityId = targetEntityId;
|
||||
this.targetEntityFeetOrEyes = lookAt;
|
||||
}
|
||||
|
||||
public FeetOrEyes getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public Integer getTargetEntityId() {
|
||||
return targetEntityId;
|
||||
}
|
||||
|
||||
public FeetOrEyes getTargetEntityFeetOrEyes() {
|
||||
return targetEntityFeetOrEyes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NetInput in) throws IOException {
|
||||
this.origin = MagicValues.key(FeetOrEyes.class, in.readVarInt());
|
||||
this.x = in.readDouble();
|
||||
this.y = in.readDouble();
|
||||
this.z = in.readDouble();
|
||||
if (in.readBoolean()) {
|
||||
this.targetEntityId = in.readVarInt();
|
||||
this.targetEntityFeetOrEyes = MagicValues.key(FeetOrEyes.class, in.readVarInt());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NetOutput out) throws IOException {
|
||||
out.writeVarInt(MagicValues.value(Integer.class, this.origin));
|
||||
out.writeDouble(this.x);
|
||||
out.writeDouble(this.y);
|
||||
out.writeDouble(this.z);
|
||||
if (this.targetEntityId != null) {
|
||||
out.writeBoolean(true);
|
||||
out.writeVarInt(this.targetEntityId);
|
||||
out.writeVarInt(MagicValues.value(Integer.class, this.targetEntityFeetOrEyes));
|
||||
} else {
|
||||
out.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue