From 49fc1ae7ce5ec585791d7dc212700a2cd3d79851 Mon Sep 17 00:00:00 2001 From: "Killar.exe" Date: Tue, 26 Nov 2024 20:36:37 +0100 Subject: [PATCH] Update to 1.21.2 --- .github/workflows/gradle.yml | 2 +- .../killarexe/copper_extension/CEActions.java | 15 +++++++------- .../recipe/exposed_copper.json | 4 +--- .../recipe/exposed_copper_door.json | 4 +--- .../recipe/exposed_copper_trapdoor.json | 4 +--- .../recipe/oxidized_copper.json | 4 +--- .../recipe/oxidized_copper_door.json | 4 +--- .../recipe/oxidized_copper_trapdoor.json | 4 +--- .../recipe/waxed_copper_block.json | 4 +--- .../recipe/waxed_copper_door.json | 4 +--- .../recipe/waxed_copper_ingot.json | 8 ++------ .../recipe/waxed_copper_trapdoor.json | 4 +--- .../recipe/waxed_exposed_copper.json | 4 +--- .../recipe/waxed_exposed_copper_door.json | 4 +--- .../recipe/waxed_exposed_copper_ingot.json | 8 ++------ .../recipe/waxed_exposed_copper_trapdoor.json | 4 +--- .../recipe/waxed_oxidized_copper.json | 4 +--- .../recipe/waxed_oxidized_copper_door.json | 4 +--- .../recipe/waxed_oxidized_copper_ingot.json | 8 ++------ .../waxed_oxidized_copper_trapdoor.json | 4 +--- .../recipe/waxed_weathered_copper.json | 4 +--- .../recipe/waxed_weathered_copper_door.json | 4 +--- .../recipe/waxed_weathered_copper_ingot.json | 8 ++------ .../waxed_weathered_copper_trapdoor.json | 4 +--- .../recipe/weathered_copper.json | 4 +--- .../recipe/weathered_copper_door.json | 4 +--- .../recipe/weathered_copper_trapdoor.json | 4 +--- .../fabric/mixin/ItemEntityMixin.java | 5 +++-- .../fabric/mixin/ItemMixin.java | 11 +++------- .../fabric/registry/CEItems.java | 20 +++++++++++-------- gradle.properties | 12 +++++------ .../neoforge/mixin/ItemEntityMixin.java | 5 +++-- .../neoforge/mixin/ItemMixin.java | 13 +++--------- 33 files changed, 67 insertions(+), 132 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index ab1aa45..31b9fef 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -10,7 +10,7 @@ permissions: contents: read env: - mod_version: 1.4.0 + mod_version: 1.4.2 jobs: build: diff --git a/common/src/main/java/github/killarexe/copper_extension/CEActions.java b/common/src/main/java/github/killarexe/copper_extension/CEActions.java index b3fcfc2..7af26bd 100644 --- a/common/src/main/java/github/killarexe/copper_extension/CEActions.java +++ b/common/src/main/java/github/killarexe/copper_extension/CEActions.java @@ -7,7 +7,6 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; -import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; @@ -41,7 +40,7 @@ private static void scrap(Item scarpItem, ItemStack currentStack, ItemStack othe ItemEntity itemEntity = new ItemEntity(level, serverPlayer.getX(), serverPlayer.getY(), serverPlayer.getZ(), result); level.addFreshEntity(itemEntity); - serverPlayer.getCooldowns().addCooldown(otherStack.getItem(), amount * 8); + serverPlayer.getCooldowns().addCooldown(otherStack, amount * 8); } private static Optional getScrapItem(Item item) { @@ -58,21 +57,21 @@ private static Optional getScrapItem(Item item) { return Optional.empty(); } - public static void scrapUse(Player player, InteractionHand hand, CallbackInfoReturnable> callbackInfo) { + public static void scrapUse(Player player, InteractionHand hand, CallbackInfoReturnable callbackInfo) { ItemStack currentHandStack = player.getItemInHand(hand); ItemStack otherHandStack = player.getOffhandItem(); Optional scrapItem = getScrapItem(currentHandStack.getItem()); if (scrapItem.isPresent() && otherHandStack.is(ItemTags.AXES)) { - if (player instanceof ServerPlayer serverPlayer && !player.getCooldowns().isOnCooldown(otherHandStack.getItem())) { + if (player instanceof ServerPlayer serverPlayer && !player.getCooldowns().isOnCooldown(otherHandStack)) { scrap(scrapItem.get(), currentHandStack, otherHandStack, serverPlayer, serverPlayer.isShiftKeyDown() ? currentHandStack.getCount() : 1); - callbackInfo.setReturnValue(InteractionResultHolder.success(currentHandStack)); + callbackInfo.setReturnValue(InteractionResult.SUCCESS.heldItemTransformedTo(currentHandStack)); } - callbackInfo.setReturnValue(InteractionResultHolder.consume(currentHandStack)); + callbackInfo.setReturnValue(InteractionResult.CONSUME.heldItemTransformedTo(currentHandStack)); } } public static void rustEntityStack( - T nextItem, ItemStack stack, Level level, + T nextItem, ItemStack stack, ServerLevel level, ItemEntity entity, GameRules.Key oxidationGameRule, RandomSource random) { int count = stack.getCount(); @@ -81,7 +80,7 @@ public static void rustEntityStack( ItemEntity newItemEntity = new ItemEntity(level, pos.x, pos.y, pos.z, new ItemStack(nextItem, count)); newItemEntity.copyPosition(entity); level.addFreshEntity(newItemEntity); - entity.kill(); + entity.kill(level); } } diff --git a/common/src/main/resources/data/copper_extension/recipe/exposed_copper.json b/common/src/main/resources/data/copper_extension/recipe/exposed_copper.json index 083deda..8623b61 100644 --- a/common/src/main/resources/data/copper_extension/recipe/exposed_copper.json +++ b/common/src/main/resources/data/copper_extension/recipe/exposed_copper.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "#": { - "item": "copper_extension:exposed_copper_ingot" - } + "#": "copper_extension:exposed_copper_ingot" }, "pattern": [ "###", diff --git a/common/src/main/resources/data/copper_extension/recipe/exposed_copper_door.json b/common/src/main/resources/data/copper_extension/recipe/exposed_copper_door.json index fb99226..1443cb4 100644 --- a/common/src/main/resources/data/copper_extension/recipe/exposed_copper_door.json +++ b/common/src/main/resources/data/copper_extension/recipe/exposed_copper_door.json @@ -7,9 +7,7 @@ "##" ], "key": { - "#": { - "item": "copper_extension:exposed_copper_ingot" - } + "#": "copper_extension:exposed_copper_ingot" }, "result": { "id": "minecraft:exposed_copper_door", diff --git a/common/src/main/resources/data/copper_extension/recipe/exposed_copper_trapdoor.json b/common/src/main/resources/data/copper_extension/recipe/exposed_copper_trapdoor.json index 1eaa74f..027de4a 100644 --- a/common/src/main/resources/data/copper_extension/recipe/exposed_copper_trapdoor.json +++ b/common/src/main/resources/data/copper_extension/recipe/exposed_copper_trapdoor.json @@ -6,9 +6,7 @@ "###" ], "key": { - "#": { - "item": "copper_extension:exposed_copper_ingot" - } + "#": "copper_extension:exposed_copper_ingot" }, "result": { "id": "minecraft:exposed_copper_trapdoor", diff --git a/common/src/main/resources/data/copper_extension/recipe/oxidized_copper.json b/common/src/main/resources/data/copper_extension/recipe/oxidized_copper.json index a54beae..7978fc9 100644 --- a/common/src/main/resources/data/copper_extension/recipe/oxidized_copper.json +++ b/common/src/main/resources/data/copper_extension/recipe/oxidized_copper.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "#": { - "item": "copper_extension:oxidized_copper_ingot" - } + "#": "copper_extension:oxidized_copper_ingot" }, "pattern": [ "###", diff --git a/common/src/main/resources/data/copper_extension/recipe/oxidized_copper_door.json b/common/src/main/resources/data/copper_extension/recipe/oxidized_copper_door.json index 7de1a72..f1a278e 100644 --- a/common/src/main/resources/data/copper_extension/recipe/oxidized_copper_door.json +++ b/common/src/main/resources/data/copper_extension/recipe/oxidized_copper_door.json @@ -7,9 +7,7 @@ "##" ], "key": { - "#": { - "item": "copper_extension:oxidized_copper_ingot" - } + "#": "copper_extension:oxidized_copper_ingot" }, "result": { "id": "minecraft:oxidized_copper_door", diff --git a/common/src/main/resources/data/copper_extension/recipe/oxidized_copper_trapdoor.json b/common/src/main/resources/data/copper_extension/recipe/oxidized_copper_trapdoor.json index 3e80024..ef2234d 100644 --- a/common/src/main/resources/data/copper_extension/recipe/oxidized_copper_trapdoor.json +++ b/common/src/main/resources/data/copper_extension/recipe/oxidized_copper_trapdoor.json @@ -6,9 +6,7 @@ "###" ], "key": { - "#": { - "item": "copper_extension:oxidized_copper_ingot" - } + "#": "copper_extension:oxidized_copper_ingot" }, "result": { "id": "minecraft:oxidized_copper_trapdoor", diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_copper_block.json b/common/src/main/resources/data/copper_extension/recipe/waxed_copper_block.json index 5a52357..7a19e9d 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_copper_block.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_copper_block.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "#": { - "item": "copper_extension:waxed_copper_ingot" - } + "#": "copper_extension:waxed_copper_ingot" }, "pattern": [ "###", diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_copper_door.json b/common/src/main/resources/data/copper_extension/recipe/waxed_copper_door.json index 172e847..5db135e 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_copper_door.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_copper_door.json @@ -7,9 +7,7 @@ "##" ], "key": { - "#": { - "item": "copper_extension:waxed_copper_ingot" - } + "#": "copper_extension:waxed_copper_ingot" }, "result": { "id": "minecraft:waxed_copper_door", diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_copper_ingot.json b/common/src/main/resources/data/copper_extension/recipe/waxed_copper_ingot.json index 2b5154c..3d89bc7 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_copper_ingot.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_copper_ingot.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shapeless", "category": "misc", "ingredients": [ - { - "item": "minecraft:copper_ingot" - }, - { - "item": "minecraft:honeycomb" - } + "minecraft:copper_ingot", + "minecraft:honeycomb" ], "result": { "id": "copper_extension:waxed_copper_ingot" diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_copper_trapdoor.json b/common/src/main/resources/data/copper_extension/recipe/waxed_copper_trapdoor.json index fbc5819..8fcdff2 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_copper_trapdoor.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_copper_trapdoor.json @@ -6,9 +6,7 @@ "###" ], "key": { - "#": { - "item": "copper_extension:waxed_copper_ingot" - } + "#": "copper_extension:waxed_copper_ingot" }, "result": { "id": "minecraft:waxed_copper_trapdoor", diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper.json b/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper.json index 6d6ff1f..8453304 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "#": { - "item": "copper_extension:waxed_exposed_copper_ingot" - } + "#": "copper_extension:waxed_exposed_copper_ingot" }, "pattern": [ "###", diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper_door.json b/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper_door.json index 8df71e0..bbb3dc3 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper_door.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper_door.json @@ -7,9 +7,7 @@ "##" ], "key": { - "#": { - "item": "copper_extension:waxed_exposed_copper_ingot" - } + "#": "copper_extension:waxed_exposed_copper_ingot" }, "result": { "id": "minecraft:waxed_exposed_copper_door", diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper_ingot.json b/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper_ingot.json index 8d77994..9649cfe 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper_ingot.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper_ingot.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shapeless", "category": "misc", "ingredients": [ - { - "item": "copper_extension:exposed_copper_ingot" - }, - { - "item": "minecraft:honeycomb" - } + "copper_extension:exposed_copper_ingot", + "minecraft:honeycomb" ], "result": { "id": "copper_extension:waxed_exposed_copper_ingot" diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper_trapdoor.json b/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper_trapdoor.json index 5bd0f6a..53152be 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper_trapdoor.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_exposed_copper_trapdoor.json @@ -6,9 +6,7 @@ "###" ], "key": { - "#": { - "item": "copper_extension:waxed_exposed_copper_ingot" - } + "#": "copper_extension:waxed_exposed_copper_ingot" }, "result": { "id": "minecraft:waxed_exposed_copper_trapdoor", diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper.json b/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper.json index 9761bd9..c4fc463 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "#": { - "item": "copper_extension:waxed_oxidized_copper_ingot" - } + "#": "copper_extension:waxed_oxidized_copper_ingot" }, "pattern": [ "###", diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper_door.json b/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper_door.json index 107067c..dda19cc 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper_door.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper_door.json @@ -7,9 +7,7 @@ "##" ], "key": { - "#": { - "item": "copper_extension:waxed_oxidized_copper_ingot" - } + "#": "copper_extension:waxed_oxidized_copper_ingot" }, "result": { "id": "minecraft:waxed_oxidized_copper_door", diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper_ingot.json b/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper_ingot.json index 589a5b7..fdbcc42 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper_ingot.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper_ingot.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shapeless", "category": "misc", "ingredients": [ - { - "item": "copper_extension:oxidized_copper_ingot" - }, - { - "item": "minecraft:honeycomb" - } + "copper_extension:oxidized_copper_ingot", + "minecraft:honeycomb" ], "result": { "id": "copper_extension:waxed_oxidized_copper_ingot" diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper_trapdoor.json b/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper_trapdoor.json index 343c4eb..113b054 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper_trapdoor.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_oxidized_copper_trapdoor.json @@ -6,9 +6,7 @@ "###" ], "key": { - "#": { - "item": "copper_extension:waxed_oxidized_copper_ingot" - } + "#": "copper_extension:waxed_oxidized_copper_ingot" }, "result": { "id": "minecraft:waxed_oxidized_copper_trapdoor", diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper.json b/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper.json index a9cef3d..bd69500 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "#": { - "item": "copper_extension:waxed_weathered_copper_ingot" - } + "#": "copper_extension:waxed_weathered_copper_ingot" }, "pattern": [ "###", diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper_door.json b/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper_door.json index 59e1dcb..ebd1064 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper_door.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper_door.json @@ -7,9 +7,7 @@ "##" ], "key": { - "#": { - "item": "copper_extension:waxed_weathered_copper_ingot" - } + "#": "copper_extension:waxed_weathered_copper_ingot" }, "result": { "id": "minecraft:waxed_weathered_copper_door", diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper_ingot.json b/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper_ingot.json index fa2a50d..374f069 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper_ingot.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper_ingot.json @@ -2,12 +2,8 @@ "type": "minecraft:crafting_shapeless", "category": "misc", "ingredients": [ - { - "item": "copper_extension:weathered_copper_ingot" - }, - { - "item": "minecraft:honeycomb" - } + "copper_extension:weathered_copper_ingot", + "minecraft:honeycomb" ], "result": { "id": "copper_extension:waxed_weathered_copper_ingot" diff --git a/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper_trapdoor.json b/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper_trapdoor.json index 2b9e827..72ea705 100644 --- a/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper_trapdoor.json +++ b/common/src/main/resources/data/copper_extension/recipe/waxed_weathered_copper_trapdoor.json @@ -6,9 +6,7 @@ "###" ], "key": { - "#": { - "item": "copper_extension:waxed_weathered_copper_ingot" - } + "#": "copper_extension:waxed_weathered_copper_ingot" }, "result": { "id": "minecraft:waxed_weathered_copper_trapdoor", diff --git a/common/src/main/resources/data/copper_extension/recipe/weathered_copper.json b/common/src/main/resources/data/copper_extension/recipe/weathered_copper.json index 6c4fac0..2126610 100644 --- a/common/src/main/resources/data/copper_extension/recipe/weathered_copper.json +++ b/common/src/main/resources/data/copper_extension/recipe/weathered_copper.json @@ -2,9 +2,7 @@ "type": "minecraft:crafting_shaped", "category": "building", "key": { - "#": { - "item": "copper_extension:weathered_copper_ingot" - } + "#": "copper_extension:weathered_copper_ingot" }, "pattern": [ "###", diff --git a/common/src/main/resources/data/copper_extension/recipe/weathered_copper_door.json b/common/src/main/resources/data/copper_extension/recipe/weathered_copper_door.json index 52a6a57..288f2c7 100644 --- a/common/src/main/resources/data/copper_extension/recipe/weathered_copper_door.json +++ b/common/src/main/resources/data/copper_extension/recipe/weathered_copper_door.json @@ -7,9 +7,7 @@ "##" ], "key": { - "#": { - "item": "copper_extension:weathered_copper_ingot" - } + "#": "copper_extension:weathered_copper_ingot" }, "result": { "id": "minecraft:weathered_copper_door", diff --git a/common/src/main/resources/data/copper_extension/recipe/weathered_copper_trapdoor.json b/common/src/main/resources/data/copper_extension/recipe/weathered_copper_trapdoor.json index 93f8dfa..0a6452a 100644 --- a/common/src/main/resources/data/copper_extension/recipe/weathered_copper_trapdoor.json +++ b/common/src/main/resources/data/copper_extension/recipe/weathered_copper_trapdoor.json @@ -6,9 +6,7 @@ "###" ], "key": { - "#": { - "item": "copper_extension:weathered_copper_ingot" - } + "#": "copper_extension:weathered_copper_ingot" }, "result": { "id": "minecraft:weathered_copper_trapdoor", diff --git a/fabric/src/main/java/github/killarexe/copper_extension/fabric/mixin/ItemEntityMixin.java b/fabric/src/main/java/github/killarexe/copper_extension/fabric/mixin/ItemEntityMixin.java index 661c49a..7248ade 100644 --- a/fabric/src/main/java/github/killarexe/copper_extension/fabric/mixin/ItemEntityMixin.java +++ b/fabric/src/main/java/github/killarexe/copper_extension/fabric/mixin/ItemEntityMixin.java @@ -3,6 +3,7 @@ import github.killarexe.copper_extension.CEActions; import github.killarexe.copper_extension.CEMaps; import github.killarexe.copper_extension.fabric.registry.CEGameRules; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.Item; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -28,8 +29,8 @@ public void tick(CallbackInfo callbackInfo) { ItemEntity itemEntity = ItemEntity.class.cast(this); ItemStack stack = itemEntity.getItem(); Item nextItem = CEMaps.OXIDATION_MAP_ITEMS.get(stack.getItem()); - if (nextItem != null) { - CEActions.rustEntityStack(nextItem, stack, level(), itemEntity, CEGameRules.COPPER_OXIDATION_CHANCE, random); + if (nextItem != null && level() instanceof ServerLevel level) { + CEActions.rustEntityStack(nextItem, stack, level, itemEntity, CEGameRules.COPPER_OXIDATION_CHANCE, random); } } } diff --git a/fabric/src/main/java/github/killarexe/copper_extension/fabric/mixin/ItemMixin.java b/fabric/src/main/java/github/killarexe/copper_extension/fabric/mixin/ItemMixin.java index 0c3f669..2e72652 100644 --- a/fabric/src/main/java/github/killarexe/copper_extension/fabric/mixin/ItemMixin.java +++ b/fabric/src/main/java/github/killarexe/copper_extension/fabric/mixin/ItemMixin.java @@ -4,11 +4,7 @@ import github.killarexe.copper_extension.CEMaps; import github.killarexe.copper_extension.fabric.registry.CEGameRules; import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.tags.ItemTags; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.item.ItemEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -16,7 +12,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import net.fabricmc.fabric.api.item.v1.FabricItem; -import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; @@ -33,16 +28,16 @@ public abstract class ItemMixin implements FeatureElement, ItemLike, FabricItem @Inject(method = "inventoryTick(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;IZ)V", at = @At("HEAD")) public void inventoryTick(ItemStack stack, Level level, Entity entity, int slot, boolean selected, CallbackInfo callbackInfo) { Item item = stack.getItem(); - if(entity instanceof Player player && CEMaps.OXIDATION_MAP_ITEMS.containsKey(item)) { + if(level instanceof ServerLevel serverLevel && entity instanceof Player player && CEMaps.OXIDATION_MAP_ITEMS.containsKey(item)) { int count = stack.getCount(); - if(player.getRandom().nextFloat() < level.getGameRules().getInt(CEGameRules.COPPER_OXIDATION_CHANCE) * CEActions.BASE_CHANCE / count) { + if(player.getRandom().nextFloat() < serverLevel.getGameRules().getInt(CEGameRules.COPPER_OXIDATION_CHANCE) * CEActions.BASE_CHANCE / count) { player.getInventory().setItem(slot, new ItemStack(CEMaps.OXIDATION_MAP_ITEMS.get(item), count)); } } } @Inject(method = "use", at = @At("HEAD"), cancellable = true) - public void use(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable> callbackInfo) { + public void use(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable callbackInfo) { CEActions.scrapUse(player, interactionHand, callbackInfo); } diff --git a/fabric/src/main/java/github/killarexe/copper_extension/fabric/registry/CEItems.java b/fabric/src/main/java/github/killarexe/copper_extension/fabric/registry/CEItems.java index 710385f..3143ac4 100644 --- a/fabric/src/main/java/github/killarexe/copper_extension/fabric/registry/CEItems.java +++ b/fabric/src/main/java/github/killarexe/copper_extension/fabric/registry/CEItems.java @@ -7,6 +7,8 @@ import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; import net.minecraft.core.Registry; import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.item.CreativeModeTabs; import net.minecraft.world.item.Item; import net.minecraft.world.item.Items; @@ -14,19 +16,19 @@ public class CEItems { private static final HashMap ITEMS = new HashMap(); - public static final Item WAXED_COPPER_INGOT = createItem("waxed_copper_ingot", new Item(new Item.Properties())); + public static final Item WAXED_COPPER_INGOT = createItem("waxed_copper_ingot", new Item.Properties()); - public static final Item WAXED_EXPOSED_COPPER_INGOT = createItem("waxed_exposed_copper_ingot", new Item(new Item.Properties())); + public static final Item WAXED_EXPOSED_COPPER_INGOT = createItem("waxed_exposed_copper_ingot", new Item.Properties()); - public static final Item WAXED_WEATHERED_COPPER_INGOT = createItem("waxed_weathered_copper_ingot", new Item(new Item.Properties())); + public static final Item WAXED_WEATHERED_COPPER_INGOT = createItem("waxed_weathered_copper_ingot", new Item.Properties()); - public static final Item WAXED_OXIDIZED_COPPER_INGOT = createItem("waxed_oxidized_copper_ingot", new Item(new Item.Properties())); + public static final Item WAXED_OXIDIZED_COPPER_INGOT = createItem("waxed_oxidized_copper_ingot", new Item.Properties()); - public static final Item EXPOSED_COPPER_INGOT = createItem("exposed_copper_ingot", new Item(new Item.Properties())); + public static final Item EXPOSED_COPPER_INGOT = createItem("exposed_copper_ingot", new Item.Properties()); - public static final Item WEATHERED_COPPER_INGOT = createItem("weathered_copper_ingot", new Item(new Item.Properties())); + public static final Item WEATHERED_COPPER_INGOT = createItem("weathered_copper_ingot", new Item.Properties()); - public static final Item OXIDIZED_COPPER_INGOT = createItem("oxidized_copper_ingot", new Item(new Item.Properties())); + public static final Item OXIDIZED_COPPER_INGOT = createItem("oxidized_copper_ingot", new Item.Properties()); public static void register() { ITEMS.forEach((id, item) -> { @@ -46,7 +48,9 @@ public static void register() { CEMaps.WAXING_MAP_ITEMS.put(OXIDIZED_COPPER_INGOT, WAXED_OXIDIZED_COPPER_INGOT); } - private static T createItem(String id, T item) { + private static Item createItem(String id, Item.Properties properties) { + ResourceKey itemId = ResourceKey.create(Registries.ITEM, CEMod.id(id)); + Item item = new Item(properties.setId(itemId)); ITEMS.put(id, item); return item; } diff --git a/gradle.properties b/gradle.properties index 43e2913..512f4c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,12 +4,12 @@ org.gradle.parallel=true org.gradle.deamon=false #Common settings -minecraft_version=1.21 +minecraft_version=1.21.2 enabled_platforms=fabric,neoforge mod_id=copper_extension mod_name=Copper Extension -mod_version=1.4.1 +mod_version=1.4.2 mod_contributors=junshengxie mod_license=CC-BY-4.0 @@ -23,13 +23,13 @@ maven_group=github.killarexe.copper_extension #Fabric settings fabric_loader_version=0.16.9 -fabric_api_version=0.102.0+1.21 +fabric_api_version=0.106.0+1.21.2 fabric_mod_sources=https://github.com/Killarexe/Copper-Extension fabric_mod_main=github.killarexe.copper_extension.fabric.CEFabric #Forge settings -neoforge_version=21.0.0-beta -neoforge_minecraft_version_range=[1.21,1.22) -neoforge_version_range=[21.0.0-beta,) +neoforge_version=21.2.0-beta +neoforge_minecraft_version_range=[1.21.2,1.22) +neoforge_version_range=[21.2.0-beta,) neoforge_loader_version_range=[4,) neoforge_update_json_url=https://raw.githubusercontent.com/Killarexe/Copper-Extension/master/neoforge/update.json diff --git a/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/mixin/ItemEntityMixin.java b/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/mixin/ItemEntityMixin.java index e6ed338..f05012a 100644 --- a/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/mixin/ItemEntityMixin.java +++ b/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/mixin/ItemEntityMixin.java @@ -3,6 +3,7 @@ import github.killarexe.copper_extension.CEActions; import github.killarexe.copper_extension.CEMaps; import github.killarexe.copper_extension.neoforge.registry.CEGameRules; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.TraceableEntity; import net.minecraft.world.item.Item; import org.spongepowered.asm.mixin.Mixin; @@ -28,8 +29,8 @@ public void tick(CallbackInfo callbackInfo) { ItemEntity itemEntity = ItemEntity.class.cast(this); ItemStack stack = itemEntity.getItem(); Item nextItem = CEMaps.OXIDATION_MAP_ITEMS.get(stack.getItem()); - if (nextItem != null) { - CEActions.rustEntityStack(nextItem, stack, level(), itemEntity, CEGameRules.COPPER_OXIDATION_CHANCE, random); + if (nextItem != null && level() instanceof ServerLevel serverLevel) { + CEActions.rustEntityStack(nextItem, stack, serverLevel, itemEntity, CEGameRules.COPPER_OXIDATION_CHANCE, random); } } } diff --git a/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/mixin/ItemMixin.java b/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/mixin/ItemMixin.java index bcd15fe..78618a3 100644 --- a/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/mixin/ItemMixin.java +++ b/neoforge/src/main/java/github/killarexe/copper_extension/neoforge/mixin/ItemMixin.java @@ -4,21 +4,14 @@ import github.killarexe.copper_extension.CEMaps; import github.killarexe.copper_extension.neoforge.registry.CEGameRules; import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.tags.ItemTags; import net.minecraft.world.InteractionHand; -import net.minecraft.world.InteractionResultHolder; -import net.minecraft.world.entity.item.ItemEntity; import net.neoforged.neoforge.common.extensions.IItemExtension; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.core.BlockPos; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; @@ -35,16 +28,16 @@ public abstract class ItemMixin implements FeatureElement, ItemLike, IItemExtens @Inject(method = "inventoryTick(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/Entity;IZ)V", at = @At("HEAD")) public void inventoryTick(ItemStack stack, Level level, Entity entity, int slot, boolean selected, CallbackInfo callbackInfo) { Item item = stack.getItem(); - if(entity instanceof Player player && CEMaps.OXIDATION_MAP_ITEMS.containsKey(item)) { + if(level instanceof ServerLevel serverLevel && entity instanceof Player player && CEMaps.OXIDATION_MAP_ITEMS.containsKey(item)) { int count = stack.getCount(); - if(player.getRandom().nextFloat() < level.getGameRules().getInt(CEGameRules.COPPER_OXIDATION_CHANCE) * CEActions.BASE_CHANCE / count) { + if(player.getRandom().nextFloat() < serverLevel.getGameRules().getInt(CEGameRules.COPPER_OXIDATION_CHANCE) * CEActions.BASE_CHANCE / count) { player.getInventory().setItem(slot, new ItemStack(CEMaps.OXIDATION_MAP_ITEMS.get(item), count)); } } } @Inject(method = "use", at = @At("HEAD"), cancellable = true) - public void use(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable> callbackInfo) { + public void use(Level level, Player player, InteractionHand interactionHand, CallbackInfoReturnable callbackInfo) { CEActions.scrapUse(player, interactionHand, callbackInfo); }