Skip to content

Commit

Permalink
1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Jun 10, 2022
1 parent 7e0bd69 commit 380a9e8
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 47 deletions.
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies {
}

architectury {
common(false)
common(rootProject.forge_enabled.toBoolean())
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -39,14 +39,12 @@ private static int openGui(CommandContext<CommandSourceStack> 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()
);
));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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;
import net.minecraft.world.item.Items;
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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
20 changes: 2 additions & 18 deletions common/src/main/java/org/samo_lego/tradernpcs/item/TradeStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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!"));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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 {
@Override
public void onInitialize() {
Traders.init();

CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> Traders.registerCommands());
CommandRegistrationCallback.EVENT.register((dispatcher, context, selection) -> Traders.registerCommands());
}
}
4 changes: 2 additions & 2 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
15 changes: 8 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pluginManagement {

include("common")
include("fabric")
//include("forge")
if (forge_enabled.toBoolean()) {
include("forge")
}

rootProject.name = "tradernpcs"

0 comments on commit 380a9e8

Please sign in to comment.