видно новых игроков и их передвижения
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* DmitriyMX <dimon550@gmail.com>
|
||||
* 2018-05-12
|
||||
*/
|
||||
package mc.core.network.proto_125.packets;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import mc.core.network.SCPacket;
|
||||
import mc.core.network.proto_125.ByteArrayOutputNetStream;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Setter
|
||||
@ToString
|
||||
public class EntityLookHeadPacket implements SCPacket {
|
||||
private int id;
|
||||
private double yaw;
|
||||
|
||||
@Override
|
||||
public byte[] toByteArray() {
|
||||
ByteArrayOutputNetStream netStream = new ByteArrayOutputNetStream();
|
||||
|
||||
netStream.writeInt(id);
|
||||
netStream.writeByte((byte)(int)((yaw * 256f) / 360f));
|
||||
|
||||
return netStream.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* DmitriyMX <dimon550@gmail.com>
|
||||
* 2018-05-12
|
||||
*/
|
||||
package mc.core.network.proto_125.packets;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import mc.core.network.SCPacket;
|
||||
import mc.core.network.proto_125.ByteArrayOutputNetStream;
|
||||
import mc.core.player.Look;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Setter
|
||||
@ToString
|
||||
public class EntityLookPacket implements SCPacket {
|
||||
private int id;
|
||||
private Look look;
|
||||
|
||||
@Override
|
||||
public byte[] toByteArray() {
|
||||
ByteArrayOutputNetStream netStream = new ByteArrayOutputNetStream();
|
||||
|
||||
netStream.writeInt(id);
|
||||
netStream.writeByte((byte)(int)((look.getYaw() * 256f) / 360f));
|
||||
netStream.writeByte((byte)(int)((look.getPitch() * 256f) / 360f));
|
||||
|
||||
return netStream.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* DmitriyMX <dimon550@gmail.com>
|
||||
* 2018-05-12
|
||||
*/
|
||||
package mc.core.network.proto_125.packets;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import mc.core.Location;
|
||||
import mc.core.network.SCPacket;
|
||||
import mc.core.network.proto_125.ByteArrayOutputNetStream;
|
||||
import mc.core.player.Look;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Setter
|
||||
@ToString
|
||||
public class EntityLookRelativeMovePacket implements SCPacket {
|
||||
private int id;
|
||||
private Location location;
|
||||
private Look look;
|
||||
|
||||
@Override
|
||||
public byte[] toByteArray() {
|
||||
ByteArrayOutputNetStream netStream = new ByteArrayOutputNetStream();
|
||||
|
||||
netStream.writeInt(id);
|
||||
netStream.writeByte((byte) (location.getX() * 32d));
|
||||
netStream.writeByte((byte) (location.getY() * 32d));
|
||||
netStream.writeByte((byte) (location.getZ() * 32d));
|
||||
netStream.writeByte((byte)(int)((look.getYaw() * 256f) / 360f));
|
||||
netStream.writeByte((byte)(int)((look.getPitch() * 256f) / 360f));
|
||||
|
||||
return netStream.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* DmitriyMX <dimon550@gmail.com>
|
||||
* 2018-05-11
|
||||
*/
|
||||
package mc.core.network.proto_125.packets;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import mc.core.Location;
|
||||
import mc.core.network.SCPacket;
|
||||
import mc.core.network.proto_125.ByteArrayOutputNetStream;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Setter
|
||||
@ToString
|
||||
public class EntityRelativeMovePacket implements SCPacket {
|
||||
private int id;
|
||||
private Location location;
|
||||
|
||||
@Override
|
||||
public byte[] toByteArray() {
|
||||
ByteArrayOutputNetStream netStream = new ByteArrayOutputNetStream();
|
||||
|
||||
netStream.writeInt(id);
|
||||
netStream.writeByte((byte) (location.getX() * 32d));
|
||||
netStream.writeByte((byte) (location.getY() * 32d));
|
||||
netStream.writeByte((byte) (location.getZ() * 32d));
|
||||
|
||||
return netStream.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* DmitriyMX <dimon550@gmail.com>
|
||||
* 2018-05-11
|
||||
*/
|
||||
package mc.core.network.proto_125.packets;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import mc.core.Location;
|
||||
import mc.core.network.SCPacket;
|
||||
import mc.core.network.proto_125.ByteArrayOutputNetStream;
|
||||
import mc.core.player.Look;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Setter
|
||||
@ToString
|
||||
public class EntityTeleportPacket implements SCPacket {
|
||||
private int id;
|
||||
private Location location;
|
||||
private Look look;
|
||||
|
||||
@Override
|
||||
public byte[] toByteArray() {
|
||||
ByteArrayOutputNetStream netStream = new ByteArrayOutputNetStream();
|
||||
|
||||
netStream.writeInt(id);
|
||||
netStream.writeInt((int) (location.getBlockX() * 32d));
|
||||
netStream.writeInt((int) (location.getBlockY() * 32d));
|
||||
netStream.writeInt((int) (location.getBlockZ() * 32d));
|
||||
netStream.writeByte((byte)(int)((look.getYaw() * 256f) / 360f));
|
||||
netStream.writeByte((byte)(int)((look.getPitch() * 256f) / 360f));
|
||||
|
||||
return netStream.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,11 @@ public class PacketManager {
|
||||
.put(0x0D, PositionAndLookPacket.class)
|
||||
.put(0x14, SpawnNamedEntityPacket.class)
|
||||
.put(0x1D, DestroyEntityPacket.class)
|
||||
.put(0x1F, EntityRelativeMovePacket.class)
|
||||
.put(0x20, EntityLookPacket.class)
|
||||
.put(0x21, EntityLookRelativeMovePacket.class)
|
||||
.put(0x22, EntityTeleportPacket.class)
|
||||
.put(0x23, EntityLookHeadPacket.class)
|
||||
.put(0x32, ChunkAllocationPacket.class)
|
||||
.put(0x33, ChunkDataPacket.class)
|
||||
.put(0xC9, PlayerInfoPacket.class)
|
||||
|
||||
Reference in New Issue
Block a user