mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-12-18 16:17:45 +01:00
Merge pull request #81 from Gerrygames/1.13
fix teams packet, rewrite items in metadata
This commit is contained in:
commit
7c49689738
@ -10,8 +10,8 @@
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers.BackwardsBlockEntityProvider.BackwardsBlockEntityHandler;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
@ -37,7 +37,7 @@ public class BannerHandler implements BackwardsBlockEntityHandler {
|
||||
int color = (blockId - WALL_BANNER_START) >> 2;
|
||||
tag.put(new IntTag("Base", (15 - color)));
|
||||
} else {
|
||||
Via.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
|
||||
ViaBackwards.getPlatform().getLogger().warning("Why does this block have the banner block entity? :(" + tag);
|
||||
}
|
||||
|
||||
// Invert colors
|
||||
|
@ -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_12_2to1_13 = loadData("mapping-1.12.2to1.13.json");
|
||||
|
||||
Via.getPlatform().getLogger().info("Loading block mapping...");
|
||||
ViaBackwards.getPlatform().getLogger().info("Loading block mapping...");
|
||||
blockMappings = new BlockMappingsShortArray(mapping1_13.getAsJsonObject("blocks"), mapping1_12.getAsJsonObject("blocks"), mapping1_12_2to1_13.getAsJsonObject("blockstates"));
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.packets;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.api.rewriters.Rewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.BackwardsMappings;
|
||||
@ -42,7 +43,7 @@ public class BlockItemPackets1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
if (newId != -1)
|
||||
return newId;
|
||||
|
||||
Via.getPlatform().getLogger().warning("Missing block completely " + oldId);
|
||||
ViaBackwards.getPlatform().getLogger().warning("Missing block completely " + oldId);
|
||||
// Default stone
|
||||
return 1 << 4;
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.Protocol1_12_2To1_13;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.EntityTypeMapping;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.data.PaintingMapping;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
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_12;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
@ -399,6 +400,12 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
||||
}
|
||||
}
|
||||
|
||||
// Rewrite items
|
||||
else if (typeId == 6) {
|
||||
meta.setMetaType(MetaType1_12.Slot);
|
||||
BlockItemPackets1_13.toClient((Item) meta.getValue());
|
||||
}
|
||||
|
||||
// Discontinue particles
|
||||
else if (typeId == 15) {
|
||||
meta.setMetaType(MetaType1_12.Discontinued);
|
||||
@ -457,8 +464,13 @@ public class EntityPackets1_13 extends EntityRewriter<Protocol1_12_2To1_13> {
|
||||
// Remove boat splash timer
|
||||
registerMetaHandler().filter(EntityType.BOAT, 12).removed();
|
||||
|
||||
//Remove shooter UUID
|
||||
registerMetaHandler().filter(EntityType.ABSTRACT_ARROW, true, 7).removed();
|
||||
|
||||
registerMetaHandler().filter(EntityType.SPECTRAL_ARROW, 8).handleIndexChange(7);
|
||||
|
||||
// Remove Trident special loyalty level
|
||||
registerMetaHandler().filter(EntityType.TRIDENT, 7).removed();
|
||||
registerMetaHandler().filter(EntityType.TRIDENT, 8).removed();
|
||||
|
||||
// Handle new wolf colors
|
||||
registerMetaHandler().filter(EntityType.WOLF, 17).handle(e -> {
|
||||
|
@ -105,23 +105,32 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
if (displayName.length() > 32) displayName = displayName.substring(0, 32);
|
||||
wrapper.write(Type.STRING, displayName);
|
||||
|
||||
String prefix = wrapper.read(Type.STRING);
|
||||
String suffix = wrapper.read(Type.STRING);
|
||||
|
||||
wrapper.passthrough(Type.BYTE); //Flags
|
||||
|
||||
wrapper.passthrough(Type.STRING); //Name Tag Visibility
|
||||
wrapper.passthrough(Type.STRING); //Collision Rule
|
||||
byte flags = wrapper.read(Type.BYTE);
|
||||
String nameTagVisibility = wrapper.read(Type.STRING);
|
||||
String collisionRule = wrapper.read(Type.STRING);
|
||||
|
||||
int colour = wrapper.read(Type.VAR_INT);
|
||||
if (colour == 21) {
|
||||
colour = -1;
|
||||
}
|
||||
|
||||
wrapper.write(Type.BYTE, (byte) colour);
|
||||
//TODO team color/prefix handling changed from 1.12.2 to 1.13 and to 1.13.1 again afaik
|
||||
String prefix = wrapper.read(Type.STRING);
|
||||
String suffix = wrapper.read(Type.STRING);
|
||||
prefix = ChatRewriter.jsonTextToLegacy(prefix);
|
||||
prefix += "§" + (colour > -1 && colour <= 15 ? Integer.toHexString(colour) : "r");
|
||||
if (prefix.length() > 16) prefix = prefix.substring(0, 16);
|
||||
if (prefix.endsWith("§")) prefix = prefix.substring(0, prefix.length() - 1);
|
||||
suffix = ChatRewriter.jsonTextToLegacy(suffix);
|
||||
if (suffix.endsWith("§")) suffix = suffix.substring(0, suffix.length() - 1);
|
||||
wrapper.write(Type.STRING, prefix);
|
||||
wrapper.write(Type.STRING, suffix);
|
||||
|
||||
wrapper.write(Type.STRING, ChatRewriter.jsonTextToLegacy(prefix));
|
||||
wrapper.write(Type.STRING, ChatRewriter.jsonTextToLegacy(suffix));
|
||||
wrapper.write(Type.BYTE, flags);
|
||||
wrapper.write(Type.STRING, nameTagVisibility);
|
||||
wrapper.write(Type.STRING, collisionRule);
|
||||
|
||||
wrapper.write(Type.BYTE, (byte) colour);
|
||||
}
|
||||
|
||||
if (action == 0 || action == 3 || action == 4) {
|
||||
@ -175,8 +184,9 @@ public class PlayerPacket1_13 extends Rewriter<Protocol1_12_2To1_13> {
|
||||
|
||||
// Ignore fields
|
||||
wrapper.read(Type.BOOLEAN);
|
||||
wrapper.read(Type.OPTIONAL_POSITION);
|
||||
|
||||
if (wrapper.read(Type.BOOLEAN)) {
|
||||
wrapper.read(Type.POSITION);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
package nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.providers;
|
||||
|
||||
import nl.matsv.viabackwards.ViaBackwards;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.block_entity_handlers.*;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12_2to1_13.storage.BackwardsBlockStorage;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
@ -54,7 +55,7 @@ public class BackwardsBlockEntityProvider implements Provider {
|
||||
BackwardsBlockEntityHandler handler = handlers.get(id);
|
||||
if (handler == null) {
|
||||
if (Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Unhandled BlockEntity " + id + " full tag: " + tag);
|
||||
ViaBackwards.getPlatform().getLogger().warning("Unhandled BlockEntity " + id + " full tag: " + tag);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
@ -63,7 +64,7 @@ public class BackwardsBlockEntityProvider implements Provider {
|
||||
|
||||
if (!storage.contains(position)) {
|
||||
if (Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Handled BlockEntity does not have a stored block :( " + id + " full tag: " + tag);
|
||||
ViaBackwards.getPlatform().getLogger().warning("Handled BlockEntity does not have a stored block :( " + id + " full tag: " + tag);
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ public class Protocol1_13To1_13_1 extends BackwardsProtocol {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
short flags = wrapper.read(Type.UNSIGNED_BYTE);
|
||||
if ((flags & 0x04) != 0) flags |= 0x02;
|
||||
wrapper.write(Type.UNSIGNED_BYTE, flags);
|
||||
|
Loading…
Reference in New Issue
Block a user