some 1.14.4 packets

This commit is contained in:
Bixilon 2020-07-21 20:25:04 +02:00
parent 62e2a237d0
commit 3a009d5ee1
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
6 changed files with 85 additions and 29 deletions

View File

@ -84,7 +84,9 @@ public class PacketBlockEntityMetadata implements ClientboundPacket {
END_GATEWAY_DESTINATION(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_9_4, 8)}), 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)}), 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)}), 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; final VersionValueMap<Integer> valueMap;

View File

@ -14,10 +14,13 @@
package de.bixilon.minosoft.protocol.packets.clientbound.play; package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.game.datatypes.GameMode; 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.logging.Log;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket; import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer; import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.PacketHandler; import de.bixilon.minosoft.protocol.protocol.PacketHandler;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class PacketChangeGameState implements ClientboundPacket { public class PacketChangeGameState implements ClientboundPacket {
Reason reason; Reason reason;
@ -33,7 +36,8 @@ public class PacketChangeGameState implements ClientboundPacket {
case VERSION_1_11_2: case VERSION_1_11_2:
case VERSION_1_12_2: case VERSION_1_12_2:
case VERSION_1_13_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(); value = buffer.readFloat();
return true; return true;
} }
@ -73,35 +77,40 @@ public class PacketChangeGameState implements ClientboundPacket {
} }
public enum Reason { public enum Reason {
INVALID_BED(0), INVALID_BED(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 0)}),
END_RAIN(1), END_RAIN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 1), new MapSet<>(ProtocolVersion.VERSION_1_7_10, 2)}),
START_RAIN(2), START_RAIN(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 2), new MapSet<>(ProtocolVersion.VERSION_1_7_10, 1)}),
CHANGE_GAMEMODE(3), CHANGE_GAMEMODE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 3)}),
ENTER_CREDITS(4), ENTER_CREDITS(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 4)}),
DEMO_MESSAGES(5), DEMO_MESSAGES(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 5)}),
ARROW_HITTING_PLAYER(6), ARROW_HITTING_PLAYER(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 6)}),
FADE_VALUE(7), FADE_VALUE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 7)}),
FADE_TIME(8), FADE_TIME(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 8)}),
PLAY_PUFFERFISH_STING_SOUND(9), PLAY_PUFFERFISH_STING_SOUND(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 9)}),
PLAY_ELDER_GUARDIAN_MOB_APPEARANCE(10); PLAY_ELDER_GUARDIAN_MOB_APPEARANCE(new MapSet[]{new MapSet<>(ProtocolVersion.VERSION_1_7_10, 10)});
final byte id;
Reason(int id) { final VersionValueMap<Integer> valueMap;
this.id = (byte) id;
Reason(MapSet<ProtocolVersion, Integer>[] values) {
valueMap = new VersionValueMap<>(values, true);
} }
public static Reason byId(byte id) { public static Reason byId(int id, ProtocolVersion version) {
for (Reason g : values()) { for (Reason reason : values()) {
if (g.getId() == id) { if (reason.getId(version) == id) {
return g; return reason;
} }
} }
return null; return null;
} }
public byte getId() { public int getId(ProtocolVersion version) {
return id; Integer ret = valueMap.get(version);
if (ret == null) {
return -2;
}
return ret;
} }
} }
} }

View File

@ -30,6 +30,7 @@ public class PacketJoinGame implements ClientboundPacket {
GameMode gameMode; GameMode gameMode;
Dimension dimension; Dimension dimension;
Difficulty difficulty; Difficulty difficulty;
int viewDistance = -1;
int maxPlayers; int maxPlayers;
LevelType levelType; LevelType levelType;
boolean reducedDebugScreen; boolean reducedDebugScreen;
@ -77,6 +78,21 @@ public class PacketJoinGame implements ClientboundPacket {
reducedDebugScreen = buffer.readBoolean(); reducedDebugScreen = buffer.readBoolean();
return true; 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; return false;
@ -84,7 +100,7 @@ public class PacketJoinGame implements ClientboundPacket {
@Override @Override
public void log() { 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 @Override
@ -119,4 +135,8 @@ public class PacketJoinGame implements ClientboundPacket {
public Dimension getDimension() { public Dimension getDimension() {
return dimension; return dimension;
} }
public int getViewDistance() {
return viewDistance;
}
} }

View File

@ -44,6 +44,11 @@ public class PacketRespawn implements ClientboundPacket {
gameMode = GameMode.byId(buffer.readByte()); gameMode = GameMode.byId(buffer.readByte());
levelType = LevelType.byType(buffer.readString()); levelType = LevelType.byType(buffer.readString());
return true; 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; return false;

View File

@ -21,6 +21,7 @@ import de.bixilon.minosoft.protocol.protocol.PacketHandler;
public class PacketServerDifficulty implements ClientboundPacket { public class PacketServerDifficulty implements ClientboundPacket {
Difficulty difficulty; Difficulty difficulty;
boolean locked;
@Override @Override
@ -34,6 +35,10 @@ public class PacketServerDifficulty implements ClientboundPacket {
case VERSION_1_13_2: case VERSION_1_13_2:
difficulty = Difficulty.byId(buffer.readByte()); difficulty = Difficulty.byId(buffer.readByte());
return true; return true;
case VERSION_1_14_4:
difficulty = Difficulty.byId(buffer.readByte());
locked = buffer.readBoolean();
return true;
} }
return false; return false;

View File

@ -13,10 +13,7 @@
package de.bixilon.minosoft.protocol.packets.clientbound.play; package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.game.datatypes.entities.EntityObject; import de.bixilon.minosoft.game.datatypes.entities.*;
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.meta.EntityMetaData; import de.bixilon.minosoft.game.datatypes.entities.meta.EntityMetaData;
import de.bixilon.minosoft.logging.Log; import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket; import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
@ -28,7 +25,7 @@ import java.lang.reflect.InvocationTargetException;
import java.util.UUID; import java.util.UUID;
public class PacketSpawnObject implements ClientboundPacket { public class PacketSpawnObject implements ClientboundPacket {
EntityObject object; Entity object;
public static EntityMetaData getEntityData(Class<? extends EntityMetaData> clazz, InByteBuffer buffer, ProtocolVersion v) { public static EntityMetaData getEntityData(Class<? extends EntityMetaData> clazz, InByteBuffer buffer, ProtocolVersion v) {
try { 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())); 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; return object;
} }
@ -96,6 +93,24 @@ public class PacketSpawnObject implements ClientboundPacket {
short yaw = buffer.readAngle(); short yaw = buffer.readAngle();
int data = buffer.readInt(); 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 { try {
// velocity present AND metadata // velocity present AND metadata
Velocity velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort()); Velocity velocity = new Velocity(buffer.readShort(), buffer.readShort(), buffer.readShort());