Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +01:00
More consistent client entity tracking
Dieser Commit ist enthalten in:
Ursprung
71a68bf36e
Commit
3eba8ba922
@ -118,7 +118,7 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
wrapper.write(Type.INT, position.z());
|
||||
};
|
||||
|
||||
private static final PacketHandler SEND_DECLARE_COMMANDS_AND_TAGS =
|
||||
public static final PacketHandler SEND_DECLARE_COMMANDS_AND_TAGS =
|
||||
w -> {
|
||||
// Send fake declare commands
|
||||
w.create(ClientboundPackets1_13.DECLARE_COMMANDS, wrapper -> {
|
||||
@ -388,30 +388,6 @@ public class Protocol1_13To1_12_2 extends AbstractProtocol<ClientboundPackets1_1
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_12_1.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// Store the player
|
||||
int entityId = wrapper.get(Type.INT, 0);
|
||||
wrapper.user().getEntityTracker(Protocol1_13To1_12_2.class).addEntity(entityId, Entity1_13Types.EntityType.PLAYER);
|
||||
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 1);
|
||||
clientChunks.setEnvironment(dimensionId);
|
||||
}
|
||||
});
|
||||
handler(SEND_DECLARE_COMMANDS_AND_TAGS);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
registerClientbound(ClientboundPackets1_12_1.CRAFT_RECIPE_RESPONSE, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -27,6 +27,7 @@ import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.metadata.MetadataRewriter1_13To1_12_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class EntityPackets {
|
||||
|
||||
@ -128,6 +129,23 @@ public class EntityPackets {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_12_1.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
|
||||
handler(wrapper -> {
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 1);
|
||||
clientChunks.setEnvironment(dimensionId);
|
||||
});
|
||||
handler(metadataRewriter.playerTrackerHandler());
|
||||
handler(Protocol1_13To1_12_2.SEND_DECLARE_COMMANDS_AND_TAGS);
|
||||
}
|
||||
});
|
||||
|
||||
metadataRewriter.registerRemoveEntities(ClientboundPackets1_12_1.DESTROY_ENTITIES);
|
||||
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_12_1.ENTITY_METADATA, Types1_12.METADATA_LIST, Types1_13.METADATA_LIST);
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPacke
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.metadata.MetadataRewriter1_14To1_13_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -195,6 +196,42 @@ public class EntityPackets {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
handler(wrapper -> {
|
||||
// Store the player
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 1);
|
||||
clientChunks.setEnvironment(dimensionId);
|
||||
});
|
||||
handler(metadataRewriter.playerTrackerHandler());
|
||||
handler(wrapper -> {
|
||||
short difficulty = wrapper.read(Type.UNSIGNED_BYTE); // 19w11a removed difficulty from join game
|
||||
PacketWrapper difficultyPacket = wrapper.create(ClientboundPackets1_14.SERVER_DIFFICULTY);
|
||||
difficultyPacket.write(Type.UNSIGNED_BYTE, difficulty);
|
||||
difficultyPacket.write(Type.BOOLEAN, false); // Unknown value added in 19w11a
|
||||
difficultyPacket.scheduleSend(protocol.getClass());
|
||||
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players
|
||||
wrapper.passthrough(Type.STRING); // Level Type
|
||||
|
||||
wrapper.write(Type.VAR_INT, WorldPackets.SERVERSIDE_VIEW_DISTANCE); // Serverside view distance, added in 19w13a
|
||||
});
|
||||
handler(wrapper -> {
|
||||
// Manually send the packet
|
||||
wrapper.send(Protocol1_14To1_13_2.class);
|
||||
wrapper.cancel();
|
||||
|
||||
// View distance has to be sent after the join packet
|
||||
WorldPackets.sendViewDistancePacket(wrapper.user());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.USE_BED, ClientboundPackets1_14.ENTITY_METADATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
|
@ -25,7 +25,6 @@ import com.viaversion.viaversion.api.minecraft.BlockFace;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.NibbleArray;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_14Types;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
@ -288,55 +287,6 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// Store the player
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 1);
|
||||
clientChunks.setEnvironment(dimensionId);
|
||||
|
||||
int entityId = wrapper.get(Type.INT, 0);
|
||||
|
||||
Entity1_14Types entType = Entity1_14Types.PLAYER;
|
||||
// Register Type ID
|
||||
EntityTracker1_14 tracker = wrapper.user().getEntityTracker(Protocol1_14To1_13_2.class);
|
||||
tracker.addEntity(entityId, entType);
|
||||
tracker.setClientEntityId(entityId);
|
||||
}
|
||||
});
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
short difficulty = wrapper.read(Type.UNSIGNED_BYTE); // 19w11a removed difficulty from join game
|
||||
PacketWrapper difficultyPacket = wrapper.create(ClientboundPackets1_14.SERVER_DIFFICULTY);
|
||||
difficultyPacket.write(Type.UNSIGNED_BYTE, difficulty);
|
||||
difficultyPacket.write(Type.BOOLEAN, false); // Unknown value added in 19w11a
|
||||
difficultyPacket.scheduleSend(protocol.getClass());
|
||||
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players
|
||||
wrapper.passthrough(Type.STRING); // Level Type
|
||||
|
||||
wrapper.write(Type.VAR_INT, SERVERSIDE_VIEW_DISTANCE); // Serverside view distance, added in 19w13a
|
||||
}
|
||||
});
|
||||
handler(wrapper -> {
|
||||
// Manually send the packet
|
||||
wrapper.send(Protocol1_14To1_13_2.class);
|
||||
wrapper.cancel();
|
||||
|
||||
// View distance has to be sent after the join packet
|
||||
sendViewDistancePacket(wrapper.user());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.MAP_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -394,7 +344,7 @@ public class WorldPackets {
|
||||
});
|
||||
}
|
||||
|
||||
private static void sendViewDistancePacket(UserConnection connection) throws Exception {
|
||||
static void sendViewDistancePacket(UserConnection connection) throws Exception {
|
||||
PacketWrapper setViewDistance = PacketWrapper.create(ClientboundPackets1_14.UPDATE_VIEW_DISTANCE, null, connection);
|
||||
setViewDistance.write(Type.VAR_INT, WorldPackets.SERVERSIDE_VIEW_DISTANCE);
|
||||
setViewDistance.send(Protocol1_14To1_13_2.class);
|
||||
|
@ -18,6 +18,7 @@
|
||||
package com.viaversion.viaversion.protocols.protocol1_15to1_14_4;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types;
|
||||
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
@ -31,9 +32,7 @@ import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.data.MappingData
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.metadata.MetadataRewriter1_15To1_14_4;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.packets.EntityPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.packets.InventoryPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.packets.PlayerPackets;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.packets.WorldPackets;
|
||||
import com.viaversion.viaversion.api.minecraft.RegistryType;
|
||||
import com.viaversion.viaversion.rewriter.SoundRewriter;
|
||||
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
@ -55,7 +54,6 @@ public class Protocol1_15To1_14_4 extends AbstractProtocol<ClientboundPackets1_1
|
||||
itemRewriter.register();
|
||||
|
||||
EntityPackets.register(this);
|
||||
PlayerPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
|
||||
SoundRewriter soundRewriter = new SoundRewriter(this);
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.protocols.protocol1_15to1_14_4.packets;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
@ -79,6 +80,32 @@ public class EntityPackets {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
handler(wrapper -> wrapper.write(Type.LONG, 0L)); // Level Seed
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
handler(metadataRewriter.playerTrackerHandler());
|
||||
handler(wrapper -> wrapper.write(Type.LONG, 0L)); // Level Seed
|
||||
|
||||
map(Type.UNSIGNED_BYTE); // 3 - Max Players
|
||||
map(Type.STRING); // 4 - Level Type
|
||||
map(Type.VAR_INT); // 5 - View Distance
|
||||
map(Type.BOOLEAN); // 6 - Reduce Debug Info
|
||||
|
||||
handler(wrapper -> wrapper.write(Type.BOOLEAN, !Via.getConfig().is1_15InstantRespawn())); // Show Death Screen
|
||||
}
|
||||
});
|
||||
|
||||
metadataRewriter.registerMetadataRewriter(ClientboundPackets1_14.ENTITY_METADATA, Types1_14.METADATA_LIST);
|
||||
metadataRewriter.registerRemoveEntities(ClientboundPackets1_14.DESTROY_ENTITIES);
|
||||
}
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2022 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viaversion.protocols.protocol1_15to1_14_4.packets;
|
||||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_15Types;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||
|
||||
public class PlayerPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
protocol.registerClientbound(ClientboundPackets1_14.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
handler(wrapper -> wrapper.write(Type.LONG, 0L)); // Level Seed
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
|
||||
handler(wrapper -> {
|
||||
// Register Type ID
|
||||
EntityTracker tracker = wrapper.user().getEntityTracker(Protocol1_15To1_14_4.class);
|
||||
int entityId = wrapper.get(Type.INT, 0);
|
||||
tracker.addEntity(entityId, Entity1_15Types.PLAYER);
|
||||
});
|
||||
handler(wrapper -> wrapper.write(Type.LONG, 0L)); // Level Seed
|
||||
|
||||
map(Type.UNSIGNED_BYTE); // 3 - Max Players
|
||||
map(Type.STRING); // 4 - Level Type
|
||||
map(Type.VAR_INT); // 5 - View Distance
|
||||
map(Type.BOOLEAN); // 6 - Reduce Debug Info
|
||||
|
||||
handler(wrapper -> wrapper.write(Type.BOOLEAN, !Via.getConfig().is1_15InstantRespawn())); // Show Death Screen
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -63,9 +63,7 @@ public class EntityPackets {
|
||||
map(Type.LONG); // Seed
|
||||
map(Type.UNSIGNED_BYTE, Type.VAR_INT); // Max players
|
||||
// ...
|
||||
handler(wrapper -> {
|
||||
wrapper.user().getEntityTracker(Protocol1_16_2To1_16_1.class).addEntity(wrapper.get(Type.INT, 0), Entity1_16_2Types.PLAYER);
|
||||
});
|
||||
handler(metadataRewriter.playerTrackerHandler());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -17,6 +17,10 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_16_2Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
||||
@ -66,6 +70,42 @@ public final class EntityPackets extends EntityRewriter<Protocol1_17To1_16_4> {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Entity ID
|
||||
map(Type.BOOLEAN); // Hardcore
|
||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||
map(Type.BYTE); // Previous Gamemode
|
||||
map(Type.STRING_ARRAY); // World List
|
||||
map(Type.NBT); // Registry
|
||||
map(Type.NBT); // Current dimension
|
||||
handler(wrapper -> {
|
||||
// Add new dimension fields
|
||||
CompoundTag dimensionRegistry = wrapper.get(Type.NBT, 0).get("minecraft:dimension_type");
|
||||
ListTag dimensions = dimensionRegistry.get("value");
|
||||
for (Tag dimension : dimensions) {
|
||||
CompoundTag dimensionCompound = ((CompoundTag) dimension).get("element");
|
||||
addNewDimensionData(dimensionCompound);
|
||||
}
|
||||
|
||||
CompoundTag currentDimensionTag = wrapper.get(Type.NBT, 1);
|
||||
addNewDimensionData(currentDimensionTag);
|
||||
});
|
||||
handler(playerTrackerHandler());
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
CompoundTag dimensionData = wrapper.passthrough(Type.NBT);
|
||||
addNewDimensionData(dimensionData);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -156,4 +196,9 @@ public final class EntityPackets extends EntityRewriter<Protocol1_17To1_16_4> {
|
||||
public EntityType typeFromId(int type) {
|
||||
return Entity1_17Types.getTypeFromId(type);
|
||||
}
|
||||
|
||||
private static void addNewDimensionData(CompoundTag tag) {
|
||||
tag.put("min_y", new IntTag(0));
|
||||
tag.put("height", new IntTag(256));
|
||||
}
|
||||
}
|
||||
|
@ -17,16 +17,10 @@
|
||||
*/
|
||||
package com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.ListTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_16_2;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
@ -164,44 +158,6 @@ public final class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Entity ID
|
||||
map(Type.BOOLEAN); // Hardcore
|
||||
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||
map(Type.BYTE); // Previous Gamemode
|
||||
map(Type.STRING_ARRAY); // World List
|
||||
map(Type.NBT); // Registry
|
||||
map(Type.NBT); // Current dimension
|
||||
handler(wrapper -> {
|
||||
// Add new dimension fields
|
||||
CompoundTag dimensionRegistry = wrapper.get(Type.NBT, 0).get("minecraft:dimension_type");
|
||||
ListTag dimensions = dimensionRegistry.get("value");
|
||||
for (Tag dimension : dimensions) {
|
||||
CompoundTag dimensionCompound = ((CompoundTag) dimension).get("element");
|
||||
addNewDimensionData(dimensionCompound);
|
||||
}
|
||||
|
||||
CompoundTag currentDimensionTag = wrapper.get(Type.NBT, 1);
|
||||
addNewDimensionData(currentDimensionTag);
|
||||
|
||||
UserConnection user = wrapper.user();
|
||||
user.getEntityTracker(Protocol1_17To1_16_4.class).addEntity(wrapper.get(Type.INT, 0), Entity1_17Types.PLAYER);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.RESPAWN, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
CompoundTag dimensionData = wrapper.passthrough(Type.NBT);
|
||||
addNewDimensionData(dimensionData);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
blockRewriter.registerEffect(ClientboundPackets1_16_2.EFFECT, 1010, 2001);
|
||||
}
|
||||
|
||||
@ -234,9 +190,4 @@ public final class WorldPackets {
|
||||
blockChangePacket.send(Protocol1_17To1_16_4.class);
|
||||
}
|
||||
}
|
||||
|
||||
private static void addNewDimensionData(CompoundTag tag) {
|
||||
tag.put("min_y", new IntTag(0));
|
||||
tag.put("height", new IntTag(256));
|
||||
}
|
||||
}
|
||||
|
@ -402,9 +402,7 @@ public abstract class EntityRewriter<T extends Protocol> extends RewriterBase<T>
|
||||
return wrapper -> {
|
||||
final EntityTracker tracker = tracker(wrapper.user());
|
||||
final int entityId = wrapper.get(Type.INT, 0);
|
||||
if (tracker.clientEntityId() == -1) {
|
||||
tracker.setClientEntityId(entityId);
|
||||
}
|
||||
tracker.setClientEntityId(entityId);
|
||||
tracker.addEntity(entityId, tracker.playerType());
|
||||
};
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren