From 380a9e87ddd3139b6e484b445991bba140d591b0 Mon Sep 17 00:00:00 2001 From: samolego <34912839+samolego@users.noreply.github.com> Date: Fri, 10 Jun 2022 11:23:52 +0200 Subject: [PATCH] 1.19 --- common/build.gradle | 2 +- .../tradernpcs/command/TraderCommand.java | 10 ++++------ .../tradernpcs/gui/TradeEditGUI.java | 8 ++++---- .../tradernpcs/gui/TradeMenuGUI.java | 8 ++++---- .../samo_lego/tradernpcs/item/TradeStack.java | 20 ++----------------- .../profession/SurvivalTraderProfession.java | 4 ++-- .../tradernpcs/fabric/TradersFabric.java | 4 ++-- fabric/src/main/resources/fabric.mod.json | 4 ++-- gradle.properties | 15 +++++++------- settings.gradle | 4 +++- 10 files changed, 32 insertions(+), 47 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index 3b15087..23552fb 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -9,7 +9,7 @@ dependencies { } architectury { - common(false) + common(rootProject.forge_enabled.toBoolean()) } publishing { diff --git a/common/src/main/java/org/samo_lego/tradernpcs/command/TraderCommand.java b/common/src/main/java/org/samo_lego/tradernpcs/command/TraderCommand.java index a320d8d..118993d 100644 --- a/common/src/main/java/org/samo_lego/tradernpcs/command/TraderCommand.java +++ b/common/src/main/java/org/samo_lego/tradernpcs/command/TraderCommand.java @@ -5,8 +5,8 @@ import com.mojang.brigadier.tree.LiteralCommandNode; import net.minecraft.commands.CommandSourceStack; import net.minecraft.network.chat.ClickEvent; +import net.minecraft.network.chat.Component; import net.minecraft.network.chat.HoverEvent; -import net.minecraft.network.chat.TextComponent; import net.minecraft.server.level.ServerPlayer; import org.samo_lego.taterzens.api.professions.TaterzenProfession; import org.samo_lego.taterzens.commands.NpcCommand; @@ -39,14 +39,12 @@ private static int openGui(CommandContext context) throws Co } else { String id = TraderNPCProfession.ID.toString(); // Doesn't have profession assigned - player.sendMessage( + player.sendSystemMessage( errorText("taterzens.profession.lacking", id) .withStyle(style -> style - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent(id))) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(id))) .withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/npc edit professions add tradernpcs:trader")) - ), - player.getUUID() - ); + )); } }); } diff --git a/common/src/main/java/org/samo_lego/tradernpcs/gui/TradeEditGUI.java b/common/src/main/java/org/samo_lego/tradernpcs/gui/TradeEditGUI.java index 611504a..48de946 100644 --- a/common/src/main/java/org/samo_lego/tradernpcs/gui/TradeEditGUI.java +++ b/common/src/main/java/org/samo_lego/tradernpcs/gui/TradeEditGUI.java @@ -1,6 +1,6 @@ package org.samo_lego.tradernpcs.gui; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; @@ -8,7 +8,7 @@ import net.minecraft.world.item.trading.MerchantOffer; import net.minecraft.world.item.trading.MerchantOffers; import org.jetbrains.annotations.Nullable; -import org.samo_lego.taterzens.fabric.gui.ListItemsGUI; +import org.samo_lego.taterzens.gui.ListItemsGUI; import org.samo_lego.tradernpcs.gui.slot.TradeSlot; import org.samo_lego.tradernpcs.mixin.MerchantOfferAccessor; import org.samo_lego.tradernpcs.profession.TraderNPCProfession; @@ -46,11 +46,11 @@ public TradeEditGUI(TraderNPCProfession profession, ServerPlayer player, int max final ItemStack pane = new ItemStack(Items.BLACK_STAINED_GLASS_PANE); pane.setTag(customData.copy()); - pane.setHoverName(TextComponent.EMPTY); + pane.setHoverName(Component.literal("")); final ItemStack tradeFor = new ItemStack(Items.SPECTRAL_ARROW); tradeFor.setTag(customData.copy()); - tradeFor.setHoverName(new TextComponent("->")); + tradeFor.setHoverName(Component.literal("->")); // GUI skeleton for (i = 9; i + 8 < this.getSize(); i += 9) { diff --git a/common/src/main/java/org/samo_lego/tradernpcs/gui/TradeMenuGUI.java b/common/src/main/java/org/samo_lego/tradernpcs/gui/TradeMenuGUI.java index dadc25c..9c1d56d 100644 --- a/common/src/main/java/org/samo_lego/tradernpcs/gui/TradeMenuGUI.java +++ b/common/src/main/java/org/samo_lego/tradernpcs/gui/TradeMenuGUI.java @@ -2,7 +2,7 @@ import eu.pb4.sgui.api.elements.GuiElement; import eu.pb4.sgui.api.gui.SimpleGui; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.inventory.MenuType; import net.minecraft.world.item.ItemStack; @@ -21,7 +21,7 @@ public TradeMenuGUI(SurvivalTraderProfession profession, ServerPlayer player) { // Edit trades ItemStack edit = new ItemStack(Items.EMERALD); - edit.setHoverName(new TextComponent("Edit trades")); + edit.setHoverName(Component.literal("Edit trades")); GuiElement editTradesBtn = new GuiElement(edit, (index, type1, action) -> { this.close(); new TradeEditGUI(profession, player, 0).open(); @@ -30,7 +30,7 @@ public TradeMenuGUI(SurvivalTraderProfession profession, ServerPlayer player) { // Set stock ItemStack stock = new ItemStack(Items.CHEST); - stock.setHoverName(new TextComponent("Set stock & collect earnings")); + stock.setHoverName(Component.literal("Set stock & collect earnings")); GuiElement setStockBtn = new GuiElement(stock, (index, type1, action) -> { this.close(); new SurvivalStockGUI(profession, player).open(); @@ -39,7 +39,7 @@ public TradeMenuGUI(SurvivalTraderProfession profession, ServerPlayer player) { // View trades ItemStack view = new ItemStack(Items.ENDER_EYE); - view.setHoverName(new TextComponent("View trades")); + view.setHoverName(Component.literal("View trades")); GuiElement viewTradesBtn = new GuiElement(view, (index, type1, action) -> { this.close(); new TradeGUI(profession, player).open(); diff --git a/common/src/main/java/org/samo_lego/tradernpcs/item/TradeStack.java b/common/src/main/java/org/samo_lego/tradernpcs/item/TradeStack.java index 6df4561..1236329 100644 --- a/common/src/main/java/org/samo_lego/tradernpcs/item/TradeStack.java +++ b/common/src/main/java/org/samo_lego/tradernpcs/item/TradeStack.java @@ -2,34 +2,18 @@ import net.minecraft.world.item.ItemStack; -public class TradeStack { - private final ItemStack first; - private final ItemStack second; - +public record TradeStack(ItemStack first, ItemStack second) { public TradeStack(ItemStack payment) { this(payment, ItemStack.EMPTY); } - public TradeStack(ItemStack payment1, ItemStack payment2) { - this.first = payment1; - this.second = payment2; - } - @Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj instanceof TradeStack trd) { - return trd.getFirst().equals(this.first) && trd.getSecond().equals(this.second); + return trd.first().equals(this.first) && trd.second().equals(this.second); } return false; } - - public ItemStack getFirst() { - return this.first; - } - - public ItemStack getSecond() { - return this.second; - } } diff --git a/common/src/main/java/org/samo_lego/tradernpcs/profession/SurvivalTraderProfession.java b/common/src/main/java/org/samo_lego/tradernpcs/profession/SurvivalTraderProfession.java index 92888e6..9b31a80 100644 --- a/common/src/main/java/org/samo_lego/tradernpcs/profession/SurvivalTraderProfession.java +++ b/common/src/main/java/org/samo_lego/tradernpcs/profession/SurvivalTraderProfession.java @@ -3,7 +3,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.InteractionHand; @@ -129,7 +129,7 @@ private void setOwner() { this.ownerUUID = owner.getUUID(); // Todo - better implementation once Taterzens gets better lang support - owner.sendMessage(new TextComponent(owner.getGameProfile().getName() + ", I'm your survival trader!"), this.npc.getUUID()); + owner.sendSystemMessage(Component.literal(owner.getGameProfile().getName() + ", I'm your survival trader!")); } } diff --git a/fabric/src/main/java/org/samo_lego/tradernpcs/fabric/TradersFabric.java b/fabric/src/main/java/org/samo_lego/tradernpcs/fabric/TradersFabric.java index 8a6ed51..080fe3d 100644 --- a/fabric/src/main/java/org/samo_lego/tradernpcs/fabric/TradersFabric.java +++ b/fabric/src/main/java/org/samo_lego/tradernpcs/fabric/TradersFabric.java @@ -1,7 +1,7 @@ package org.samo_lego.tradernpcs.fabric; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import org.samo_lego.tradernpcs.Traders; public class TradersFabric implements ModInitializer { @@ -9,6 +9,6 @@ public class TradersFabric implements ModInitializer { public void onInitialize() { Traders.init(); - CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> Traders.registerCommands()); + CommandRegistrationCallback.EVENT.register((dispatcher, context, selection) -> Traders.registerCommands()); } } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index e435469..3503fd3 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -23,8 +23,8 @@ "mixins": ["tradernpcs-common.mixins.json"], "depends": { "fabric": "*", - "minecraft": ">=1.18.2", - "taterzens": ">=1.9.0" + "minecraft": ">=1.19", + "taterzens": ">=1.10.0" }, "recommends": { "taterzens": ">=${taterzens}" diff --git a/gradle.properties b/gradle.properties index 403b7c5..3f25a1e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,19 +1,20 @@ org.gradle.jvmargs=-Xmx2048M # Fabric -minecraft_version=1.18.2 -yarn_mappings=1.18.2+build.3 -loader_version=0.13.3 +minecraft_version=1.19 +yarn_mappings=1.19+build.1 +loader_version=0.14.7 #Fabric api -fabric_version=0.51.1+1.18.2 +fabric_version=0.55.3+1.19 #Forge -forge_version=40.1.0 +forge_version=41.0.5 +forge_enabled=false -mod_version = 1.1.1 +mod_version = 1.2.0 maven_group = org.samo_lego archives_base_name = tradernpcs # Deps -taterzens = 1.9.0 +taterzens = 1.10.1 diff --git a/settings.gradle b/settings.gradle index a3b4a66..ebb6633 100644 --- a/settings.gradle +++ b/settings.gradle @@ -9,6 +9,8 @@ pluginManagement { include("common") include("fabric") -//include("forge") +if (forge_enabled.toBoolean()) { + include("forge") +} rootProject.name = "tradernpcs"