Merge pull request #109 from ForceUpdate1/1.14

[WIP] Add 1.14.x support, some 1.13.x fixes
This commit is contained in:
Mats 2019-06-29 15:12:36 +02:00 committed by GitHub
commit ff1bf45fd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 4370 additions and 219 deletions

View File

@ -15,7 +15,7 @@
<parent> <parent>
<artifactId>viabackwards-parent</artifactId> <artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId> <groupId>nl.matsv</groupId>
<version>3.0.0-19w11b</version> <version>3.0.0-1.14.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -44,6 +44,34 @@
<configuration> <configuration>
<createDependencyReducedPom>false</createDependencyReducedPom> <createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>false</minimizeJar> <minimizeJar>false</minimizeJar>
<relocations>
<relocation>
<pattern>com.github.steveice10.opennbt</pattern>
<shadedPattern>us.myles.viaversion.libs.opennbt</shadedPattern>
</relocation>
<relocation>
<pattern>com.google.gson</pattern>
<shadedPattern>us.myles.viaversion.libs.gson</shadedPattern>
</relocation>
<relocation>
<pattern>javassist</pattern>
<shadedPattern>us.myles.viaversion.libs.javassist</shadedPattern>
</relocation>
<relocation>
<pattern>org.yaml.snakeyaml</pattern>
<shadedPattern>us.myles.viaversion.libs.snakeyaml</shadedPattern>
</relocation>
<relocation>
<pattern>net.md_5.bungee</pattern>
<shadedPattern>us.myles.viaversion.libs.bungeecordchat</shadedPattern>
<includes>
<include>net.md_5.bungee.api.chat.**</include>
<include>net.md_5.bungee.api.ChatColor</include>
<include>net.md_5.bungee.api.ChatMessageType</include>
<include>net.md_5.bungee.chat.**</include>
</includes>
</relocation>
</relocations>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
@ -76,6 +104,12 @@
<version>${project.parent.version}</version> <version>${project.parent.version}</version>
</dependency> </dependency>
<dependency>
<groupId>nl.matsv</groupId>
<artifactId>viabackwards-fabric</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency> <dependency>
<groupId>nl.matsv</groupId> <groupId>nl.matsv</groupId>
<artifactId>viabackwards-sponge</artifactId> <artifactId>viabackwards-sponge</artifactId>

View File

@ -15,7 +15,7 @@
<parent> <parent>
<artifactId>viabackwards-parent</artifactId> <artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId> <groupId>nl.matsv</groupId>
<version>3.0.0-19w11b</version> <version>3.0.0-1.14.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -1,6 +1,6 @@
name: ViaBackwards name: ViaBackwards
version: ${project.version} version: ${project.version}
description: Allows 1.9.x on a 1.10 Spigot server description: Allow older Minecraft versions to connect to a newer server version.
main: nl.matsv.viabackwards.BukkitPlugin main: nl.matsv.viabackwards.BukkitPlugin
authors: [Matsv] authors: [Matsv]

View File

@ -15,7 +15,7 @@
<parent> <parent>
<artifactId>viabackwards-parent</artifactId> <artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId> <groupId>nl.matsv</groupId>
<version>3.0.0-19w11b</version> <version>3.0.0-1.14.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -15,7 +15,7 @@
<parent> <parent>
<artifactId>viabackwards-parent</artifactId> <artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId> <groupId>nl.matsv</groupId>
<version>3.0.0-19w11b</version> <version>3.0.0-1.14.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -20,6 +20,9 @@ import nl.matsv.viabackwards.protocol.protocol1_12to1_12_1.Protocol1_12To1_12_1;
import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2; import nl.matsv.viabackwards.protocol.protocol1_13_1to1_13_2.Protocol1_13_1To1_13_2;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1; import nl.matsv.viabackwards.protocol.protocol1_13to1_13_1.Protocol1_13To1_13_1;
import nl.matsv.viabackwards.protocol.protocol1_14_1to1_14_2.Protocol1_14_1To1_14_2;
import nl.matsv.viabackwards.protocol.protocol1_14_2to1_14_3.Protocol1_14_2To1_14_3;
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.Protocol1_14To1_14_1;
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10; import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.api.protocol.ProtocolVersion; import us.myles.ViaVersion.api.protocol.ProtocolVersion;
@ -46,6 +49,9 @@ public interface ViaBackwardsPlatform {
ProtocolRegistry.registerProtocol(new Protocol1_13To1_13_1(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_13_1.getId()); ProtocolRegistry.registerProtocol(new Protocol1_13To1_13_1(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_13_1.getId());
ProtocolRegistry.registerProtocol(new Protocol1_13_1To1_13_2(), Collections.singletonList(ProtocolVersion.v1_13_1.getId()), ProtocolVersion.v1_13_2.getId()); ProtocolRegistry.registerProtocol(new Protocol1_13_1To1_13_2(), Collections.singletonList(ProtocolVersion.v1_13_1.getId()), ProtocolVersion.v1_13_2.getId());
ProtocolRegistry.registerProtocol(new Protocol1_13_2To1_14(), Collections.singletonList(ProtocolVersion.v1_13_2.getId()), ProtocolVersion.v1_14.getId()); ProtocolRegistry.registerProtocol(new Protocol1_13_2To1_14(), Collections.singletonList(ProtocolVersion.v1_13_2.getId()), ProtocolVersion.v1_14.getId());
ProtocolRegistry.registerProtocol(new Protocol1_14To1_14_1(), Collections.singletonList(ProtocolVersion.v1_14.getId()), ProtocolVersion.v1_14_1.getId());
ProtocolRegistry.registerProtocol(new Protocol1_14_1To1_14_2(), Collections.singletonList(ProtocolVersion.v1_14_1.getId()), ProtocolVersion.v1_14_2.getId());
ProtocolRegistry.registerProtocol(new Protocol1_14_2To1_14_3(), Collections.singletonList(ProtocolVersion.v1_14_2.getId()), ProtocolVersion.v1_14_3.getId());
} }
} }

View File

@ -286,7 +286,8 @@ public class EntityType1_13 {
EVOCATION_FANGS(79, EntityType.EVOCATION_FANGS), EVOCATION_FANGS(79, EntityType.EVOCATION_FANGS),
FISHIHNG_HOOK(90, EntityType.FISHING_BOBBER), FISHIHNG_HOOK(90, EntityType.FISHING_BOBBER),
SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW), SPECTRAL_ARROW(91, EntityType.SPECTRAL_ARROW),
DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL); DRAGON_FIREBALL(93, EntityType.DRAGON_FIREBALL),
TRIDENT(94, EntityType.TRIDENT);
private final int id; private final int id;
private final EntityType type; private final EntityType type;
@ -307,5 +308,12 @@ public class EntityType1_13 {
return output.map(ObjectType::getType); return output.map(ObjectType::getType);
} }
public static Optional<ObjectType> fromEntityType(EntityType type) {
for (ObjectType ent : ObjectType.values())
if (ent.getType() == type)
return Optional.of(ent);
return Optional.empty();
}
} }
} }

View File

@ -2,7 +2,7 @@ package nl.matsv.viabackwards.api.entities.types;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import us.myles.ViaVersion.api.Via; import nl.matsv.viabackwards.ViaBackwards;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -13,7 +13,7 @@ public class EntityType1_14 {
Optional<EntityType> type = EntityType.findById(typeID); Optional<EntityType> type = EntityType.findById(typeID);
if (!type.isPresent()) { if (!type.isPresent()) {
Via.getPlatform().getLogger().severe("Could not find type id " + typeID); ViaBackwards.getPlatform().getLogger().severe("Could not find type id " + typeID);
return EntityType.ENTITY; // Fall back to the basic ENTITY return EntityType.ENTITY; // Fall back to the basic ENTITY
} }
@ -59,6 +59,7 @@ public class EntityType1_14 {
CHICKEN(8, ABSTRACT_ANIMAL), CHICKEN(8, ABSTRACT_ANIMAL),
COW(10, ABSTRACT_ANIMAL), COW(10, ABSTRACT_ANIMAL),
MOOSHROOM(49, COW), MOOSHROOM(49, COW),
PANDA(52, ABSTRACT_INSENTIENT),
PIG(54, ABSTRACT_ANIMAL), PIG(54, ABSTRACT_ANIMAL),
POLAR_BEAR(57, ABSTRACT_ANIMAL), POLAR_BEAR(57, ABSTRACT_ANIMAL),
RABBIT(59, ABSTRACT_ANIMAL), RABBIT(59, ABSTRACT_ANIMAL),

View File

@ -88,8 +88,9 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
} }
protected Item handleItemToServer(Item item) { protected Item handleItemToServer(Item item) {
if (item == null || item.getTag() == null) if (item == null) return null;
return null; if (item.getTag() == null) return item;
CompoundTag tag = item.getTag(); CompoundTag tag = item.getTag();
if (tag.contains("ViaBackwards|" + getProtocolName())) { if (tag.contains("ViaBackwards|" + getProtocolName())) {
CompoundTag via = tag.get("ViaBackwards|" + getProtocolName()); CompoundTag via = tag.get("ViaBackwards|" + getProtocolName());

View File

@ -30,6 +30,7 @@ import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
import us.myles.ViaVersion.exception.CancelException; import us.myles.ViaVersion.exception.CancelException;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -51,6 +52,9 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
@Getter(AccessLevel.PROTECTED) @Getter(AccessLevel.PROTECTED)
@Setter(AccessLevel.PROTECTED) @Setter(AccessLevel.PROTECTED)
private int displayNameIndex = 2; private int displayNameIndex = 2;
@Getter(AccessLevel.PROTECTED)
@Setter(AccessLevel.PROTECTED)
private boolean isDisplayNameJson = false;
protected AbstractEntityType getEntityType(UserConnection connection, int id) { protected AbstractEntityType getEntityType(UserConnection connection, int id) {
return getEntityTracker(connection).getEntityType(id); return getEntityTracker(connection).getEntityType(id);
@ -149,7 +153,11 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
if (entData.getMobName() != null && if (entData.getMobName() != null &&
(data.getValue() == null || ((String) data.getValue()).isEmpty()) && (data.getValue() == null || ((String) data.getValue()).isEmpty()) &&
data.getMetaType().getTypeID() == getDisplayNameMetaType().getTypeID()) { data.getMetaType().getTypeID() == getDisplayNameMetaType().getTypeID()) {
data.setValue(entData.getMobName()); String mobName = entData.getMobName();
if (isDisplayNameJson) {
mobName = ChatRewriter.legacyTextToJson(mobName);
}
data.setValue(mobName);
} }
} }

View File

@ -20,7 +20,7 @@ import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1; import us.myles.ViaVersion.protocols.protocol1_12to1_11_1.Protocol1_12To1_11_1;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
@Getter @Getter
@Setter @Setter
@ -37,7 +37,7 @@ public class ShoulderTracker extends StoredObject {
public void update() { public void update() {
PacketWrapper wrapper = new PacketWrapper(0x0F, null, getUser()); PacketWrapper wrapper = new PacketWrapper(0x0F, null, getUser());
wrapper.write(Type.STRING, Protocol1_9TO1_8.fixJson(generateString())); wrapper.write(Type.STRING, Protocol1_9To1_8.fixJson(generateString()));
wrapper.write(Type.BYTE, (byte) 2); wrapper.write(Type.BYTE, (byte) 2);
try { try {

View File

@ -27,6 +27,7 @@ import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type; import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag; import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import us.myles.viaversion.libs.opennbt.tag.builtin.DoubleTag;
import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag; import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
import java.util.Collections; import java.util.Collections;
@ -172,6 +173,24 @@ public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
if (wrapper.get(Type.VAR_INT, 0) == 1) { // Shift click
// https://github.com/ViaVersion/ViaVersion/pull/754
// Previously clients grab the item from the clicked slot *before* it has
// been moved however now they grab the slot item *after* it has been moved
// and send that in the packet.
wrapper.set(Type.ITEM, 0, null); // Set null item (probably will work)
// Apologize (may happen in some cases, maybe if inventory is full?)
PacketWrapper confirm = wrapper.create(0x6);
confirm.write(Type.BYTE, wrapper.get(Type.UNSIGNED_BYTE, 0).byteValue());
confirm.write(Type.SHORT, wrapper.get(Type.SHORT, 1));
confirm.write(Type.BOOLEAN, false); // Success - not used
wrapper.sendToServer(Protocol1_11_1To1_12.class, true, true);
wrapper.cancel();
confirm.sendToServer(Protocol1_11_1To1_12.class, true, true);
return;
}
Item item = wrapper.get(Type.ITEM, 0); Item item = wrapper.get(Type.ITEM, 0);
handleItemToServer(item); handleItemToServer(item);
} }

View File

@ -31,7 +31,7 @@ public class BackwardsMappings {
us.myles.viaversion.libs.gson.JsonObject mapping1_13 = MappingData.loadData("mapping-1.13.json"); us.myles.viaversion.libs.gson.JsonObject mapping1_13 = MappingData.loadData("mapping-1.13.json");
us.myles.viaversion.libs.gson.JsonObject mapping1_12_2to1_13 = loadData("mapping-1.12.2to1.13.json"); us.myles.viaversion.libs.gson.JsonObject mapping1_12_2to1_13 = loadData("mapping-1.12.2to1.13.json");
ViaBackwards.getPlatform().getLogger().info("Loading block mapping..."); ViaBackwards.getPlatform().getLogger().info("Loading 1.13 -> 1.12.2 block mapping...");
blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates")); blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates"));
} }

View File

@ -39,6 +39,6 @@ public class SoundMapping {
} }
public static int getOldSound(int newSound) { public static int getOldSound(int newSound) {
return newSound >= sounds.length ? -1 : sounds[newSound]; return newSound < 0 || newSound >= sounds.length ? -1 : sounds[newSound];
} }
} }

View File

@ -76,7 +76,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
@Override @Override
protected void registerPackets(Protocol1_12_2To1_13 protocol) { protected void registerPackets(Protocol1_12_2To1_13 protocol) {
NBT_TAG_NAME = "ViaBackwards|" + protocol.getClass().getSimpleName(); NBT_TAG_NAME = "ViaBackwards|" + protocol.getClass().getSimpleName() + "|Part2";
// Block Action // Block Action
protocol.out(State.PLAY, 0x0A, 0x0A, new PacketRemapper() { protocol.out(State.PLAY, 0x0A, 0x0A, new PacketRemapper() {
@Override @Override
@ -382,7 +382,10 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
if (wrapper.read(Type.BOOLEAN)) { if (wrapper.read(Type.BOOLEAN)) {
wrapper.read(Type.STRING); wrapper.read(Type.STRING);
} }
if (type > 9) continue; if (type > 9) {
wrapper.set(Type.VAR_INT, 1, wrapper.get(Type.VAR_INT, 1) - 1);
continue;
}
wrapper.write(Type.BYTE, (byte) ((type << 4) | (direction & 0x0F))); wrapper.write(Type.BYTE, (byte) ((type << 4) | (direction & 0x0F)));
wrapper.write(Type.BYTE, x); wrapper.write(Type.BYTE, x);
wrapper.write(Type.BYTE, z); wrapper.write(Type.BYTE, z);
@ -458,11 +461,11 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
rewrite(244).repItem(new Item((short) 241, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Button"))); rewrite(244).repItem(new Item((short) 241, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Button")));
rewrite(246).repItem(new Item((short) 241, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Button"))); rewrite(246).repItem(new Item((short) 241, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Button")));
rewrite(191).repItem(new Item((short) 160, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Trapdoor"))); rewrite(191).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Trapdoor")));
rewrite(189).repItem(new Item((short) 160, (byte) 1, (short) -1, getNamedTag("1.13 Birch Trapdoor"))); rewrite(189).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Birch Trapdoor")));
rewrite(188).repItem(new Item((short) 160, (byte) 1, (short) -1, getNamedTag("1.13 Spruce Trapdoor"))); rewrite(188).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Spruce Trapdoor")));
rewrite(190).repItem(new Item((short) 160, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Trapdoor"))); rewrite(190).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Jungle Trapdoor")));
rewrite(192).repItem(new Item((short) 160, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Trapdoor"))); rewrite(192).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Dark Oak Trapdoor")));
rewrite(164).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Pressure Plate"))); rewrite(164).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Acacia Pressure Plate")));
rewrite(162).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Birch Pressure Plate"))); rewrite(162).repItem(new Item((short) 187, (byte) 1, (short) -1, getNamedTag("1.13 Birch Pressure Plate")));
@ -487,6 +490,12 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
rewrite(783).repItem(new Item((short) 587, (byte) 1, (short) -1, getNamedTag("1.13 Nautilus Shell"))); rewrite(783).repItem(new Item((short) 587, (byte) 1, (short) -1, getNamedTag("1.13 Nautilus Shell")));
rewrite(782).repItem(new Item((short) 545, (byte) 1, (short) -1, getNamedTag("1.13 Phantom Membrane"))); rewrite(782).repItem(new Item((short) 545, (byte) 1, (short) -1, getNamedTag("1.13 Phantom Membrane")));
rewrite(465).repItem(new Item((short) 510, (byte) 1, (short) -1, getNamedTag("1.13 Turtle Shell"))); rewrite(465).repItem(new Item((short) 510, (byte) 1, (short) -1, getNamedTag("1.13 Turtle Shell")));
rewrite(427).repItem(new Item((short) 561, (byte) 1, (short) -1, getNamedTag("1.13 Turtle Egg")));
rewrite(466).repItem(new Item((short) 582, (byte) 1, (short) -1, getNamedTag("1.13 Scute")));
rewrite(781).repItem(new Item((short) 488, (byte) 1, (short) -1, getNamedTag("1.13 Trident")));
rewrite(80).repItem(new Item((short) 561, (byte) 1, (short) -1, getNamedTag("1.13 Sea Pickle")));
rewrite(79).repItem(new Item((short) 76, (byte) 1, (short) -1, getNamedTag("1.13 Seagrass")));
rewrite(454).repItem(new Item((short) 238, (byte) 1, (short) -1, getNamedTag("1.13 Conduit")));
rewrite(554).repItem(new Item((short) 76, (byte) 1, (short) -1, getNamedTag("1.13 Kelp"))); rewrite(554).repItem(new Item((short) 76, (byte) 1, (short) -1, getNamedTag("1.13 Kelp")));
rewrite(611).repItem(new Item((short) 508, (byte) 1, (short) -1, getNamedTag("1.13 Dried Kelp"))); rewrite(611).repItem(new Item((short) 508, (byte) 1, (short) -1, getNamedTag("1.13 Dried Kelp")));
@ -562,12 +571,15 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
rewrite(437).repItem(new Item((short) 86, (byte) 1, (short) -1, getNamedTag("1.13 Horn Coral Block"))); rewrite(437).repItem(new Item((short) 86, (byte) 1, (short) -1, getNamedTag("1.13 Horn Coral Block")));
// Coral End // Coral End
rewrite(131).repItem(new Item((short) 711, (byte) 1, (short) -1, getNamedTag("1.13 Smooth Quartz")));
rewrite(132).repItem(new Item((short) 350, (byte) 1, (short) -1, getNamedTag("1.13 Smooth Red Sandstone")));
rewrite(133).repItem(new Item((short) 68, (byte) 1, (short) -1, getNamedTag("1.13 Smooth Sandstone")));
rewrite(134).repItem(new Item((short) 118, (byte) 1, (short) -1, getNamedTag("1.13 Smooth Stone")));
rewrite(181).repItem(new Item((short) 182, (byte) 1, (short) -1, getNamedTag("1.13 Carved Pumpkin"))); rewrite(181).repItem(new Item((short) 182, (byte) 1, (short) -1, getNamedTag("1.13 Carved Pumpkin")));
rewrite(427).repItem(new Item((short) 561, (byte) 1, (short) -1, getNamedTag("1.13 Turtle Egg"))); rewrite(205).repItem(new Item((short) 90, (byte) 1, (short) -1, getNamedTag("1.13 Mushroom Stem")));
rewrite(466).repItem(new Item((short) 582, (byte) 1, (short) -1, getNamedTag("1.13 Scute")));
rewrite(781).repItem(new Item((short) 488, (byte) 1, (short) -1, getNamedTag("1.13 Trident")));
enchantmentMappings.put("minecraft:loyalty", "§r§7Loyalty"); enchantmentMappings.put("minecraft:loyalty", "§r§7Loyalty");
enchantmentMappings.put("minecraft:impaling", "§r§7Impaling"); enchantmentMappings.put("minecraft:impaling", "§r§7Impaling");
@ -626,7 +638,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
if (rawId == null) { if (rawId == null) {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) { if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Failed to get 1.12 item for " + item.getId()); ViaBackwards.getPlatform().getLogger().warning("Failed to get 1.12 item for " + item.getId());
} }
rawId = 0x10000; // Stone rawId = 0x10000; // Stone
} }
@ -867,7 +879,6 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
@Override @Override
protected Item handleItemToServer(Item item) { protected Item handleItemToServer(Item item) {
item = super.handleItemToServer(item);
if (item == null) return null; if (item == null) return null;
CompoundTag tag = item.getTag(); CompoundTag tag = item.getTag();
@ -1087,7 +1098,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
rawId &= ~0xF; // Remove data rawId &= ~0xF; // Remove data
} else { } else {
if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) { if (!Via.getConfig().isSuppress1_13ConversionErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("Failed to get 1.13 item for " + item.getId()); ViaBackwards.getPlatform().getLogger().warning("Failed to get 1.13 item for " + item.getId());
} }
rawId = 16; // Stone rawId = 16; // Stone
} }
@ -1095,6 +1106,7 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
item.setId(MappingData.oldToNewItems.get(rawId).shortValue()); item.setId(MappingData.oldToNewItems.get(rawId).shortValue());
item.setData((short) 0); item.setData((short) 0);
item = super.handleItemToServer(item);
return item; return item;
} }

View File

@ -1,5 +1,6 @@
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14; package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14;
import lombok.Getter;
import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.BackwardsProtocol; import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker; import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
@ -9,6 +10,7 @@ import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.BlockItemPack
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.EntityPackets1_14; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.EntityPackets1_14;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.PlayerPackets1_14; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.PlayerPackets1_14;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.SoundPackets1_14; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets.SoundPackets1_14;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
@ -17,9 +19,10 @@ import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@Getter
public class Protocol1_13_2To1_14 extends BackwardsProtocol { public class Protocol1_13_2To1_14 extends BackwardsProtocol {
public static BlockItemPackets1_14 blockItem; private BlockItemPackets1_14 blockItemPackets;
public static EntityPackets1_14 entity; private EntityPackets1_14 entityPackets;
static { static {
BackwardsMappings.init(); BackwardsMappings.init();
@ -28,79 +31,95 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
@Override @Override
protected void registerPackets() { protected void registerPackets() {
blockItem = new BlockItemPackets1_14(); blockItemPackets = new BlockItemPackets1_14();
blockItem.register(this); blockItemPackets.register(this);
entity = new EntityPackets1_14(); entityPackets = new EntityPackets1_14();
entity.register(this); entityPackets.register(this);
new PlayerPackets1_14().register(this); new PlayerPackets1_14().register(this);
new SoundPackets1_14().register(this); new SoundPackets1_14().register(this);
out(State.PLAY, 0x2E, 0x2D); // c registerOutgoing(State.PLAY, 0x15, 0x16);
out(State.PLAY, 0x2F, 0x2E); // c
out(State.PLAY, 0x30, 0x2F); // c registerOutgoing(State.PLAY, 0x17, 0x18);
out(State.PLAY, 0x31, 0x30); // c
out(State.PLAY, 0x32, 0x31); // c registerOutgoing(State.PLAY, 0x18, 0x19);
out(State.PLAY, 0x33, 0x32); // c
// Entity sound registerOutgoing(State.PLAY, 0x19, 0x1A);
out(State.PLAY, 0x4E, -1, new PacketRemapper() { registerOutgoing(State.PLAY, 0x1A, 0x1B);
registerOutgoing(State.PLAY, 0x1B, 0x1C);
registerOutgoing(State.PLAY, 0x54, 0x1D);
registerOutgoing(State.PLAY, 0x1C, 0x1E);
registerOutgoing(State.PLAY, 0x1E, 0x20);
registerOutgoing(State.PLAY, 0x20, 0x21);
registerOutgoing(State.PLAY, 0x2B, 0x27);
registerOutgoing(State.PLAY, 0x2C, 0x2B);
registerOutgoing(State.PLAY, 0x30, 0x2D);
registerOutgoing(State.PLAY, 0x31, 0x2E);
registerOutgoing(State.PLAY, 0x32, 0x2F);
registerOutgoing(State.PLAY, 0x33, 0x30);
registerOutgoing(State.PLAY, 0x34, 0x31);
// Position and look
registerOutgoing(State.PLAY, 0x35, 0x32);
registerOutgoing(State.PLAY, 0x36, 0x34);
registerOutgoing(State.PLAY, 0x38, 0x36);
registerOutgoing(State.PLAY, 0x39, 0x37);
registerOutgoing(State.PLAY, 0x3B, 0x39);
registerOutgoing(State.PLAY, 0x3C, 0x3A);
registerOutgoing(State.PLAY, 0x3D, 0x3B);
registerOutgoing(State.PLAY, 0x3E, 0x3C);
registerOutgoing(State.PLAY, 0x3F, 0x3D);
registerOutgoing(State.PLAY, 0x42, 0x3E);
registerOutgoing(State.PLAY, 0x44, 0x40);
registerOutgoing(State.PLAY, 0x45, 0x41);
registerOutgoing(State.PLAY, 0x47, 0x43);
registerOutgoing(State.PLAY, 0x48, 0x44);
registerOutgoing(State.PLAY, 0x49, 0x45);
registerOutgoing(State.PLAY, 0x4A, 0x46);
registerOutgoing(State.PLAY, 0x4B, 0x47);
registerOutgoing(State.PLAY, 0x4C, 0x48);
registerOutgoing(State.PLAY, 0x4E, 0x4A);
registerOutgoing(State.PLAY, 0x4F, 0x4B);
registerOutgoing(State.PLAY, 0x52, 0x4C);
registerOutgoing(State.PLAY, 0x53, 0x4E); // c
registerOutgoing(State.PLAY, 0x55, 0x4F); // c
registerOutgoing(State.PLAY, 0x56, 0x50); // c
//Update View Position
registerOutgoing(State.PLAY, 0x40, -1, new PacketRemapper() {
@Override @Override
public void registerMap() { // c public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper packetWrapper) throws Exception { public void handle(PacketWrapper packetWrapper) throws Exception {
packetWrapper.cancel(); // todo packetWrapper.cancel();
}
});
}
});
//Update View Distance
registerOutgoing(State.PLAY, 0x41, -1, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper packetWrapper) throws Exception {
packetWrapper.cancel();
} }
}); });
} }
}); });
//Unknown packet added in 19w11a - 0x02 registerOutgoing(State.PLAY, 0x57, 0x51, new PacketRemapper() { // c
registerIncoming(State.PLAY, 0x03, 0x02); // r
registerIncoming(State.PLAY, 0x04, 0x03); // r
registerIncoming(State.PLAY, 0x05, 0x04); // r
registerIncoming(State.PLAY, 0x06, 0x05); // r
registerIncoming(State.PLAY, 0x07, 0x06); // r
registerIncoming(State.PLAY, 0x08, 0x07); // r
registerIncoming(State.PLAY, 0x0A, 0x09); // r
registerIncoming(State.PLAY, 0x0B, 0x0A); // r
registerIncoming(State.PLAY, 0x0D, 0x0C); // r
registerIncoming(State.PLAY, 0x0E, 0x0D); // r
//Unknown packet added in 19w11a - 0x0F
registerIncoming(State.PLAY, 0x10, 0x0E); // r
registerIncoming(State.PLAY, 0x11, 0x0F); // r
registerIncoming(State.PLAY, 0x12, 0x10); // r
registerIncoming(State.PLAY, 0x13, 0x11); // r
registerIncoming(State.PLAY, 0x14, 0x12); // r
registerIncoming(State.PLAY, 0x15, 0x13); // r
registerIncoming(State.PLAY, 0x16, 0x14); // r
registerIncoming(State.PLAY, 0x17, 0x15); // r
registerIncoming(State.PLAY, 0x18, 0x16); // r
registerIncoming(State.PLAY, 0x19, 0x17); // r
registerIncoming(State.PLAY, 0x1B, 0x19); // r
registerIncoming(State.PLAY, 0x1C, 0x1A); // r
registerIncoming(State.PLAY, 0x1E, 0x1C); // r
registerIncoming(State.PLAY, 0x1F, 0x1D); // r
registerIncoming(State.PLAY, 0x20, 0x1E); // r
registerIncoming(State.PLAY, 0x21, 0x1F); // r
registerIncoming(State.PLAY, 0x22, 0x20); // r
registerIncoming(State.PLAY, 0x23, 0x21); // r
registerIncoming(State.PLAY, 0x25, 0x23); // r
registerIncoming(State.PLAY, 0x29, 0x27); // r
registerIncoming(State.PLAY, 0x2A, 0x28); // r
registerIncoming(State.PLAY, 0x2C, 0x2A); // r
registerOutgoing(State.PLAY, 0x4F, 0x4E); // c
registerOutgoing(State.PLAY, 0x50, 0x4F); // c
registerOutgoing(State.PLAY, 0x51, 0x50); // c
registerOutgoing(State.PLAY, 0x52, 0x51, new PacketRemapper() { // c
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -120,7 +139,7 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
if (wrapper.passthrough(Type.BOOLEAN)) { if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.STRING); // Title wrapper.passthrough(Type.STRING); // Title
wrapper.passthrough(Type.STRING); // Description wrapper.passthrough(Type.STRING); // Description
blockItem.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon blockItemPackets.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
wrapper.passthrough(Type.VAR_INT); // Frame type wrapper.passthrough(Type.VAR_INT); // Frame type
int flags = wrapper.passthrough(Type.INT); // Flags int flags = wrapper.passthrough(Type.INT); // Flags
if ((flags & 1) != 0) if ((flags & 1) != 0)
@ -141,11 +160,11 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
} }
}); });
registerOutgoing(State.PLAY, 0x53, 0x52); // c registerOutgoing(State.PLAY, 0x58, 0x52); // c
registerOutgoing(State.PLAY, 0x54, 0x53); // c registerOutgoing(State.PLAY, 0x59, 0x53); // c
// tags // tags
registerOutgoing(State.PLAY, 0x56, 0x55, new PacketRemapper() { registerOutgoing(State.PLAY, 0x5B, 0x55, new PacketRemapper() {
@Override @Override
public void registerMap() { // c public void registerMap() { // c
handler(new PacketHandler() { handler(new PacketHandler() {
@ -187,28 +206,135 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
// Light update // Light update
out(State.PLAY, 0x57, -1, new PacketRemapper() { out(State.PLAY, 0x24, -1, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper packetWrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
packetWrapper.cancel(); // todo int x = wrapper.read(Type.VAR_INT);
int z = wrapper.read(Type.VAR_INT);
int skyLightMask = wrapper.read(Type.VAR_INT);
int blockLightMask = wrapper.read(Type.VAR_INT);
int emptySkyLightMask = wrapper.read(Type.VAR_INT);
int emptyBlockLightMask = wrapper.read(Type.VAR_INT);
byte[][] skyLight = new byte[16][];
// we don't need void and +256 light
if (isSet(skyLightMask, 0)) {
wrapper.read(Type.BYTE_ARRAY);
}
for (int i = 0; i < 16; i++) {
if (isSet(skyLightMask, i + 1)) {
Byte[] array = wrapper.read(Type.BYTE_ARRAY);
skyLight[i] = new byte[array.length];
for (int j = 0; j < array.length; j++) {
skyLight[i][j] = array[j];
}
} else if (isSet(emptySkyLightMask, i + 1)) {
skyLight[i] = ChunkLightStorage.EMPTY_LIGHT;
}
}
if (isSet(skyLightMask, 17)) {
wrapper.read(Type.BYTE_ARRAY);
}
byte[][] blockLight = new byte[16][];
if (isSet(blockLightMask, 0)) {
wrapper.read(Type.BYTE_ARRAY);
}
for (int i = 0; i < 16; i++) {
if (isSet(blockLightMask, i + 1)) {
Byte[] array = wrapper.read(Type.BYTE_ARRAY);
blockLight[i] = new byte[array.length];
for (int j = 0; j < array.length; j++) {
blockLight[i][j] = array[j];
}
} else if (isSet(emptyBlockLightMask, i + 1)) {
blockLight[i] = ChunkLightStorage.EMPTY_LIGHT;
}
}
if (isSet(blockLightMask, 17)) {
wrapper.read(Type.BYTE_ARRAY);
}
wrapper.user().get(ChunkLightStorage.class).setStoredLight(skyLight, blockLight, x, z);
wrapper.cancel();
}
private boolean isSet(int mask, int i) {
return (mask & (1 << i)) != 0;
} }
}); });
} }
}); });
//Incomming
//Unknown packet added in 19w11a - 0x02
registerIncoming(State.PLAY, 0x03, 0x02); // r
registerIncoming(State.PLAY, 0x04, 0x03); // r
registerIncoming(State.PLAY, 0x05, 0x04); // r
registerIncoming(State.PLAY, 0x06, 0x05); // r
registerIncoming(State.PLAY, 0x07, 0x06); // r
registerIncoming(State.PLAY, 0x08, 0x07); // r
registerIncoming(State.PLAY, 0x0A, 0x09); // r
registerIncoming(State.PLAY, 0x0B, 0x0A); // r
registerIncoming(State.PLAY, 0x0D, 0x0C); // r
registerIncoming(State.PLAY, 0x0E, 0x0D); // r
//Unknown packet added in 19w11a - 0x0F
registerIncoming(State.PLAY, 0x0F, 0x0E); // r
registerIncoming(State.PLAY, 0x11, 0x10); // r
registerIncoming(State.PLAY, 0x12, 0x11); // r
registerIncoming(State.PLAY, 0x13, 0x12); // r
registerIncoming(State.PLAY, 0x14, 0x0F); // r
registerIncoming(State.PLAY, 0x15, 0x13); // r
registerIncoming(State.PLAY, 0x16, 0x14); // r
registerIncoming(State.PLAY, 0x17, 0x15); // r
registerIncoming(State.PLAY, 0x18, 0x16); // r
registerIncoming(State.PLAY, 0x19, 0x17); // r
registerIncoming(State.PLAY, 0x1B, 0x19); // r
registerIncoming(State.PLAY, 0x1C, 0x1A); // r
registerIncoming(State.PLAY, 0x1E, 0x1C); // r
registerIncoming(State.PLAY, 0x1F, 0x1D); // r
registerIncoming(State.PLAY, 0x20, 0x1E); // r
registerIncoming(State.PLAY, 0x21, 0x1F); // r
registerIncoming(State.PLAY, 0x22, 0x20); // r
registerIncoming(State.PLAY, 0x23, 0x21); // r
registerIncoming(State.PLAY, 0x25, 0x23); // r
// registerIncoming(State.PLAY, 0x29, 0x27); // r
registerIncoming(State.PLAY, 0x2A, 0x27); // r
registerIncoming(State.PLAY, 0x2B, 0x28); // r
registerIncoming(State.PLAY, 0x2D, 0x2A); // r
} }
public static int getNewBlockStateId(int id) { public static int getNewBlockStateId(int id) {
int newId = BackwardsMappings.blockMappings.getNewBlock(id); int newId = BackwardsMappings.blockStateMappings.getNewBlock(id);
if (newId == -1) { if (newId == -1) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 block for 1.13.2 block " + id); ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 blockstate id for 1.13.2 block " + id);
return 0; return 0;
} }
return newId; return newId;
} }
public static int getNewBlockId(int id) {
int newId = BackwardsMappings.blockMappings.getNewBlock(id);
if (newId == -1) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.14 block id for 1.13.2 block " + id);
return id;
}
return newId;
}
@Override @Override
public void init(UserConnection user) { public void init(UserConnection user) {
// Register ClientWorld // Register ClientWorld
@ -221,5 +347,8 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
// Init protocol in EntityTracker // Init protocol in EntityTracker
user.get(EntityTracker.class).initProtocol(this); user.get(EntityTracker.class).initProtocol(this);
if (!user.has(ChunkLightStorage.class))
user.put(new ChunkLightStorage(user));
} }
} }

View File

@ -14,6 +14,7 @@ import java.util.Arrays;
import java.util.Map; import java.util.Map;
public class BackwardsMappings { public class BackwardsMappings {
public static BlockMappings blockStateMappings;
public static BlockMappings blockMappings; public static BlockMappings blockMappings;
public static void init() { public static void init() {
@ -21,8 +22,9 @@ public class BackwardsMappings {
JsonObject mapping1_14 = MappingData.loadData("mapping-1.14.json"); JsonObject mapping1_14 = MappingData.loadData("mapping-1.14.json");
JsonObject mapping1_13_2to1_14 = loadData("mapping-1.13.2to1.14.json"); JsonObject mapping1_13_2to1_14 = loadData("mapping-1.13.2to1.14.json");
ViaBackwards.getPlatform().getLogger().info("Loading block mapping..."); ViaBackwards.getPlatform().getLogger().info("Loading 1.14 -> 1.13.2 block mapping...");
blockMappings = new BlockMappingsShortArray(mapping1_14.getAsJsonObject("blockstates"), mapping1_13_2.getAsJsonObject("blockstates"), mapping1_13_2to1_14.getAsJsonObject("blockstates")); blockStateMappings = new BlockMappingsShortArray(mapping1_14.getAsJsonObject("blockstates"), mapping1_13_2.getAsJsonObject("blockstates"), mapping1_13_2to1_14.getAsJsonObject("blockstates"));
//blockMappings = new BlockMappingsShortArray(mapping1_14.getAsJsonObject("blocks"), mapping1_13_2.getAsJsonObject("blocks"), mapping1_13_2to1_14.getAsJsonObject("blocks"));
} }
@ -84,7 +86,7 @@ public class BackwardsMappings {
} }
private static class BlockMappingsShortArray implements BlockMappings { private static class BlockMappingsShortArray implements BlockMappings {
private short[] oldToNew = new short[11258 + 1]; private short[] oldToNew = new short[11270 + 1];
private BlockMappingsShortArray(JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) { private BlockMappingsShortArray(JsonObject newIdentifiers, JsonObject oldIdentifiers, JsonObject mapping) {
Arrays.fill(oldToNew, (short) -1); Arrays.fill(oldToNew, (short) -1);

View File

@ -1,6 +1,5 @@
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data; package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data;
import us.myles.ViaVersion.api.entities.Entity1_13Types; import us.myles.ViaVersion.api.entities.Entity1_13Types;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.EntityTypeRewriter; import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.EntityTypeRewriter;
@ -35,6 +34,12 @@ public class EntityTypeMapping {
oldEntityToOldObject.put(type1_13.getId(), object1_13.getId()); oldEntityToOldObject.put(type1_13.getId(), object1_13.getId());
} }
} }
for(Entity1_13Types.EntityType type : Entity1_13Types.EntityType.values()){
if(!entityTypes.containsValue(type.getId())){
entityTypes.put(type.getId(), type.getId());
}
}
entityTypes.put(50, 48); // ocelot
} }
public static Optional<Integer> getOldId(int type1_14) { public static Optional<Integer> getOldId(int type1_14) {

View File

@ -9,7 +9,7 @@ import java.util.Arrays;
import static us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.loadData; import static us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.loadData;
public class SoundMapping { public class SoundMapping {
private static short[] sounds = new short[789]; private static short[] sounds = new short[795];
public static void init() { public static void init() {
JsonObject mapping1_13_2 = loadData("mapping-1.13.2.json"); JsonObject mapping1_13_2 = loadData("mapping-1.13.2.json");

View File

@ -2,17 +2,24 @@ package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
import nl.matsv.viabackwards.api.entities.types.EntityType1_14;
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter; import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLightStorage;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord; import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
import us.myles.ViaVersion.api.minecraft.Environment; import us.myles.ViaVersion.api.minecraft.Environment;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk; import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection; import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13_2;
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.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_13;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.ChatRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type; import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
@ -26,6 +33,8 @@ import us.myles.viaversion.libs.opennbt.tag.builtin.ListTag;
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag; import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
import us.myles.viaversion.libs.opennbt.tag.builtin.Tag; import us.myles.viaversion.libs.opennbt.tag.builtin.Tag;
import java.util.ArrayList;
import java.util.List;
import java.util.Set; import java.util.Set;
public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14> { public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14> {
@ -34,7 +43,7 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
@Override @Override
protected void registerPackets(Protocol1_13_2To1_14 protocol) { protected void registerPackets(Protocol1_13_2To1_14 protocol) {
// Open window // Open window
protocol.registerOutgoing(State.PLAY, 0x58, 0x14, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x2E, 0x14, new PacketRemapper() {
@Override @Override
public void registerMap() { // c public void registerMap() { // c
handler(new PacketHandler() { handler(new PacketHandler() {
@ -44,8 +53,10 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
wrapper.write(Type.UNSIGNED_BYTE, (short) id); wrapper.write(Type.UNSIGNED_BYTE, (short) id);
int type = wrapper.read(Type.VAR_INT); int type = wrapper.read(Type.VAR_INT);
String stringType = null; String stringType = null;
String title = null;
int slotSize = 0; int slotSize = 0;
if (type < 6) { if (type < 6) {
if (type == 2) title = "Barrel";
stringType = "minecraft:container"; stringType = "minecraft:container";
slotSize = (type + 1) * 9; slotSize = (type + 1) * 9;
} else } else
@ -53,32 +64,46 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
case 11: case 11:
stringType = "minecraft:crafting_table"; stringType = "minecraft:crafting_table";
break; break;
case 14: case 9: //blast furnace
case 20: //smoker
case 13: //furnace
case 14: //grindstone
if (type == 9) title = "Blast Furnace";
if (type == 20) title = "Smoker";
if (type == 14) title = "Grindstone";
stringType = "minecraft:furnace"; stringType = "minecraft:furnace";
slotSize = 3;
break; break;
case 6: case 6:
stringType = "minecraft:dropper"; stringType = "minecraft:dropper";
slotSize = 9;
break; break;
case 12: case 12:
stringType = "minecraft:enchanting_table"; stringType = "minecraft:enchanting_table";
break; break;
case 10: case 10:
stringType = "minecraft:brewing_stand"; stringType = "minecraft:brewing_stand";
slotSize = 5;
break; break;
case 18: case 18:
stringType = "minecraft:villager"; stringType = "minecraft:villager";
break; break;
case 8: case 8:
stringType = "minecraft:beacon"; stringType = "minecraft:beacon";
slotSize = 1;
break; break;
case 21: //cartography_table
case 7: case 7:
if (type == 21) title = "Cartography Table";
stringType = "minecraft:anvil"; stringType = "minecraft:anvil";
break; break;
case 15: case 15:
stringType = "minecraft:hopper"; stringType = "minecraft:hopper";
slotSize = 5;
break; break;
case 19: case 19:
stringType = "minecraft:shulker_box"; stringType = "minecraft:shulker_box";
slotSize = 27;
break; break;
} }
@ -89,7 +114,9 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
} }
wrapper.write(Type.STRING, stringType); wrapper.write(Type.STRING, stringType);
wrapper.passthrough(Type.STRING); String t = wrapper.read(Type.STRING);
if (title != null) t = ChatRewriter.legacyTextToJson(title);
wrapper.write(Type.STRING, t);
wrapper.write(Type.UNSIGNED_BYTE, (short) slotSize); wrapper.write(Type.UNSIGNED_BYTE, (short) slotSize);
} }
}); });
@ -97,7 +124,7 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
}); });
// Horse window // Horse window
protocol.registerOutgoing(State.PLAY, 0x14, 0x14, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x1F, 0x14, new PacketRemapper() {
@Override @Override
public void registerMap() { // c public void registerMap() { // c
handler(new PacketHandler() { handler(new PacketHandler() {
@ -114,7 +141,7 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
}); });
// Window items packet // Window items packet
protocol.registerOutgoing(State.PLAY, 0x15, 0x15, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x14, 0x15, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID map(Type.UNSIGNED_BYTE); // 0 - Window ID
@ -124,14 +151,17 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
Item[] stacks = wrapper.get(Type.FLAT_VAR_INT_ITEM_ARRAY, 0); Item[] stacks = wrapper.get(Type.FLAT_VAR_INT_ITEM_ARRAY, 0);
for (Item stack : stacks) handleItemToClient(stack); for (int i = 0; i < stacks.length; i++) {
stacks[i] = handleItemToClient(stacks[i]);
}
wrapper.set(Type.FLAT_VAR_INT_ITEM_ARRAY, 0, stacks);
} }
}); });
} }
}); });
// Set slot packet // Set slot packet
protocol.registerOutgoing(State.PLAY, 0x17, 0x17, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x16, 0x17, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.BYTE); // 0 - Window ID map(Type.BYTE); // 0 - Window ID
@ -141,36 +171,46 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
handleItemToClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); Item item = wrapper.get(Type.FLAT_VAR_INT_ITEM, 0);
item = handleItemToClient(item);
wrapper.set(Type.FLAT_VAR_INT_ITEM, 0, item);
} }
}); });
} }
}); });
// Trade list // Trade list
protocol.out(State.PLAY, 0x59, 0x19, new PacketRemapper() { protocol.out(State.PLAY, 0x27, 0x19, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
wrapper.write(Type.STRING, "minecraft:trader_list"); wrapper.write(Type.STRING, "minecraft:trader_list");
wrapper.read(Type.STRING); // Remove channel // wrapper.read(Type.STRING); // Remove channel
int windowId = wrapper.read(Type.INT); int windowId = wrapper.read(Type.VAR_INT);
wrapper.write(Type.VAR_INT, windowId); wrapper.write(Type.INT, windowId);
int size = wrapper.passthrough(Type.UNSIGNED_BYTE); int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
// Input Item // Input Item
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); Item input = wrapper.read(Type.FLAT_VAR_INT_ITEM);
input = handleItemToClient(input);
wrapper.write(Type.FLAT_VAR_INT_ITEM, input);
// Output Item // Output Item
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); Item output = wrapper.read(Type.FLAT_VAR_INT_ITEM);
output = handleItemToClient(output);
wrapper.write(Type.FLAT_VAR_INT_ITEM, output);
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
if (secondItem) { if (secondItem) {
// Second Item // Second Item
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); Item second = wrapper.read(Type.FLAT_VAR_INT_ITEM);
second = handleItemToClient(second);
wrapper.write(Type.FLAT_VAR_INT_ITEM, second);
} }
wrapper.passthrough(Type.BOOLEAN); // Trade disabled wrapper.passthrough(Type.BOOLEAN); // Trade disabled
@ -190,7 +230,7 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
}); });
// Book open // Book open
protocol.registerOutgoing(State.PLAY, 0x2C, 0x19, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x2D, 0x19, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -204,7 +244,7 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
}); });
// Entity Equipment Packet // Entity Equipment Packet
protocol.registerOutgoing(State.PLAY, 0x42, 0x42, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x46, 0x42, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -214,7 +254,34 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
handleItemToClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); Item item = handleItemToClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
wrapper.set(Type.FLAT_VAR_INT_ITEM, 0, item);
}
});
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int entityId = wrapper.get(Type.VAR_INT, 0);
AbstractEntityType entityType = wrapper.user().get(EntityTracker.class).get(getProtocol()).getEntityType(entityId);
if (entityType == null) return; // TODO: Check why there might (?) be an untracked entity
if (entityType.isOrHasParent(EntityType1_14.EntityType.ABSTRACT_HORSE)) {
wrapper.setId(0x3F);
wrapper.resetReader();
wrapper.passthrough(Type.VAR_INT);
wrapper.read(Type.VAR_INT);
Item item = wrapper.read(Type.FLAT_VAR_INT_ITEM);
int armorType = item == null || item.getIdentifier() == 0 ? 0 : item.getIdentifier() - 726;
if (armorType < 0 || armorType > 3) {
ViaBackwards.getPlatform().getLogger().warning("Received invalid horse armor: " + item);
wrapper.cancel();
return;
}
List<Metadata> metadataList = new ArrayList<>();
metadataList.add(new Metadata(16, MetaType1_13_2.VarInt, armorType));
wrapper.write(Types1_13.METADATA_LIST, metadataList);
}
} }
}); });
} }
@ -223,7 +290,7 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
Set<String> removedTypes = ImmutableSet.of("crafting_special_suspiciousstew", "blasting", "smoking", "campfire_cooking", "stonecutting"); Set<String> removedTypes = ImmutableSet.of("crafting_special_suspiciousstew", "blasting", "smoking", "campfire_cooking", "stonecutting");
// Declare Recipes // Declare Recipes
protocol.registerOutgoing(State.PLAY, 0x55, 0x54, new PacketRemapper() { // c protocol.registerOutgoing(State.PLAY, 0x5A, 0x54, new PacketRemapper() { // c
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -262,23 +329,37 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
wrapper.passthrough(Type.STRING); // Group wrapper.passthrough(Type.STRING); // Group
int ingredientsNo = wrapper.passthrough(Type.VAR_INT); int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
for (int j = 0; j < ingredientsNo; j++) { for (int j = 0; j < ingredientsNo; j++) {
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients Item[] items = wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
for (Item item : items) handleItemToClient(item); for (int k = 0; k < items.length; k++) {
items[k] = handleItemToClient(items[k]);
} }
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
}
Item result = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));// Result
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
} else if (type.equals("crafting_shaped")) { } else if (type.equals("crafting_shaped")) {
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT); int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.STRING); // Group wrapper.passthrough(Type.STRING); // Group
for (int j = 0; j < ingredientsNo; j++) { for (int j = 0; j < ingredientsNo; j++) {
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients Item[] items = wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
for (Item item : items) handleItemToClient(item); for (int k = 0; k < items.length; k++) {
items[k] = handleItemToClient(items[k]);
} }
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
}
Item result = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));// Result
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
} else if (type.equals("smelting")) { } else if (type.equals("smelting")) {
wrapper.passthrough(Type.STRING); // Group wrapper.passthrough(Type.STRING); // Group
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients Item[] items = wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
for (Item item : items) handleItemToClient(item); for (int k = 0; k < items.length; k++) {
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); items[k] = handleItemToClient(items[k]);
}
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, items);
Item result = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));// Result
wrapper.write(Type.FLAT_VAR_INT_ITEM, result);
wrapper.passthrough(Type.FLOAT); // EXP wrapper.passthrough(Type.FLOAT); // EXP
wrapper.passthrough(Type.VAR_INT); // Cooking time wrapper.passthrough(Type.VAR_INT); // Cooking time
} }
@ -308,7 +389,8 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
handleItemToServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); Item item = handleItemToServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
wrapper.set(Type.FLAT_VAR_INT_ITEM, 0, item);
} }
}); });
} }
@ -324,7 +406,9 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
handleItemToServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0)); Item item = wrapper.get(Type.FLAT_VAR_INT_ITEM, 0);
item = handleItemToServer(item);
wrapper.set(Type.FLAT_VAR_INT_ITEM, 0, item);
} }
}); });
} }
@ -359,7 +443,7 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
wrapper.set(Type.VAR_INT, 0, Protocol1_13_2To1_14.getNewBlockStateId(wrapper.get(Type.VAR_INT, 0))); wrapper.set(Type.VAR_INT, 0, Protocol1_13_2To1_14.getNewBlockStateId(wrapper.get(Type.VAR_INT, 0))); //TODO proper block id
} }
}); });
} }
@ -403,7 +487,7 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
}); });
//Chunk //Chunk
protocol.registerOutgoing(State.PLAY, 0x22, 0x22, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x21, 0x22, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@ -413,16 +497,29 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
Chunk chunk = wrapper.read(new Chunk1_14Type(clientWorld)); Chunk chunk = wrapper.read(new Chunk1_14Type(clientWorld));
wrapper.write(new Chunk1_13Type(clientWorld), chunk); wrapper.write(new Chunk1_13Type(clientWorld), chunk);
for (ChunkSection section : chunk.getSections()) { ChunkLightStorage.ChunkLight chunkLight = wrapper.user().get(ChunkLightStorage.class).getStoredLight(chunk.getX(), chunk.getZ());
for (int i = 0; i < chunk.getSections().length; i++) {
ChunkSection section = chunk.getSections()[i];
if (section == null) continue; if (section == null) continue;
section.setBlockLight(new byte[2048]);
if (chunkLight == null) {
section.setBlockLight(ChunkLightStorage.FULL_LIGHT);
if (clientWorld.getEnvironment() == Environment.NORMAL) { if (clientWorld.getEnvironment() == Environment.NORMAL) {
section.setSkyLight(new byte[2048]); section.setSkyLight(ChunkLightStorage.FULL_LIGHT);
} }
for (int i = 0; i < section.getPaletteSize(); i++) { } else {
int old = section.getPaletteEntry(i); final byte[] blockLight = chunkLight.getBlockLight()[i];
section.setBlockLight(blockLight != null ? blockLight : ChunkLightStorage.FULL_LIGHT);
if (clientWorld.getEnvironment() == Environment.NORMAL) {
final byte[] skyLight = chunkLight.getSkyLight()[i];
section.setSkyLight(skyLight != null ? skyLight : ChunkLightStorage.FULL_LIGHT);
}
}
for (int j = 0; j < section.getPaletteSize(); j++) {
int old = section.getPaletteEntry(j);
int newId = Protocol1_13_2To1_14.getNewBlockStateId(old); int newId = Protocol1_13_2To1_14.getNewBlockStateId(old);
section.setPaletteEntry(i, newId); section.setPaletteEntry(j, newId);
} }
} }
} }
@ -430,8 +527,23 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
} }
}); });
// Unload chunk
protocol.registerOutgoing(State.PLAY, 0x1D, 0x1F, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int x = wrapper.passthrough(Type.INT);
int z = wrapper.passthrough(Type.INT);
wrapper.user().get(ChunkLightStorage.class).unloadChunk(x, z);
}
});
}
});
// Effect packet // Effect packet
protocol.registerOutgoing(State.PLAY, 0x23, 0x23, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x22, 0x23, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // Effect Id map(Type.INT); // Effect Id
@ -453,7 +565,7 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
}); });
//spawn particle //spawn particle
protocol.registerOutgoing(State.PLAY, 0x24, 0x24, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x23, 0x24, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Particle ID map(Type.INT); // 0 - Particle ID
@ -470,12 +582,15 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
int id = wrapper.get(Type.INT, 0); int id = wrapper.get(Type.INT, 0);
id = EntityPackets1_14.getOldParticleId(id);
if (id == 3 || id == 20) { if (id == 3 || id == 20) {
int data = wrapper.passthrough(Type.VAR_INT); int data = wrapper.passthrough(Type.VAR_INT);
wrapper.set(Type.VAR_INT, 0, Protocol1_14To1_13_2.getNewBlockStateId(data)); wrapper.set(Type.VAR_INT, 0, Protocol1_13_2To1_14.getNewBlockStateId(data));
} else if (id == 27) { } else if (id == 27) {
handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); Item item = handleItemToClient(wrapper.read(Type.FLAT_VAR_INT_ITEM));
wrapper.write(Type.FLAT_VAR_INT_ITEM, item);
} }
wrapper.set(Type.INT, 0, id);
} }
}); });
} }
@ -494,7 +609,7 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
}); });
//respawn //respawn
protocol.registerOutgoing(State.PLAY, 0x38, 0x38, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x3A, 0x38, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.INT); // 0 - Dimension ID map(Type.INT); // 0 - Dimension ID
@ -505,13 +620,14 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
int dimensionId = wrapper.get(Type.INT, 0); int dimensionId = wrapper.get(Type.INT, 0);
clientWorld.setEnvironment(dimensionId); clientWorld.setEnvironment(dimensionId);
wrapper.write(Type.UNSIGNED_BYTE, (short) 0); // todo - do we need to store it from difficulty packet? wrapper.write(Type.UNSIGNED_BYTE, (short) 0); // todo - do we need to store it from difficulty packet?
wrapper.user().get(ChunkLightStorage.class).clear();
} }
}); });
} }
}); });
// Spawn position // Spawn position
protocol.registerOutgoing(State.PLAY, 0x49, 0x49, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x4D, 0x49, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION1_14, Type.POSITION); map(Type.POSITION1_14, Type.POSITION);
@ -521,7 +637,105 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
rewrite(247).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Brick Wall")));
rewrite(248).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Prismarine Wall")));
rewrite(249).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Red Sandstone Wall")));
rewrite(250).repItem(new Item((short) 246, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Stone Brick Wall")));
rewrite(251).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Granite Wall")));
rewrite(252).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Stone Brick Wall")));
rewrite(253).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Nether Brick Wall")));
rewrite(254).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Andesite Wall")));
rewrite(255).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Red Nether Brick Wall")));
rewrite(256).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Sandstone Wall")));
rewrite(257).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 End Stone Brick Wall")));
rewrite(258).repItem(new Item((short) 245, (byte) 1, (short) -1, getNamedTag("1.14 Diorite Wall")));
rewrite(121).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Stone Slab")));
rewrite(124).repItem(new Item((short) 123, (byte) 1, (short) -1, getNamedTag("1.14 Cut Sandstone Slab")));
rewrite(132).repItem(new Item((short) 131, (byte) 1, (short) -1, getNamedTag("1.14 Cut Red Sandstone Slab")));
rewrite(492).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Polished Granite Slab")));
rewrite(493).repItem(new Item((short) 131, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Red Sandstone Slab")));
rewrite(494).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Stone Brick Slab")));
rewrite(495).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Polished Diorite Slab")));
rewrite(496).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Cobblestone Slab")));
rewrite(497).repItem(new Item((short) 123, (byte) 1, (short) -1, getNamedTag("1.14 End Stone Brick Slab")));
rewrite(498).repItem(new Item((short) 123, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Cut Sandstone Slab")));
rewrite(499).repItem(new Item((short) 130, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Quartz Slab")));
rewrite(500).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Granite Slab")));
rewrite(501).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Andesite Slab")));
rewrite(502).repItem(new Item((short) 129, (byte) 1, (short) -1, getNamedTag("1.14 Red Nether Brick Slab")));
rewrite(503).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Polished Andesite Slab")));
rewrite(504).repItem(new Item((short) 126, (byte) 1, (short) -1, getNamedTag("1.14 Diorite Slab")));
rewrite(478).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Polished Granite Stairs")));
rewrite(479).repItem(new Item((short) 371, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Red Sandstone Stairs")));
rewrite(480).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Stone Brick Stairs")));
rewrite(481).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Polished Diorite Stairs")));
rewrite(482).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Mossy Cobblestone Stairs")));
rewrite(483).repItem(new Item((short) 235, (byte) 1, (short) -1, getNamedTag("1.14 End Stone Brick Stairs")));
rewrite(484).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Stone Stairs")));
rewrite(485).repItem(new Item((short) 235, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Sandstone Stairs")));
rewrite(486).repItem(new Item((short) 278, (byte) 1, (short) -1, getNamedTag("1.14 Smooth Quartz Stairs")));
rewrite(487).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Granite Stairs")));
rewrite(488).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Andesite Stairs")));
rewrite(489).repItem(new Item((short) 228, (byte) 1, (short) -1, getNamedTag("1.14 Red Nether Brick Stairs")));
rewrite(490).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Polished Andesite Stairs")));
rewrite(491).repItem(new Item((short) 163, (byte) 1, (short) -1, getNamedTag("1.14 Diorite Stairs")));
rewrite(108).repItem(new Item((short) 111, (byte) 1, (short) -1, getNamedTag("1.14 Cornflower")));
rewrite(109).repItem(new Item((short) 105, (byte) 1, (short) -1, getNamedTag("1.14 Lily of the Valley")));
rewrite(110).repItem(new Item((short) 100, (byte) 1, (short) -1, getNamedTag("1.14 Wither Rose")));
rewrite(614).repItem(new Item((short) 611, (byte) 1, (short) -1, getNamedTag("1.14 Bamboo")));
rewrite(857).repItem(new Item((short) 547, (byte) 1, (short) -1, getNamedTag("1.14 Suspicious Stew")));
rewrite(795).repItem(new Item((short) 793, (byte) 1, (short) -1, getNamedTag("1.14 Leather Horse Armor")));
rewrite(647).repItem(new Item((short) 635, (byte) 1, (short) -1, getNamedTag("1.14 Blue Dye")));
rewrite(648).repItem(new Item((short) 634, (byte) 1, (short) -1, getNamedTag("1.14 Brown Dye")));
rewrite(649).repItem(new Item((short) 631, (byte) 1, (short) -1, getNamedTag("1.14 Black Dye")));
rewrite(650).repItem(new Item((short) 646, (byte) 1, (short) -1, getNamedTag("1.14 White Dye")));
rewrite(505).repItem(new Item((short) 299, (byte) 1, (short) -1, getNamedTag("1.14 Scaffolding")));
rewrite(516).repItem(new Item((short) 515, (byte) 1, (short) -1, getNamedTag("1.14 Jigsaw Block")));
rewrite(517).repItem(new Item((short) 694, (byte) 1, (short) -1, getNamedTag("1.14 Composter")));
rewrite(864).repItem(new Item((short) 155, (byte) 1, (short) -1, getNamedTag("1.14 Barrel")));
rewrite(858).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Loom")));
rewrite(865).repItem(new Item((short) 160, (byte) 1, (short) -1, getNamedTag("1.14 Smoker")));
rewrite(866).repItem(new Item((short) 160, (byte) 1, (short) -1, getNamedTag("1.14 Blast Furnace")));
rewrite(867).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Cartography Table")));
rewrite(868).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Fletching Table")));
rewrite(869).repItem(new Item((short) 265, (byte) 1, (short) -1, getNamedTag("1.14 Grindstone")));
rewrite(870).repItem(new Item((short) 143, (byte) 1, (short) -1, getNamedTag("1.14 Lectern")));
rewrite(871).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Smithing Table")));
rewrite(872).repItem(new Item((short) 158, (byte) 1, (short) -1, getNamedTag("1.14 Stonecutter")));
rewrite(859).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Flower Banner Pattern")));
rewrite(860).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Creeper Banner Pattern")));
rewrite(861).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Skull Banner Pattern")));
rewrite(862).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Mojang Banner Pattern")));
rewrite(863).repItem(new Item((short) 615, (byte) 1, (short) -1, getNamedTag("1.14 Globe Banner Pattern")));
rewrite(873).repItem(new Item((short) 113, (byte) 1, (short) -1, getNamedTag("1.14 Bell")));
rewrite(874).repItem(new Item((short) 234, (byte) 1, (short) -1, getNamedTag("1.14 Lantern")));
rewrite(875).repItem(new Item((short) 820, (byte) 1, (short) -1, getNamedTag("1.14 Sweet Berries")));
rewrite(876).repItem(new Item((short) 146, (byte) 1, (short) -1, getNamedTag("1.14 Campfire")));
rewrite(590).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Spruce Sign")));
rewrite(591).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Birch Sign")));
rewrite(592).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Jungle Sign")));
rewrite(593).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Acacia Sign")));
rewrite(594).repItem(new Item((short) 589, (byte) 1, (short) -1, getNamedTag("1.14 Dark Oak Sign")));
rewrite(856).repItem(new Item((short) 525, (byte) 1, (short) -1, getNamedTag("1.14 Crossbow")));
rewrite(699).repItem(new Item((short) 721, (byte) 1, (short) -1, getNamedTag("1.14 Cat Spawn Egg")));
rewrite(712).repItem(new Item((short) 725, (byte) 1, (short) -1, getNamedTag("1.14 Fox Spawn Egg")));
rewrite(722).repItem(new Item((short) 735, (byte) 1, (short) -1, getNamedTag("1.14 Panda Spawn Egg")));
rewrite(726).repItem(new Item((short) 754, (byte) 1, (short) -1, getNamedTag("1.14 Pillager Spawn Egg")));
rewrite(730).repItem(new Item((short) 734, (byte) 1, (short) -1, getNamedTag("1.14 Ravager Spawn Egg")));
rewrite(741).repItem(new Item((short) 698, (byte) 1, (short) -1, getNamedTag("1.14 Trader Llama Spawn Egg")));
rewrite(747).repItem(new Item((short) 739, (byte) 1, (short) -1, getNamedTag("1.14 Wandering Trader Spawn Egg")));
} }
@Override @Override
@ -559,10 +773,10 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
} }
@Override @Override
public Item handleItemToServer(Item i) { public Item handleItemToServer(Item item) {
Item item = super.handleItemToServer(i);
if (item == null) return null; if (item == null) return null;
item.setIdentifier(getNewItemId(item.getIdentifier())); item.setIdentifier(getNewItemId(item.getIdentifier()));
item = super.handleItemToServer(item);
CompoundTag tag; CompoundTag tag;
if ((tag = item.getTag()) != null) { if ((tag = item.getTag()) != null) {
@ -587,6 +801,15 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
return item; return item;
} }
@Override
protected CompoundTag getNamedTag(String text) {
CompoundTag tag = new CompoundTag("");
tag.put(new CompoundTag("display"));
((CompoundTag) tag.get("display")).put(new StringTag("Name", ChatRewriter.legacyTextToJson(text)));
return tag;
}
public static int getNewItemId(int id) { public static int getNewItemId(int id) {
Integer newId = MappingData.oldToNewItems.get(id); Integer newId = MappingData.oldToNewItems.get(id);
if (newId == null) { if (newId == null) {
@ -599,6 +822,10 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
public static int getOldItemId(int id) { public static int getOldItemId(int id) {
Integer oldId = MappingData.oldToNewItems.inverse().get(id); Integer oldId = MappingData.oldToNewItems.inverse().get(id);
return oldId != null ? oldId : 1; if (oldId == null) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.13.2 item for 1.14 item " + id);
return 1;
}
return oldId;
} }
} }

View File

@ -1,11 +1,13 @@
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets; package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets;
import nl.matsv.viabackwards.ViaBackwards; import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.entities.meta.MetaHandler;
import nl.matsv.viabackwards.api.entities.storage.EntityData; import nl.matsv.viabackwards.api.entities.storage.EntityData;
import nl.matsv.viabackwards.api.entities.storage.MetaStorage; import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType; import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
import nl.matsv.viabackwards.api.entities.types.EntityType1_13; import nl.matsv.viabackwards.api.entities.types.EntityType1_13;
import nl.matsv.viabackwards.api.entities.types.EntityType1_14; import nl.matsv.viabackwards.api.entities.types.EntityType1_14;
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
import nl.matsv.viabackwards.api.rewriters.EntityRewriter; import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13; import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets.BlockItemPackets1_13;
import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14; import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
@ -13,15 +15,16 @@ import nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.data.EntityTypeMappin
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.VillagerData; import us.myles.ViaVersion.api.minecraft.VillagerData;
import us.myles.ViaVersion.api.minecraft.item.Item; import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata; import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13_2; import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_13_2;
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.type.Type; import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_12;
import us.myles.ViaVersion.api.type.types.version.Types1_13_2; import us.myles.ViaVersion.api.type.types.version.Types1_13_2;
import us.myles.ViaVersion.api.type.types.version.Types1_14; import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.packets.State; import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.Particle;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.Optional; import java.util.Optional;
@ -62,10 +65,38 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
Optional<EntityType1_13.ObjectType> type = EntityType1_13.ObjectType.findById(EntityTypeMapping.getObjectId( int id = wrapper.get(Type.BYTE, 0);
EntityTypeMapping.getOldId(wrapper.get(Type.BYTE, 0)) EntityType1_13.EntityType entityType = EntityType1_13.getTypeFromId(EntityTypeMapping.getOldId(id).orElse(id), false);
.orElse(0) Optional<EntityType1_13.ObjectType> type;
).orElse(0)); if (entityType.isOrHasParent(EntityType1_13.EntityType.MINECART_ABSTRACT)) {
type = Optional.of(EntityType1_13.ObjectType.MINECART);
int data = 0;
switch (entityType) {
case CHEST_MINECART:
data = 1;
break;
case FURNACE_MINECART:
data = 2;
break;
case TNT_MINECART:
data = 3;
break;
case SPAWNER_MINECART:
data = 4;
break;
case HOPPER_MINECART:
data = 5;
break;
case COMMANDBLOCK_MINECART:
data = 6;
break;
}
if (data != 0)
wrapper.set(Type.INT, 0, data);
} else {
type = EntityType1_13.ObjectType.fromEntityType(entityType);
}
if (type.isPresent()) { if (type.isPresent()) {
wrapper.set(Type.BYTE, 0, (byte) type.get().getId()); wrapper.set(Type.BYTE, 0, (byte) type.get().getId());
} }
@ -124,8 +155,13 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
); );
Optional<Integer> oldId = EntityTypeMapping.getOldId(type); Optional<Integer> oldId = EntityTypeMapping.getOldId(type);
if (!oldId.isPresent()) { if (!oldId.isPresent()) {
if (!hasData(entityType)) Optional<EntityData> oldType = getEntityData(entityType);
if (!oldType.isPresent()) {
ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13.2 entity type for 1.14 entity type " + type + "/" + entityType); ViaBackwards.getPlatform().getLogger().warning("Could not find 1.13.2 entity type for 1.14 entity type " + type + "/" + entityType);
wrapper.cancel();
} else {
wrapper.set(Type.VAR_INT, 1, oldType.get().getReplacementId());
}
} else { } else {
wrapper.set(Type.VAR_INT, 1, oldId.get()); wrapper.set(Type.VAR_INT, 1, oldId.get());
} }
@ -167,6 +203,26 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
} }
}); });
// Spawn Experience Orb
protocol.registerOutgoing(State.PLAY, 0x01, 0x01, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity id
// Track entity
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
addTrackedEntity(
wrapper.user(),
wrapper.get(Type.VAR_INT, 0),
EntityType1_14.EntityType.XP_ORB
);
}
});
}
});
// Spawn painting // Spawn painting
protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x04, 0x04, new PacketRemapper() {
@Override @Override
@ -176,6 +232,18 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
map(Type.VAR_INT); map(Type.VAR_INT);
map(Type.POSITION1_14, Type.POSITION); map(Type.POSITION1_14, Type.POSITION);
map(Type.BYTE); map(Type.BYTE);
// Track entity
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
addTrackedEntity(
wrapper.user(),
wrapper.get(Type.VAR_INT, 0),
EntityType1_14.EntityType.PAINTING
);
}
});
} }
}); });
@ -212,9 +280,24 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
} }
}); });
// Destroy entities
protocol.registerOutgoing(State.PLAY, 0x37, 0x35, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT_ARRAY); // 0 - Entity IDS
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
for (int entity : wrapper.get(Type.VAR_INT_ARRAY, 0))
getEntityTracker(wrapper.user()).removeEntity(entity);
}
});
}
});
// Metadata packet // Metadata packet
protocol.registerOutgoing(State.PLAY, 0x3F, 0x3F, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x43, 0x3F, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID map(Type.VAR_INT); // 0 - Entity ID
@ -258,6 +341,10 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
addTrackedEntity(wrapper.user(), entityId, EntityType1_14.EntityType.PLAYER); addTrackedEntity(wrapper.user(), entityId, EntityType1_14.EntityType.PLAYER);
wrapper.write(Type.UNSIGNED_BYTE, (short) 0); wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
wrapper.passthrough(Type.UNSIGNED_BYTE); // Max Players
wrapper.passthrough(Type.STRING); // Level Type
wrapper.read(Type.VAR_INT); //Read View Distance
} }
}); });
} }
@ -266,40 +353,165 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
regEntType(EntityType1_14.EntityType.CAT, EntityType1_14.EntityType.OCELOT).mobName("Cat").spawnMetadata(e -> { setDisplayNameJson(true);
e.add(new Metadata(13, MetaType1_13_2.Byte, (byte) 0x4)); // Tamed cat setDisplayNameMetaType(MetaType1_13_2.OptChat);
});
regEntType(EntityType1_14.EntityType.OCELOT, EntityType1_14.EntityType.OCELOT).mobName("Ocelot"); regEntType(EntityType1_14.EntityType.CAT, EntityType1_14.EntityType.OCELOT).mobName("Cat");
regEntType(EntityType1_14.EntityType.TRADER_LLAMA, EntityType1_14.EntityType.LLAMA).mobName("Trader Llama"); regEntType(EntityType1_14.EntityType.TRADER_LLAMA, EntityType1_14.EntityType.LLAMA).mobName("Trader Llama");
regEntType(EntityType1_14.EntityType.FOX, EntityType1_14.EntityType.WOLF).mobName("Fox");
regEntType(EntityType1_14.EntityType.PANDA, EntityType1_14.EntityType.POLAR_BEAR).mobName("Panda");
regEntType(EntityType1_14.EntityType.PILLAGER, EntityType1_14.EntityType.VILLAGER).mobName("Pillager");
regEntType(EntityType1_14.EntityType.WANDERING_TRADER, EntityType1_14.EntityType.VILLAGER).mobName("Wandering Trader");
regEntType(EntityType1_14.EntityType.RAVAGER, EntityType1_14.EntityType.COW).mobName("Ravager");
registerMetaHandler().handle(e -> { registerMetaHandler().handle(e -> {
if (e.getData().getMetaType().getTypeID() == 6) { // Slot Metadata meta = e.getData();
Protocol1_13_2To1_14.blockItem.handleItemToClient((Item) e.getData().getValue()); int typeId = meta.getMetaType().getTypeID();
if (typeId <= 15) {
meta.setMetaType(MetaType1_13_2.byId(typeId));
} }
return e.getData();
MetaType type = meta.getMetaType();
if (type == MetaType1_13_2.Slot) {
Item item = (Item) meta.getValue();
meta.setValue(getProtocol().getBlockItemPackets().handleItemToClient(item));
} else if (type == MetaType1_13_2.BlockID) {
int blockstate = (Integer) meta.getValue();
meta.setValue(getProtocol().getNewBlockStateId(blockstate));
}
return meta;
}); });
// Remove bed location - todo send sleep packet
registerMetaHandler().filter(EntityType1_14.EntityType.LIVINGENTITY, true, 12).removed(); registerMetaHandler().filter(EntityType1_14.EntityType.PILLAGER, 15).removed();
registerMetaHandler().filter(EntityType1_14.EntityType.LIVINGENTITY, true).handle(e -> {
if (e.getIndex() > 12) e.getData().setId(e.getIndex() - 1); registerMetaHandler().filter(EntityType1_14.EntityType.FOX, 15).removed();
return e.getData(); registerMetaHandler().filter(EntityType1_14.EntityType.FOX, 16).removed();
}); registerMetaHandler().filter(EntityType1_14.EntityType.FOX, 17).removed();
// Remove entity pose registerMetaHandler().filter(EntityType1_14.EntityType.FOX, 18).removed();
registerMetaHandler().filter(EntityType1_14.EntityType.ENTITY, true, 6).removed();
registerMetaHandler().filter(EntityType1_14.EntityType.ENTITY, true).handle(e -> { registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 15).removed();
if (e.getIndex() > 6) e.getData().setId(e.getIndex() - 1); registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 16).removed();
return e.getData(); registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 17).removed();
}); registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 18).removed();
registerMetaHandler().filter(EntityType1_14.EntityType.CAT, 13).removed(); registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 19).removed();
registerMetaHandler().filter(EntityType1_14.EntityType.CAT, 14).removed(); registerMetaHandler().filter(EntityType1_14.EntityType.PANDA, 20).removed();
registerMetaHandler().filter(EntityType1_14.EntityType.CAT, 15).removed();
// Villager data -> var int registerMetaHandler().filter(EntityType1_14.EntityType.CAT, 18).removed();
registerMetaHandler().filter(EntityType1_14.EntityType.CAT, 19).removed();
registerMetaHandler().filter(EntityType1_14.EntityType.CAT, 20).removed();
registerMetaHandler().handle(e -> { registerMetaHandler().handle(e -> {
if (e.getData().getValue() instanceof VillagerData) { AbstractEntityType type = e.getEntity().getType();
e.getData().setMetaType(MetaType1_13_2.VarInt); Metadata meta = e.getData();
e.getData().setValue(villagerDataToProfession(((VillagerData) e.getData().getValue()))); if (type.isOrHasParent(EntityType1_14.EntityType.ABSTRACT_ILLAGER_BASE) || type == EntityType1_14.EntityType.RAVAGER || type == EntityType1_14.EntityType.WITCH) {
int index = e.getIndex();
if (index == 14) {
//TODO handle
throw new RemovedValueException();
} else if (index > 14) {
meta.setId(index - 1);
} }
return e.getData(); }
return meta;
});
registerMetaHandler().filter(EntityType1_14.EntityType.AREA_EFFECT_CLOUD, 10).handle(e -> {
Metadata meta = e.getData();
Particle particle = (Particle) meta.getValue();
particle.setId(getOldParticleId(particle.getId()));
return meta;
});
registerMetaHandler().filter(EntityType1_14.EntityType.FIREWORKS_ROCKET, 8).handle(e -> {
Metadata meta = e.getData();
meta.setMetaType(MetaType1_13_2.VarInt);
Integer value = (Integer) meta.getValue();
if (value == null) meta.setValue(0);
return meta;
});
registerMetaHandler().filter(EntityType1_14.EntityType.ABSTRACT_ARROW, true).handle(e -> {
Metadata meta = e.getData();
int index = e.getIndex();
if (index == 9) {
throw new RemovedValueException();
} else if (index > 9) {
meta.setId(index - 1);
}
return meta;
});
MetaHandler villagerDataHandler = e -> {
Metadata meta = e.getData();
VillagerData villagerData = (VillagerData) meta.getValue();
meta.setValue(villagerDataToProfession(villagerData));
meta.setMetaType(MetaType1_13_2.VarInt);
return meta;
};
registerMetaHandler().filter(EntityType1_14.EntityType.ZOMBIE_VILLAGER, 18).handle(villagerDataHandler);
registerMetaHandler().filter(EntityType1_14.EntityType.VILLAGER, 15).handle(villagerDataHandler);
registerMetaHandler().filter(EntityType1_14.EntityType.ZOMBIE, true).handle(e -> {
Metadata meta = e.getData();
int index = e.getIndex();
if (index >= 16) {
meta.setId(index + 1);
}
return meta;
});
// Remove bed location - todo send sleep packet
registerMetaHandler().filter(EntityType1_14.EntityType.LIVINGENTITY, true).handle(e -> {
Metadata meta = e.getData();
int index = e.getIndex();
if (index == 12) {
throw new RemovedValueException();
} else if (index > 12) {
meta.setId(index - 1);
}
return meta;
});
registerMetaHandler().handle(e -> {
Metadata meta = e.getData();
int index = e.getIndex();
if (index == 6) {
throw new RemovedValueException();
} else if (index > 6) {
meta.setId(index - 1);
}
return meta;
});
registerMetaHandler().handle(e -> {
Metadata meta = e.getData();
int typeId = meta.getMetaType().getTypeID();
if (typeId > 15) {
ViaBackwards.getPlatform().getLogger().warning("New 1.14 metadata was not handled: " + meta + " entity: " + e.getEntity().getType());
return null;
}
return meta;
});
registerMetaHandler().filter(EntityType1_14.EntityType.OCELOT, 13).handle(e -> {
Metadata meta = e.getData();
meta.setId(15);
meta.setMetaType(MetaType1_13_2.VarInt);
meta.setValue(0);
return meta;
});
registerMetaHandler().filter(EntityType1_14.EntityType.CAT).handle(e -> {
Metadata meta = e.getData();
if (meta.getId() == 15) {
meta.setValue(1);
} else if (meta.getId() == 13) {
meta.setValue((byte) ((byte) meta.getValue() & 0x4));
}
return meta;
}); });
} }
@ -329,4 +541,23 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
return 5; // Nitwit return 5; // Nitwit
} }
} }
public static int getOldParticleId(int id) {
if (id >= 45) {
id -= 1; // new 39 -> 44
}
if (id >= 30) {
id -= 1; // skip new short happy villager
}
if (id >= 28) {
id -= 1; // new 24 -> 27
}
if (id >= 14) {
id -= 1; // new water drip 11 -> 13
}
if (id >= 12) {
id -= 2; // new lava drips 10, 11
}
return id;
}
} }

View File

@ -23,7 +23,7 @@ public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
}); });
// Open Sign Editor // Open Sign Editor
protocol.registerOutgoing(State.PLAY, 0x2D, 0x2C, new PacketRemapper() { // c protocol.registerOutgoing(State.PLAY, 0x2F, 0x2C, new PacketRemapper() { // c
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION1_14, Type.POSITION); map(Type.POSITION1_14, Type.POSITION);
@ -40,20 +40,20 @@ public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
}); });
// Edit Book // Edit Book
protocol.registerIncoming(State.PLAY, 0x0c, 0x0B, new PacketRemapper() { protocol.registerIncoming(State.PLAY, 0x0C, 0x0B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
Protocol1_13_2To1_14.blockItem.handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); getProtocol().getBlockItemPackets().handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
} }
}); });
} }
}); });
// Player Digging // Player Digging
protocol.registerIncoming(State.PLAY, 0x1a, 0x18, new PacketRemapper() { protocol.registerIncoming(State.PLAY, 0x1A, 0x18, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -63,7 +63,7 @@ public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
}); });
// Recipe Book Data // Recipe Book Data
protocol.registerIncoming(State.PLAY, 0x1d, 0x1B, new PacketRemapper() { protocol.registerIncoming(State.PLAY, 0x1D, 0x1B, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); map(Type.VAR_INT);
@ -79,11 +79,11 @@ public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
wrapper.passthrough(Type.BOOLEAN); // Smelting Recipe Book Open wrapper.passthrough(Type.BOOLEAN); // Smelting Recipe Book Open
wrapper.passthrough(Type.BOOLEAN); // Smelting Recipe Filter Active wrapper.passthrough(Type.BOOLEAN); // Smelting Recipe Filter Active
// Unknown new booleans // Blast furnace/smoker data
wrapper.read(Type.BOOLEAN); wrapper.write(Type.BOOLEAN, false);
wrapper.read(Type.BOOLEAN); wrapper.write(Type.BOOLEAN, false);
wrapper.read(Type.BOOLEAN); wrapper.write(Type.BOOLEAN, false);
wrapper.read(Type.BOOLEAN); wrapper.write(Type.BOOLEAN, false);
} }
} }
}); });
@ -99,7 +99,7 @@ public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
}); });
// Update Structure Block // Update Structure Block
protocol.registerIncoming(State.PLAY, 0x27, 0x25, new PacketRemapper() { protocol.registerIncoming(State.PLAY, 0x28, 0x25, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION, Type.POSITION1_14); map(Type.POSITION, Type.POSITION1_14);
@ -107,7 +107,7 @@ public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
}); });
// Update Sign // Update Sign
protocol.registerIncoming(State.PLAY, 0x28, 0x26, new PacketRemapper() { protocol.registerIncoming(State.PLAY, 0x29, 0x26, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.POSITION, Type.POSITION1_14); map(Type.POSITION, Type.POSITION1_14);
@ -115,7 +115,7 @@ public class PlayerPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
}); });
// Player Block Placement // Player Block Placement
protocol.registerIncoming(State.PLAY, 0x2b, 0x29, new PacketRemapper() { protocol.registerIncoming(State.PLAY, 0x2C, 0x29, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
handler(new PacketHandler() { handler(new PacketHandler() {

View File

@ -13,7 +13,7 @@ public class SoundPackets1_14 extends Rewriter<Protocol1_13_2To1_14> {
@Override @Override
protected void registerPackets(Protocol1_13_2To1_14 protocol) { protected void registerPackets(Protocol1_13_2To1_14 protocol) {
// Sound Effect // Sound Effect
protocol.registerOutgoing(State.PLAY, 0x4D, 0x4D, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x51, 0x4D, new PacketRemapper() {
@Override @Override
public void registerMap() { public void registerMap() {
map(Type.VAR_INT); // Sound Id map(Type.VAR_INT); // Sound Id

View File

@ -0,0 +1,80 @@
package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.storage;
import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class ChunkLightStorage extends StoredObject {
public static final byte[] FULL_LIGHT = new byte[2048];
public static final byte[] EMPTY_LIGHT = new byte[2048];
private static Constructor<?> fastUtilLongObjectHashMap;
private final Map<Long, ChunkLight> storedLight = createLongObjectMap();
static {
Arrays.fill(FULL_LIGHT, (byte) 0xFF);
Arrays.fill(EMPTY_LIGHT, (byte) 0x0);
try {
fastUtilLongObjectHashMap = Class.forName("it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap").getConstructor();
} catch (ClassNotFoundException | NoSuchMethodException ignored) {
}
}
public ChunkLightStorage(UserConnection user) {
super(user);
}
public void setStoredLight(byte[][] skyLight, byte[][] blockLight, int x, int z) {
storedLight.put(getChunkSectionIndex(x, z), new ChunkLight(skyLight, blockLight));
}
public ChunkLight getStoredLight(int x, int z) {
return storedLight.get(getChunkSectionIndex(x, z));
}
public void clear() {
storedLight.clear();
}
public void unloadChunk(int x, int z) {
storedLight.remove(getChunkSectionIndex(x, z));
}
private long getChunkSectionIndex(int x, int z) {
return ((x & 0x3FFFFFFL) << 38) | (z & 0x3FFFFFFL);
}
private Map<Long, ChunkLight> createLongObjectMap() {
if (fastUtilLongObjectHashMap != null) {
try {
return (Map<Long, ChunkLight>) fastUtilLongObjectHashMap.newInstance();
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
e.printStackTrace();
}
}
return new HashMap<>();
}
public static class ChunkLight {
private final byte[][] skyLight;
private final byte[][] blockLight;
public ChunkLight(byte[][] skyLight, byte[][] blockLight) {
this.skyLight = skyLight;
this.blockLight = blockLight;
}
public byte[][] getSkyLight() {
return skyLight;
}
public byte[][] getBlockLight() {
return blockLight;
}
}
}

View File

@ -109,7 +109,7 @@ public class WorldPackets1_13_1 {
int id = wrapper.get(Type.INT, 0); int id = wrapper.get(Type.INT, 0);
int data = wrapper.get(Type.INT, 1); int data = wrapper.get(Type.INT, 1);
if (id == 1010) { // Play record if (id == 1010) { // Play record
wrapper.set(Type.INT, 1, data = InventoryPackets1_13_1.getNewItemId(data)); wrapper.set(Type.INT, 1, data = InventoryPackets1_13_1.getOldItemId(data));
} else if (id == 2001) { // Block break + block break sound } else if (id == 2001) { // Block break + block break sound
wrapper.set(Type.INT, 1, data = Protocol1_13To1_13_1.getNewBlockStateId(data)); wrapper.set(Type.INT, 1, data = Protocol1_13To1_13_1.getNewBlockStateId(data));
} }

View File

@ -0,0 +1,15 @@
package nl.matsv.viabackwards.protocol.protocol1_14_1to1_14_2;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import us.myles.ViaVersion.api.data.UserConnection;
public class Protocol1_14_1To1_14_2 extends BackwardsProtocol {
@Override
protected void registerPackets() {
}
@Override
public void init(UserConnection userConnection) {
}
}

View File

@ -0,0 +1,114 @@
package nl.matsv.viabackwards.protocol.protocol1_14_2to1_14_3;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
public class Protocol1_14_2To1_14_3 extends BackwardsProtocol {
@Override
protected void registerPackets() {
// Trade list
registerOutgoing(State.PLAY, 0x27, 0x27, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.VAR_INT);
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
}
wrapper.passthrough(Type.BOOLEAN);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.FLOAT);
}
wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.BOOLEAN);
wrapper.read(Type.BOOLEAN);
}
});
}
});
// Declare recipes
registerOutgoing(State.PLAY, 0x5A, 0x5A, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int size = wrapper.passthrough(Type.VAR_INT);
int deleted = 0;
for (int i = 0; i < size; i++) {
String fullType = wrapper.read(Type.STRING);
String type = fullType.replace("minecraft:", "");
String id = wrapper.read(Type.STRING); // id
if (type.equals("crafting_special_repairitem")) {
deleted++;
continue;
}
wrapper.write(Type.STRING, fullType);
wrapper.write(Type.STRING, id);
if (type.equals("crafting_shapeless")) {
wrapper.passthrough(Type.STRING); // Group
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
for (int j = 0; j < ingredientsNo; j++) {
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
}
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
} else if (type.equals("crafting_shaped")) {
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.STRING); // Group
for (int j = 0; j < ingredientsNo; j++) {
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
}
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
} else if (type.equals("smelting")) {
wrapper.passthrough(Type.STRING); // Group
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);// Result
wrapper.passthrough(Type.FLOAT); // EXP
wrapper.passthrough(Type.VAR_INT); // Cooking time
} else if (type.equals("stonecutting")) {
wrapper.passthrough(Type.STRING); // Group?
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM); // Result
} else if (type.equals("blasting") || type.equals("campfire_cooking") || type.equals("smoking")) {
wrapper.passthrough(Type.STRING); // Group
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
wrapper.passthrough(Type.FLOAT); // EXP
wrapper.passthrough(Type.VAR_INT); // Cooking time
}
}
wrapper.set(Type.VAR_INT, 0, size - deleted);
}
});
}
});
}
@Override
public void init(UserConnection userConnection) {
}
}

View File

@ -0,0 +1,37 @@
package nl.matsv.viabackwards.protocol.protocol1_14to1_14_1;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.entities.Entity1_14Types;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Marco Neuhaus on 15.05.2019 for the Project ViaBackwardsFoorcee.
*/
public class MetadataRewriter {
public static void handleMetadata(int entityId, Entity1_14Types.EntityType type, List<Metadata> metadatas, UserConnection connection) {
if (type == null) return;
for (Metadata metadata : new ArrayList<>(metadatas)) {
try {
if (type.is(Entity1_14Types.EntityType.VILLAGER) || type.is(Entity1_14Types.EntityType.WANDERING_TRADER)) {
if (metadata.getId() >= 16) {
metadata.setId(metadata.getId() - 1);
}
}
} catch (Exception e) {
metadatas.remove(metadata);
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("An error occurred with entity metadata handler");
Via.getPlatform().getLogger().warning("Metadata: " + metadata);
e.printStackTrace();
}
}
}
}
}

View File

@ -0,0 +1,22 @@
package nl.matsv.viabackwards.protocol.protocol1_14to1_14_1;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.packets.EntityPackets;
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.storage.EntityTracker;
import us.myles.ViaVersion.api.data.UserConnection;
/**
* Created by Marco Neuhaus on 15.05.2019 for the Project ViaBackwardsFoorcee.
*/
public class Protocol1_14To1_14_1 extends BackwardsProtocol {
@Override
protected void registerPackets() {
EntityPackets.register(this);
}
@Override
public void init(UserConnection userConnection) {
userConnection.put(new EntityTracker(userConnection));
}
}

View File

@ -0,0 +1,106 @@
package nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.packets;
import com.google.common.base.Optional;
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.MetadataRewriter;
import nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.storage.EntityTracker;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.entities.Entity1_14Types;
import us.myles.ViaVersion.api.entities.Entity1_14Types.EntityType;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.packets.State;
/**
* Created by Marco Neuhaus on 15.05.2019 for the Project ViaBackwardsFoorcee.
*/
public class EntityPackets {
public static void register(Protocol protocol) {
// Spawn Mob
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
map(Type.UUID); // 1 - Entity UUID
map(Type.VAR_INT); // 2 - Entity Type
map(Type.DOUBLE); // 3 - X
map(Type.DOUBLE); // 4 - Y
map(Type.DOUBLE); // 5 - Z
map(Type.BYTE); // 6 - Yaw
map(Type.BYTE); // 7 - Pitch
map(Type.BYTE); // 8 - Head Pitch
map(Type.SHORT); // 9 - Velocity X
map(Type.SHORT); // 10 - Velocity Y
map(Type.SHORT); // 11 - Velocity Z
map(Types1_14.METADATA_LIST); // 12 - Metadata
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int entityId = wrapper.get(Type.VAR_INT, 0);
int type = wrapper.get(Type.VAR_INT, 1);
Entity1_14Types.EntityType entType = Entity1_14Types.getTypeFromId(type);
// Register Type ID
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user());
}
});
}
});
// Spawn Player
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
map(Type.UUID); // 1 - Player UUID
map(Type.DOUBLE); // 2 - X
map(Type.DOUBLE); // 3 - Y
map(Type.DOUBLE); // 4 - Z
map(Type.BYTE); // 5 - Yaw
map(Type.BYTE); // 6 - Pitch
map(Types1_14.METADATA_LIST); // 7 - Metadata
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int entityId = wrapper.get(Type.VAR_INT, 0);
Entity1_14Types.EntityType entType = Entity1_14Types.EntityType.PLAYER;
// Register Type ID
wrapper.user().get(EntityTracker.class).addEntity(entityId, entType);
MetadataRewriter.handleMetadata(entityId, entType, wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user());
}
});
}
});
// Entity Metadata
protocol.registerOutgoing(State.PLAY, 0x43, 0x43, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // 0 - Entity ID
map(Types1_14.METADATA_LIST); // 1 - Metadata list
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int entityId = wrapper.get(Type.VAR_INT, 0);
Optional<EntityType> type = wrapper.user().get(EntityTracker.class).get(entityId);
MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user());
}
});
}
});
}
}

View File

@ -0,0 +1,49 @@
package nl.matsv.viabackwards.protocol.protocol1_14to1_14_1.storage;
import com.google.common.base.Optional;
import lombok.Getter;
import lombok.Setter;
import us.myles.ViaVersion.api.data.ExternalJoinGameListener;
import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.entities.Entity1_14Types;
import us.myles.ViaVersion.api.entities.Entity1_14Types.EntityType;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Created by Marco Neuhaus on 15.05.2019 for the Project ViaBackwardsFoorcee.
*/
public class EntityTracker extends StoredObject implements ExternalJoinGameListener {
private final Map<Integer, EntityType> clientEntityTypes = new ConcurrentHashMap<>();
@Getter
@Setter
private int clientEntityId;
public EntityTracker(UserConnection user) {
super(user);
}
public void removeEntity(int entityId) {
clientEntityTypes.remove(entityId);
}
public void addEntity(int entityId, Entity1_14Types.EntityType type) {
clientEntityTypes.put(entityId, type);
}
public boolean has(int entityId) {
return clientEntityTypes.containsKey(entityId);
}
public Optional<EntityType> get(int id) {
return Optional.fromNullable(clientEntityTypes.get(id));
}
@Override
public void onExternalJoinGame(int playerEntityId) {
clientEntityId = playerEntityId;
clientEntityTypes.put(playerEntityId, Entity1_14Types.EntityType.PLAYER);
}
}

View File

@ -4779,14 +4779,14 @@
"minecraft:dark_oak_door[facing=east,half=lower,hinge=left,open=false,powered=false]": "minecraft:dark_oak_door[facing=east,half=lower,hinge=right,open=false,powered=false]", "minecraft:dark_oak_door[facing=east,half=lower,hinge=left,open=false,powered=false]": "minecraft:dark_oak_door[facing=east,half=lower,hinge=right,open=false,powered=false]",
"minecraft:dark_oak_door[facing=east,half=lower,hinge=right,open=true,powered=true]": "minecraft:dark_oak_door[facing=east,half=lower,hinge=right,open=true,powered=false]", "minecraft:dark_oak_door[facing=east,half=lower,hinge=right,open=true,powered=true]": "minecraft:dark_oak_door[facing=east,half=lower,hinge=right,open=true,powered=false]",
"minecraft:dark_oak_door[facing=east,half=lower,hinge=right,open=false,powered=true]": "minecraft:dark_oak_door[facing=east,half=lower,hinge=right,open=false,powered=false]", "minecraft:dark_oak_door[facing=east,half=lower,hinge=right,open=false,powered=true]": "minecraft:dark_oak_door[facing=east,half=lower,hinge=right,open=false,powered=false]",
"minecraft:lever[face=floor,facing=north,powered=true]": "minecraft:lever[face=floor,facing=south,powered=false]",
"minecraft:lever[face=floor,facing=south,powered=true]": "minecraft:lever[face=floor,facing=north,powered=false]", "minecraft:lever[face=floor,facing=south,powered=true]": "minecraft:lever[face=floor,facing=north,powered=false]",
"minecraft:lever[face=floor,facing=west,powered=true]": "minecraft:lever[face=floor,facing=east,powered=false]", "minecraft:lever[face=floor,facing=south,powered=false]": "minecraft:lever[face=floor,facing=north,powered=true]",
"minecraft:lever[face=floor,facing=east,powered=true]": "minecraft:lever[face=floor,facing=west,powered=false]", "minecraft:lever[face=floor,facing=east,powered=true]": "minecraft:lever[face=floor,facing=west,powered=false]",
"minecraft:lever[face=ceiling,facing=north,powered=true]": "minecraft:lever[face=ceiling,facing=south,powered=false]", "minecraft:lever[face=floor,facing=east,powered=false]": "minecraft:lever[face=floor,facing=west,powered=true]",
"minecraft:lever[face=ceiling,facing=south,powered=true]": "minecraft:lever[face=ceiling,facing=north,powered=false]", "minecraft:lever[face=ceiling,facing=south,powered=true]": "minecraft:lever[face=ceiling,facing=north,powered=false]",
"minecraft:lever[face=ceiling,facing=west,powered=true]": "minecraft:lever[face=ceiling,facing=east,powered=false]", "minecraft:lever[face=ceiling,facing=south,powered=false]": "minecraft:lever[face=ceiling,facing=north,powered=true]",
"minecraft:lever[face=ceiling,facing=east,powered=true]": "minecraft:lever[face=ceiling,facing=west,powered=false]", "minecraft:lever[face=ceiling,facing=east,powered=true]": "minecraft:lever[face=ceiling,facing=west,powered=false]",
"minecraft:lever[face=ceiling,facing=east,powered=false]": "minecraft:lever[face=ceiling,facing=west,powered=true]",
"minecraft:dried_kelp_block": "minecraft:hay_block[axis=y]", "minecraft:dried_kelp_block": "minecraft:hay_block[axis=y]",
"minecraft:dead_tube_coral_block": "minecraft:light_gray_wool", "minecraft:dead_tube_coral_block": "minecraft:light_gray_wool",
"minecraft:dead_brain_coral_block": "minecraft:light_gray_wool", "minecraft:dead_brain_coral_block": "minecraft:light_gray_wool",
@ -5128,6 +5128,194 @@
"minecraft:black_wall_banner[facing=south]": "minecraft:white_wall_banner[facing=south]", "minecraft:black_wall_banner[facing=south]": "minecraft:white_wall_banner[facing=south]",
"minecraft:black_wall_banner[facing=west]": "minecraft:white_wall_banner[facing=west]", "minecraft:black_wall_banner[facing=west]": "minecraft:white_wall_banner[facing=west]",
"minecraft:black_wall_banner[facing=east]": "minecraft:white_wall_banner[facing=east]", "minecraft:black_wall_banner[facing=east]": "minecraft:white_wall_banner[facing=east]",
"minecraft:turtle_egg[eggs=1,hatch=0]": "minecraft:cocoa[age=0,facing=west]",
"minecraft:turtle_egg[eggs=1,hatch=1]": "minecraft:cocoa[age=0,facing=west]",
"minecraft:turtle_egg[eggs=1,hatch=2]": "minecraft:cocoa[age=0,facing=west]",
"minecraft:turtle_egg[eggs=2,hatch=0]": "minecraft:cocoa[age=0,facing=west]",
"minecraft:turtle_egg[eggs=2,hatch=1]": "minecraft:cocoa[age=0,facing=west]",
"minecraft:turtle_egg[eggs=2,hatch=2]": "minecraft:cocoa[age=0,facing=west]",
"minecraft:turtle_egg[eggs=3,hatch=0]": "minecraft:cocoa[age=1,facing=west]",
"minecraft:turtle_egg[eggs=3,hatch=1]": "minecraft:cocoa[age=1,facing=west]",
"minecraft:turtle_egg[eggs=3,hatch=2]": "minecraft:cocoa[age=1,facing=west]",
"minecraft:turtle_egg[eggs=4,hatch=0]": "minecraft:cocoa[age=2,facing=west]",
"minecraft:turtle_egg[eggs=4,hatch=1]": "minecraft:cocoa[age=2,facing=west]",
"minecraft:turtle_egg[eggs=4,hatch=2]": "minecraft:cocoa[age=2,facing=west]",
"minecraft:sea_pickle[pickles=1,waterlogged=true]": "minecraft:cocoa[age=0,facing=east]",
"minecraft:sea_pickle[pickles=1,waterlogged=false]": "minecraft:cocoa[age=0,facing=east]",
"minecraft:sea_pickle[pickles=2,waterlogged=true]": "minecraft:cocoa[age=0,facing=east]",
"minecraft:sea_pickle[pickles=2,waterlogged=false]": "minecraft:cocoa[age=0,facing=east]",
"minecraft:sea_pickle[pickles=3,waterlogged=true]": "minecraft:cocoa[age=1,facing=east]",
"minecraft:sea_pickle[pickles=3,waterlogged=false]": "minecraft:cocoa[age=1,facing=east]",
"minecraft:sea_pickle[pickles=4,waterlogged=true]": "minecraft:cocoa[age=2,facing=east]",
"minecraft:sea_pickle[pickles=4,waterlogged=false]": "minecraft:cocoa[age=2,facing=east]",
"minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=false]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=false,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=false,west=false]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=true,north=true,south=false,up=true,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=true,north=true,south=false,up=true,west=false]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=true,north=true,south=false,up=false,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=true,north=true,south=false,up=false,west=false]": "minecraft:brown_mushroom_block[down=false,east=true,north=true,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=true,east=true,north=false,south=true,up=true,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=true,north=false,south=true,up=true,west=false]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=true,north=false,south=true,up=false,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=true,north=false,south=true,up=false,west=false]": "minecraft:brown_mushroom_block[down=false,east=true,north=false,south=true,up=true,west=false]",
"minecraft:brown_mushroom_block[down=true,east=true,north=false,south=false,up=true,west=true]": "minecraft:brown_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=true,east=true,north=false,south=false,up=true,west=false]": "minecraft:brown_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=true,east=true,north=false,south=false,up=false,west=true]": "minecraft:brown_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=true,east=true,north=false,south=false,up=false,west=false]": "minecraft:brown_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=true,east=false,north=true,south=true,up=true,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=false,north=true,south=true,up=true,west=false]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=false,north=true,south=true,up=false,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=false,north=true,south=true,up=false,west=false]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=false,north=true,south=false,up=true,west=true]": "minecraft:brown_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=false,north=true,south=false,up=true,west=false]": "minecraft:brown_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=true,east=false,north=true,south=false,up=false,west=true]": "minecraft:brown_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=false,north=true,south=false,up=false,west=false]": "minecraft:brown_mushroom_block[down=false,east=false,north=false,south=false,up=false,west=false]",
"minecraft:brown_mushroom_block[down=true,east=false,north=false,south=true,up=true,west=true]": "minecraft:brown_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=false,north=false,south=true,up=true,west=false]": "minecraft:brown_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=false]",
"minecraft:brown_mushroom_block[down=true,east=false,north=false,south=true,up=false,west=true]": "minecraft:brown_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=false,north=false,south=true,up=false,west=false]": "minecraft:brown_mushroom_block[down=false,east=false,north=false,south=false,up=false,west=false]",
"minecraft:brown_mushroom_block[down=true,east=false,north=false,south=false,up=true,west=true]": "minecraft:brown_mushroom_block[down=false,east=false,north=false,south=false,up=true,west=true]",
"minecraft:brown_mushroom_block[down=true,east=false,north=false,south=false,up=true,west=false]": "minecraft:brown_mushroom_block[down=false,east=false,north=false,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=true,east=false,north=false,south=false,up=false,west=true]": "minecraft:brown_mushroom_block[down=false,east=false,north=false,south=false,up=false,west=false]",
"minecraft:brown_mushroom_block[down=true,east=false,north=false,south=false,up=false,west=false]": "minecraft:brown_mushroom_block[down=false,east=false,north=false,south=false,up=false,west=false]",
"minecraft:brown_mushroom_block[down=false,east=true,north=true,south=true,up=true,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=false,east=true,north=true,south=true,up=true,west=false]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=false,east=true,north=true,south=true,up=false,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=false,east=true,north=true,south=true,up=false,west=false]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=false,east=true,north=true,south=false,up=true,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=false,east=true,north=true,south=false,up=false,west=true]": "minecraft:brown_mushroom_block[down=false,east=true,north=true,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=false,east=true,north=true,south=false,up=false,west=false]": "minecraft:brown_mushroom_block[down=false,east=true,north=true,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=false,east=true,north=false,south=true,up=true,west=true]": "minecraft:brown_mushroom_block[down=false,east=true,north=false,south=true,up=true,west=false]",
"minecraft:brown_mushroom_block[down=false,east=true,north=false,south=true,up=false,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=false,east=true,north=false,south=true,up=false,west=false]": "minecraft:brown_mushroom_block[down=false,east=true,north=false,south=true,up=true,west=false]",
"minecraft:brown_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=true]": "minecraft:brown_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=false,east=true,north=false,south=false,up=false,west=true]": "minecraft:brown_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=false,east=true,north=false,south=false,up=false,west=false]": "minecraft:brown_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=false,east=false,north=true,south=true,up=true,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=false,east=false,north=true,south=true,up=true,west=false]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=false,east=false,north=true,south=true,up=false,west=true]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=false,east=false,north=true,south=true,up=false,west=false]": "minecraft:brown_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=false,east=false,north=true,south=false,up=false,west=true]": "minecraft:brown_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=true]",
"minecraft:brown_mushroom_block[down=false,east=false,north=true,south=false,up=false,west=false]": "minecraft:brown_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=false]",
"minecraft:brown_mushroom_block[down=false,east=false,north=false,south=true,up=false,west=true]": "minecraft:brown_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=true]",
"minecraft:brown_mushroom_block[down=false,east=false,north=false,south=true,up=false,west=false]": "minecraft:brown_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=false]",
"minecraft:brown_mushroom_block[down=false,east=false,north=false,south=false,up=false,west=true]": "minecraft:brown_mushroom_block[down=false,east=false,north=false,south=false,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=false]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=false,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=false,west=false]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=true,north=true,south=false,up=true,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=true,north=true,south=false,up=true,west=false]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=true,north=true,south=false,up=false,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=true,north=true,south=false,up=false,west=false]": "minecraft:red_mushroom_block[down=false,east=true,north=true,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=true,east=true,north=false,south=true,up=true,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=true,north=false,south=true,up=true,west=false]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=true,north=false,south=true,up=false,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=true,north=false,south=true,up=false,west=false]": "minecraft:red_mushroom_block[down=false,east=true,north=false,south=true,up=true,west=false]",
"minecraft:red_mushroom_block[down=true,east=true,north=false,south=false,up=true,west=true]": "minecraft:red_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=true,east=true,north=false,south=false,up=true,west=false]": "minecraft:red_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=true,east=true,north=false,south=false,up=false,west=true]": "minecraft:red_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=true,east=true,north=false,south=false,up=false,west=false]": "minecraft:red_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=true,east=false,north=true,south=true,up=true,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=false,north=true,south=true,up=true,west=false]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=false,north=true,south=true,up=false,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=false,north=true,south=true,up=false,west=false]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=false,north=true,south=false,up=true,west=true]": "minecraft:red_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=false,north=true,south=false,up=true,west=false]": "minecraft:red_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=true,east=false,north=true,south=false,up=false,west=true]": "minecraft:red_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=false,north=true,south=false,up=false,west=false]": "minecraft:red_mushroom_block[down=false,east=false,north=false,south=false,up=false,west=false]",
"minecraft:red_mushroom_block[down=true,east=false,north=false,south=true,up=true,west=true]": "minecraft:red_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=false,north=false,south=true,up=true,west=false]": "minecraft:red_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=false]",
"minecraft:red_mushroom_block[down=true,east=false,north=false,south=true,up=false,west=true]": "minecraft:red_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=false,north=false,south=true,up=false,west=false]": "minecraft:red_mushroom_block[down=false,east=false,north=false,south=false,up=false,west=false]",
"minecraft:red_mushroom_block[down=true,east=false,north=false,south=false,up=true,west=true]": "minecraft:red_mushroom_block[down=false,east=false,north=false,south=false,up=true,west=true]",
"minecraft:red_mushroom_block[down=true,east=false,north=false,south=false,up=true,west=false]": "minecraft:red_mushroom_block[down=false,east=false,north=false,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=true,east=false,north=false,south=false,up=false,west=true]": "minecraft:red_mushroom_block[down=false,east=false,north=false,south=false,up=false,west=false]",
"minecraft:red_mushroom_block[down=true,east=false,north=false,south=false,up=false,west=false]": "minecraft:red_mushroom_block[down=false,east=false,north=false,south=false,up=false,west=false]",
"minecraft:red_mushroom_block[down=false,east=true,north=true,south=true,up=true,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=false,east=true,north=true,south=true,up=true,west=false]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=false,east=true,north=true,south=true,up=false,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=false,east=true,north=true,south=true,up=false,west=false]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=false,east=true,north=true,south=false,up=true,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=false,east=true,north=true,south=false,up=false,west=true]": "minecraft:red_mushroom_block[down=false,east=true,north=true,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=false,east=true,north=true,south=false,up=false,west=false]": "minecraft:red_mushroom_block[down=false,east=true,north=true,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=false,east=true,north=false,south=true,up=true,west=true]": "minecraft:red_mushroom_block[down=false,east=true,north=false,south=true,up=true,west=false]",
"minecraft:red_mushroom_block[down=false,east=true,north=false,south=true,up=false,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=false,east=true,north=false,south=true,up=false,west=false]": "minecraft:red_mushroom_block[down=false,east=true,north=false,south=true,up=true,west=false]",
"minecraft:red_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=true]": "minecraft:red_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=false,east=true,north=false,south=false,up=false,west=true]": "minecraft:red_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=false,east=true,north=false,south=false,up=false,west=false]": "minecraft:red_mushroom_block[down=false,east=true,north=false,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=false,east=false,north=true,south=true,up=true,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=false,east=false,north=true,south=true,up=true,west=false]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=false,east=false,north=true,south=true,up=false,west=true]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=false,east=false,north=true,south=true,up=false,west=false]": "minecraft:red_mushroom_block[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=false,east=false,north=true,south=false,up=false,west=true]": "minecraft:red_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=true]",
"minecraft:red_mushroom_block[down=false,east=false,north=true,south=false,up=false,west=false]": "minecraft:red_mushroom_block[down=false,east=false,north=true,south=false,up=true,west=false]",
"minecraft:red_mushroom_block[down=false,east=false,north=false,south=true,up=false,west=true]": "minecraft:red_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=true]",
"minecraft:red_mushroom_block[down=false,east=false,north=false,south=true,up=false,west=false]": "minecraft:red_mushroom_block[down=false,east=false,north=false,south=true,up=true,west=false]",
"minecraft:red_mushroom_block[down=false,east=false,north=false,south=false,up=false,west=true]": "minecraft:red_mushroom_block[down=false,east=false,north=false,south=false,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=false]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=true,south=false,up=true,west=true]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=true,south=false,up=true,west=false]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=true,south=false,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=true,south=false,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=false,south=true,up=true,west=true]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=false,south=true,up=true,west=false]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=false,south=true,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=false,south=true,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=false,south=false,up=true,west=true]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=false,south=false,up=true,west=false]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=false,south=false,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=true,north=false,south=false,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=true,south=true,up=true,west=true]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=true,south=true,up=true,west=false]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=true,south=true,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=true,south=true,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=true,south=false,up=true,west=true]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=true,south=false,up=true,west=false]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=true,south=false,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=true,south=false,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=false,south=true,up=true,west=true]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=false,south=true,up=true,west=false]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=false,south=true,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=false,south=true,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=false,south=false,up=true,west=true]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=false,south=false,up=true,west=false]": "minecraft:mushroom_stem[down=true,east=true,north=true,south=true,up=true,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=false,south=false,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=true,east=false,north=false,south=false,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=true,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=true,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=true,south=false,up=true,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=true,south=false,up=true,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=true,south=false,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=true,south=false,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=false,south=true,up=true,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=false,south=true,up=true,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=false,south=true,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=false,south=true,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=false,south=false,up=true,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=false,south=false,up=true,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=false,south=false,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=true,north=false,south=false,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=true,south=true,up=true,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=true,south=true,up=true,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=true,south=true,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=true,south=true,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=true,south=false,up=true,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=true,south=false,up=true,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=true,south=false,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=true,south=false,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=false,south=true,up=true,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=false,south=true,up=true,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=false,south=true,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=false,south=true,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=false,south=false,up=true,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=false,south=false,up=true,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=false,south=false,up=false,west=true]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:mushroom_stem[down=false,east=false,north=false,south=false,up=false,west=false]": "minecraft:mushroom_stem[down=false,east=true,north=true,south=true,up=false,west=true]",
"minecraft:skeleton_wall_skull[facing=north]": "id:2306", "minecraft:skeleton_wall_skull[facing=north]": "id:2306",
"minecraft:skeleton_wall_skull[facing=south]": "id:2307", "minecraft:skeleton_wall_skull[facing=south]": "id:2307",
"minecraft:skeleton_wall_skull[facing=west]": "id:2308", "minecraft:skeleton_wall_skull[facing=west]": "id:2308",

63
fabric/pom.xml Normal file
View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016 Matsv
~
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId>
<version>3.0.0-1.14.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>viabackwards-fabric</artifactId>
<repositories>
<repository>
<id>fabric-repo</id>
<url>https://maven.fabricmc.net/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.fabricmc</groupId>
<artifactId>fabric-loader</artifactId>
<version>0.4.8+build.154</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.8.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>nl.matsv</groupId>
<artifactId>viabackwards-core</artifactId>
<version>${project.parent.version}</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<targetPath>.</targetPath>
<filtering>true</filtering>
<directory>src/main/resources/</directory>
<includes>
<include>*</include>
</includes>
</resource>
</resources>
</build>
</project>

View File

@ -0,0 +1,34 @@
/*
* Copyright (c) 2016 Matsv
*
* 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 nl.matsv.viabackwards;
import lombok.Getter;
import net.fabricmc.loader.api.FabricLoader;
import nl.matsv.viabackwards.api.ViaBackwardsPlatform;
import nl.matsv.viabackwards.fabric.util.LoggerWrapper;
import org.apache.logging.log4j.LogManager;
import java.util.logging.Logger;
public class ViaFabricAddon implements ViaBackwardsPlatform, Runnable {
@Getter
private final Logger logger = new LoggerWrapper(LogManager.getLogger("ViaRewind"));
@Override
public void run() {
this.init();
}
@Override
public void disable() {
// Not possible
}
}

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) 2016 Matsv
*
* 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 nl.matsv.viabackwards.fabric.util;
import java.text.MessageFormat;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
public class LoggerWrapper extends Logger {
private final org.apache.logging.log4j.Logger base;
public LoggerWrapper(org.apache.logging.log4j.Logger logger) {
super("logger", null);
this.base = logger;
}
public void log(LogRecord record) {
this.log(record.getLevel(), record.getMessage());
}
public void log(Level level, String msg) {
if (level == Level.FINE) {
this.base.debug(msg);
} else if (level == Level.WARNING) {
this.base.warn(msg);
} else if (level == Level.SEVERE) {
this.base.error(msg);
} else if (level == Level.INFO) {
this.base.info(msg);
} else {
this.base.trace(msg);
}
}
public void log(Level level, String msg, Object param1) {
if (level == Level.FINE) {
this.base.debug(msg, param1);
} else if (level == Level.WARNING) {
this.base.warn(msg, param1);
} else if (level == Level.SEVERE) {
this.base.error(msg, param1);
} else if (level == Level.INFO) {
this.base.info(msg, param1);
} else {
this.base.trace(msg, param1);
}
}
public void log(Level level, String msg, Object[] params) {
log(level, MessageFormat.format(msg, params));
}
public void log(Level level, String msg, Throwable params) {
if (level == Level.FINE) {
this.base.debug(msg, params);
} else if (level == Level.WARNING) {
this.base.warn(msg, params);
} else if (level == Level.SEVERE) {
this.base.error(msg, params);
} else if (level == Level.INFO) {
this.base.info(msg, params);
} else {
this.base.trace(msg, params);
}
}
}

View File

@ -0,0 +1,29 @@
{
"schemaVersion": 1,
"id": "viabackwards",
"name": "ViaBackwards",
"version": "${project.version}",
"description": "Allow older Minecraft versions to connect to a newer server version.",
"license": "MIT",
"contact": {
"homepage": "https://github.com/ViaVersion/ViaBackwards",
"issues": "https://github.com/ViaVersion/ViaBackwards/issues",
"sources": "https://github.com/ViaVersion/ViaBackwards"
},
"environment": "*",
"authors": [
"Matsv"
],
"entrypoints": {
"viafabric:via_api_initialized": [
"nl.matsv.viabackwards.ViaFabricAddon"
]
},
"depends": {
"fabricloader": ">=0.4.0",
"viafabric": "*"
},
"recommends": {
"viarewind": "*"
}
}

11
pom.xml
View File

@ -16,7 +16,7 @@
<groupId>nl.matsv</groupId> <groupId>nl.matsv</groupId>
<artifactId>viabackwards-parent</artifactId> <artifactId>viabackwards-parent</artifactId>
<version>3.0.0-19w11b</version> <version>3.0.0-1.14.3</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<description>Allow newer clients to join older server versions.</description> <description>Allow newer clients to join older server versions.</description>
@ -27,6 +27,7 @@
<module>core</module> <module>core</module>
<module>bukkit</module> <module>bukkit</module>
<module>bungee</module> <module>bungee</module>
<module>fabric</module>
<module>sponge</module> <module>sponge</module>
<module>velocity</module> <module>velocity</module>
<module>all</module> <module>all</module>
@ -56,17 +57,11 @@
<version>1.16.18</version> <version>1.16.18</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
</dependency>
<!-- ViaVersion --> <!-- ViaVersion -->
<dependency> <dependency>
<groupId>us.myles</groupId> <groupId>us.myles</groupId>
<artifactId>viaversion</artifactId> <artifactId>viaversion</artifactId>
<version>2.0.0-19w09a</version> <version>2.1.2</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -15,7 +15,7 @@
<parent> <parent>
<artifactId>viabackwards-parent</artifactId> <artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId> <groupId>nl.matsv</groupId>
<version>3.0.0-19w11b</version> <version>3.0.0-1.14.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -27,7 +27,7 @@ import java.util.logging.Logger;
name = "ViaBackwards", name = "ViaBackwards",
version = VersionInfo.VERSION, version = VersionInfo.VERSION,
authors = {"Matsv"}, authors = {"Matsv"},
description = "Allow older Minecraft versions to connect to an newer server version.", description = "Allow older Minecraft versions to connect to a newer server version.",
dependencies = {@Dependency(id = "viaversion")} dependencies = {@Dependency(id = "viaversion")}
) )
public class SpongePlugin implements ViaBackwardsPlatform { public class SpongePlugin implements ViaBackwardsPlatform {

View File

@ -15,7 +15,7 @@
<parent> <parent>
<artifactId>viabackwards-parent</artifactId> <artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId> <groupId>nl.matsv</groupId>
<version>3.0.0-19w11b</version> <version>3.0.0-1.14.3</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -27,7 +27,7 @@ import java.util.logging.Logger;
name = "ViaBackwards", name = "ViaBackwards",
version = VersionInfo.VERSION, version = VersionInfo.VERSION,
authors = {"Matsv"}, authors = {"Matsv"},
description = "Allow older Minecraft versions to connect to an newer server version.", description = "Allow older Minecraft versions to connect to a newer server version.",
dependencies = {@Dependency(id = "viaversion")} dependencies = {@Dependency(id = "viaversion")}
) )
public class VelocityPlugin implements ViaBackwardsPlatform { public class VelocityPlugin implements ViaBackwardsPlatform {