Skip to content

Commit b37f5a3

Browse files
committed
Port to 25w10a
1 parent 94035bf commit b37f5a3

17 files changed

Lines changed: 127 additions & 78 deletions

File tree

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G
33

44
# Fabric Properties
55
# check these on https://fabricmc.net/develop
6-
minecraft_version=25w08a
7-
yarn_mappings=25w08a+build.6
6+
minecraft_version=25w10a
7+
yarn_mappings=25w10a+build.9
88
loader_version=0.18.4
99

1010
# Mod Properties
@@ -13,4 +13,4 @@ org.gradle.jvmargs=-Xmx1G
1313
archives_base_name = itematic
1414

1515
# Dependencies
16-
fabric_version=0.118.0+1.21.5
16+
fabric_version=0.118.5+1.21.5

src/client/java/net/errorcraft/itematic/access/client/gui/screen/GameModeSelectionScreenGameModeSelectionAccess.java

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package net.errorcraft.itematic.access.client.gui.screen;
2+
3+
import net.minecraft.item.Item;
4+
import net.minecraft.item.ItemStack;
5+
import net.minecraft.registry.Registry;
6+
import net.minecraft.registry.RegistryKey;
7+
8+
public interface GameModeSwitcherScreenAccess {
9+
interface GameModeSelectionAccess {
10+
default ItemStack itematic$icon(Registry<Item> registry) {
11+
return ItemStack.EMPTY;
12+
}
13+
default void itematic$setIcon(RegistryKey<Item> item) {}
14+
}
15+
}

src/client/java/net/errorcraft/itematic/mixin/client/gui/screen/GameModeSelectionScreenExtender.java renamed to src/client/java/net/errorcraft/itematic/mixin/client/gui/screen/GameModeSwitcherScreenExtender.java

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package net.errorcraft.itematic.mixin.client.gui.screen;
22

33

4-
import net.errorcraft.itematic.access.client.gui.screen.GameModeSelectionScreenGameModeSelectionAccess;
4+
import net.errorcraft.itematic.access.client.gui.screen.GameModeSwitcherScreenAccess;
55
import net.errorcraft.itematic.item.ItemKeys;
66
import net.minecraft.client.MinecraftClient;
77
import net.minecraft.client.gui.DrawContext;
8-
import net.minecraft.client.gui.screen.GameModeSelectionScreen;
8+
import net.minecraft.client.gui.screen.GameModeSwitcherScreen;
99
import net.minecraft.item.Item;
1010
import net.minecraft.item.ItemConvertible;
1111
import net.minecraft.item.ItemStack;
@@ -20,52 +20,53 @@
2020
import org.spongepowered.asm.mixin.injection.At;
2121
import org.spongepowered.asm.mixin.injection.Redirect;
2222

23-
public class GameModeSelectionScreenExtender {
24-
@Mixin(GameModeSelectionScreen.ButtonWidget.class)
23+
public class GameModeSwitcherScreenExtender {
24+
@Mixin(GameModeSwitcherScreen.ButtonWidget.class)
2525
public static class ButtonWidgetExtender {
2626
@Redirect(
2727
method = "renderWidget",
2828
at = @At(
2929
value = "INVOKE",
30-
target = "Lnet/minecraft/client/gui/screen/GameModeSelectionScreen$GameModeSelection;renderIcon(Lnet/minecraft/client/gui/DrawContext;II)V"
30+
target = "Lnet/minecraft/client/gui/screen/GameModeSwitcherScreen$GameModeSelection;renderIcon(Lnet/minecraft/client/gui/DrawContext;II)V"
3131
)
3232
)
33-
private void renderIconUseRegistryEntry(GameModeSelectionScreen.GameModeSelection instance, DrawContext context, int x, int y) {
33+
private void renderIconUseRegistryEntry(GameModeSwitcherScreen.GameModeSelection instance, DrawContext context, int x, int y) {
3434
World world = MinecraftClient.getInstance().world;
3535
if (world == null) {
3636
return;
3737
}
38+
3839
ItemStack stack = instance.itematic$icon(world.getRegistryManager().getOrThrow(RegistryKeys.ITEM));
3940
context.drawItem(stack, x, y);
4041
}
4142
}
4243

43-
@Mixin(GameModeSelectionScreen.GameModeSelection.class)
44-
public static class GameModeSelectionExtender implements GameModeSelectionScreenGameModeSelectionAccess {
45-
@Final
44+
@Mixin(GameModeSwitcherScreen.GameModeSelection.class)
45+
public static class GameModeSelectionExtender implements GameModeSwitcherScreenAccess.GameModeSelectionAccess {
4646
@Shadow
47-
public static GameModeSelectionScreen.GameModeSelection CREATIVE;
48-
4947
@Final
50-
@Shadow
51-
public static GameModeSelectionScreen.GameModeSelection SURVIVAL;
48+
public static GameModeSwitcherScreen.GameModeSelection CREATIVE;
5249

53-
@Final
5450
@Shadow
55-
public static GameModeSelectionScreen.GameModeSelection ADVENTURE;
51+
@Final
52+
public static GameModeSwitcherScreen.GameModeSelection SURVIVAL;
5653

54+
@Shadow
5755
@Final
56+
public static GameModeSwitcherScreen.GameModeSelection ADVENTURE;
57+
5858
@Shadow
59-
public static GameModeSelectionScreen.GameModeSelection SPECTATOR;
59+
@Final
60+
public static GameModeSwitcherScreen.GameModeSelection SPECTATOR;
6061

6162
@Unique
6263
private RegistryKey<Item> icon;
6364

6465
static {
65-
((GameModeSelectionExtender)(Object) CREATIVE).icon = ItemKeys.GRASS_BLOCK;
66-
((GameModeSelectionExtender)(Object) SURVIVAL).icon = ItemKeys.IRON_SWORD;
67-
((GameModeSelectionExtender)(Object) ADVENTURE).icon = ItemKeys.MAP;
68-
((GameModeSelectionExtender)(Object) SPECTATOR).icon = ItemKeys.ENDER_EYE;
66+
CREATIVE.itematic$setIcon(ItemKeys.GRASS_BLOCK);
67+
SURVIVAL.itematic$setIcon(ItemKeys.IRON_SWORD);
68+
ADVENTURE.itematic$setIcon(ItemKeys.MAP);
69+
SPECTATOR.itematic$setIcon(ItemKeys.ENDER_EYE);
6970
}
7071

7172
@Redirect(
@@ -84,9 +85,15 @@ private static ItemStack newItemStackReturnEmptyStack(ItemConvertible item) {
8485
if (this.icon == null) {
8586
return ItemStack.EMPTY;
8687
}
88+
8789
return registry.getOptional(this.icon)
8890
.map(ItemStack::new)
8991
.orElse(ItemStack.EMPTY);
9092
}
93+
94+
@Override
95+
public void itematic$setIcon(RegistryKey<Item> icon) {
96+
this.icon = icon;
97+
}
9198
}
9299
}

src/client/resources/itematic.client.mixins.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"gui.screen.CustomizeFlatLevelScreenExtender",
1313
"gui.screen.CustomizeFlatLevelScreenExtender$SuperflatLayersListWidgetExtender",
1414
"gui.screen.CustomizeFlatLevelScreenExtender$SuperflatLayersListWidgetExtender$SuperflatLayerEntryExtender",
15-
"gui.screen.GameModeSelectionScreenExtender$ButtonWidgetExtender",
16-
"gui.screen.GameModeSelectionScreenExtender$GameModeSelectionExtender",
15+
"gui.screen.GameModeSwitcherScreenExtender$ButtonWidgetExtender",
16+
"gui.screen.GameModeSwitcherScreenExtender$GameModeSelectionExtender",
1717
"gui.screen.StatsScreenAccessor$ItemStatsListWidgetAccessor$EntryAccessor",
1818
"gui.screen.StatsScreenExtender",
1919
"gui.screen.StatsScreenExtender$ItemStatsListWidgetExtender",

src/main/java/net/errorcraft/itematic/item/ItemUtil.java

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
import net.minecraft.predicate.FluidPredicate;
7171
import net.minecraft.predicate.NumberRange;
7272
import net.minecraft.predicate.StatePredicate;
73+
import net.minecraft.predicate.component.ComponentPredicateTypes;
74+
import net.minecraft.predicate.component.ComponentsPredicate;
7375
import net.minecraft.predicate.entity.EntityPredicate;
7476
import net.minecraft.predicate.entity.LocationPredicate;
7577
import net.minecraft.predicate.item.*;
@@ -228,11 +230,15 @@ private void bootstrapConsumables() {
228230
.block(BlockPredicate.Builder.create()
229231
.tag(this.blocks, BlockTags.CONVERTABLE_TO_MUD))
230232
),
231-
MatchToolLootCondition.builder(
232-
ItemPredicate.Builder.create()
233-
.subPredicate(ItemSubPredicateTypes.POTION_CONTENTS, new PotionContentsPredicate(RegistryEntryList.of(
234-
this.potions.getOrThrow(PotionKeys.WATER)
235-
)))
233+
MatchToolLootCondition.builder(ItemPredicate.Builder.create()
234+
.components(ComponentsPredicate.Builder.create()
235+
.partial(
236+
ComponentPredicateTypes.POTION_CONTENTS,
237+
new PotionContentsPredicate(RegistryEntryList.of(
238+
this.potions.getOrThrow(PotionKeys.WATER)
239+
))
240+
).build()
241+
)
236242
)
237243
),
238244
UncheckedSequenceHandler.builder()
@@ -5495,11 +5501,16 @@ private void bootstrapToolsAndWeapons() {
54955501
.itematic$usedItemAtLeast(TridentItem.MIN_DRAW_DURATION)
54965502
.itematic$inWaterOrRain(true)
54975503
),
5498-
MatchToolLootCondition.builder(
5499-
ItemPredicate.Builder.create()
5500-
.subPredicate(ItemSubPredicateTypes.ENCHANTMENTS, EnchantmentsPredicate.enchantments(List.of(
5501-
new EnchantmentPredicate(this.enchantments.getOrThrow(Enchantments.RIPTIDE), NumberRange.IntRange.ANY)
5502-
))))
5504+
MatchToolLootCondition.builder(ItemPredicate.Builder.create()
5505+
.components(ComponentsPredicate.Builder.create()
5506+
.partial(
5507+
ComponentPredicateTypes.ENCHANTMENTS,
5508+
EnchantmentsPredicate.enchantments(List.of(
5509+
new EnchantmentPredicate(this.enchantments.getOrThrow(Enchantments.RIPTIDE), NumberRange.IntRange.ANY)
5510+
))
5511+
).build()
5512+
)
5513+
)
55035514
),
55045515
PassingSequenceHandler.builder()
55055516
.add(TwirlPlayerAction.INSTANCE)
@@ -7372,9 +7383,13 @@ private void bootstrapEquipment() {
73727383
.with(StackableItemComponent.of(1))
73737384
.with(DamageableItemComponent.ofPreserved(432))
73747385
.with(GliderItemComponent.of(ItemPredicate.Builder.create()
7375-
.subPredicate(ItemSubPredicateTypes.DAMAGE, DamagePredicate.durability(
7376-
NumberRange.IntRange.atLeast(2)))
7377-
.build()))
7386+
.components(ComponentsPredicate.Builder.create()
7387+
.partial(
7388+
ComponentPredicateTypes.DAMAGE,
7389+
DamagePredicate.durability(NumberRange.IntRange.atLeast(2))
7390+
).build()
7391+
).build()
7392+
))
73787393
.with(EquipmentItemComponent.of(EquippableComponent.builder(EquipmentSlot.CHEST)
73797394
.swappable(true)
73807395
.equipSound(this.soundEvents.getOrThrow(SoundEventKeys.ARMOR_EQUIP_ELYTRA))
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package net.errorcraft.itematic.mixin.block;
2+
3+
import net.minecraft.block.TntBlock;
4+
import net.minecraft.entity.LivingEntity;
5+
import net.minecraft.util.math.BlockPos;
6+
import net.minecraft.world.World;
7+
import org.jetbrains.annotations.Nullable;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.gen.Invoker;
10+
11+
@Mixin(TntBlock.class)
12+
public interface TntBlockAccessor {
13+
@Invoker("primeTnt")
14+
static boolean primeTnt(World world, BlockPos pos, @Nullable LivingEntity igniter) {
15+
throw new AssertionError();
16+
}
17+
}

src/main/java/net/errorcraft/itematic/mixin/block/TntBlockExtender.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private boolean isOfForFlintAndSteelUseRegistryKeyCheck(ItemStack instance, Item
3636
}
3737

3838
@ModifyExpressionValue(
39-
method = "primeTnt(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/LivingEntity;)V",
39+
method = "primeTnt(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/LivingEntity;)Z",
4040
at = @At(
4141
value = "NEW",
4242
target = "(Lnet/minecraft/world/World;DDDLnet/minecraft/entity/LivingEntity;)Lnet/minecraft/entity/TntEntity;"
@@ -48,7 +48,7 @@ private static TntEntity setBlockState(TntEntity original, World world, BlockPos
4848
}
4949

5050
@Redirect(
51-
method = "primeTnt(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/LivingEntity;)V",
51+
method = "primeTnt(Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/entity/LivingEntity;)Z",
5252
at = @At(
5353
value = "INVOKE",
5454
target = "Lnet/minecraft/world/World;playSound(Lnet/minecraft/entity/Entity;DDDLnet/minecraft/sound/SoundEvent;Lnet/minecraft/sound/SoundCategory;FF)V"

src/main/java/net/errorcraft/itematic/predicate/item/ItemPredicateUtil.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,27 @@
66
import net.minecraft.network.RegistryByteBuf;
77
import net.minecraft.network.codec.PacketCodec;
88
import net.minecraft.network.codec.PacketCodecs;
9-
import net.minecraft.predicate.ComponentPredicate;
109
import net.minecraft.predicate.NumberRange;
10+
import net.minecraft.predicate.component.ComponentsPredicate;
1111
import net.minecraft.predicate.item.ItemPredicate;
12-
import net.minecraft.predicate.item.ItemSubPredicate;
1312
import net.minecraft.registry.RegistryKeys;
1413
import net.minecraft.registry.entry.RegistryEntryList;
1514

16-
import java.util.Map;
1715
import java.util.Optional;
1816

1917
public class ItemPredicateUtil {
2018
public static final PacketCodec<RegistryByteBuf, ItemPredicate> PACKET_CODEC = PacketCodec.tuple(
2119
PacketCodecs.optional(PacketCodecs.registryEntryList(RegistryKeys.ITEM)), ItemPredicate::items,
2220
NumberRangeUtil.INTEGER_RANGE_PACKET_CODEC, ItemPredicate::count,
23-
ComponentPredicate.PACKET_CODEC, ItemPredicate::components,
24-
PacketCodecs.registryCodec(ItemSubPredicate.PREDICATES_MAP_CODEC), ItemPredicate::subPredicates,
21+
ComponentsPredicate.PACKET_CODEC, ItemPredicate::components,
2522
ItemPredicateExtraFields.PACKET_CODEC, itemPredicate -> ((ItemPredicateAccess)(Object) itemPredicate).itematic$extraFields(),
2623
ItemPredicateUtil::create
2724
);
2825

2926
private ItemPredicateUtil() {}
3027

31-
private static ItemPredicate create(Optional<RegistryEntryList<Item>> items, NumberRange.IntRange count, ComponentPredicate components, Map<ItemSubPredicate.Type<?>, ItemSubPredicate> subPredicates, ItemPredicateExtraFields extraFields) {
32-
ItemPredicate predicate = new ItemPredicate(items, count, components, subPredicates);
28+
private static ItemPredicate create(Optional<RegistryEntryList<Item>> items, NumberRange.IntRange count, ComponentsPredicate components, ItemPredicateExtraFields extraFields) {
29+
ItemPredicate predicate = new ItemPredicate(items, count, components);
3330
((ItemPredicateAccess)(Object) predicate).itematic$setExtraFields(extraFields);
3431
return predicate;
3532
}

src/main/java/net/errorcraft/itematic/village/trade/Trade.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import net.minecraft.loot.context.LootContext;
1414
import net.minecraft.loot.function.LootFunction;
1515
import net.minecraft.loot.function.LootFunctionTypes;
16-
import net.minecraft.predicate.ComponentPredicate;
16+
import net.minecraft.predicate.component.ComponentMapPredicate;
1717
import net.minecraft.registry.RegistryEntryLookup;
1818
import net.minecraft.registry.RegistryKeys;
1919
import net.minecraft.registry.entry.RegistryEntry;
@@ -62,7 +62,7 @@ private Input createWantedStacks(LootContext context) {
6262
private TradedItem createGivenStack(Input wants, LootContext context) {
6363
ItemStack gives = this.gives.createStack(context);
6464
return this.tradeModifier.flatMap(tradeModifier -> tradeModifier.apply(wants, gives, context))
65-
.orElseGet(() -> new TradedItem(gives.getRegistryEntry(), gives.getCount(), ComponentPredicate.of(gives.getComponents())));
65+
.orElseGet(() -> new TradedItem(gives.getRegistryEntry(), gives.getCount(), ComponentMapPredicate.of(gives.getComponents())));
6666
}
6767

6868
public static Builder builder(Entry gives) {
@@ -166,7 +166,7 @@ public Optional<TradedItem> getTradedItem(int index) {
166166
}
167167

168168
ItemStack stack = this.stacks.get(index);
169-
return Optional.of(new TradedItem(stack.getRegistryEntry(), stack.getCount(), ComponentPredicate.of(stack.getComponents())));
169+
return Optional.of(new TradedItem(stack.getRegistryEntry(), stack.getCount(), ComponentMapPredicate.of(stack.getComponents())));
170170
}
171171

172172
public ItemStack getStack(int index) {

0 commit comments

Comments
 (0)