3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 09:00:09 +01:00
Dieser Commit ist enthalten in:
KennyTV 2020-06-10 19:34:22 +02:00
Ursprung 029f399a14
Commit e1b2702231
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
5 geänderte Dateien mit 97 neuen und 45 gelöschten Zeilen

Datei anzeigen

@ -80,7 +80,7 @@ public class ProtocolVersion {
register(v1_15 = new ProtocolVersion(573, "1.15")); register(v1_15 = new ProtocolVersion(573, "1.15"));
register(v1_15_1 = new ProtocolVersion(575, "1.15.1")); register(v1_15_1 = new ProtocolVersion(575, "1.15.1"));
register(v1_15_2 = new ProtocolVersion(578, "1.15.2")); register(v1_15_2 = new ProtocolVersion(578, "1.15.2"));
register(v1_16 = new ProtocolVersion(722, "1.16")); register(v1_16 = new ProtocolVersion(725, "1.16"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN")); register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
} }

Datei anzeigen

@ -10,7 +10,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class TagRewriter { public class TagRewriter {
public static final int[] EMPTY_ARRAY = {}; private static final int[] EMPTY_ARRAY = {-1};
private final Protocol protocol; private final Protocol protocol;
private final IdRewriteFunction blockRewriter; private final IdRewriteFunction blockRewriter;
private final IdRewriteFunction itemRewriter; private final IdRewriteFunction itemRewriter;
@ -26,6 +26,9 @@ public class TagRewriter {
this.entityRewriter = entityRewriter; this.entityRewriter = entityRewriter;
} }
/**
* Adds an empty tag (since the client crashes if a checked tag is not registered.)
*/
public void addEmptyTag(TagType tagType, String id) { public void addEmptyTag(TagType tagType, String id) {
getNewTags(tagType).add(new TagData(id, EMPTY_ARRAY)); getNewTags(tagType).add(new TagData(id, EMPTY_ARRAY));
} }

Datei anzeigen

@ -104,6 +104,29 @@ public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, Clien
} }
}); });
registerIncoming(ServerboundPackets1_16.INTERACT_ENTITY, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
wrapper.passthrough(Type.VAR_INT); // Entity Id
int action = wrapper.passthrough(Type.VAR_INT);
if (action == 0 || action == 2) {
if (action == 2) {
// Location
wrapper.passthrough(Type.FLOAT);
wrapper.passthrough(Type.FLOAT);
wrapper.passthrough(Type.FLOAT);
}
wrapper.passthrough(Type.VAR_INT); // Hand
// New boolean: Whether the client is sneaking/pressing shift
wrapper.read(Type.BOOLEAN);
}
});
}
});
cancelIncoming(ServerboundPackets1_16.GENERATE_JIGSAW); cancelIncoming(ServerboundPackets1_16.GENERATE_JIGSAW);
cancelIncoming(ServerboundPackets1_16.UPDATE_JIGSAW_BLOCK); cancelIncoming(ServerboundPackets1_16.UPDATE_JIGSAW_BLOCK);
} }
@ -164,7 +187,8 @@ public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, Clien
@Override @Override
public void init(UserConnection userConnection) { public void init(UserConnection userConnection) {
userConnection.put(new EntityTracker1_16(userConnection)); userConnection.put(new EntityTracker1_16(userConnection));
if (!userConnection.has(ClientWorld.class)) if (!userConnection.has(ClientWorld.class)) {
userConnection.put(new ClientWorld(userConnection)); userConnection.put(new ClientWorld(userConnection));
}
} }
} }

Datei anzeigen

@ -3,15 +3,14 @@ package us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets;
import com.github.steveice10.opennbt.tag.builtin.ByteTag; import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.FloatTag; 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.ListTag;
import com.github.steveice10.opennbt.tag.builtin.LongTag; import com.github.steveice10.opennbt.tag.builtin.LongTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag; import com.github.steveice10.opennbt.tag.builtin.StringTag;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.entities.Entity1_16Types; import us.myles.ViaVersion.api.entities.Entity1_16Types;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_14; import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15; import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
@ -53,6 +52,7 @@ public class EntityPackets {
static { static {
ListTag list = new ListTag("dimension", CompoundTag.class); ListTag list = new ListTag("dimension", CompoundTag.class);
list.add(createOverworldEntry()); list.add(createOverworldEntry());
list.add(createOverworldCavesEntry());
list.add(createNetherEntry()); list.add(createNetherEntry());
list.add(createEndEntry()); list.add(createEndEntry());
DIMENSIONS_TAG.put(list); DIMENSIONS_TAG.put(list);
@ -60,45 +60,69 @@ public class EntityPackets {
private static CompoundTag createOverworldEntry() { private static CompoundTag createOverworldEntry() {
CompoundTag tag = new CompoundTag(""); CompoundTag tag = new CompoundTag("");
tag.put(new StringTag("key", "minecraft:overworld")); tag.put(new StringTag("name", "minecraft:overworld"));
CompoundTag elementTag = new CompoundTag("element"); tag.put(new ByteTag("has_ceiling", (byte) 0));
elementTag.put(new ByteTag("natural", (byte) 1)); addSharedOverwaldEntries(tag);
elementTag.put(new FloatTag("ambient_light", 0));
elementTag.put(new ByteTag("shrunk", (byte) 0));
elementTag.put(new ByteTag("ultrawarm", (byte) 0));
elementTag.put(new ByteTag("has_ceiling", (byte) 0));
elementTag.put(new ByteTag("has_skylight", (byte) 1));
tag.put(elementTag);
return tag; return tag;
} }
private static CompoundTag createOverworldCavesEntry() {
CompoundTag tag = new CompoundTag("");
tag.put(new StringTag("name", "minecraft:overworld_caves"));
tag.put(new ByteTag("has_ceiling", (byte) 1));
addSharedOverwaldEntries(tag);
return tag;
}
private static void addSharedOverwaldEntries(CompoundTag tag) {
tag.put(new ByteTag("piglin_safe", (byte) 0));
tag.put(new ByteTag("natural", (byte) 1));
tag.put(new FloatTag("ambient_light", 0));
tag.put(new StringTag("infiniburn", "minecraft:infiniburn_overworld"));
tag.put(new ByteTag("respawn_anchor_works", (byte) 0));
tag.put(new ByteTag("has_skylight", (byte) 1));
tag.put(new ByteTag("bed_works", (byte) 1));
tag.put(new ByteTag("has_raids", (byte) 1));
tag.put(new IntTag("logical_height", 256));
tag.put(new ByteTag("shrunk", (byte) 0));
tag.put(new ByteTag("ultrawarm", (byte) 0));
}
private static CompoundTag createNetherEntry() { private static CompoundTag createNetherEntry() {
CompoundTag tag = new CompoundTag(""); CompoundTag tag = new CompoundTag("");
tag.put(new StringTag("key", "minecraft:the_nether")); tag.put(new ByteTag("piglin_safe", (byte) 1));
CompoundTag elementTag = new CompoundTag("element"); tag.put(new ByteTag("natural", (byte) 0));
elementTag.put(new ByteTag("natural", (byte) 0)); tag.put(new FloatTag("ambient_light", 0.1F));
elementTag.put(new LongTag("fixed_time", 18000)); tag.put(new StringTag("infiniburn", "minecraft:infiniburn_nether"));
elementTag.put(new FloatTag("ambient_light", 0.1F)); tag.put(new ByteTag("respawn_anchor_works", (byte) 1));
elementTag.put(new ByteTag("shrunk", (byte) 1)); tag.put(new ByteTag("has_skylight", (byte) 0));
elementTag.put(new ByteTag("ultrawarm", (byte) 1)); tag.put(new ByteTag("bed_works", (byte) 0));
elementTag.put(new ByteTag("has_ceiling", (byte) 1)); tag.put(new LongTag("fixed_time", 18000));
elementTag.put(new ByteTag("has_skylight", (byte) 0)); tag.put(new ByteTag("has_raids", (byte) 0));
tag.put(elementTag); tag.put(new StringTag("name", "minecraft:the_nether"));
tag.put(new IntTag("logical_height", 128));
tag.put(new ByteTag("shrunk", (byte) 1));
tag.put(new ByteTag("ultrawarm", (byte) 1));
tag.put(new ByteTag("has_ceiling", (byte) 1));
return tag; return tag;
} }
private static CompoundTag createEndEntry() { private static CompoundTag createEndEntry() {
CompoundTag tag = new CompoundTag(""); CompoundTag tag = new CompoundTag("");
tag.put(new StringTag("key", "minecraft:the_end")); tag.put(new ByteTag("piglin_safe", (byte) 0));
CompoundTag elementTag = new CompoundTag("element"); tag.put(new ByteTag("natural", (byte) 0));
elementTag.put(new ByteTag("natural", (byte) 0)); tag.put(new FloatTag("ambient_light", 0));
elementTag.put(new LongTag("fixed_time", 6000)); tag.put(new StringTag("infiniburn", "minecraft:infiniburn_end"));
elementTag.put(new FloatTag("ambient_light", 0)); tag.put(new ByteTag("respawn_anchor_works", (byte) 0));
elementTag.put(new ByteTag("shrunk", (byte) 0)); tag.put(new ByteTag("has_skylight", (byte) 0));
elementTag.put(new ByteTag("ultrawarm", (byte) 0)); tag.put(new ByteTag("bed_works", (byte) 0));
elementTag.put(new ByteTag("has_ceiling", (byte) 0)); tag.put(new LongTag("fixed_time", 6000));
elementTag.put(new ByteTag("has_skylight", (byte) 0)); tag.put(new ByteTag("has_raids", (byte) 1));
tag.put(elementTag); tag.put(new StringTag("name", "minecraft:the_end"));
tag.put(new IntTag("logical_height", 256));
tag.put(new ByteTag("shrunk", (byte) 0));
tag.put(new ByteTag("ultrawarm", (byte) 0));
tag.put(new ByteTag("has_ceiling", (byte) 0));
return tag; return tag;
} }
@ -161,17 +185,9 @@ public class EntityPackets {
public void registerMap() { public void registerMap() {
map(Type.INT); // Entity ID map(Type.INT); // Entity ID
map(Type.UNSIGNED_BYTE); // Gamemode map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.NOTHING, new ValueTransformer<Void, String[]>(Type.STRING_ARRAY) { // World list - only used for command completion handler(wrapper -> {
@Override wrapper.write(Type.STRING_ARRAY, WORLD_NAMES); // World list - only used for command completion
public String[] transform(PacketWrapper wrapper, Void input) throws Exception { wrapper.write(Type.NBT, DIMENSIONS_TAG); // Dimension registry
return WORLD_NAMES;
}
});
map(Type.NOTHING, new ValueTransformer<Void, CompoundTag>(Type.NBT) { // whatever this is
@Override
public CompoundTag transform(PacketWrapper wrapper, Void input) throws Exception {
return DIMENSIONS_TAG;
}
}); });
handler(DIMENSION_HANDLER); // Dimension handler(DIMENSION_HANDLER); // Dimension
map(Type.LONG); // Seed map(Type.LONG); // Seed

Datei anzeigen

@ -31,6 +31,15 @@ public class WorldPackets {
blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE); blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING); blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING);
protocol.registerOutgoing(ClientboundPackets1_15.UPDATE_LIGHT, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // x
map(Type.VAR_INT); // y
handler(wrapper -> wrapper.write(Type.BOOLEAN, true)); // Take neighbour's light into account as well
}
});
protocol.registerOutgoing(ClientboundPackets1_15.CHUNK_DATA, new PacketRemapper() { protocol.registerOutgoing(ClientboundPackets1_15.CHUNK_DATA, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {