3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-26 16:12:43 +01:00

Merge remote-tracking branch 'origin/1.14' into 1.14

Dieser Commit ist enthalten in:
Marco 2019-05-21 22:07:50 +02:00
Commit 347da9c309
5 geänderte Dateien mit 60 neuen und 16 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -21,7 +21,7 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@Getter
public class Protocol1_13_2To1_14 extends BackwardsProtocol {
private BlockItemPackets1_14 blockItemPackets;
private EntityPackets1_14 entityPacket;
private EntityPackets1_14 entityPackets;
static {
BackwardsMappings.init();
@ -32,8 +32,8 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol {
protected void registerPackets() {
blockItemPackets = new BlockItemPackets1_14();
blockItemPackets.register(this);
entityPacket = new EntityPackets1_14();
entityPacket.register(this);
entityPackets = new EntityPackets1_14();
entityPackets.register(this);
new PlayerPackets1_14().register(this);
new SoundPackets1_14().register(this);

Datei anzeigen

@ -2,6 +2,9 @@ package nl.matsv.viabackwards.protocol.protocol1_13_2to1_14.packets;
import com.google.common.collect.ImmutableSet;
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.protocol.protocol1_13_2to1_14.Protocol1_13_2To1_14;
import us.myles.ViaVersion.api.PacketWrapper;
@ -10,9 +13,12 @@ import us.myles.ViaVersion.api.minecraft.Environment;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
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.PacketRemapper;
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.protocols.protocol1_13to1_12_2.ChatRewriter;
import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.types.Chunk1_13Type;
@ -26,7 +32,9 @@ 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.Tag;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14> {
@ -224,6 +232,31 @@ public class BlockItemPackets1_14 extends BlockItemRewriter<Protocol1_13_2To1_14
handleItemToClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
}
});
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.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);
}
}
});
}
});

Datei anzeigen

@ -289,6 +289,9 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
@Override
protected void registerRewrites() {
setDisplayNameJson(true);
setDisplayNameMetaType(MetaType1_13_2.OptChat);
regEntType(EntityType1_14.EntityType.CAT, EntityType1_14.EntityType.OCELOT).mobName("Cat").spawnMetadata(e -> {
// e.add(new Metadata(13, MetaType1_13_2.Byte, (byte) 0x4)); // Tamed cat
});
@ -426,7 +429,7 @@ public class EntityPackets1_14 extends EntityRewriter<Protocol1_13_2To1_14> {
Metadata meta = e.getData();
int typeId = meta.getMetaType().getTypeID();
if (typeId > 15) {
System.out.println("new 1.14 metadata was not handled: " + meta + " entity: " + e.getEntity().getType());
ViaBackwards.getPlatform().getLogger().warning("New 1.14 metadata was not handled: " + meta + " entity: " + e.getEntity().getType());
return null;
}
return meta;

Datei anzeigen

@ -2525,16 +2525,16 @@
"minecraft:cartography_table": "minecraft:crafting_table",
"minecraft:fletching_table": "minecraft:crafting_table",
"minecraft:smithing_table": "minecraft:crafting_table",
"minecraft:lantern[hanging=true]": "redstone_lamp[lit=true]",
"minecraft:lantern[hanging=false]": "redstone_lamp[lit=true]",
"minecraft:composter[level=0]": "[level=0]",
"minecraft:composter[level=1]": "[level=0]",
"minecraft:composter[level=2]": "[level=1]",
"minecraft:composter[level=3]": "[level=1]",
"minecraft:composter[level=4]": "[level=1]",
"minecraft:composter[level=5]": "[level=2]",
"minecraft:composter[level=6]": "[level=2]",
"minecraft:composter[level=7]": "[level=2]",
"minecraft:composter[level=8]": "[level=3]"
"minecraft:lantern[hanging=true]": "minecraft:redstone_lamp[lit=true]",
"minecraft:lantern[hanging=false]": "minecraft:redstone_lamp[lit=true]",
"minecraft:composter[level=0]": "minecraft:cauldron[level=0]",
"minecraft:composter[level=1]": "minecraft:cauldron[level=0]",
"minecraft:composter[level=2]": "minecraft:cauldron[level=1]",
"minecraft:composter[level=3]": "minecraft:cauldron[level=1]",
"minecraft:composter[level=4]": "minecraft:cauldron[level=1]",
"minecraft:composter[level=5]": "minecraft:cauldron[level=2]",
"minecraft:composter[level=6]": "minecraft:cauldron[level=2]",
"minecraft:composter[level=7]": "minecraft:cauldron[level=2]",
"minecraft:composter[level=8]": "minecraft:cauldron[level=3]"
}
}