mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 08:58:02 -04:00
some 1.14.4 packets
This commit is contained in:
parent
62e2a237d0
commit
3a009d5ee1
@ -84,7 +84,9 @@ public class PacketBlockEntityMetadata implements ClientboundPacket {
|
||||
END_GATEWAY_DESTINATION(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 8)}),
|
||||
SET_TEXT_ON_SIGN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 9)}),
|
||||
DECLARE_SHULKER_BOX(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_11_2, 10)}),
|
||||
SET_BED_COLOR(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_12_2, 11)});
|
||||
SET_BED_COLOR(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_12_2, 11)}),
|
||||
SET_DATA_JIGSAW(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_14_4, 12)}),
|
||||
SET_ITEMS_IN_CAMPFIRE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_14_4, 13)});
|
||||
|
||||
final VersionValueMap<Integer> valueMap;
|
||||
|
||||
|
@ -14,10 +14,13 @@
|
||||
package de.bixilon.minosoft.protocol.packets.clientbound.play;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.GameMode;
|
||||
import de.bixilon.minosoft.game.datatypes.MapSet;
|
||||
import de.bixilon.minosoft.game.datatypes.VersionValueMap;
|
||||
import de.bixilon.minosoft.logging.Log;
|
||||
import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
|
||||
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
|
||||
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||
|
||||
public class PacketChangeGameState implements ClientboundPacket {
|
||||
Reason reason;
|
||||
@ -33,7 +36,8 @@ public class PacketChangeGameState implements ClientboundPacket {
|
||||
case VERSION_1_11_2:
|
||||
case VERSION_1_12_2:
|
||||
case VERSION_1_13_2:
|
||||
reason = Reason.byId(buffer.readByte());
|
||||
case VERSION_1_14_4:
|
||||
reason = Reason.byId(buffer.readByte(), buffer.getVersion());
|
||||
value = buffer.readFloat();
|
||||
return true;
|
||||
}
|
||||
@ -73,35 +77,40 @@ public class PacketChangeGameState implements ClientboundPacket {
|
||||
}
|
||||
|
||||
public enum Reason {
|
||||
INVALID_BED(0),
|
||||
END_RAIN(1),
|
||||
START_RAIN(2),
|
||||
CHANGE_GAMEMODE(3),
|
||||
ENTER_CREDITS(4),
|
||||
DEMO_MESSAGES(5),
|
||||
ARROW_HITTING_PLAYER(6),
|
||||
FADE_VALUE(7),
|
||||
FADE_TIME(8),
|
||||
PLAY_PUFFERFISH_STING_SOUND(9),
|
||||
PLAY_ELDER_GUARDIAN_MOB_APPEARANCE(10);
|
||||
INVALID_BED(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 0)}),
|
||||
END_RAIN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 1), new MapSet<>(ProtocolVersion.VERSION_1_7_10, 2)}),
|
||||
START_RAIN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 2), new MapSet<>(ProtocolVersion.VERSION_1_7_10, 1)}),
|
||||
CHANGE_GAMEMODE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 3)}),
|
||||
ENTER_CREDITS(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 4)}),
|
||||
DEMO_MESSAGES(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 5)}),
|
||||
ARROW_HITTING_PLAYER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 6)}),
|
||||
FADE_VALUE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 7)}),
|
||||
FADE_TIME(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 8)}),
|
||||
PLAY_PUFFERFISH_STING_SOUND(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 9)}),
|
||||
PLAY_ELDER_GUARDIAN_MOB_APPEARANCE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 10)});
|
||||
|
||||
final byte id;
|
||||
|
||||
Reason(int id) {
|
||||
this.id = (byte) id;
|
||||
final VersionValueMap<Integer> valueMap;
|
||||
|
||||
Reason(MapSet<ProtocolVersion, Integer>[] values) {
|
||||
valueMap = new VersionValueMap<>(values, true);
|
||||
}
|
||||
|
||||
public static Reason byId(byte id) {
|
||||
for (Reason g : values()) {
|
||||
if (g.getId() == id) {
|
||||
return g;
|
||||
public static Reason byId(int id, ProtocolVersion version) {
|
||||
for (Reason reason : values()) {
|
||||
if (reason.getId(version) == id) {
|
||||
return reason;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public byte getId() {
|
||||
return id;
|
||||
public int getId(ProtocolVersion version) {
|
||||
Integer ret = valueMap.get(version);
|
||||
if (ret == null) {
|
||||
return -2;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ public class PacketJoinGame implements ClientboundPacket {
|
||||
GameMode gameMode;
|
||||
Dimension dimension;
|
||||
Difficulty difficulty;
|
||||
int viewDistance = -1;
|
||||
int maxPlayers;
|
||||
LevelType levelType;
|
||||
boolean reducedDebugScreen;
|
||||
@ -77,6 +78,21 @@ public class PacketJoinGame implements ClientboundPacket {
|
||||
reducedDebugScreen = buffer.readBoolean();
|
||||
return true;
|
||||
}
|
||||
case VERSION_1_14_4: {
|
||||
this.entityId = buffer.readInt();
|
||||
byte gameModeRaw = buffer.readByte();
|
||||
hardcore = BitByte.isBitSet(gameModeRaw, 3);
|
||||
// remove hardcore bit and get gamemode
|
||||
gameModeRaw &= ~0x8;
|
||||
gameMode = GameMode.byId(gameModeRaw);
|
||||
|
||||
dimension = Dimension.byId(buffer.readInt());
|
||||
maxPlayers = buffer.readByte();
|
||||
levelType = LevelType.byType(buffer.readString());
|
||||
viewDistance = buffer.readVarInt();
|
||||
reducedDebugScreen = buffer.readBoolean();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -84,7 +100,7 @@ public class PacketJoinGame implements ClientboundPacket {
|
||||
|
||||
@Override
|
||||
public void log() {
|
||||
Log.protocol(String.format("Receiving join game packet (entityId=%s, gameMode=%s, dimension=%s, difficulty=%s, hardcore=%s)", entityId, gameMode.name(), dimension.name(), difficulty.name(), hardcore));
|
||||
Log.protocol(String.format("Receiving join game packet (entityId=%s, gameMode=%s, dimension=%s, difficulty=%s, hardcore=%s, viewDistance=%d)", entityId, gameMode.name(), dimension.name(), difficulty.name(), hardcore, viewDistance));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -119,4 +135,8 @@ public class PacketJoinGame implements ClientboundPacket {
|
||||
public Dimension getDimension() {
|
||||
return dimension;
|
||||
}
|
||||
|
||||
public int getViewDistance() {
|
||||
return viewDistance;
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,11 @@ public class PacketRespawn implements ClientboundPacket {
|
||||
gameMode = GameMode.byId(buffer.readByte());
|
||||
levelType = LevelType.byType(buffer.readString());
|
||||
return true;
|
||||
case VERSION_1_14_4:
|
||||
dimension = Dimension.byId(buffer.readInt());
|
||||
gameMode = GameMode.byId(buffer.readByte());
|
||||
levelType = LevelType.byType(buffer.readString());
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -21,6 +21,7 @@ import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
||||
|
||||
public class PacketServerDifficulty implements ClientboundPacket {
|
||||
Difficulty difficulty;
|
||||
boolean locked;
|
||||
|
||||
|
||||
@Override
|
||||
@ -34,6 +35,10 @@ public class PacketServerDifficulty implements ClientboundPacket {
|
||||
case VERSION_1_13_2:
|
||||
difficulty = Difficulty.byId(buffer.readByte());
|
||||
return true;
|
||||
case VERSION_1_14_4:
|
||||
difficulty = Difficulty.byId(buffer.readByte());
|
||||
locked = buffer.readBoolean();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -13,10 +13,7 @@
|
||||
|
||||
package de.bixilon.minosoft.protocol.packets.clientbound.play;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.entities.EntityObject;
|
||||
import de.bixilon.minosoft.game.datatypes.entities.Location;
|
||||
import de.bixilon.minosoft.game.datatypes.entities.Objects;
|
||||
import de.bixilon.minosoft.game.datatypes.entities.Velocity;
|
||||
import de.bixilon.minosoft.game.datatypes.entities.*;
|
||||
import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
|
||||
import de.bixilon.minosoft.logging.Log;
|
||||
import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
|
||||
@ -28,7 +25,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PacketSpawnObject implements ClientboundPacket {
|
||||
EntityObject object;
|
||||
Entity object;
|
||||
|
||||
public static EntityMetaData getEntityData(Class<? extends EntityMetaData> clazz, InByteBuffer buffer, ProtocolVersion v) {
|
||||
try {
|
||||
@ -44,7 +41,7 @@ public class PacketSpawnObject implements ClientboundPacket {
|
||||
Log.protocol(String.format("Object spawned at %s (entityId=%d, type=%s)", object.getLocation().toString(), object.getEntityId(), object.getEntityType().name()));
|
||||
}
|
||||
|
||||
public EntityObject getObject() {
|
||||
public Entity getObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
@ -96,6 +93,24 @@ public class PacketSpawnObject implements ClientboundPacket {
|
||||
short yaw = buffer.readAngle();
|
||||
int data = buffer.readInt();
|
||||
|
||||
try {
|
||||
// velocity present AND metadata
|
||||
Velocity velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort());
|
||||
object = type.getClazz().getConstructor(int.class, Location.class, short.class, short.class, int.class, Velocity.class).newInstance(entityId, location, yaw, pitch, data, velocity);
|
||||
return true;
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
case VERSION_1_14_4: {
|
||||
int entityId = buffer.readVarInt();
|
||||
UUID uuid = buffer.readUUID();
|
||||
Entities type = Entities.byId(buffer.readVarInt(), buffer.getVersion());
|
||||
Location location = new Location(buffer.readDouble(), buffer.readDouble(), buffer.readDouble());
|
||||
short pitch = buffer.readAngle();
|
||||
short yaw = buffer.readAngle();
|
||||
int data = buffer.readInt();
|
||||
|
||||
try {
|
||||
// velocity present AND metadata
|
||||
Velocity velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort());
|
||||
|
Loading…
x
Reference in New Issue
Block a user