From 32450265fef163193cc1237381d650e4d224af50 Mon Sep 17 00:00:00 2001 From: Patbox <39821509+Patbox@users.noreply.github.com> Date: Mon, 6 Jun 2022 13:43:20 +0200 Subject: [PATCH] Update to 1.19 --- build.gradle | 13 +- gradle.properties | 12 +- .../java/eu/pb4/graves/GenericModInfo.java | 32 ++-- .../java/eu/pb4/graves/GraveNetworking.java | 24 ++- .../eu/pb4/graves/client/GraveRenderer.java | 10 +- .../java/eu/pb4/graves/config/Config.java | 126 +++++++------- .../eu/pb4/graves/config/ConfigManager.java | 4 - .../graves/config/data/old/ConfigDataV1.java | 155 ------------------ src/main/java/eu/pb4/graves/grave/Grave.java | 34 ++-- .../pb4/graves/mixin/LivingEntityMixin.java | 39 ++--- .../graves/mixin/ServerPlayerEntityMixin.java | 7 +- .../eu/pb4/graves/mixin/ServerWorldMixin.java | 4 +- .../java/eu/pb4/graves/other/Commands.java | 17 +- .../java/eu/pb4/graves/other/GraveUtils.java | 5 +- .../eu/pb4/graves/other/GravesLookType.java | 8 +- .../eu/pb4/graves/other/VisualGraveData.java | 21 ++- .../pb4/graves/registry/GraveBlockEntity.java | 17 +- .../pb4/graves/registry/VisualGraveBlock.java | 5 +- .../registry/VisualGraveBlockEntity.java | 25 ++- src/main/java/eu/pb4/graves/ui/GraveGui.java | 13 +- .../java/eu/pb4/graves/ui/GraveListGui.java | 20 ++- src/main/java/eu/pb4/graves/ui/PagedGui.java | 4 +- 22 files changed, 225 insertions(+), 370 deletions(-) delete mode 100644 src/main/java/eu/pb4/graves/config/data/old/ConfigDataV1.java diff --git a/build.gradle b/build.gradle index c51a30d..cabaa92 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.10-SNAPSHOT' + id 'fabric-loom' version '0.12-SNAPSHOT' id 'maven-publish' id "com.modrinth.minotaur" version "2.+" id 'com.matthewprenger.cursegradle' version '1.4.0' @@ -56,11 +56,11 @@ dependencies { modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" - modImplementation include("eu.pb4:sgui:1.0.2+1.18.2") - modImplementation include("eu.pb4:hologram-api:0.2.1+1.18-pre5") - modImplementation include("eu.pb4:placeholder-api:1.1.3+1.17.1") - modImplementation include("eu.pb4:polymer:0.2.0-rc.2+1.18.2") - modImplementation include("fr.catcore:server-translations-api:1.4.12+1.18.2") + modImplementation include("eu.pb4:sgui:1.1.0+1.19") + modImplementation include("eu.pb4:hologram-api:0.2.2+1.19") + modImplementation include("eu.pb4:placeholder-api:2.0.0-beta.2+1.19") + modImplementation include("eu.pb4:polymer:0.2.0-rc.4+1.19-rc2") + modImplementation include("fr.catcore:server-translations-api:1.4.14+1.19-rc2") //modImplementation include("fr.catcore:server-translations-api:1.4.8+1.18-pre1") modImplementation include("me.lucko:fabric-permissions-api:0.1-SNAPSHOT") @@ -142,6 +142,7 @@ curseforge { changelogType = "markdown" addGameVersion ((String) project.minecraft_version) addGameVersion "Fabric" + addGameVersion "Quilt" mainArtifact(remapJar) afterEvaluate { diff --git a/gradle.properties b/gradle.properties index 5f19c5d..d17947b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,14 +3,16 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/use -minecraft_version=1.18.2 -yarn_mappings=1.18.2+build.2 -loader_version=0.13.3 +minecraft_version=1.19-rc2 +yarn_mappings=1.19-rc2+build.1 +loader_version=0.14.6 #Fabric api -fabric_version=0.48.0+1.18.2 +fabric_version=0.55.0+1.19 + + # Mod Properties - mod_version = 2.0.3+1.18.2 + mod_version = 2.0.4+1.19 maven_group = eu.pb4 archives_base_name = graves diff --git a/src/main/java/eu/pb4/graves/GenericModInfo.java b/src/main/java/eu/pb4/graves/GenericModInfo.java index 7d2b8ce..e726969 100644 --- a/src/main/java/eu/pb4/graves/GenericModInfo.java +++ b/src/main/java/eu/pb4/graves/GenericModInfo.java @@ -24,7 +24,7 @@ public static void build(ModContainer container) { var source = ImageIO.read(Files.newInputStream(container.getPath("assets/logo_mini.png"))); for (int y = 0; y < source.getHeight(); y++) { - var base = new LiteralText(""); + var base = Text.literal(""); int line = 0; int color = source.getRGB(0, y) & 0xFFFFFF; for (int x = 0; x < source.getWidth(); x++) { @@ -33,19 +33,19 @@ public static void build(ModContainer container) { if (color == colorPixel) { line++; } else { - base.append(new LiteralText(chr.repeat(line)).setStyle(Style.EMPTY.withColor(color))); + base.append(Text.literal(chr.repeat(line)).setStyle(Style.EMPTY.withColor(color))); color = colorPixel; line = 1; } } - base.append(new LiteralText(chr.repeat(line)).setStyle(Style.EMPTY.withColor(color))); + base.append(Text.literal(chr.repeat(line)).setStyle(Style.EMPTY.withColor(color))); icon.add(base); } } catch (Throwable e) { e.printStackTrace(); while (icon.size() < 16) { - icon.add(new LiteralText("/!\\ [ Invalid icon file ] /!\\").setStyle(Style.EMPTY.withColor(0xFF0000).withItalic(true))); + icon.add(Text.literal("/!\\ [ Invalid icon file ] /!\\").setStyle(Style.EMPTY.withColor(0xFF0000).withItalic(true))); } } @@ -58,28 +58,28 @@ public static void build(ModContainer container) { var output = new ArrayList(); try { - about.add(new LiteralText(container.getMetadata().getName()).setStyle(Style.EMPTY.withColor(0x00e6b4).withBold(true).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,container.getMetadata().getContact().get("github").orElse(""))))); - about.add(new TranslatableText("text.graves.about.version").setStyle(Style.EMPTY.withColor(0xf7e1a7)) - .append(new LiteralText(container.getMetadata().getVersion().getFriendlyString()).setStyle(Style.EMPTY.withColor(Formatting.WHITE)))); + about.add(Text.literal(container.getMetadata().getName()).setStyle(Style.EMPTY.withColor(0x00e6b4).withBold(true).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,container.getMetadata().getContact().get("github").orElse(""))))); + about.add(Text.translatable("text.graves.about.version").setStyle(Style.EMPTY.withColor(0xf7e1a7)) + .append(Text.literal(container.getMetadata().getVersion().getFriendlyString()).setStyle(Style.EMPTY.withColor(Formatting.WHITE)))); aboutBasic.addAll(about); - aboutBasic.add(LiteralText.EMPTY); + aboutBasic.add(Text.empty()); aboutBasic.add(Text.of(container.getMetadata().getDescription())); var contributors = new ArrayList(); contributors.addAll(container.getMetadata().getAuthors().stream().map((p) -> p.getName()).collect(Collectors.toList())); contributors.addAll(container.getMetadata().getContributors().stream().map((p) -> p.getName()).collect(Collectors.toList())); - about.add(new LiteralText("") - .append(new TranslatableText("text.graves.about.contributors") + about.add(Text.literal("") + .append(Text.translatable("text.graves.about.contributors") .setStyle(Style.EMPTY.withColor(Formatting.AQUA) .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, - new LiteralText(String.join(", ", contributors) + Text.literal(String.join(", ", contributors) )) ))) .append("") .setStyle(Style.EMPTY.withColor(Formatting.DARK_GRAY))); - about.add(LiteralText.EMPTY); + about.add(Text.empty()); var desc = new ArrayList<>(List.of(container.getMetadata().getDescription().split(" "))); @@ -89,13 +89,13 @@ public static void build(ModContainer container) { (descPart.isEmpty() ? descPart : descPart.append(" ")).append(desc.remove(0)); if (descPart.length() > 16) { - about.add(new LiteralText(descPart.toString()).setStyle(Style.EMPTY.withColor(Formatting.GRAY))); + about.add(Text.literal(descPart.toString()).setStyle(Style.EMPTY.withColor(Formatting.GRAY))); descPart = new StringBuilder(); } } if (descPart.length() > 0) { - about.add(new LiteralText(descPart.toString()).setStyle(Style.EMPTY.withColor(Formatting.GRAY))); + about.add(Text.literal(descPart.toString()).setStyle(Style.EMPTY.withColor(Formatting.GRAY))); } } @@ -103,7 +103,7 @@ public static void build(ModContainer container) { int a = 0; for (int i = 0; i < icon.length; i++) { if (i == (icon.length - about.size() - 1) / 2 + a && a < about.size()) { - output.add(icon[i].shallowCopy().append(new LiteralText(" ").setStyle(Style.EMPTY.withItalic(false)).append(about.get(a++)))); + output.add(icon[i].copy().append(Text.literal(" ").setStyle(Style.EMPTY.withItalic(false)).append(about.get(a++)))); } else { output.add(icon[i]); } @@ -114,7 +114,7 @@ public static void build(ModContainer container) { } } catch (Exception e) { e.printStackTrace(); - var invalid = new LiteralText("/!\\ [ Invalid about mod info ] /!\\").setStyle(Style.EMPTY.withColor(0xFF0000).withItalic(true)); + var invalid = Text.literal("/!\\ [ Invalid about mod info ] /!\\").setStyle(Style.EMPTY.withColor(0xFF0000).withItalic(true)); output.add(invalid); about.add(invalid); diff --git a/src/main/java/eu/pb4/graves/GraveNetworking.java b/src/main/java/eu/pb4/graves/GraveNetworking.java index 7bd4b3c..6f7d73e 100644 --- a/src/main/java/eu/pb4/graves/GraveNetworking.java +++ b/src/main/java/eu/pb4/graves/GraveNetworking.java @@ -2,8 +2,7 @@ import eu.pb4.graves.config.ConfigManager; import eu.pb4.graves.other.VisualGraveData; -import eu.pb4.placeholders.PlaceholderAPI; -import eu.pb4.polymer.api.item.PolymerItemUtils; +import eu.pb4.placeholders.api.Placeholders; import eu.pb4.polymer.api.networking.PolymerPacketUtils; import eu.pb4.polymer.api.networking.PolymerSyncUtils; import fr.catcore.server.translations.api.LocalizationTarget; @@ -64,19 +63,28 @@ public static boolean sendGrave(ServerPlayNetworkHandler handler, BlockPos block if (version == 0 && config.canClientSide) { var target = (LocalizationTarget) handler.getPlayer(); - var texts = textOverrides != null ? textOverrides : locked ? config.signProtectedText : config.signText; var buf = PolymerPacketUtils.buf(0); buf.writeBlockPos(blockPos); buf.writeNbt(data.toNbt()); - buf.writeVarInt(texts.length); - for (var text : texts) { - buf.writeString(Text.Serializer.toJson( - LocalizableText.asLocalizedFor(PlaceholderAPI.parsePredefinedText(text, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, placeholders), target) - )); + if (textOverrides != null) { + buf.writeVarInt(textOverrides.length); + for (var text : textOverrides) { + buf.writeString(Text.Serializer.toJson(text)); + } + } else { + var texts = locked ? config.signProtectedText : config.signText; + + buf.writeVarInt(texts.length); + for (var text : texts) { + buf.writeString(Text.Serializer.toJson( + LocalizableText.asLocalizedFor(Placeholders.parseText(text, Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, placeholders), target) + )); + } } + PolymerPacketUtils.sendPacket(handler, SERVER_GRAVE, buf); return true; } diff --git a/src/main/java/eu/pb4/graves/client/GraveRenderer.java b/src/main/java/eu/pb4/graves/client/GraveRenderer.java index f1109c3..4f5a3c3 100644 --- a/src/main/java/eu/pb4/graves/client/GraveRenderer.java +++ b/src/main/java/eu/pb4/graves/client/GraveRenderer.java @@ -21,10 +21,10 @@ import net.minecraft.state.property.Properties; import net.minecraft.util.Identifier; import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.random.Random; import org.jetbrains.annotations.Nullable; import java.util.Map; -import java.util.Random; import static eu.pb4.graves.registry.AbstractGraveBlock.IS_LOCKED; @@ -67,7 +67,7 @@ public void renderHead(AbstractGraveBlockEntity entity, float tickDelta, MatrixS var client = MinecraftClient.getInstance(); matrixStack.translate(0.1D, -0.65D, 0.1D); matrixStack.scale(0.8F, 0.8F, 0.8F); - client.getBlockRenderManager().renderBlock(lower, entity.getPos(), entity.getWorld(), matrixStack, vertexConsumers.getBuffer(RenderLayers.getBlockLayer(lower)), true, new Random()); + client.getBlockRenderManager().renderBlock(lower, entity.getPos(), entity.getWorld(), matrixStack, vertexConsumers.getBuffer(RenderLayers.getBlockLayer(lower)), true, Random.create()); matrixStack.pop(); } matrixStack.push(); @@ -87,7 +87,7 @@ public static RenderLayer getRenderLayer(@Nullable GameProfile profile) { if (profile != null) { MinecraftClient minecraftClient = MinecraftClient.getInstance(); Map map = minecraftClient.getSkinProvider().getTextures(profile); - return map.containsKey(com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN) ? RenderLayer.getEntityTranslucent(minecraftClient.getSkinProvider().loadSkin(map.get(com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN), com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN)) : RenderLayer.getEntityTranslucent(DefaultSkinHelper.getTexture(PlayerEntity.getUuidFromProfile(profile))); + return map.containsKey(com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN) ? RenderLayer.getEntityTranslucent(minecraftClient.getSkinProvider().loadSkin(map.get(com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN), com.mojang.authlib.minecraft.MinecraftProfileTexture.Type.SKIN)) : RenderLayer.getEntityTranslucent(DefaultSkinHelper.getTexture(profile.getId())); } else { return RenderLayer.getEntityCutoutNoCullZOffset(SKULL_TEXTURE); } @@ -125,9 +125,9 @@ public void renderGrave(AbstractGraveBlockEntity entity, float tickDelta, Matrix var model = entity.getCachedState().get(IS_LOCKED) ? this.graveStoneModel : this.graveStoneUnlockedModel; if (MinecraftClient.isAmbientOcclusionEnabled() && model.useAmbientOcclusion()) { - renderer.renderSmooth(world, model, entity.getCachedState(), entity.getPos(), matrixStack, vertexConsumers.getBuffer(RenderLayers.getBlockLayer(entity.getCachedState())), false, new Random(), 0, overlay); + renderer.renderSmooth(world, model, entity.getCachedState(), entity.getPos(), matrixStack, vertexConsumers.getBuffer(RenderLayers.getBlockLayer(entity.getCachedState())), false, Random.create(), 0, overlay); } else { - renderer.renderFlat(world, model, entity.getCachedState(), entity.getPos(), matrixStack, vertexConsumers.getBuffer(RenderLayers.getBlockLayer(entity.getCachedState())), false, new Random(), 0, overlay); + renderer.renderFlat(world, model, entity.getCachedState(), entity.getPos(), matrixStack, vertexConsumers.getBuffer(RenderLayers.getBlockLayer(entity.getCachedState())), false, Random.create(), 0, overlay); } matrixStack.push(); diff --git a/src/main/java/eu/pb4/graves/config/Config.java b/src/main/java/eu/pb4/graves/config/Config.java index 547eab2..55009d1 100644 --- a/src/main/java/eu/pb4/graves/config/Config.java +++ b/src/main/java/eu/pb4/graves/config/Config.java @@ -7,23 +7,25 @@ import eu.pb4.graves.other.GravesLookType; import eu.pb4.graves.other.GravesXPCalculation; import eu.pb4.graves.registry.IconItem; -import eu.pb4.placeholders.TextParser; +import eu.pb4.placeholders.api.TextParserUtils; +import eu.pb4.placeholders.api.node.EmptyNode; +import eu.pb4.placeholders.api.node.TextNode; import net.minecraft.block.BlockEntityProvider; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.CropBlock; import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.command.CommandRegistryWrapper; import net.minecraft.command.argument.BlockArgumentParser; import net.minecraft.command.argument.ItemStringReader; import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; import net.minecraft.nbt.NbtCompound; import net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; +import net.minecraft.util.registry.Registry; import org.jetbrains.annotations.Nullable; import java.text.SimpleDateFormat; @@ -33,39 +35,39 @@ public final class Config { public final ConfigData configData; public final GravesLookType style; - public final Text[] hologramProtectedText; - public final Text[] hologramText; - public final Text[] hologramVisualText; + public final TextNode[] hologramProtectedText; + public final TextNode[] hologramText; + public final TextNode[] hologramVisualText; - public final Text[] signProtectedText; - public final Text[] signText; - public final Text[] signVisualText; + public final TextNode[] signProtectedText; + public final TextNode[] signText; + public final TextNode[] signVisualText; - public final Text graveTitle; + public final TextNode graveTitle; public final Text guiTitle; - public final Text[] guiProtectedText; - public final Text[] guiText; + public final TextNode[] guiProtectedText; + public final TextNode[] guiText; public final ItemStack[] guiProtectedItem; public final ItemStack[] guiItem; @Nullable - public final Text noLongerProtectedMessage; + public final TextNode noLongerProtectedMessage; @Nullable - public final Text graveExpiredMessage; + public final TextNode graveExpiredMessage; @Nullable - public final Text graveBrokenMessage; + public final TextNode graveBrokenMessage; @Nullable - public final Text createdGraveMessage; + public final TextNode createdGraveMessage; @Nullable - public final Text creationFailedGraveMessage; + public final TextNode creationFailedGraveMessage; @Nullable - public final Text creationFailedVoidMessage; + public final TextNode creationFailedVoidMessage; @Nullable - public final Text creationFailedPvPMessage; + public final TextNode creationFailedPvPMessage; @Nullable - public final Text creationFailedClaimMessage; + public final TextNode creationFailedClaimMessage; public final GravesXPCalculation xpCalc; public final BlockStyleEntry[] customBlockStateStylesLocked; @@ -116,31 +118,31 @@ public Config(ConfigData data) { this.signText = parse(data.customStyleSignText); this.signVisualText = parse(data.customStyleSignVisualText); - this.graveTitle = TextParser.parse(data.graveTitle); + this.graveTitle = TextParserUtils.formatNodes(data.graveTitle); this.canClientSide = data.allowClientSideStyle && this.style.allowClient; - this.guiTitle = TextParser.parse(data.guiTitle); + this.guiTitle = TextParserUtils.formatText(data.guiTitle); this.guiProtectedText = parse(data.guiProtectedText); this.guiText = parse(data.guiText); - this.noLongerProtectedMessage = parse(data.messageProtectionEnded, null); - this.graveExpiredMessage = parse(data.messageGraveExpired, null); - this.graveBrokenMessage = parse(data.messageGraveBroken, null); - this.createdGraveMessage = parse(data.messageGraveCreated, null); - this.creationFailedGraveMessage = parse(data.messageCreationFailed, null); - this.creationFailedVoidMessage = parse(data.messageCreationFailedVoid, null); - this.creationFailedPvPMessage = parse(data.messageCreationFailedPvP, null); - this.creationFailedClaimMessage = parse(data.messageCreationFailedClaim, null); - - this.guiPreviousPageText = parse(data.guiPreviousPageText, LiteralText.EMPTY); - this.guiPreviousPageBlockedText = parse(data.guiPreviousPageBlockedText, LiteralText.EMPTY); - this.guiNextPageText = parse(data.guiNextPageText, LiteralText.EMPTY); - this.guiNextPageBlockedText = parse(data.guiNextPageBlockedText, LiteralText.EMPTY); - this.guiRemoveProtectionText = parse(data.guiRemoveProtectionText, LiteralText.EMPTY); - this.guiBreakGraveText = parse(data.guiBreakGraveText, LiteralText.EMPTY); - this.guiQuickPickupText = parse(data.guiQuickPickupText, LiteralText.EMPTY); - this.guiCantReverseAction = parse(data.guiCantReverseAction, LiteralText.EMPTY); - this.guiClickToConfirm = parse(data.guiClickToConfirm, LiteralText.EMPTY); + this.noLongerProtectedMessage = parse(data.messageProtectionEnded); + this.graveExpiredMessage = parse(data.messageGraveExpired); + this.graveBrokenMessage = parse(data.messageGraveBroken); + this.createdGraveMessage = parse(data.messageGraveCreated); + this.creationFailedGraveMessage = parse(data.messageCreationFailed); + this.creationFailedVoidMessage = parse(data.messageCreationFailedVoid); + this.creationFailedPvPMessage = parse(data.messageCreationFailedPvP); + this.creationFailedClaimMessage = parse(data.messageCreationFailedClaim); + + this.guiPreviousPageText = parseText(data.guiPreviousPageText); + this.guiPreviousPageBlockedText = parseText(data.guiPreviousPageBlockedText); + this.guiNextPageText = parseText(data.guiNextPageText); + this.guiNextPageBlockedText = parseText(data.guiNextPageBlockedText); + this.guiRemoveProtectionText = parseText(data.guiRemoveProtectionText); + this.guiBreakGraveText = parseText(data.guiBreakGraveText); + this.guiQuickPickupText = parseText(data.guiQuickPickupText); + this.guiCantReverseAction = parseText(data.guiCantReverseAction); + this.guiClickToConfirm = parseText(data.guiClickToConfirm); this.guiInfoIcon = parseItem(data.guiInfoIcon); this.guiBarItem = parseItem(data.guiBarItem); @@ -169,7 +171,7 @@ public Config(ConfigData data) { var id = Identifier.tryParse(entry.getKey()); if (id != null) { - this.worldNameOverrides.put(id, parse(entry.getValue(), null)); + this.worldNameOverrides.put(id, parseText(entry.getValue())); } } @@ -205,17 +207,21 @@ private static Set parseIds(List ids) { return set; } - private static Text parse(String string, Text defaultText) { - return !string.isEmpty() ? TextParser.parse(string) : defaultText; + private static TextNode parse(String string) { + return !string.isEmpty() ? TextParserUtils.formatNodes(string) : null; + } + + private static Text parseText(String string) { + return !string.isEmpty() ? TextParserUtils.formatText(string) : Text.empty(); } private static ItemStack parseItem(String itemDef) { try { - var item = new ItemStringReader(new StringReader(itemDef), true).consume(); - var itemStack = item.getItem().getDefaultStack(); + var item = ItemStringReader.item(CommandRegistryWrapper.of(Registry.ITEM), new StringReader(itemDef)); + var itemStack = item.item().value().getDefaultStack(); - if (item.getNbt() != null) { - itemStack.setNbt(item.getNbt()); + if (item.nbt() != null) { + itemStack.setNbt(item.nbt()); } return itemStack; } catch (Exception e) { @@ -241,10 +247,10 @@ private static BlockStyleEntry[] parseBlockStyles(List stringList) { for (String stateName : stringList) { try { - var stateData = new BlockArgumentParser(new StringReader(stateName), true).parse(true); - if (stateData.getBlockState().getBlock() != GraveBlock.INSTANCE && stateData.getBlockState() != null) { - if (stateData.getBlockState().hasBlockEntity()) { - var blockEntity = ((BlockEntityProvider) stateData.getBlockState().getBlock()).createBlockEntity(BlockPos.ORIGIN, stateData.getBlockState()); + var stateData = BlockArgumentParser.block(Registry.BLOCK, new StringReader(stateName), true); + if (stateData.blockState().getBlock() != GraveBlock.INSTANCE && stateData.blockState() != null) { + if (stateData.blockState().hasBlockEntity()) { + var blockEntity = ((BlockEntityProvider) stateData.blockState().getBlock()).createBlockEntity(BlockPos.ORIGIN, stateData.blockState()); BlockEntityType i = null; var packet = blockEntity.toUpdatePacket(); @@ -252,13 +258,13 @@ private static BlockStyleEntry[] parseBlockStyles(List stringList) { i = bePacket.getBlockEntityType(); } - if (stateData.getNbtData() != null) { - blockEntity.readNbt(stateData.getNbtData()); + if (stateData.nbt() != null) { + blockEntity.readNbt(stateData.nbt()); } - blockStates.add(new BlockStyleEntry(stateData.getBlockState(), i, blockEntity.toInitialChunkDataNbt())); + blockStates.add(new BlockStyleEntry(stateData.blockState(), i, blockEntity.toInitialChunkDataNbt())); } else { - blockStates.add(new BlockStyleEntry(stateData.getBlockState(), null, null)); + blockStates.add(new BlockStyleEntry(stateData.blockState(), null, null)); } } else { blockStates.add(new BlockStyleEntry(Blocks.POTATOES.getDefaultState().with(CropBlock.AGE, 7), null, null)); @@ -307,19 +313,19 @@ public String getFormattedTime(long time) { return builder.toString(); } - private static Text[] parse(List strings) { - List texts = new ArrayList<>(); + private static TextNode[] parse(List strings) { + List texts = new ArrayList<>(); for (String line : strings) { if (line == null) { continue; } else if (line.isEmpty()) { - texts.add(LiteralText.EMPTY); + texts.add(EmptyNode.INSTANCE); } else { - texts.add(TextParser.parse(line)); + texts.add(TextParserUtils.formatNodes(line)); } } - return texts.toArray(new Text[0]); + return texts.toArray(new TextNode[0]); } public static record BlockStyleEntry(BlockState state, BlockEntityType blockEntityType, diff --git a/src/main/java/eu/pb4/graves/config/ConfigManager.java b/src/main/java/eu/pb4/graves/config/ConfigManager.java index 78fba05..7143b7b 100644 --- a/src/main/java/eu/pb4/graves/config/ConfigManager.java +++ b/src/main/java/eu/pb4/graves/config/ConfigManager.java @@ -2,12 +2,9 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; import eu.pb4.graves.GravesMod; import eu.pb4.graves.config.data.ConfigData; import eu.pb4.graves.config.data.VersionedConfigData; -import eu.pb4.graves.config.data.old.ConfigDataV1; import net.fabricmc.loader.api.FabricLoader; import org.apache.commons.io.IOUtils; @@ -45,7 +42,6 @@ public static boolean loadConfig() { String json = IOUtils.toString(new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8)); config = switch (GSON.fromJson(json, VersionedConfigData.class).CONFIG_VERSION_DONT_TOUCH_THIS) { - case 1 -> GSON.fromJson(json, ConfigDataV1.class).update(); default -> GSON.fromJson(json, ConfigData.class); }; diff --git a/src/main/java/eu/pb4/graves/config/data/old/ConfigDataV1.java b/src/main/java/eu/pb4/graves/config/data/old/ConfigDataV1.java deleted file mode 100644 index 73fc6fb..0000000 --- a/src/main/java/eu/pb4/graves/config/data/old/ConfigDataV1.java +++ /dev/null @@ -1,155 +0,0 @@ -package eu.pb4.graves.config.data.old; - -import eu.pb4.graves.config.data.ConfigData; -import eu.pb4.graves.config.data.VersionedConfigData; -import eu.pb4.graves.other.GravesLookType; -import eu.pb4.graves.other.GravesXPCalculation; - -import java.util.ArrayList; -import java.util.List; - -public class ConfigDataV1 extends VersionedConfigData { - public String graveType = GravesLookType.PLAYER_HEAD.name; - public String lockedTexture = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjdjYWI1NmM4MmNiODFiZGI5OTc5YTQ2NGJjOWQzYmEzZTY3MjJiYTEyMmNmNmM1Mjg3MzAxMGEyYjU5YWVmZSJ9fX0="; - public String unlockedTexture = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjdjYWI1NmM4MmNiODFiZGI5OTc5YTQ2NGJjOWQzYmEzZTY3MjJiYTEyMmNmNmM1Mjg3MzAxMGEyYjU5YWVmZSJ9fX0="; - - public boolean isProtected = true; - public boolean shouldProtectionExpire = true; - public int protectionTime = 300; - public boolean shouldBreak = true; - public int breakAfter = 900; - - public boolean storeExperience = true; - public String xpStorageType = GravesXPCalculation.VANILLA.name; - public double xpPercentTypeValue = 100; - - public boolean createGravesFromPvP = true; - public boolean createGravesInClaims = true; - public boolean dropItemsAfterExpiring = true; - - public boolean hologram = true; - public List hologramProtectedText = getDefaultProtectedHologram(); - public List hologramText = getDefaultHologram(); - - public String guiTitle = ""; - public List guiProtectedText = getDefaultProtectedGui(); - public List guiText = getDefaultGui(); - - public boolean displayNoLongerProtectedMessage = true; - public String noLongerProtectedMessage = "${position}':'${world}':'${item_count}'>"; - - public boolean displayGraveExpiredMessage = true; - public String graveExpiredMessage = "${position}':'${world}':'${item_count}'>"; - - public boolean displayGraveBrokenMessage = true; - public String graveBrokenMessage = "${position}':'${world}':'${item_count}'>"; - - public boolean displayCreatedGraveMessage = true; - public String createdGraveMessage = "${position}':'${world}'>"; - - public boolean displayCreationFailedGraveMessage = true; - public String creationFailedGraveMessage = "${position}':'${world}'>"; - - public boolean displayCreationFailedPvPGraveMessage = true; - public String creationFailedPvPGraveMessage = "${position}':'${world}'>"; - - public boolean displayCreationFailedClaimGraveMessage = true; - public String creationFailedClaimMessage = "${position}':'${world}'>"; - - public String neverExpires = "Never"; - - public String yearsText = "y"; - public String daysText = "d"; - public String hoursText = "h"; - public String minutesText = "m"; - public String secondsText = "s"; - - public String graveTitle = ""; - - - private static List getDefaultProtectedHologram() { - List list = new ArrayList<>(); - - list.add("${player}'>"); - list.add("${death_cause}"); - list.add(""); - list.add("${item_count}':'${xp}'>"); - list.add("${protection_time}'>"); - list.add("${break_time}'>"); - - return list; - } - - private static List getDefaultHologram() { - List list = new ArrayList<>(); - - list.add("${player}'>"); - list.add("${death_cause}"); - list.add(""); - list.add("${item_count}':'${xp}'>"); - list.add(""); - list.add("${break_time}'>"); - - return list; - } - - private static List getDefaultProtectedGui() { - List list = new ArrayList<>(); - - list.add("${position} (${world})"); - list.add("${death_cause}"); - list.add("${item_count}':'${xp}'>"); - list.add("${protection_time}'>"); - list.add("${break_time}'>"); - - return list; - } - - private static List getDefaultGui() { - List list = new ArrayList<>(); - - list.add("${position} (${world})"); - list.add("${death_cause}"); - list.add("${item_count}':'${xp}'>"); - list.add(""); - list.add("${break_time}'>"); - - return list; - } - - public ConfigData update() { - var config = new ConfigData(); - config.graveStyle = this.graveType; - config.presetHeadUnlockedTexture = this.unlockedTexture; - config.presetHeadLockedTexture = this.lockedTexture; - config.protectionTime = this.shouldProtectionExpire ? this.protectionTime : -1; - config.breakingTime = this.shouldBreak ? this.breakAfter : -1; - config.xpStorageType = this.storeExperience ? this.xpStorageType : GravesXPCalculation.DROP.name; - config.xpPercentTypeValue = this.xpPercentTypeValue; - config.createFromPvP = this.createGravesFromPvP; - config.createInClaims = this.createGravesInClaims; - config.dropItemsAfterExpiring = this.dropItemsAfterExpiring; - config.hologram = this.hologram; - config.hologramProtectedText = this.hologramProtectedText; - config.hologramText = this.hologramText; - config.guiTitle = this.guiTitle; - config.guiProtectedText = this.guiProtectedText; - config.guiText = this.guiText; - config.messageProtectionEnded = this.displayNoLongerProtectedMessage ? this.noLongerProtectedMessage : ""; - config.messageCreationFailed = this.displayCreationFailedGraveMessage ? this.creationFailedGraveMessage : ""; - config.messageGraveCreated = this.displayCreatedGraveMessage ? this.createdGraveMessage : ""; - config.messageGraveExpired = this.displayGraveExpiredMessage ? this.graveExpiredMessage : ""; - config.messageGraveBroken = this.displayGraveBrokenMessage ? this.graveBrokenMessage : ""; - config.messageCreationFailed = this.displayCreationFailedGraveMessage ? this.creationFailedGraveMessage : ""; - config.messageCreationFailedPvP = this.displayCreationFailedPvPGraveMessage ? this.creationFailedPvPGraveMessage : ""; - config.messageCreationFailedClaim = this.displayCreationFailedClaimGraveMessage ? this.creationFailedClaimMessage : ""; - config.yearsText = this.yearsText; - config.daysText = this.daysText; - config.hoursText = this.hoursText; - config.minutesText = this.minutesText; - config.secondsText = this.secondsText; - - config.graveTitle = this.graveTitle; - return config; - } -} \ No newline at end of file diff --git a/src/main/java/eu/pb4/graves/grave/Grave.java b/src/main/java/eu/pb4/graves/grave/Grave.java index e761de6..56e0bd0 100644 --- a/src/main/java/eu/pb4/graves/grave/Grave.java +++ b/src/main/java/eu/pb4/graves/grave/Grave.java @@ -6,7 +6,8 @@ import eu.pb4.graves.other.*; import eu.pb4.graves.registry.GraveBlockEntity; import eu.pb4.graves.ui.GraveGui; -import eu.pb4.placeholders.PlaceholderAPI; +import eu.pb4.placeholders.api.Placeholders; +import eu.pb4.placeholders.api.node.TextNode; import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.inventory.Inventory; @@ -15,11 +16,10 @@ import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtHelper; import net.minecraft.nbt.NbtList; -import net.minecraft.network.MessageType; +import net.minecraft.network.message.MessageType; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.ItemScatterer; @@ -38,7 +38,7 @@ @SuppressWarnings({"unused"}) public final class Grave { - public static final Text DEFAULT_DEATH_CAUSE = new LiteralText("Unknown cause"); + public static final Text DEFAULT_DEATH_CAUSE = Text.literal("Unknown cause"); public static final GameProfile DEFAULT_GAME_PROFILE = new GameProfile(UUID.fromString("9586e5ab-157a-4658-ad80-b07552a9ca63"), "Herobrine"); @Nullable @@ -187,18 +187,18 @@ public Map getPlaceholders(MinecraftServer server) { long breakTime = GraveManager.INSTANCE.getBreakingTime() > -1 ? getTimeLeft(GraveManager.INSTANCE.getBreakingTime(), config.configData.useRealTime) : Long.MAX_VALUE; Map values = new HashMap<>(); - values.put("player", new LiteralText(this.gameProfile != null ? this.gameProfile.getName() : "")); - values.put("protection_time", new LiteralText("" + (GraveManager.INSTANCE.getProtectionTime() > -1 ? config.getFormattedTime(protectionTime) : config.configData.infinityText))); - values.put("break_time", new LiteralText("" + (GraveManager.INSTANCE.getBreakingTime() > -1 ? config.getFormattedTime(breakTime) : config.configData.infinityText))); - values.put("xp", new LiteralText("" + this.xp)); - values.put("item_count", new LiteralText("" + this.itemCount)); - values.put("position", new LiteralText("" + this.location.blockPos().toShortString())); + values.put("player", Text.literal(this.gameProfile != null ? this.gameProfile.getName() : "")); + values.put("protection_time", Text.literal("" + (GraveManager.INSTANCE.getProtectionTime() > -1 ? config.getFormattedTime(protectionTime) : config.configData.infinityText))); + values.put("break_time", Text.literal("" + (GraveManager.INSTANCE.getBreakingTime() > -1 ? config.getFormattedTime(breakTime) : config.configData.infinityText))); + values.put("xp", Text.literal("" + this.xp)); + values.put("item_count", Text.literal("" + this.itemCount)); + values.put("position", Text.literal("" + this.location.blockPos().toShortString())); values.put("world", GraveUtils.toWorldName(this.location.world())); values.put("death_cause", this.deathCause); - values.put("minecraft_day", new LiteralText("" + this.minecraftDay)); - values.put("creation_date", new LiteralText(config.fullDateFormat.format(new Date(this.creationTime * 1000)))); - values.put("since_creation", new LiteralText(config.getFormattedTime(System.currentTimeMillis() / 1000 - this.creationTime))); - values.put("id", new LiteralText("" + this.id)); + values.put("minecraft_day", Text.literal("" + this.minecraftDay)); + values.put("creation_date", Text.literal(config.fullDateFormat.format(new Date(this.creationTime * 1000)))); + values.put("since_creation", Text.literal(config.getFormattedTime(System.currentTimeMillis() / 1000 - this.creationTime))); + values.put("id", Text.literal("" + this.id)); return values; } @@ -351,7 +351,7 @@ public void destroyGrave(MinecraftServer server, @Nullable PlayerEntity breaker) boolean shouldBreak = this.shouldNaturallyBreak(); if (owner != breaker && owner != null) { - Text text; + TextNode text; if (!shouldBreak) { text = config.graveBrokenMessage; @@ -360,7 +360,7 @@ public void destroyGrave(MinecraftServer server, @Nullable PlayerEntity breaker) } if (text != null) { - owner.sendMessage(PlaceholderAPI.parsePredefinedText(text, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, this.getPlaceholders(server)), MessageType.SYSTEM, Util.NIL_UUID); + owner.sendMessage(Placeholders.parseText(text, Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, this.getPlaceholders(server)), MessageType.SYSTEM); } } @@ -396,7 +396,7 @@ public void updateSelf(MinecraftServer server) { if (config.noLongerProtectedMessage != null) { ServerPlayerEntity player = this.gameProfile != null ? server.getPlayerManager().getPlayer(this.gameProfile.getId()) : null; if (player != null) { - player.sendMessage(PlaceholderAPI.parsePredefinedText(config.noLongerProtectedMessage, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, this.getPlaceholders(server)), MessageType.SYSTEM, Util.NIL_UUID); + player.sendMessage(Placeholders.parseText(config.noLongerProtectedMessage, Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, this.getPlaceholders(server)), MessageType.SYSTEM); } } } diff --git a/src/main/java/eu/pb4/graves/mixin/LivingEntityMixin.java b/src/main/java/eu/pb4/graves/mixin/LivingEntityMixin.java index 8a35707..7738882 100644 --- a/src/main/java/eu/pb4/graves/mixin/LivingEntityMixin.java +++ b/src/main/java/eu/pb4/graves/mixin/LivingEntityMixin.java @@ -2,31 +2,32 @@ import eu.pb4.graves.GravesApi; import eu.pb4.graves.GravesMod; -import eu.pb4.graves.registry.GraveBlock; -import eu.pb4.graves.registry.GraveBlockEntity; -import eu.pb4.graves.event.PlayerGraveCreationEvent; import eu.pb4.graves.config.Config; import eu.pb4.graves.config.ConfigManager; -import eu.pb4.graves.grave.*; +import eu.pb4.graves.event.PlayerGraveCreationEvent; +import eu.pb4.graves.grave.Grave; +import eu.pb4.graves.grave.PositionedItemStack; import eu.pb4.graves.other.GraveUtils; import eu.pb4.graves.other.GravesXPCalculation; -import eu.pb4.graves.other.Location; import eu.pb4.graves.other.PlayerAdditions; +import eu.pb4.graves.registry.GraveBlock; +import eu.pb4.graves.registry.GraveBlockEntity; import eu.pb4.graves.registry.TempBlock; -import eu.pb4.placeholders.PlaceholderAPI; +import eu.pb4.placeholders.api.Placeholders; +import eu.pb4.placeholders.api.node.TextNode; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.ExperienceOrbEntity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.network.MessageType; +import net.minecraft.network.message.MessageType; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.state.property.Properties; -import net.minecraft.text.*; -import net.minecraft.util.Formatting; +import net.minecraft.text.ClickEvent; +import net.minecraft.text.Style; +import net.minecraft.text.Text; import net.minecraft.util.ItemScatterer; import net.minecraft.util.Util; import net.minecraft.util.collection.DefaultedList; @@ -56,8 +57,8 @@ private void graves_onKill(CallbackInfo ci) { @Inject(method = "damage", at = @At("TAIL")) private void graves_printDamage1(DamageSource source, float amount, CallbackInfoReturnable cir) { if (((Object) this) instanceof ServerPlayerEntity player && ((PlayerAdditions) player).graves_getPrintNextDamageSource()) { - player.sendMessage(new TranslatableText("text.graves.damage_source_info", - new LiteralText(source.name).setStyle(Style.EMPTY.withUnderline(true).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, source.name))) + player.sendMessage(Text.translatable("text.graves.damage_source_info", + Text.literal(source.name).setStyle(Style.EMPTY.withUnderline(true).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, source.name))) ), false); } } @@ -65,8 +66,8 @@ private void graves_printDamage1(DamageSource source, float amount, CallbackInfo @Inject(method = "applyDamage", at = @At("TAIL")) private void graves_printDamage2(DamageSource source, float amount, CallbackInfo ci) { if (((Object) this) instanceof ServerPlayerEntity player && ((PlayerAdditions) player).graves_getPrintNextDamageSource()) { - player.sendMessage(new TranslatableText("text.graves.damage_source_info", - new LiteralText(source.name).setStyle(Style.EMPTY.withUnderline(true).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, source.name))) + player.sendMessage(Text.translatable("text.graves.damage_source_info", + Text.literal(source.name).setStyle(Style.EMPTY.withUnderline(true).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, source.name))) ), false); } } @@ -82,9 +83,9 @@ private void replaceWithGrave(DamageSource source, CallbackInfo ci) { return; } - Text text = null; + TextNode text = null; Map placeholders = Map.of( - "position", new LiteralText("" + player.getBlockPos().toShortString()), + "position", Text.literal("" + player.getBlockPos().toShortString()), "world", GraveUtils.toWorldName(player.getWorld().getRegistryKey().getValue()) ); @@ -151,7 +152,7 @@ private void replaceWithGrave(DamageSource source, CallbackInfo ci) { GravesMod.DO_ON_NEXT_TICK.add(() -> { - Text text2; + TextNode text2; Map placeholders2 = placeholders; BlockState storedBlockState = world.getBlockState(gravePos).getBlock() == TempBlock.INSTANCE ? oldBlockState : Blocks.AIR.getDefaultState(); @@ -177,7 +178,7 @@ private void replaceWithGrave(DamageSource source, CallbackInfo ci) { ((PlayerAdditions) player).graves_setLastGrave(-1); } if (text2 != null) { - player.sendMessage(PlaceholderAPI.parsePredefinedText(text2, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, placeholders2), MessageType.SYSTEM, Util.NIL_UUID); + player.sendMessage(Placeholders.parseText(text2, Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, placeholders2), MessageType.SYSTEM); } }); @@ -200,7 +201,7 @@ private void replaceWithGrave(DamageSource source, CallbackInfo ci) { } if (text != null) { - player.sendMessage(PlaceholderAPI.parsePredefinedText(text, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, placeholders), MessageType.SYSTEM, Util.NIL_UUID); + player.sendMessage(Placeholders.parseText(text, Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, placeholders), MessageType.SYSTEM); } } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/eu/pb4/graves/mixin/ServerPlayerEntityMixin.java b/src/main/java/eu/pb4/graves/mixin/ServerPlayerEntityMixin.java index 07557f8..d7d5f8e 100644 --- a/src/main/java/eu/pb4/graves/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/eu/pb4/graves/mixin/ServerPlayerEntityMixin.java @@ -11,10 +11,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; +import net.minecraft.network.encryption.PlayerPublicKey; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -27,10 +29,11 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Pl private boolean graves_printNextSource = false; - public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile profile) { - super(world, pos, yaw, profile); + public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile, @Nullable PlayerPublicKey publicKey) { + super(world, pos, yaw, gameProfile, publicKey); } + @Shadow protected abstract void fall(double heightDifference, boolean onGround, BlockState landedState, BlockPos landedPosition); @Unique diff --git a/src/main/java/eu/pb4/graves/mixin/ServerWorldMixin.java b/src/main/java/eu/pb4/graves/mixin/ServerWorldMixin.java index 6fd4e1e..aa05473 100644 --- a/src/main/java/eu/pb4/graves/mixin/ServerWorldMixin.java +++ b/src/main/java/eu/pb4/graves/mixin/ServerWorldMixin.java @@ -21,8 +21,8 @@ @Mixin(value = ServerWorld.class, priority = 1005) public abstract class ServerWorldMixin extends World { - protected ServerWorldMixin(MutableWorldProperties properties, RegistryKey registryRef, RegistryEntry registryEntry, Supplier profiler, boolean isClient, boolean debugWorld, long seed) { - super(properties, registryRef, registryEntry, profiler, isClient, debugWorld, seed); + protected ServerWorldMixin(MutableWorldProperties properties, RegistryKey registryRef, RegistryEntry dimension, Supplier profiler, boolean isClient, boolean debugWorld, long seed, int maxChainedNeighborUpdates) { + super(properties, registryRef, dimension, profiler, isClient, debugWorld, seed, maxChainedNeighborUpdates); } @Inject(method = "canPlayerModifyAt", at = @At("HEAD"), cancellable = true) diff --git a/src/main/java/eu/pb4/graves/other/Commands.java b/src/main/java/eu/pb4/graves/other/Commands.java index eec21e7..5f0f58e 100644 --- a/src/main/java/eu/pb4/graves/other/Commands.java +++ b/src/main/java/eu/pb4/graves/other/Commands.java @@ -9,12 +9,11 @@ import eu.pb4.graves.config.ConfigManager; import eu.pb4.graves.ui.GraveListGui; import me.lucko.fabric.api.permissions.v0.Permissions; -import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.minecraft.command.argument.GameProfileArgumentType; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.LiteralText; -import net.minecraft.text.TranslatableText; +import net.minecraft.text.Text; import net.minecraft.util.Formatting; import java.util.ArrayList; @@ -25,7 +24,7 @@ public class Commands { public static void register() { - CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> { + CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { dispatcher.register( literal("graves") .requires(Permissions.require("universal_graves.list", true)) @@ -63,7 +62,7 @@ private static int toggleDamageSourceInfo(CommandContext co var bl = pl.graves_getPrintNextDamageSource(); pl.graves_setPrintNextDamageSource(!bl); - context.getSource().sendFeedback(new TranslatableText("text.graves.damage_source_info." + (bl ? "disabled" : "enabled")), false); + context.getSource().sendFeedback(Text.translatable("text.graves.damage_source_info." + (bl ? "disabled" : "enabled")), false); return 0; } @@ -83,10 +82,10 @@ private static int listOthers(CommandContext context, boole List profiles = new ArrayList(context.getArgument("player", GameProfileArgumentType.GameProfileArgument.class).getNames(context.getSource())); if (profiles.size() == 0) { - context.getSource().sendFeedback(new LiteralText("This player doesn't exist!"), false); + context.getSource().sendFeedback(Text.literal("This player doesn't exist!"), false); return 0; } else if (profiles.size() > 1) { - context.getSource().sendFeedback(new LiteralText("Only one player can be selected!"), false); + context.getSource().sendFeedback(Text.literal("Only one player can be selected!"), false); return 0; } try { @@ -100,13 +99,13 @@ private static int listOthers(CommandContext context, boole private static int reloadConfig(CommandContext context) { if (ConfigManager.loadConfig()) { - context.getSource().sendFeedback(new LiteralText("Reloaded config!"), false); + context.getSource().sendFeedback(Text.literal("Reloaded config!"), false); for (var player : context.getSource().getServer().getPlayerManager().getPlayerList()) { GraveNetworking.sendConfig(player.networkHandler); } } else { - context.getSource().sendError(new LiteralText("Error accrued while reloading config!").formatted(Formatting.RED)); + context.getSource().sendError(Text.literal("Error accrued while reloading config!").formatted(Formatting.RED)); } return 1; diff --git a/src/main/java/eu/pb4/graves/other/GraveUtils.java b/src/main/java/eu/pb4/graves/other/GraveUtils.java index e9dbabb..a5d83c6 100644 --- a/src/main/java/eu/pb4/graves/other/GraveUtils.java +++ b/src/main/java/eu/pb4/graves/other/GraveUtils.java @@ -8,7 +8,6 @@ import eu.pb4.graves.registry.TempBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.ExperienceOrbEntity; import net.minecraft.item.ItemStack; @@ -16,9 +15,7 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.property.Property; -import net.minecraft.tag.Tag; import net.minecraft.tag.TagKey; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; @@ -165,7 +162,7 @@ public static Text toWorldName(Identifier identifier) { parts.add(String.join("", s)); } } - return new LiteralText(String.join(" ", parts)); + return Text.literal(String.join(" ", parts)); } public static boolean hasSkippedEnchantment(ItemStack stack) { diff --git a/src/main/java/eu/pb4/graves/other/GravesLookType.java b/src/main/java/eu/pb4/graves/other/GravesLookType.java index 3f2fde4..baa7801 100644 --- a/src/main/java/eu/pb4/graves/other/GravesLookType.java +++ b/src/main/java/eu/pb4/graves/other/GravesLookType.java @@ -3,7 +3,7 @@ import eu.pb4.graves.GraveNetworking; import eu.pb4.graves.config.ConfigManager; import eu.pb4.graves.grave.Grave; -import eu.pb4.placeholders.PlaceholderAPI; +import eu.pb4.placeholders.api.Placeholders; import eu.pb4.polymer.mixin.block.BlockEntityUpdateS2CPacketAccessor; import fr.catcore.server.translations.api.LocalizationTarget; import fr.catcore.server.translations.api.text.LocalizableText; @@ -112,16 +112,16 @@ public void sendNbt(ServerPlayerEntity player, BlockState state, BlockPos pos, i if (entry.blockEntityType() != null && entry.blockEntityNbt() != null) { var compound = entry.blockEntityNbt().copy(); - var texts = textOverride != null ? textOverride : isLocked ? config.signProtectedText : config.signText; + var texts = isLocked ? config.signProtectedText : config.signText; var placeholders = (graveInfo != null ? graveInfo.getPlaceholders(player.getServer()) : visualData.getPlaceholders(player.getServer())); - var size = Math.min(4, texts.length); + var size = Math.min(4, (textOverride != null ? textOverride : texts).length); var target = (LocalizationTarget) player; for (int i = 0; i < size; i++) { compound.putString("Text" + (i + 1), Text.Serializer.toJson( - LocalizableText.asLocalizedFor(PlaceholderAPI.parsePredefinedText(texts[i], PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, placeholders), target) + textOverride != null ? textOverride[i] : LocalizableText.asLocalizedFor(Placeholders.parseText(texts[i], Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, placeholders), target) ) ); } diff --git a/src/main/java/eu/pb4/graves/other/VisualGraveData.java b/src/main/java/eu/pb4/graves/other/VisualGraveData.java index 5345cbd..b14d0e0 100644 --- a/src/main/java/eu/pb4/graves/other/VisualGraveData.java +++ b/src/main/java/eu/pb4/graves/other/VisualGraveData.java @@ -7,7 +7,6 @@ import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtHelper; import net.minecraft.server.MinecraftServer; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; @@ -33,18 +32,18 @@ public Map getPlaceholders(MinecraftServer server) { Config config = ConfigManager.getConfig(); Map values = new HashMap<>(); - values.put("player", new LiteralText(this.gameProfile != null ? this.gameProfile.getName() : "")); - values.put("protection_time", new LiteralText("" + (config.configData.protectionTime > -1 ? config.getFormattedTime(0) : config.configData.infinityText))); - values.put("break_time", new LiteralText("" + (config.configData.breakingTime > -1 ? config.getFormattedTime(0) : config.configData.infinityText))); - values.put("xp", new LiteralText("0")); - values.put("item_count", new LiteralText("0")); - values.put("position", new LiteralText("" + this.location.blockPos().toShortString())); + values.put("player", Text.literal(this.gameProfile != null ? this.gameProfile.getName() : "")); + values.put("protection_time", Text.literal("" + (config.configData.protectionTime > -1 ? config.getFormattedTime(0) : config.configData.infinityText))); + values.put("break_time", Text.literal("" + (config.configData.breakingTime > -1 ? config.getFormattedTime(0) : config.configData.infinityText))); + values.put("xp", Text.literal("0")); + values.put("item_count", Text.literal("0")); + values.put("position", Text.literal("" + this.location.blockPos().toShortString())); values.put("world", GraveUtils.toWorldName(this.location.world())); values.put("death_cause", this.deathCause); - values.put("minecraft_day", new LiteralText("" + this.minecraftDay)); - values.put("creation_date", new LiteralText(config.fullDateFormat.format(new Date(this.creationTime * 1000)))); - values.put("since_creation", new LiteralText(config.getFormattedTime(System.currentTimeMillis() / 1000 - this.creationTime))); - values.put("id", new LiteralText("")); + values.put("minecraft_day", Text.literal("" + this.minecraftDay)); + values.put("creation_date", Text.literal(config.fullDateFormat.format(new Date(this.creationTime * 1000)))); + values.put("since_creation", Text.literal(config.getFormattedTime(System.currentTimeMillis() / 1000 - this.creationTime))); + values.put("id", Text.literal("")); return values; } diff --git a/src/main/java/eu/pb4/graves/registry/GraveBlockEntity.java b/src/main/java/eu/pb4/graves/registry/GraveBlockEntity.java index 412105a..d4f7af2 100644 --- a/src/main/java/eu/pb4/graves/registry/GraveBlockEntity.java +++ b/src/main/java/eu/pb4/graves/registry/GraveBlockEntity.java @@ -11,7 +11,8 @@ import eu.pb4.graves.other.VisualGraveData; import eu.pb4.holograms.api.elements.SpacingHologramElement; import eu.pb4.holograms.api.holograms.WorldHologram; -import eu.pb4.placeholders.PlaceholderAPI; +import eu.pb4.placeholders.api.Placeholders; +import eu.pb4.placeholders.api.node.EmptyNode; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; @@ -25,8 +26,8 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.property.Properties; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; +import net.minecraft.text.TextContent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.Vec3d; @@ -213,11 +214,11 @@ public boolean canAddPlayer(ServerPlayerEntity player) { List texts = new ArrayList<>(); - for (Text text : isProtected ? config.hologramProtectedText : config.hologramText) { - if (text != LiteralText.EMPTY) { - texts.add(PlaceholderAPI.parsePredefinedText(text, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, placeholders)); + for (var text : isProtected ? config.hologramProtectedText : config.hologramText) { + if (text != EmptyNode.INSTANCE) { + texts.add(Placeholders.parseText(text, Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, placeholders)); } else { - texts.add(LiteralText.EMPTY); + texts.add(Text.empty()); } } @@ -225,7 +226,7 @@ public boolean canAddPlayer(ServerPlayerEntity player) { if (texts.size() != self.hologram.getElements().size()) { self.hologram.clearElements(); for (Text text : texts) { - if (text == LiteralText.EMPTY) { + if (text.getContent() == TextContent.EMPTY) { self.hologram.addElement(new SpacingHologramElement(0.28)); } else { self.hologram.addText(text); @@ -234,7 +235,7 @@ public boolean canAddPlayer(ServerPlayerEntity player) { } else { int x = 0; for (Text text : texts) { - if (text == LiteralText.EMPTY) { + if (text.getContent() == TextContent.EMPTY) { self.hologram.setElement(x, new SpacingHologramElement(0.28)); } else { self.hologram.setText(x, text); diff --git a/src/main/java/eu/pb4/graves/registry/VisualGraveBlock.java b/src/main/java/eu/pb4/graves/registry/VisualGraveBlock.java index 5b2a5a6..e2c27e8 100644 --- a/src/main/java/eu/pb4/graves/registry/VisualGraveBlock.java +++ b/src/main/java/eu/pb4/graves/registry/VisualGraveBlock.java @@ -26,7 +26,6 @@ import net.minecraft.server.world.ServerWorld; import net.minecraft.state.StateManager; import net.minecraft.state.property.Properties; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; @@ -62,7 +61,7 @@ public void onPlaced(World world, BlockPos pos, BlockState state, @Nullable Livi if (placer != null) { var optional = world.getBlockEntity(pos, VisualGraveBlockEntity.BLOCK_ENTITY_TYPE); if (optional.isPresent()) { - optional.get().textOverrides = new Text[]{LiteralText.EMPTY, LiteralText.EMPTY, LiteralText.EMPTY, LiteralText.EMPTY}; + optional.get().textOverrides = new Text[]{Text.empty(), Text.empty(), Text.empty(), Text.empty()}; } } } @@ -152,7 +151,7 @@ public void onClose() { int i = 0; for (var text : grave.textOverrides) { - sign.setLine(i, text.shallowCopy()); + sign.setLine(i, text.copy()); i++; if (i == 4) { diff --git a/src/main/java/eu/pb4/graves/registry/VisualGraveBlockEntity.java b/src/main/java/eu/pb4/graves/registry/VisualGraveBlockEntity.java index af7018e..9afaadf 100644 --- a/src/main/java/eu/pb4/graves/registry/VisualGraveBlockEntity.java +++ b/src/main/java/eu/pb4/graves/registry/VisualGraveBlockEntity.java @@ -6,7 +6,8 @@ import eu.pb4.graves.other.VisualGraveData; import eu.pb4.holograms.api.elements.SpacingHologramElement; import eu.pb4.holograms.api.holograms.WorldHologram; -import eu.pb4.placeholders.PlaceholderAPI; +import eu.pb4.placeholders.api.Placeholders; +import eu.pb4.placeholders.api.node.EmptyNode; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.entity.BlockEntity; @@ -15,8 +16,8 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.state.property.Properties; -import net.minecraft.text.LiteralText; import net.minecraft.text.Text; +import net.minecraft.text.TextContent; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.Vec3d; @@ -138,18 +139,18 @@ public boolean canAddPlayer(ServerPlayerEntity player) { if (self.textOverrides != null) { for (Text text : self.textOverrides) { - if (text != LiteralText.EMPTY) { - texts.add(PlaceholderAPI.parsePredefinedText(text, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, placeholders)); + if (text.getContent() == TextContent.EMPTY) { + texts.add(text); } else { - texts.add(LiteralText.EMPTY); + texts.add(Text.empty()); } } } else { - for (Text text : config.hologramVisualText) { - if (!text.equals(LiteralText.EMPTY)) { - texts.add(PlaceholderAPI.parsePredefinedText(text, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, placeholders)); + for (var text : config.hologramVisualText) { + if (!text.equals(EmptyNode.INSTANCE)) { + texts.add(Placeholders.parseText(text, Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, placeholders)); } else { - texts.add(LiteralText.EMPTY); + texts.add(Text.empty()); } } } @@ -161,7 +162,7 @@ public boolean canAddPlayer(ServerPlayerEntity player) { int x = 0; for (Text text : texts) { - if (text.equals(LiteralText.EMPTY)) { + if (text.getContent() == TextContent.EMPTY) { self.hologram.setElement(x, new SpacingHologramElement(0.28)); } else { self.hologram.setText(x, text); @@ -190,10 +191,6 @@ public VisualGraveData getClientData() { return this.visualData; } - public Text[] getSignText() { - return this.textOverrides != null ? this.textOverrides : ConfigManager.getConfig().signVisualText; - } - public Text[] getTextOverrides() { return this.textOverrides; } diff --git a/src/main/java/eu/pb4/graves/ui/GraveGui.java b/src/main/java/eu/pb4/graves/ui/GraveGui.java index c6b11b6..139e4cc 100644 --- a/src/main/java/eu/pb4/graves/ui/GraveGui.java +++ b/src/main/java/eu/pb4/graves/ui/GraveGui.java @@ -1,11 +1,10 @@ package eu.pb4.graves.ui; -import eu.pb4.graves.GraveNetworking; import eu.pb4.graves.config.ConfigManager; import eu.pb4.graves.grave.Grave; import eu.pb4.graves.other.OutputSlot; import eu.pb4.graves.registry.GraveCompassItem; -import eu.pb4.placeholders.PlaceholderAPI; +import eu.pb4.placeholders.api.Placeholders; import eu.pb4.sgui.api.ClickType; import eu.pb4.sgui.api.elements.GuiElementBuilder; import me.lucko.fabric.api.permissions.v0.Permissions; @@ -30,7 +29,7 @@ public GraveGui(ServerPlayerEntity player, Grave grave, boolean canTake) { super(player); this.grave = grave; this.canTake = canTake; - this.setTitle(PlaceholderAPI.parsePredefinedText(ConfigManager.getConfig().graveTitle, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, grave.getPlaceholders(player.getWorld().getServer()))); + this.setTitle(Placeholders.parseText(ConfigManager.getConfig().graveTitle, Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, grave.getPlaceholders(player.getWorld().getServer()))); this.inventory = this.grave.asInventory(); this.updateDisplay(); } @@ -87,8 +86,8 @@ protected DisplayElement getNavElement(int id) { var placeholders = grave.getPlaceholders(this.player.getServer()); List parsed = new ArrayList<>(); - for (Text text : grave.isProtected() ? ConfigManager.getConfig().guiProtectedText : ConfigManager.getConfig().guiText) { - MutableText out = (MutableText) PlaceholderAPI.parsePredefinedText(text, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, placeholders); + for (var text : grave.isProtected() ? ConfigManager.getConfig().guiProtectedText : ConfigManager.getConfig().guiText) { + MutableText out = (MutableText) Placeholders.parseText(text, Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, placeholders); if (out.getStyle().getColor() == null) { out.setStyle(out.getStyle().withColor(Formatting.WHITE)); } @@ -135,7 +134,7 @@ private DisplayElement getRemoveProtection() { return DisplayElement.of(GuiElementBuilder.from(config.guiRemoveProtectionIcon) .setName(config.guiRemoveProtectionText) .addLoreLine(config.guiCantReverseAction) - .addLoreLine(LiteralText.EMPTY) + .addLoreLine(Text.empty()) .addLoreLine(config.guiClickToConfirm) .hideFlags() .setCallback((x, y, z) -> { @@ -163,7 +162,7 @@ private DisplayElement getRemoveProtection() { return DisplayElement.of(GuiElementBuilder.from(config.guiBreakGraveIcon) .setName(config.guiBreakGraveText) .addLoreLine(config.guiCantReverseAction) - .addLoreLine(LiteralText.EMPTY) + .addLoreLine(Text.empty()) .addLoreLine(config.guiClickToConfirm) .setSkullOwner("") .hideFlags() diff --git a/src/main/java/eu/pb4/graves/ui/GraveListGui.java b/src/main/java/eu/pb4/graves/ui/GraveListGui.java index 92db076..d2ee7b7 100644 --- a/src/main/java/eu/pb4/graves/ui/GraveListGui.java +++ b/src/main/java/eu/pb4/graves/ui/GraveListGui.java @@ -5,19 +5,21 @@ import eu.pb4.graves.config.ConfigManager; import eu.pb4.graves.grave.Grave; import eu.pb4.graves.grave.GraveManager; -import eu.pb4.placeholders.PlaceholderAPI; +import eu.pb4.placeholders.api.Placeholders; import eu.pb4.sgui.api.elements.GuiElementBuilder; import me.lucko.fabric.api.permissions.v0.Permissions; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; -import net.minecraft.text.LiteralText; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; public class GraveListGui extends PagedGui { private final UUID targetUUID; @@ -32,10 +34,10 @@ public GraveListGui(ServerPlayerEntity player, GameProfile profile, boolean canM if (player.getUuid().equals(this.targetUUID)) { this.setTitle(ConfigManager.getConfig().guiTitle); } else { - this.setTitle(PlaceholderAPI.parsePredefinedText( + this.setTitle(Placeholders.parseText( ConfigManager.getConfig().graveTitle, - PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, - Map.of("player", new LiteralText(profile.getName())) + Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, + Map.of("player", Text.literal(profile.getName())) )); } this.graves = new ArrayList<>(GraveManager.INSTANCE.getByUuid(this.targetUUID)); @@ -58,8 +60,8 @@ protected DisplayElement getElement(int id) { var placeholders = grave.getPlaceholders(this.player.getServer()); List parsed = new ArrayList<>(); - for (Text text : grave.isProtected() ? ConfigManager.getConfig().guiProtectedText : ConfigManager.getConfig().guiText) { - MutableText out = (MutableText) PlaceholderAPI.parsePredefinedText(text, PlaceholderAPI.PREDEFINED_PLACEHOLDER_PATTERN, placeholders); + for (var text : grave.isProtected() ? ConfigManager.getConfig().guiProtectedText : ConfigManager.getConfig().guiText) { + MutableText out = (MutableText) Placeholders.parseText(text, Placeholders.PREDEFINED_PLACEHOLDER_PATTERN, placeholders); if (out.getStyle().getColor() == null) { out.setStyle(out.getStyle().withColor(Formatting.WHITE)); } @@ -68,7 +70,7 @@ protected DisplayElement getElement(int id) { var list = grave.isProtected() ? config.guiProtectedItem : config.guiItem; var element = GuiElementBuilder.from(list[Math.abs(grave.hashCode() % list.length)]) - .setName((MutableText) parsed.remove(0)) + .setName(parsed.remove(0)) .setLore(parsed) .setCallback((index, type, action) -> { if (type.isRight) { diff --git a/src/main/java/eu/pb4/graves/ui/PagedGui.java b/src/main/java/eu/pb4/graves/ui/PagedGui.java index d63c99c..58b9f4c 100644 --- a/src/main/java/eu/pb4/graves/ui/PagedGui.java +++ b/src/main/java/eu/pb4/graves/ui/PagedGui.java @@ -13,7 +13,7 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; -import net.minecraft.text.LiteralText; +import net.minecraft.text.Text; import org.jetbrains.annotations.Nullable; public abstract class PagedGui extends SimpleGui { @@ -152,7 +152,7 @@ public static DisplayElement previousPage(PagedGui gui) { public static DisplayElement filler() { return DisplayElement.of( GuiElementBuilder.from(ConfigManager.getConfig().guiBarItem) - .setName(LiteralText.EMPTY) + .setName(Text.empty()) .hideFlags() ); }