Change gamemode data type in JOIN_GAME handlers (#3541)

This commit is contained in:
RK_01 2023-12-03 18:35:19 +01:00 committed by GitHub
parent 916c08ce7e
commit 1f453dc0d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 27 additions and 40 deletions

View File

@ -44,9 +44,7 @@ public class EntityPackets {
handler(wrapper -> {
short gamemode = wrapper.read(Type.UNSIGNED_BYTE);
wrapper.write(Type.BOOLEAN, (gamemode & 0x08) != 0); // Hardcore
gamemode &= ~0x08;
wrapper.write(Type.UNSIGNED_BYTE, gamemode);
wrapper.write(Type.BYTE, (byte) (gamemode & ~0x08)); // Gamemode
});
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List

View File

@ -206,7 +206,7 @@ public class EntityPackets {
@Override
public void register() {
map(Type.INT); // Entity ID
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Gamemode
handler(wrapper -> {
wrapper.write(Type.BYTE, (byte) -1); // Previous gamemode, set to none
wrapper.write(Type.STRING_ARRAY, Arrays.copyOf(WORLD_NAMES, WORLD_NAMES.length)); // World list - only used for command completion

View File

@ -22,9 +22,9 @@ 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.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
@ -70,7 +70,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
public void register() {
map(Type.INT); // Entity ID
map(Type.BOOLEAN); // Hardcore
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NAMED_COMPOUND_TAG); // Registry

View File

@ -62,7 +62,7 @@ public final class Protocol1_18_2To1_18 extends AbstractProtocol<ClientboundPack
public void register() {
map(Type.INT); // Entity ID
map(Type.BOOLEAN); // Hardcore
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NAMED_COMPOUND_TAG); // Registry

View File

@ -18,11 +18,11 @@
package com.viaversion.viaversion.protocols.protocol1_18to1_17_1.packets;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_17;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.type.types.version.Types1_17;
import com.viaversion.viaversion.api.type.types.version.Types1_18;
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
@ -45,7 +45,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_17_1
public void register() {
map(Type.INT); // Entity ID
map(Type.BOOLEAN); // Hardcore
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NAMED_COMPOUND_TAG); // Registry

View File

@ -210,7 +210,7 @@ public final class Protocol1_19_1To1_19 extends AbstractProtocol<ClientboundPack
public void register() {
map(Type.INT); // Entity ID
map(Type.BOOLEAN); // Hardcore
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
handler(wrapper -> {

View File

@ -18,8 +18,8 @@
package com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.packets;
import com.google.gson.JsonElement;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_3;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_3;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
@ -29,6 +29,7 @@ import com.viaversion.viaversion.protocols.protocol1_19_1to1_19.ClientboundPacke
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.Protocol1_19_3To1_19_1;
import com.viaversion.viaversion.rewriter.EntityRewriter;
import java.util.BitSet;
import java.util.UUID;
@ -49,7 +50,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_1
public void register() {
map(Type.INT); // Entity id
map(Type.BOOLEAN); // Hardcore
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NAMED_COMPOUND_TAG); // Dimension registry

View File

@ -17,13 +17,9 @@
*/
package com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.packets;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.github.steveice10.opennbt.tag.builtin.*;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
@ -48,7 +44,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
public void register() {
map(Type.INT); // Entity id
map(Type.BOOLEAN); // Hardcore
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NAMED_COMPOUND_TAG); // Dimension registry

View File

@ -27,15 +27,15 @@ import com.google.gson.JsonElement;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.data.entity.DimensionData;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.type.types.version.Types1_18;
import com.viaversion.viaversion.api.type.types.version.Types1_19;
import com.viaversion.viaversion.data.entity.DimensionDataImpl;
@ -46,11 +46,8 @@ import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.storage.Dimensio
import com.viaversion.viaversion.rewriter.EntityRewriter;
import com.viaversion.viaversion.util.Key;
import com.viaversion.viaversion.util.Pair;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18, Protocol1_19To1_18_2> {
@ -199,7 +196,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
public void register() {
map(Type.INT); // Entity ID
map(Type.BOOLEAN); // Hardcore
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NAMED_COMPOUND_TAG); // Registry

View File

@ -18,8 +18,8 @@
package com.viaversion.viaversion.protocols.protocol1_20_2to1_20.rewriter;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
@ -71,7 +71,7 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
wrapper.passthrough(Type.INT); // Entity id
wrapper.passthrough(Type.BOOLEAN); // Hardcore
final byte gamemode = wrapper.read(Type.UNSIGNED_BYTE).byteValue();
final byte gamemode = wrapper.read(Type.BYTE);
final byte previousGamemode = wrapper.read(Type.BYTE);
wrapper.passthrough(Type.STRING_ARRAY); // World List
@ -187,4 +187,4 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
public EntityType typeFromId(final int type) {
return EntityTypes1_19_4.getTypeFromId(type);
}
}
}

View File

@ -17,15 +17,10 @@
*/
package com.viaversion.viaversion.protocols.protocol1_20to1_19_4.packets;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.FloatTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.github.steveice10.opennbt.tag.builtin.*;
import com.viaversion.viaversion.api.minecraft.Quaternion;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
@ -54,7 +49,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_4
public void register() {
map(Type.INT); // Entity id
map(Type.BOOLEAN); // Hardcore
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.BYTE); // Gamemode
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NAMED_COMPOUND_TAG); // Dimension registry
@ -160,4 +155,4 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_4
private Quaternion rotateY180(final Quaternion quaternion) {
return new Quaternion(-quaternion.z(), quaternion.w(), quaternion.x(), -quaternion.y());
}
}
}