3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 01:00:15 +01:00

Merge pull request #1503 from creeper123123321/abstraction-update

Abstraction update
Dieser Commit ist enthalten in:
Myles 2019-11-02 14:28:58 +00:00 committet von GitHub
Commit a7d78f7f69
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
13 geänderte Dateien mit 106 neuen und 79 gelöschten Zeilen

Datei anzeigen

@ -11,3 +11,5 @@ cache:
script: script:
- mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false - mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false
- mvn clean install -B -U - mvn clean install -B -U
install: true

Datei anzeigen

@ -77,7 +77,7 @@ public class ProtocolVersion {
register(v1_14_2 = new ProtocolVersion(485, "1.14.2")); register(v1_14_2 = new ProtocolVersion(485, "1.14.2"));
register(v1_14_3 = new ProtocolVersion(490, "1.14.3")); register(v1_14_3 = new ProtocolVersion(490, "1.14.3"));
register(v1_14_4 = new ProtocolVersion(498, "1.14.4")); register(v1_14_4 = new ProtocolVersion(498, "1.14.4"));
register(v1_15 = new ProtocolVersion(556, "1.15")); register(v1_15 = new ProtocolVersion(560, "1.15"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN")); register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
} }

Datei anzeigen

@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_12to1_11_1;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -20,23 +21,30 @@ public class ChatItemRewriter {
if (hoverEvent.has("action") && hoverEvent.has("value")) { if (hoverEvent.has("action") && hoverEvent.has("value")) {
String type = hoverEvent.get("action").getAsString(); String type = hoverEvent.get("action").getAsString();
if (type.equals("show_item") || type.equals("show_entity")) { if (type.equals("show_item") || type.equals("show_entity")) {
if (hoverEvent.get("value").isJsonPrimitive()) { JsonElement value = hoverEvent.get("value");
if (hoverEvent.get("value").getAsJsonPrimitive().isString()) {
String value = hoverEvent.get("value").getAsString(); if (value.isJsonPrimitive() && value.getAsJsonPrimitive().isString()) {
value = indexRemoval.matcher(value).replaceAll(""); String newValue = indexRemoval.matcher(value.getAsString()).replaceAll("");
hoverEvent.addProperty("value", value); hoverEvent.addProperty("value", newValue);
} else if (value.isJsonArray()) {
JsonArray newArray = new JsonArray();
for (JsonElement valueElement : value.getAsJsonArray()) {
if (valueElement.isJsonPrimitive() && valueElement.getAsJsonPrimitive().isString()) {
String newValue = indexRemoval.matcher(valueElement.getAsString()).replaceAll("");
newArray.add(new JsonPrimitive(newValue));
}
} }
hoverEvent.add("value", newArray);
} }
} }
} }
} }
} else { } else if (obj.has("extra")) {
if (obj.has("extra")) { toClient(obj.get("extra"), user);
toClient(obj.get("extra"), user);
}
} }
} } else if (element instanceof JsonArray) {
if (element instanceof JsonArray) {
JsonArray array = (JsonArray) element; JsonArray array = (JsonArray) element;
for (JsonElement value : array) { for (JsonElement value : array) {
toClient(value, user); toClient(value, user);

Datei anzeigen

@ -108,7 +108,7 @@ public class Protocol1_13To1_12_2 extends Protocol {
}; };
// These are arbitrary rewrite values, it just needs an invalid color code character. // These are arbitrary rewrite values, it just needs an invalid color code character.
protected final static EnumMap<ChatColor, Character> SCOREBOARD_TEAM_NAME_REWRITE = new EnumMap<>(ChatColor.class); protected static final EnumMap<ChatColor, Character> SCOREBOARD_TEAM_NAME_REWRITE = new EnumMap<>(ChatColor.class);
static { static {
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.BLACK, 'g'); SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.BLACK, 'g');
@ -127,6 +127,13 @@ public class Protocol1_13To1_12_2 extends Protocol {
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.LIGHT_PURPLE, 'z'); SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.LIGHT_PURPLE, 'z');
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.YELLOW, '!'); SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.YELLOW, '!');
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.WHITE, '?'); SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.WHITE, '?');
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.MAGIC, '#');
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.BOLD, '(');
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.STRIKETHROUGH, ')');
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.UNDERLINE, ':');
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.ITALIC, ';');
SCOREBOARD_TEAM_NAME_REWRITE.put(ChatColor.RESET, '/');
MappingData.init(); MappingData.init();
ConnectionData.init(); ConnectionData.init();
RecipeData.init(); RecipeData.init();

Datei anzeigen

@ -61,27 +61,28 @@ public class EntityPackets {
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
@Override @Override
public void registerMap() { 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, Type.NOTHING); // removed - probably sent in an update packet?
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
int entityId = wrapper.passthrough(Type.VAR_INT); int entityId = wrapper.get(Type.VAR_INT, 0);
wrapper.passthrough(Type.UUID); int typeId = wrapper.get(Type.VAR_INT, 1);
int typeId = wrapper.read(Type.VAR_INT);
Entity1_15Types.EntityType entityType = Entity1_15Types.getTypeFromId(getNewEntityId(typeId)); Entity1_15Types.EntityType entityType = Entity1_15Types.getTypeFromId(getNewEntityId(typeId));
wrapper.user().get(EntityTracker1_15.class).addEntity(entityId, entityType); wrapper.user().get(EntityTracker1_15.class).addEntity(entityId, entityType);
wrapper.write(Type.VAR_INT, entityType.getId()); wrapper.set(Type.VAR_INT, 1, entityType.getId());
wrapper.passthrough(Type.DOUBLE);
wrapper.passthrough(Type.DOUBLE);
wrapper.passthrough(Type.DOUBLE);
wrapper.passthrough(Type.BYTE);
wrapper.passthrough(Type.BYTE);
wrapper.passthrough(Type.BYTE);
wrapper.passthrough(Type.SHORT);
wrapper.passthrough(Type.SHORT);
wrapper.passthrough(Type.SHORT);
wrapper.read(Types1_14.METADATA_LIST); // removed - probably sent in an update packet?
} }
}); });
} }
@ -91,23 +92,22 @@ public class EntityPackets {
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() { protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
@Override @Override
public void registerMap() { 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, Type.NOTHING); // removed - probably sent in an update packet?
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
int entityId = wrapper.passthrough(Type.VAR_INT); int entityId = wrapper.get(Type.VAR_INT, 0);
wrapper.passthrough(Type.UUID);
int typeId = wrapper.read(Type.VAR_INT); Entity1_15Types.EntityType entityType = Entity1_15Types.EntityType.PLAYER;
Entity1_15Types.EntityType entityType = Entity1_15Types.getTypeFromId(getNewEntityId(typeId));
wrapper.user().get(EntityTracker1_15.class).addEntity(entityId, entityType); wrapper.user().get(EntityTracker1_15.class).addEntity(entityId, entityType);
wrapper.write(Type.VAR_INT, entityType.getId());
wrapper.passthrough(Type.DOUBLE);
wrapper.passthrough(Type.DOUBLE);
wrapper.passthrough(Type.DOUBLE);
wrapper.passthrough(Type.BYTE);
wrapper.passthrough(Type.BYTE);
wrapper.read(Types1_14.METADATA); // removed - probably sent in an update packet?
} }
}); });
} }

Datei anzeigen

@ -11311,30 +11311,32 @@
"11308": "minecraft:bee_nest[facing=east,honey_level=3]", "11308": "minecraft:bee_nest[facing=east,honey_level=3]",
"11309": "minecraft:bee_nest[facing=east,honey_level=4]", "11309": "minecraft:bee_nest[facing=east,honey_level=4]",
"11310": "minecraft:bee_nest[facing=east,honey_level=5]", "11310": "minecraft:bee_nest[facing=east,honey_level=5]",
"11311": "minecraft:bee_hive[facing=north,honey_level=0]", "11311": "minecraft:beehive[facing=north,honey_level=0]",
"11312": "minecraft:bee_hive[facing=north,honey_level=1]", "11312": "minecraft:beehive[facing=north,honey_level=1]",
"11313": "minecraft:bee_hive[facing=north,honey_level=2]", "11313": "minecraft:beehive[facing=north,honey_level=2]",
"11314": "minecraft:bee_hive[facing=north,honey_level=3]", "11314": "minecraft:beehive[facing=north,honey_level=3]",
"11315": "minecraft:bee_hive[facing=north,honey_level=4]", "11315": "minecraft:beehive[facing=north,honey_level=4]",
"11316": "minecraft:bee_hive[facing=north,honey_level=5]", "11316": "minecraft:beehive[facing=north,honey_level=5]",
"11317": "minecraft:bee_hive[facing=south,honey_level=0]", "11317": "minecraft:beehive[facing=south,honey_level=0]",
"11318": "minecraft:bee_hive[facing=south,honey_level=1]", "11318": "minecraft:beehive[facing=south,honey_level=1]",
"11319": "minecraft:bee_hive[facing=south,honey_level=2]", "11319": "minecraft:beehive[facing=south,honey_level=2]",
"11320": "minecraft:bee_hive[facing=south,honey_level=3]", "11320": "minecraft:beehive[facing=south,honey_level=3]",
"11321": "minecraft:bee_hive[facing=south,honey_level=4]", "11321": "minecraft:beehive[facing=south,honey_level=4]",
"11322": "minecraft:bee_hive[facing=south,honey_level=5]", "11322": "minecraft:beehive[facing=south,honey_level=5]",
"11323": "minecraft:bee_hive[facing=west,honey_level=0]", "11323": "minecraft:beehive[facing=west,honey_level=0]",
"11324": "minecraft:bee_hive[facing=west,honey_level=1]", "11324": "minecraft:beehive[facing=west,honey_level=1]",
"11325": "minecraft:bee_hive[facing=west,honey_level=2]", "11325": "minecraft:beehive[facing=west,honey_level=2]",
"11326": "minecraft:bee_hive[facing=west,honey_level=3]", "11326": "minecraft:beehive[facing=west,honey_level=3]",
"11327": "minecraft:bee_hive[facing=west,honey_level=4]", "11327": "minecraft:beehive[facing=west,honey_level=4]",
"11328": "minecraft:bee_hive[facing=west,honey_level=5]", "11328": "minecraft:beehive[facing=west,honey_level=5]",
"11329": "minecraft:bee_hive[facing=east,honey_level=0]", "11329": "minecraft:beehive[facing=east,honey_level=0]",
"11330": "minecraft:bee_hive[facing=east,honey_level=1]", "11330": "minecraft:beehive[facing=east,honey_level=1]",
"11331": "minecraft:bee_hive[facing=east,honey_level=2]", "11331": "minecraft:beehive[facing=east,honey_level=2]",
"11332": "minecraft:bee_hive[facing=east,honey_level=3]", "11332": "minecraft:beehive[facing=east,honey_level=3]",
"11333": "minecraft:bee_hive[facing=east,honey_level=4]", "11333": "minecraft:beehive[facing=east,honey_level=4]",
"11334": "minecraft:bee_hive[facing=east,honey_level=5]" "11334": "minecraft:beehive[facing=east,honey_level=5]",
"11335": "minecraft:honey_block",
"11336": "minecraft:honeycomb_block"
}, },
"blocks": { "blocks": {
"0": "air", "0": "air",
@ -12014,7 +12016,9 @@
"674": "jigsaw", "674": "jigsaw",
"675": "composter", "675": "composter",
"676": "bee_nest", "676": "bee_nest",
"677": "bee_hive" "677": "beehive",
"678": "honey_block",
"679": "honeycomb_block"
}, },
"items": { "items": {
"0": "minecraft:air", "0": "minecraft:air",
@ -12897,8 +12901,10 @@
"877": "minecraft:campfire", "877": "minecraft:campfire",
"878": "minecraft:honeycomb", "878": "minecraft:honeycomb",
"879": "minecraft:bee_nest", "879": "minecraft:bee_nest",
"880": "minecraft:bee_hive", "880": "minecraft:beehive",
"881": "minecraft:honey_bottle" "881": "minecraft:honey_bottle",
"882": "minecraft:honey_block",
"883": "minecraft:honeycomb_block"
}, },
"sounds": [ "sounds": [
"ambient.cave", "ambient.cave",
@ -13202,6 +13208,12 @@
"entity.guardian.hurt", "entity.guardian.hurt",
"entity.guardian.hurt_land", "entity.guardian.hurt_land",
"item.hoe.till", "item.hoe.till",
"block.honey_block.break",
"block.honey_block.fall",
"block.honey_block.hit",
"block.honey_block.place",
"block.honey_block.slide",
"block.honey_block.step",
"item.honey_bottle.drink", "item.honey_bottle.drink",
"entity.horse.ambient", "entity.horse.ambient",
"entity.horse.angry", "entity.horse.angry",
@ -13245,8 +13257,10 @@
"block.iron_door.close", "block.iron_door.close",
"block.iron_door.open", "block.iron_door.open",
"entity.iron_golem.attack", "entity.iron_golem.attack",
"entity.iron_golem.damage",
"entity.iron_golem.death", "entity.iron_golem.death",
"entity.iron_golem.hurt", "entity.iron_golem.hurt",
"entity.iron_golem.repair",
"entity.iron_golem.step", "entity.iron_golem.step",
"block.iron_trapdoor.close", "block.iron_trapdoor.close",
"block.iron_trapdoor.open", "block.iron_trapdoor.open",
@ -13367,10 +13381,8 @@
"entity.parrot.imitate.husk", "entity.parrot.imitate.husk",
"entity.parrot.imitate.illusioner", "entity.parrot.imitate.illusioner",
"entity.parrot.imitate.magma_cube", "entity.parrot.imitate.magma_cube",
"entity.parrot.imitate.panda",
"entity.parrot.imitate.phantom", "entity.parrot.imitate.phantom",
"entity.parrot.imitate.pillager", "entity.parrot.imitate.pillager",
"entity.parrot.imitate.polar_bear",
"entity.parrot.imitate.ravager", "entity.parrot.imitate.ravager",
"entity.parrot.imitate.shulker", "entity.parrot.imitate.shulker",
"entity.parrot.imitate.silverfish", "entity.parrot.imitate.silverfish",
@ -13383,9 +13395,7 @@
"entity.parrot.imitate.witch", "entity.parrot.imitate.witch",
"entity.parrot.imitate.wither", "entity.parrot.imitate.wither",
"entity.parrot.imitate.wither_skeleton", "entity.parrot.imitate.wither_skeleton",
"entity.parrot.imitate.wolf",
"entity.parrot.imitate.zombie", "entity.parrot.imitate.zombie",
"entity.parrot.imitate.zombie_pigman",
"entity.parrot.imitate.zombie_villager", "entity.parrot.imitate.zombie_villager",
"entity.parrot.step", "entity.parrot.step",
"entity.phantom.ambient", "entity.phantom.ambient",