Skip to content

Commit

Permalink
Update to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Jun 15, 2024
1 parent 6542eb2 commit 95c7d56
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/main/java/dev/emi/trinkets/TrinketsMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public void onInitialize() {
}
return TypedActionResult.pass(stack);
});
Registry.register(Registries.DATA_COMPONENT_TYPE, new Identifier(MOD_ID, "attribute_modifiers"), TrinketsAttributeModifiersComponent.TYPE);
Registry.register(Registries.DATA_COMPONENT_TYPE, Identifier.of(MOD_ID, "attribute_modifiers"), TrinketsAttributeModifiersComponent.TYPE);

CommandRegistrationCallback.EVENT.register((dispatcher, registry, env) ->
dispatcher.register(literal("trinkets")
.executes(ctx -> TrinketsFlatUI.open(ctx.getSource().getPlayerOrThrow()))
Expand Down
1 change: 0 additions & 1 deletion src/main/java/dev/emi/trinkets/api/Trinket.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;

import dev.emi.trinkets.mixin.accessor.LivingEntityAccessor;
import java.util.function.Consumer;

import net.minecraft.component.EnchantmentEffectComponentTypes;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/dev/emi/trinkets/api/TrinketsApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public static Optional<TrinketComponent> getTrinketComponent(LivingEntity living
* called in the callback of {@link ItemStack#damage(int, ServerWorld, ServerPlayerEntity, Consumer)}
*/
public static void onTrinketBroken(ItemStack stack, SlotReference ref, LivingEntity entity) {
World world = entity.getWorld();
if (!entity.getWorld().isClient) {
if (entity.getWorld() instanceof ServerWorld world) {
for(int i = 0; i < 5; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/emi/trinkets/data/SlotLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ SlotType create(String group, String name) {
var decode = reader.consume(new StringReader(this.iconItem));
var stack = new ItemStack(decode.item().value());

stack.applyComponentsFrom(decode.components());
stack.applyChanges(decode.components());

iconItem = stack;
} catch (Exception e) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/dev/emi/trinkets/poly/Elements.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

public class Elements {
public static final GuiElementBuilder FILLER = new GuiElementBuilder(Items.WHITE_STAINED_GLASS_PANE).hideTooltip()
.setCustomModelData(GuiModels.getOrCreate(new Identifier(TrinketsMain.MOD_ID, "gui/polybuttons/filler"), Items.WHITE_STAINED_GLASS_PANE).value());
.setCustomModelData(GuiModels.getOrCreate(Identifier.of(TrinketsMain.MOD_ID, "gui/polybuttons/filler"), Items.WHITE_STAINED_GLASS_PANE).value());
public static final GuiElementBuilder FILLER_NAVBAR = new GuiElementBuilder(Items.BLACK_STAINED_GLASS_PANE).hideTooltip();


public static final PolymerModelData PREVIOUS = GuiModels.getOrCreate(new Identifier(TrinketsMain.MOD_ID, "gui/polybuttons/previous"), Items.GREEN_STAINED_GLASS_PANE);
public static final PolymerModelData NEXT = GuiModels.getOrCreate(new Identifier(TrinketsMain.MOD_ID, "gui/polybuttons/next"), Items.GREEN_STAINED_GLASS_PANE);
public static final PolymerModelData SUBPAGE = GuiModels.getOrCreate(new Identifier(TrinketsMain.MOD_ID, "gui/polybuttons/subpage"), Items.LIGHT_BLUE_STAINED_GLASS_PANE);
public static final PolymerModelData PREVIOUS = GuiModels.getOrCreate(Identifier.of(TrinketsMain.MOD_ID, "gui/polybuttons/previous"), Items.GREEN_STAINED_GLASS_PANE);
public static final PolymerModelData NEXT = GuiModels.getOrCreate(Identifier.of(TrinketsMain.MOD_ID, "gui/polybuttons/next"), Items.GREEN_STAINED_GLASS_PANE);
public static final PolymerModelData SUBPAGE = GuiModels.getOrCreate(Identifier.of(TrinketsMain.MOD_ID, "gui/polybuttons/subpage"), Items.LIGHT_BLUE_STAINED_GLASS_PANE);

}
2 changes: 1 addition & 1 deletion src/main/java/dev/emi/trinkets/poly/TrinketsFlatUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public TrinketsFlatUI(ServerPlayerEntity player, boolean compact) {

this.setTitle(PolymerResourcePackUtils.hasMainPack(player)
? Text.empty().append(Text.literal(compact ? "-1." : "-0.")
.setStyle(Style.EMPTY.withColor(Formatting.WHITE).withFont(new Identifier(TrinketsMain.MOD_ID, "gui"))))
.setStyle(Style.EMPTY.withColor(Formatting.WHITE).withFont(Identifier.of(TrinketsMain.MOD_ID, "gui"))))
.append(Text.translatable("trinkets.name"))
: Text.translatable("trinkets.name")
);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/dev/emi/trinkets/poly/TrinketsPoly.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import dev.emi.trinkets.TrinketsMain;
import dev.emi.trinkets.api.TrinketsAttributeModifiersComponent;
import eu.pb4.playerdata.api.PlayerDataApi;
import eu.pb4.polymer.core.api.item.PolymerItemUtils;
import eu.pb4.polymer.core.api.other.PolymerComponent;
import net.minecraft.nbt.NbtByte;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
Expand All @@ -14,11 +14,11 @@

public class TrinketsPoly {
public static final PolyConfig CONFIG = PolyConfig.loadOrCreateConfig();
public static final Identifier COMPACT_SETTING = new Identifier(TrinketsMain.MOD_ID, "compact_ui");
public static final Identifier COMPACT_SETTING = Identifier.of(TrinketsMain.MOD_ID, "compact_ui");

public static void init() {
Elements.FILLER.hashCode();
PolymerItemUtils.markAsPolymer(TrinketsAttributeModifiersComponent.TYPE);
PolymerComponent.registerDataComponent(TrinketsAttributeModifiersComponent.TYPE);
}

public static int toggleCompactCommand(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
Expand Down
2 changes: 1 addition & 1 deletion src/testmod/java/dev/emi/trinkets/TestTrinket.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

public class TestTrinket extends TrinketItem implements PolymerItem {

private static final Identifier TEXTURE = new Identifier(TrinketsTest.MOD_ID, "textures/entity/trinket/hat.png");
private static final Identifier TEXTURE = Identifier.of(TrinketsTest.MOD_ID, "textures/entity/trinket/hat.png");

public TestTrinket(Settings settings) {
super(settings);
Expand Down

0 comments on commit 95c7d56

Please sign in to comment.