3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-20 06:50:08 +01:00
Dieser Commit ist enthalten in:
Nassim Jahnke 2024-01-24 17:34:40 +01:00
Ursprung 00176c4a0c
Commit 37561705ed
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
14 geänderte Dateien mit 219 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -24,6 +24,8 @@ package com.viaversion.viaversion.api.data.entity;
public interface DimensionData { public interface DimensionData {
int id();
int minY(); int minY();
int height(); int height();

Datei anzeigen

@ -165,6 +165,8 @@ public interface EntityTracker {
@Nullable DimensionData dimensionData(String dimension); @Nullable DimensionData dimensionData(String dimension);
@Nullable DimensionData dimensionData(int dimensionId);
void setDimensions(Map<String, DimensionData> dimensions); void setDimensions(Map<String, DimensionData> dimensions);
/** /**

Datei anzeigen

@ -0,0 +1,43 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import com.github.steveice10.opennbt.tag.builtin.Tag;
public final class RegistryEntry {
private final String key;
private final Tag tag;
public RegistryEntry(String key, Tag tag) {
this.key = key;
this.tag = tag;
}
public String key() {
return key;
}
public Tag tag() {
return tag;
}
}

Datei anzeigen

@ -86,7 +86,7 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_20 = register(763, "1.20/1.20.1", new VersionRange("1.20", 0, 1)); public static final ProtocolVersion v1_20 = register(763, "1.20/1.20.1", new VersionRange("1.20", 0, 1));
public static final ProtocolVersion v1_20_2 = register(764, "1.20.2"); public static final ProtocolVersion v1_20_2 = register(764, "1.20.2");
public static final ProtocolVersion v1_20_3 = register(765, "1.20.3/1.20.4", new VersionRange("1.20", 3, 4)); public static final ProtocolVersion v1_20_3 = register(765, "1.20.3/1.20.4", new VersionRange("1.20", 3, 4));
public static final ProtocolVersion v1_20_5 = register(766, 172, "1.20.5"); public static final ProtocolVersion v1_20_5 = register(766, 173, "1.20.5");
public static final ProtocolVersion unknown = register(-1, "UNKNOWN"); public static final ProtocolVersion unknown = register(-1, "UNKNOWN");
public static ProtocolVersion register(int version, String name) { public static ProtocolVersion register(int version, String name) {

Datei anzeigen

@ -32,6 +32,7 @@ import com.viaversion.viaversion.api.minecraft.PlayerMessageSignature;
import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.Position;
import com.viaversion.viaversion.api.minecraft.ProfileKey; import com.viaversion.viaversion.api.minecraft.ProfileKey;
import com.viaversion.viaversion.api.minecraft.Quaternion; import com.viaversion.viaversion.api.minecraft.Quaternion;
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
import com.viaversion.viaversion.api.minecraft.Vector; import com.viaversion.viaversion.api.minecraft.Vector;
import com.viaversion.viaversion.api.minecraft.Vector3f; import com.viaversion.viaversion.api.minecraft.Vector3f;
import com.viaversion.viaversion.api.minecraft.VillagerData; import com.viaversion.viaversion.api.minecraft.VillagerData;
@ -49,6 +50,7 @@ import com.viaversion.viaversion.api.type.types.FloatType;
import com.viaversion.viaversion.api.type.types.IntType; import com.viaversion.viaversion.api.type.types.IntType;
import com.viaversion.viaversion.api.type.types.LongArrayType; import com.viaversion.viaversion.api.type.types.LongArrayType;
import com.viaversion.viaversion.api.type.types.LongType; import com.viaversion.viaversion.api.type.types.LongType;
import com.viaversion.viaversion.api.type.types.RegistryEntryType;
import com.viaversion.viaversion.api.type.types.RemainingBytesType; import com.viaversion.viaversion.api.type.types.RemainingBytesType;
import com.viaversion.viaversion.api.type.types.ShortByteArrayType; import com.viaversion.viaversion.api.type.types.ShortByteArrayType;
import com.viaversion.viaversion.api.type.types.ShortType; import com.viaversion.viaversion.api.type.types.ShortType;
@ -178,6 +180,9 @@ public abstract class Type<T> implements ByteBufReader<T>, ByteBufWriter<T> {
public static final ByteArrayType SIGNATURE_BYTES = new ByteArrayType(256); public static final ByteArrayType SIGNATURE_BYTES = new ByteArrayType(256);
public static final ByteArrayType.OptionalByteArrayType OPTIONAL_SIGNATURE_BYTES = new ByteArrayType.OptionalByteArrayType(256); public static final ByteArrayType.OptionalByteArrayType OPTIONAL_SIGNATURE_BYTES = new ByteArrayType.OptionalByteArrayType(256);
public static final Type<RegistryEntry> REGISTRY_ENTRY = new RegistryEntryType();
public static final Type<RegistryEntry[]> REGISTRY_ENTRY_ARRAY = new ArrayType<>(REGISTRY_ENTRY);
public static final Type<Item> ITEM1_8 = new ItemType1_8(); public static final Type<Item> ITEM1_8 = new ItemType1_8();
public static final Type<Item> ITEM1_13 = new ItemType1_13(); public static final Type<Item> ITEM1_13 = new ItemType1_13();
public static final Type<Item> ITEM1_13_2 = new ItemType1_13_2(); public static final Type<Item> ITEM1_13_2 = new ItemType1_13_2();

Datei anzeigen

@ -0,0 +1,45 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.type.types;
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
import com.viaversion.viaversion.api.type.Type;
import io.netty.buffer.ByteBuf;
public class RegistryEntryType extends Type<RegistryEntry> {
public RegistryEntryType() {
super(RegistryEntry.class);
}
@Override
public RegistryEntry read(final ByteBuf buffer) throws Exception {
return new RegistryEntry(Type.STRING.read(buffer), Type.TAG.read(buffer));
}
@Override
public void write(final ByteBuf buffer, final RegistryEntry entry) throws Exception {
Type.STRING.write(buffer, entry.key());
Type.TAG.write(buffer, entry.tag());
}
}

Datei anzeigen

@ -25,15 +25,18 @@ import com.viaversion.viaversion.api.data.entity.DimensionData;
public final class DimensionDataImpl implements DimensionData { public final class DimensionDataImpl implements DimensionData {
private final int id;
private final int minY; private final int minY;
private final int height; private final int height;
public DimensionDataImpl(final int minY, final int height) { public DimensionDataImpl(final int id, final int minY, final int height) {
this.id = id;
this.minY = minY; this.minY = minY;
this.height = height; this.height = height;
} }
public DimensionDataImpl(final CompoundTag dimensionData) { public DimensionDataImpl(final int id, final CompoundTag dimensionData) {
this.id = id;
final Tag height = dimensionData.get("height"); final Tag height = dimensionData.get("height");
if (height instanceof IntTag) { if (height instanceof IntTag) {
this.height = ((NumberTag) height).asInt(); this.height = ((NumberTag) height).asInt();
@ -49,6 +52,11 @@ public final class DimensionDataImpl implements DimensionData {
} }
} }
@Override
public int id() {
return id;
}
@Override @Override
public int minY() { public int minY() {
return minY; return minY;

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.data.entity.StoredEntityData; import com.viaversion.viaversion.api.data.entity.StoredEntityData;
import com.viaversion.viaversion.api.data.entity.TrackedEntity; import com.viaversion.viaversion.api.data.entity.TrackedEntity;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.util.Key;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
@ -171,7 +172,12 @@ public class EntityTrackerBase implements EntityTracker, ClientEntityIdChangeLis
@Override @Override
public @Nullable DimensionData dimensionData(String dimension) { public @Nullable DimensionData dimensionData(String dimension) {
return dimensions.get(dimension); return dimensions.get(Key.stripMinecraftNamespace(dimension));
}
@Override
public @Nullable DimensionData dimensionData(int dimensionId) {
return dimensions.values().stream().filter(data -> data.id() == dimensionId).findFirst().orElse(null); // TODO Store as array as well
} }
@Override @Override

Datei anzeigen

@ -21,6 +21,7 @@ import com.github.steveice10.opennbt.stringified.SNBT;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
@ -215,10 +216,11 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
final Map<CompoundTag, String> dimensionsMap = new HashMap<>(dimensions.size()); final Map<CompoundTag, String> dimensionsMap = new HashMap<>(dimensions.size());
for (final Tag dimension : dimensions) { for (final Tag dimension : dimensions) {
final CompoundTag dimensionCompound = (CompoundTag) dimension; final CompoundTag dimensionCompound = (CompoundTag) dimension;
final NumberTag idTag = dimensionCompound.get("id");
final CompoundTag element = dimensionCompound.get("element"); final CompoundTag element = dimensionCompound.get("element");
final String name = (String) dimensionCompound.get("name").getValue(); final String name = (String) dimensionCompound.get("name").getValue();
addMonsterSpawnData(element); addMonsterSpawnData(element);
dimensionDataMap.put(name, new DimensionDataImpl(element)); dimensionDataMap.put(Key.stripMinecraftNamespace(name), new DimensionDataImpl(idTag.asInt(), element));
dimensionsMap.put(element.copy(), name); dimensionsMap.put(element.copy(), name);
} }
tracker(wrapper.user()).setDimensions(dimensionDataMap); tracker(wrapper.user()).setDimensions(dimensionDataMap);

Datei anzeigen

@ -17,8 +17,16 @@
*/ */
package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.rewriter; package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.rewriter;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.data.entity.DimensionData;
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.packet.State; import com.viaversion.viaversion.api.protocol.packet.State;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.Type;
@ -28,8 +36,10 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.Clientb
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.AttributeMappings; import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.AttributeMappings;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundConfigurationPackets1_20_5;
import com.viaversion.viaversion.rewriter.EntityRewriter; import com.viaversion.viaversion.rewriter.EntityRewriter;
import com.viaversion.viaversion.util.Key; import com.viaversion.viaversion.util.Key;
import java.util.Map;
public final class EntityPacketRewriter1_20_5 extends EntityRewriter<ClientboundPackets1_20_3, Protocol1_20_5To1_20_3> { public final class EntityPacketRewriter1_20_5 extends EntityRewriter<ClientboundPackets1_20_3, Protocol1_20_5To1_20_3> {
@ -46,9 +56,31 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
protocol.registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.REGISTRY_DATA, new PacketHandlers() { protocol.registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.REGISTRY_DATA, new PacketHandlers() {
@Override @Override
protected void register() { protected void register() {
map(Type.COMPOUND_TAG); // Registry data handler(wrapper -> {
handler(configurationDimensionDataHandler()); // Caches dimensions to access data like height later final CompoundTag registryData = wrapper.read(Type.COMPOUND_TAG);
handler(configurationBiomeSizeTracker()); // Tracks the amount of biomes sent for chunk data cacheDimensionData(wrapper.user(), registryData);
trackBiomeSize(wrapper.user(), registryData);
for (final Map.Entry<String, Tag> entry : registryData.entrySet()) {
final CompoundTag entryTag = (CompoundTag) entry.getValue();
final StringTag typeTag = entryTag.get("type");
final ListTag valueTag = entryTag.get("value");
final RegistryEntry[] registryEntries = new RegistryEntry[valueTag.size()];
for (final Tag tag : valueTag) {
final CompoundTag compoundTag = (CompoundTag) tag;
final StringTag nameTag = compoundTag.get("name");
final int id = ((NumberTag) compoundTag.get("id")).asInt();
registryEntries[id] = new RegistryEntry(nameTag.getValue(), compoundTag.get("element"));
}
final PacketWrapper registryPacket = wrapper.create(ClientboundConfigurationPackets1_20_5.REGISTRY_DATA);
registryPacket.write(Type.STRING, typeTag.getValue());
registryPacket.write(Type.REGISTRY_ENTRY_ARRAY, registryEntries);
registryPacket.send(Protocol1_20_5To1_20_3.class);
}
wrapper.cancel();
});
} }
}); });
@ -64,7 +96,11 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
map(Type.BOOLEAN); // Reduced debug info map(Type.BOOLEAN); // Reduced debug info
map(Type.BOOLEAN); // Show death screen map(Type.BOOLEAN); // Show death screen
map(Type.BOOLEAN); // Limited crafting map(Type.BOOLEAN); // Limited crafting
map(Type.STRING); // Dimension key handler(wrapper -> {
final String dimensionKey = wrapper.read(Type.STRING);
final DimensionData data = tracker(wrapper.user()).dimensionData(dimensionKey);
wrapper.write(Type.VAR_INT, data.id());
});
map(Type.STRING); // World map(Type.STRING); // World
map(Type.LONG); // Seed map(Type.LONG); // Seed
map(Type.BYTE); // Gamemode map(Type.BYTE); // Gamemode
@ -73,16 +109,20 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
map(Type.BOOLEAN); // Flat map(Type.BOOLEAN); // Flat
map(Type.OPTIONAL_GLOBAL_POSITION); // Last death location map(Type.OPTIONAL_GLOBAL_POSITION); // Last death location
create(Type.BOOLEAN, false); // Enforces secure chat - moved from server data (which is unfortunately sent a while after this) create(Type.BOOLEAN, false); // Enforces secure chat - moved from server data (which is unfortunately sent a while after this)
handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking handler(worldDataTrackerHandlerByKey1_20_5(3)); // Tracks world height and name for chunk data and entity (un)tracking
} }
}); });
protocol.registerClientbound(ClientboundPackets1_20_3.RESPAWN, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_20_3.RESPAWN, new PacketHandlers() {
@Override @Override
public void register() { public void register() {
map(Type.STRING); // Dimension handler(wrapper -> {
final String dimensionKey = wrapper.read(Type.STRING);
final DimensionData data = tracker(wrapper.user()).dimensionData(dimensionKey);
wrapper.write(Type.VAR_INT, data.id());
});
map(Type.STRING); // World map(Type.STRING); // World
handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking handler(worldDataTrackerHandlerByKey1_20_5(0)); // Tracks world height and name for chunk data and entity (un)tracking
} }
}); });

Datei anzeigen

@ -20,8 +20,8 @@ package com.viaversion.viaversion.rewriter;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag; import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag; import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
import com.github.steveice10.opennbt.tag.builtin.Tag; import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.google.common.base.Function;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.connection.UserConnection;
@ -32,6 +32,7 @@ import com.viaversion.viaversion.api.data.entity.DimensionData;
import com.viaversion.viaversion.api.data.entity.EntityTracker; import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.data.entity.TrackedEntity; import com.viaversion.viaversion.api.data.entity.TrackedEntity;
import com.viaversion.viaversion.api.minecraft.Particle; import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType; import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
@ -46,6 +47,7 @@ import com.viaversion.viaversion.data.entity.DimensionDataImpl;
import com.viaversion.viaversion.rewriter.meta.MetaFilter; import com.viaversion.viaversion.rewriter.meta.MetaFilter;
import com.viaversion.viaversion.rewriter.meta.MetaHandlerEvent; import com.viaversion.viaversion.rewriter.meta.MetaHandlerEvent;
import com.viaversion.viaversion.rewriter.meta.MetaHandlerEventImpl; import com.viaversion.viaversion.rewriter.meta.MetaHandlerEventImpl;
import com.viaversion.viaversion.util.Key;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
@ -440,6 +442,29 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
}; };
} }
public PacketHandler worldDataTrackerHandlerByKey1_20_5(final int dimensionIdIndex) {
return wrapper -> {
EntityTracker tracker = tracker(wrapper.user());
int dimensionId = wrapper.get(Type.VAR_INT, dimensionIdIndex);
DimensionData dimensionData = tracker.dimensionData(dimensionId);
if (dimensionData == null) {
Via.getPlatform().getLogger().severe("Dimension data missing for dimension: " + dimensionId + ", falling back to overworld");
dimensionData = tracker.dimensionData("minecraft:overworld");
Preconditions.checkNotNull(dimensionData, "Overworld data missing");
}
tracker.setCurrentWorldSectionHeight(dimensionData.height() >> 4);
tracker.setCurrentMinY(dimensionData.minY());
String world = wrapper.get(Type.STRING, 0);
if (tracker.currentWorld() != null && !tracker.currentWorld().equals(world)) {
tracker.clearEntities();
tracker.trackClientEntity();
}
tracker.setCurrentWorld(world);
};
}
public PacketHandler biomeSizeTracker() { public PacketHandler biomeSizeTracker() {
return wrapper -> trackBiomeSize(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 0)); return wrapper -> trackBiomeSize(wrapper.user(), wrapper.get(Type.NAMED_COMPOUND_TAG, 0));
} }
@ -470,13 +495,32 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size()); final Map<String, DimensionData> dimensionDataMap = new HashMap<>(dimensions.size());
for (final Tag dimension : dimensions) { for (final Tag dimension : dimensions) {
final CompoundTag dimensionCompound = (CompoundTag) dimension; final CompoundTag dimensionCompound = (CompoundTag) dimension;
final NumberTag idTag = dimensionCompound.get("id");
final CompoundTag element = dimensionCompound.get("element"); final CompoundTag element = dimensionCompound.get("element");
final String name = (String) dimensionCompound.get("name").getValue(); final String name = (String) dimensionCompound.get("name").getValue();
dimensionDataMap.put(name, new DimensionDataImpl(element)); dimensionDataMap.put(Key.stripMinecraftNamespace(name), new DimensionDataImpl(idTag.asInt(), element));
} }
tracker(connection).setDimensions(dimensionDataMap); tracker(connection).setDimensions(dimensionDataMap);
} }
public PacketHandler registryDataHandler1_20_5() {
return wrapper -> {
final String registryKey = Key.stripMinecraftNamespace(wrapper.get(Type.STRING, 0));
if (registryKey.equals("worldgen/biome")) {
final RegistryEntry[] entries = wrapper.get(Type.REGISTRY_ENTRY_ARRAY, 0);
tracker(wrapper.user()).setBiomesSent(entries.length);
} else if (registryKey.equals("dimension_type")) {
final RegistryEntry[] entries = wrapper.get(Type.REGISTRY_ENTRY_ARRAY, 0);
final Map<String, DimensionData> dimensionDataMap = new HashMap<>(entries.length);
for (int i = 0; i < entries.length; i++) {
final RegistryEntry entry = entries[i];
dimensionDataMap.put(entry.key(), new DimensionDataImpl(i, (CompoundTag) entry.tag()));
}
tracker(wrapper.user()).setDimensions(dimensionDataMap);
}
};
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Sub 1.14.1 methods // Sub 1.14.1 methods

Datei anzeigen

@ -1,5 +1,5 @@
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts # Project properties - we put these here so they can be modified without causing a recompile of the build scripts
projectVersion=4.10.0-24w03b-SNAPSHOT projectVersion=4.10.0-24w04a-SNAPSHOT
# Smile emoji # Smile emoji
mcVersions=1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9 mcVersions=1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9

Datei anzeigen

@ -47,9 +47,9 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
protocol.registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.REGISTRY_DATA, new PacketHandlers() { protocol.registerClientbound(State.CONFIGURATION, ClientboundConfigurationPackets1_20_3.REGISTRY_DATA, new PacketHandlers() {
@Override @Override
protected void register() { protected void register() {
map(Type.COMPOUND_TAG); // Registry data map(Type.STRING); // Registry
handler(configurationDimensionDataHandler()); // Caches dimensions to access data like height later map(Type.REGISTRY_ENTRY_ARRAY); // Data
handler(configurationBiomeSizeTracker()); // Tracks the amount of biomes sent for chunk data handler(registryDataHandler1_20_5()); // Caches dimensions to access data like height later and tracks the amount of biomes sent for chunk data
} }
}); });
@ -65,18 +65,18 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
map(Type.BOOLEAN); // Reduced debug info map(Type.BOOLEAN); // Reduced debug info
map(Type.BOOLEAN); // Show death screen map(Type.BOOLEAN); // Show death screen
map(Type.BOOLEAN); // Limited crafting map(Type.BOOLEAN); // Limited crafting
map(Type.STRING); // Dimension key map(Type.VAR_INT); // Dimension id
map(Type.STRING); // World map(Type.STRING); // World
handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking handler(worldDataTrackerHandlerByKey1_20_5(3)); // Tracks world height and name for chunk data and entity (un)tracking
} }
}); });
protocol.registerClientbound(ClientboundPackets1_20_5.RESPAWN, new PacketHandlers() { protocol.registerClientbound(ClientboundPackets1_20_5.RESPAWN, new PacketHandlers() {
@Override @Override
public void register() { public void register() {
map(Type.STRING); // Dimension map(Type.VAR_INT); // Dimension
map(Type.STRING); // World map(Type.STRING); // World
handler(worldDataTrackerHandlerByKey()); // Tracks world height and name for chunk data and entity (un)tracking handler(worldDataTrackerHandlerByKey1_20_5(0)); // Tracks world height and name for chunk data and entity (un)tracking
} }
}); });
} }