From efc4d7cba1fdf8af126392db71d9d1122ec1179c Mon Sep 17 00:00:00 2001 From: wizjany Date: Thu, 27 Jun 2019 18:37:55 -0400 Subject: [PATCH] [Fabric] Update fabric/yarn versions to 1.14.3. --- worldedit-fabric/build.gradle | 6 +-- .../worldedit/fabric/FabricBiomeRegistry.java | 2 +- .../worldedit/fabric/FabricBlockRegistry.java | 2 +- .../worldedit/fabric/FabricDataFixer.java | 46 +++++++++---------- .../sk89q/worldedit/fabric/FabricPlayer.java | 24 +++++----- .../worldedit/fabric/WorldEditFakePlayer.java | 9 ++-- 6 files changed, 44 insertions(+), 45 deletions(-) diff --git a/worldedit-fabric/build.gradle b/worldedit-fabric/build.gradle index 6045e3679..b27289bf9 100644 --- a/worldedit-fabric/build.gradle +++ b/worldedit-fabric/build.gradle @@ -22,9 +22,9 @@ buildscript { apply plugin: 'eclipse' apply plugin: 'fabric-loom' -def minecraftVersion = "1.14.2" -def fabricVersion = "0.3.0+build.185" -def yarnMappings = "1.14.2+build.7" +def minecraftVersion = "1.14.3" +def fabricVersion = "0.3.0+build.187" +def yarnMappings = "1.14.3+build.1" def loaderVersion = "0.4.8+build.155" configurations.all { Configuration it -> diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBiomeRegistry.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBiomeRegistry.java index fbf883101..692d350e1 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBiomeRegistry.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBiomeRegistry.java @@ -51,7 +51,7 @@ class FabricBiomeRegistry implements BiomeRegistry { @Override public String getName() { - return biome.getTextComponent().getString(); + return biome.getName().asFormattedString(); } } diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBlockRegistry.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBlockRegistry.java index 1d219c90c..593e95817 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBlockRegistry.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricBlockRegistry.java @@ -46,7 +46,7 @@ public class FabricBlockRegistry extends BundledBlockRegistry { public String getName(BlockType blockType) { Block block = FabricAdapter.adapt(blockType); if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) { - return block.getTextComponent().getFormattedText(); + return block.getName().asFormattedString(); } else { return super.getName(blockType); } diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricDataFixer.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricDataFixer.java index c04e06840..f307b789c 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricDataFixer.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricDataFixer.java @@ -43,8 +43,8 @@ import net.minecraft.nbt.FloatTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.StringTag; import net.minecraft.nbt.Tag; -import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import net.minecraft.util.DyeColor; import net.minecraft.util.Identifier; import net.minecraft.util.JsonHelper; @@ -1839,12 +1839,12 @@ class FabricDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wo if (!"null".equals(s) && !Strings.isNullOrEmpty(s)) { if ((s.charAt(0) != 34 || s.charAt(s.length() - 1) != 34) && (s.charAt(0) != 123 || s.charAt(s.length() - 1) != 125)) { - object = new TextComponent(s); + object = new LiteralText(s); } else { try { - object = JsonHelper.deserialize(DataConverterSignText.a, s, Component.class, true); + object = JsonHelper.deserialize(DataConverterSignText.a, s, Text.class, true); if (object == null) { - object = new TextComponent(""); + object = new LiteralText(""); } } catch (JsonParseException jsonparseexception) { ; @@ -1852,7 +1852,7 @@ class FabricDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wo if (object == null) { try { - object = Component.Serializer.fromJsonString(s); + object = Text.Serializer.fromJson(s); } catch (JsonParseException jsonparseexception1) { ; } @@ -1860,21 +1860,21 @@ class FabricDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wo if (object == null) { try { - object = Component.Serializer.fromLenientJsonString(s); + object = Text.Serializer.fromLenientJson(s); } catch (JsonParseException jsonparseexception2) { ; } } if (object == null) { - object = new TextComponent(s); + object = new LiteralText(s); } } } else { - object = new TextComponent(""); + object = new LiteralText(""); } - nbttaglist.set(i, new StringTag(Component.Serializer.toJsonString((Component) object))); + nbttaglist.set(i, new StringTag(Text.Serializer.toJson((Text) object))); } nbttagcompound1.put("pages", nbttaglist); @@ -2432,18 +2432,18 @@ class FabricDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wo private static class DataConverterSignText implements DataConverter { - public static final Gson a = new GsonBuilder().registerTypeAdapter(Component.class, new JsonDeserializer() { - Component a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { + public static final Gson a = new GsonBuilder().registerTypeAdapter(Text.class, new JsonDeserializer() { + Text a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException { if (jsonelement.isJsonPrimitive()) { - return new TextComponent(jsonelement.getAsString()); + return new LiteralText(jsonelement.getAsString()); } else if (jsonelement.isJsonArray()) { JsonArray jsonarray = jsonelement.getAsJsonArray(); - Component iTextComponent = null; + Text iTextComponent = null; Iterator iterator = jsonarray.iterator(); while (iterator.hasNext()) { JsonElement jsonelement1 = (JsonElement) iterator.next(); - Component iTextComponent1 = this.a(jsonelement1, jsonelement1.getClass(), jsondeserializationcontext); + Text iTextComponent1 = this.a(jsonelement1, jsonelement1.getClass(), jsondeserializationcontext); if (iTextComponent == null) { iTextComponent = iTextComponent1; @@ -2486,12 +2486,12 @@ class FabricDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wo if (!"null".equals(s1) && !Strings.isNullOrEmpty(s1)) { if ((s1.charAt(0) != 34 || s1.charAt(s1.length() - 1) != 34) && (s1.charAt(0) != 123 || s1.charAt(s1.length() - 1) != 125)) { - object = new TextComponent(s1); + object = new LiteralText(s1); } else { try { - object = JsonHelper.deserialize(DataConverterSignText.a, s1, Component.class, true); + object = JsonHelper.deserialize(DataConverterSignText.a, s1, Text.class, true); if (object == null) { - object = new TextComponent(""); + object = new LiteralText(""); } } catch (JsonParseException jsonparseexception) { ; @@ -2499,7 +2499,7 @@ class FabricDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wo if (object == null) { try { - object = Component.Serializer.fromJsonString(s1); + object = Text.Serializer.fromJson(s1); } catch (JsonParseException jsonparseexception1) { ; } @@ -2507,21 +2507,21 @@ class FabricDataFixer extends DataFixerBuilder implements com.sk89q.worldedit.wo if (object == null) { try { - object = Component.Serializer.fromLenientJsonString(s1); + object = Text.Serializer.fromLenientJson(s1); } catch (JsonParseException jsonparseexception2) { ; } } if (object == null) { - object = new TextComponent(s1); + object = new LiteralText(s1); } } } else { - object = new TextComponent(""); + object = new LiteralText(""); } - nbttagcompound.putString(s, Component.Serializer.toJsonString((Component) object)); + nbttagcompound.putString(s, Text.Serializer.toJson((Text) object)); } } diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java index 1944b3063..d96e0f81f 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java @@ -39,24 +39,24 @@ import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockTypes; import io.netty.buffer.Unpooled; -import net.minecraft.ChatFormat; import net.minecraft.block.Block; import net.minecraft.client.network.packet.BlockEntityUpdateS2CPacket; import net.minecraft.client.network.packet.BlockUpdateS2CPacket; import net.minecraft.client.network.packet.CustomPayloadS2CPacket; import net.minecraft.item.ItemStack; -import net.minecraft.network.chat.TextComponent; import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import net.minecraft.util.Hand; import net.minecraft.util.Identifier; import net.minecraft.util.PacketByteBuf; import net.minecraft.util.math.BlockPos; +import javax.annotation.Nullable; import java.io.IOException; import java.util.UUID; -import javax.annotation.Nullable; - public class FabricPlayer extends AbstractPlayerActor { // see ClientPlayNetHandler: search for "invalid update packet", lots of hardcoded consts @@ -81,7 +81,7 @@ public class FabricPlayer extends AbstractPlayerActor { @Override public String getName() { - return this.player.getName().getFormattedText(); + return this.player.getName().asFormattedString(); } @Override @@ -130,33 +130,33 @@ public class FabricPlayer extends AbstractPlayerActor { @Override public void printRaw(String msg) { for (String part : msg.split("\n")) { - this.player.sendMessage(new TextComponent(part)); + this.player.sendMessage(new LiteralText(part)); } } @Override public void printDebug(String msg) { - sendColorized(msg, ChatFormat.GRAY); + sendColorized(msg, Formatting.GRAY); } @Override public void print(String msg) { - sendColorized(msg, ChatFormat.LIGHT_PURPLE); + sendColorized(msg, Formatting.LIGHT_PURPLE); } @Override public void printError(String msg) { - sendColorized(msg, ChatFormat.RED); + sendColorized(msg, Formatting.RED); } @Override public void print(Component component) { - this.player.sendMessage(net.minecraft.network.chat.Component.Serializer.fromJsonString(GsonComponentSerializer.INSTANCE.serialize(component))); + this.player.sendMessage(Text.Serializer.fromJson(GsonComponentSerializer.INSTANCE.serialize(component))); } - private void sendColorized(String msg, ChatFormat formatting) { + private void sendColorized(String msg, Formatting formatting) { for (String part : msg.split("\n")) { - TextComponent component = new TextComponent(part); + LiteralText component = new LiteralText(part); component.getStyle().setColor(formatting); this.player.sendMessage(component); } diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/WorldEditFakePlayer.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/WorldEditFakePlayer.java index ea65774b7..b1dad7904 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/WorldEditFakePlayer.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/WorldEditFakePlayer.java @@ -22,16 +22,15 @@ package com.sk89q.worldedit.fabric; import com.mojang.authlib.GameProfile; import net.minecraft.entity.Entity; import net.minecraft.entity.damage.DamageSource; -import net.minecraft.network.chat.Component; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerInteractionManager; import net.minecraft.server.world.ServerWorld; import net.minecraft.stat.Stat; +import net.minecraft.text.Text; import net.minecraft.world.dimension.DimensionType; -import java.util.UUID; - import javax.annotation.Nullable; +import java.util.UUID; public class WorldEditFakePlayer extends ServerPlayerEntity { private static final GameProfile FAKE_WORLDEDIT_PROFILE = new GameProfile(UUID.nameUUIDFromBytes("worldedit".getBytes()), "[WorldEdit]"); @@ -53,11 +52,11 @@ public class WorldEditFakePlayer extends ServerPlayerEntity { } @Override - public void sendMessage(Component component) { + public void sendMessage(Text component) { } @Override - public void addChatMessage(Component component, boolean opt) { + public void addChatMessage(Text component, boolean opt) { } @Nullable