From 01349755f2535884311405f89d6d0c4cecc5e549 Mon Sep 17 00:00:00 2001 From: BrokenK3yboard <63761658+BrokenK3yboard@users.noreply.github.com> Date: Tue, 1 Oct 2024 03:06:16 -0500 Subject: [PATCH] More 1.21 port fixes 78 -> 38 compile errors --- .../modifier/FishyBusinessModifier.java | 11 +--- .../zeta/block/ext/IZetaBlockExtensions.java | 5 +- .../violetmoon/zeta/event/play/ZBonemeal.java | 16 +++-- .../play/entity/player/ZRightClickBlock.java | 5 +- .../zeta/item/ext/IZetaItemExtensions.java | 42 ++++++------- .../zeta/item/ext/ItemExtensionFactory.java | 8 +-- .../mixins/InvokerIItemStackExtension.java | 13 ---- .../block/IForgeBlockBlockExtensions.java | 5 +- .../event/play/ForgeZBonemeal.java | 34 ++++++++-- .../entity/player/ForgeZRightClickBlock.java | 20 +++--- .../item/IForgeItemItemExtensions.java | 54 ++++------------ .../mixins/self/IZetaBlockMixin_FAKE.java | 5 +- .../mixins/self/IZetaItemMixin_FAKE.java | 62 +++++++------------ .../ForgeCraftingExtensionsRegistry.java | 11 ++-- .../registry/ForgeZetaRegistry.java | 7 +-- src/main/resources/zeta.mixins.json | 1 - 16 files changed, 133 insertions(+), 166 deletions(-) delete mode 100644 src/main/java/org/violetmoon/zeta/mixin/mixins/InvokerIItemStackExtension.java diff --git a/src/main/java/org/violetmoon/zeta/advancement/modifier/FishyBusinessModifier.java b/src/main/java/org/violetmoon/zeta/advancement/modifier/FishyBusinessModifier.java index 16ae53c..1170bfd 100644 --- a/src/main/java/org/violetmoon/zeta/advancement/modifier/FishyBusinessModifier.java +++ b/src/main/java/org/violetmoon/zeta/advancement/modifier/FishyBusinessModifier.java @@ -37,16 +37,11 @@ public Set getTargets() { @Override public boolean apply(ResourceLocation res, IMutableAdvancement adv) { - ItemLike[] array = fishes.toArray(ItemLike[]::new); - Criterion criterion = FishingRodHookedTrigger. - TriggerInstance.fishedItem( - Optional.empty(), Optional.empty(), Optional.of(ItemPredicate.Builder.item().of(array).build())); - + Criterion criterion = FishingRodHookedTrigger.TriggerInstance.fishedItem( + Optional.empty(), Optional.empty(), Optional.of(ItemPredicate.Builder.item().of(array).build())); String name = BuiltInRegistries.ITEM.getKey(array[0].asItem()).toString(); adv.addOrCriterion(name, criterion); - return true; } - -} +} \ No newline at end of file diff --git a/src/main/java/org/violetmoon/zeta/block/ext/IZetaBlockExtensions.java b/src/main/java/org/violetmoon/zeta/block/ext/IZetaBlockExtensions.java index 9da0395..a13c46f 100644 --- a/src/main/java/org/violetmoon/zeta/block/ext/IZetaBlockExtensions.java +++ b/src/main/java/org/violetmoon/zeta/block/ext/IZetaBlockExtensions.java @@ -14,6 +14,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; import net.neoforged.neoforge.common.ItemAbility; +import net.neoforged.neoforge.common.util.TriState; import org.jetbrains.annotations.Nullable; import java.util.Optional; @@ -38,8 +39,8 @@ default boolean makesOpenTrapdoorAboveClimbableZeta(BlockState state, LevelReade return state.getBlock() instanceof LadderBlock && state.getValue(LadderBlock.FACING) == trapdoorState.getValue(TrapDoorBlock.FACING); } - default boolean canSustainPlantZeta(BlockState state, BlockGetter level, BlockPos pos, Direction facing, String plantabletype) { - return false; + default TriState canSustainPlantZeta(BlockState state, BlockGetter level, BlockPos soilPosition, Direction facing, BlockState plant) { + return TriState.DEFAULT; } default boolean isConduitFrameZeta(BlockState state, LevelReader level, BlockPos pos, BlockPos conduit) { diff --git a/src/main/java/org/violetmoon/zeta/event/play/ZBonemeal.java b/src/main/java/org/violetmoon/zeta/event/play/ZBonemeal.java index 464bce7..586e8fe 100644 --- a/src/main/java/org/violetmoon/zeta/event/play/ZBonemeal.java +++ b/src/main/java/org/violetmoon/zeta/event/play/ZBonemeal.java @@ -1,16 +1,24 @@ package org.violetmoon.zeta.event.play; -import org.violetmoon.zeta.event.bus.IZetaPlayEvent; -import org.violetmoon.zeta.event.bus.Resultable; - import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; +import org.violetmoon.zeta.event.bus.Cancellable; +import org.violetmoon.zeta.event.bus.IZetaPlayEvent; + +import javax.annotation.Nullable; + +public interface ZBonemeal extends IZetaPlayEvent, Cancellable { -public interface ZBonemeal extends IZetaPlayEvent, Resultable { + @Nullable Player getPlayer(); Level getLevel(); BlockPos getPos(); BlockState getBlock(); ItemStack getStack(); + boolean isValidBonemealTarget(); + void setSuccessful(boolean success); + boolean isSuccessful(); + void setCanceled(boolean canceled); } diff --git a/src/main/java/org/violetmoon/zeta/event/play/entity/player/ZRightClickBlock.java b/src/main/java/org/violetmoon/zeta/event/play/entity/player/ZRightClickBlock.java index 1cae111..948ea0c 100644 --- a/src/main/java/org/violetmoon/zeta/event/play/entity/player/ZRightClickBlock.java +++ b/src/main/java/org/violetmoon/zeta/event/play/entity/player/ZRightClickBlock.java @@ -15,16 +15,15 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; -public interface ZRightClickBlock extends IZetaPlayEvent, Cancellable, Resultable, PlayerGetter { +public interface ZRightClickBlock extends IZetaPlayEvent, Cancellable, PlayerGetter { Level getLevel(); BlockPos getPos(); InteractionHand getHand(); ItemStack getItemStack(); BlockHitResult getHitVec(); Direction getFace(); - TriState getUseBlock(); - + InteractionResult getCancellationResult(); void setCancellationResult(InteractionResult result); interface Low extends IZetaPlayEvent, ZRightClickBlock { } diff --git a/src/main/java/org/violetmoon/zeta/item/ext/IZetaItemExtensions.java b/src/main/java/org/violetmoon/zeta/item/ext/IZetaItemExtensions.java index 123d554..13d4009 100644 --- a/src/main/java/org/violetmoon/zeta/item/ext/IZetaItemExtensions.java +++ b/src/main/java/org/violetmoon/zeta/item/ext/IZetaItemExtensions.java @@ -13,50 +13,55 @@ import net.minecraft.world.item.context.UseOnContext; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraft.world.item.enchantment.EnchantmentHelper; import net.minecraft.world.item.enchantment.ItemEnchantments; import net.minecraft.world.level.LevelReader; -import org.jetbrains.annotations.NotNull; +import net.neoforged.neoforge.registries.datamaps.builtin.FurnaceFuel; +import net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps; import org.jetbrains.annotations.Nullable; import java.util.function.Consumer; public interface IZetaItemExtensions { - default InteractionResult onItemUseFirstZeta(UseOnContext context) { + private Item self() { + return (Item)this; + } + + default InteractionResult onItemUseFirstZeta(ItemStack stack, UseOnContext context) { return InteractionResult.PASS; } - default boolean isRepairableZeta() { + default boolean isRepairableZeta(ItemStack stack) { return false; } - default boolean onEntityItemUpdateZeta(ItemEntity entity) { + default boolean onEntityItemUpdateZeta(ItemStack stack, ItemEntity entity) { return false; } - default boolean doesSneakBypassUseZeta(LevelReader level, BlockPos pos, Player player) { + default boolean doesSneakBypassUseZeta(ItemStack stack, LevelReader level, BlockPos pos, Player player) { return false; } - default boolean canEquipZeta(EquipmentSlot armorType, LivingEntity entity) { + default boolean canEquipZeta(ItemStack stack, EquipmentSlot armorType, LivingEntity entity) { return false; } - default boolean isBookEnchantableZeta(ItemStack book) { + default boolean isBookEnchantableZeta(ItemStack stack, ItemStack book) { return true; } - default int getEnchantmentValueZeta() { - return stack.getEnchantmentValue(); + default int getEnchantmentValueZeta(ItemStack stack) { + return this.self().getEnchantmentValue(); } default boolean canShearZeta(ItemStack stack) { //canPerformAction return stack.getItem() instanceof ShearsItem; } - default int getEnchantmentLevelZeta(Holder enchantment) { - return EnchantmentHelper.getTagEnchantmentLevel(enchantment, stack); + default int getEnchantmentLevelZeta(ItemStack stack, Holder enchantment) { + ItemEnchantments itemenchantments = stack.getTagEnchantments(); + return itemenchantments.getLevel(enchantment); } default ItemEnchantments getAllEnchantmentsZeta(ItemStack stack, HolderLookup.RegistryLookup lookup) { @@ -67,10 +72,10 @@ default boolean shouldCauseReequipAnimationZeta(ItemStack oldStack, ItemStack ne return !oldStack.equals(newStack); } - //TODO: initCapabilities - + // IItemExtension#getBurnTime is annotated as OverrideOnly for some reason, hardcode to be safe for now default int getBurnTimeZeta(ItemStack stack, @Nullable RecipeType recipeType) { - return 0; + FurnaceFuel furnaceFuel = this.self().builtInRegistryHolder().getData(NeoForgeDataMaps.FURNACE_FUELS); + return furnaceFuel == null ? 0 : furnaceFuel.burnTime(); } default int damageItemZeta(ItemStack stack, int amount, T entity, Consumer onBroken) { @@ -82,11 +87,6 @@ default boolean isEnderMaskZeta(ItemStack stack, Player player, EnderMan enderbo } default boolean canElytraFlyZeta(ItemStack stack, LivingEntity entity) { - //forge has a funky little extension for this return stack.getItem() instanceof ElytraItem && ElytraItem.isFlyEnabled(stack); } - - default int getDefaultTooltipHideFlagsZeta(@NotNull ItemStack stack) { - return 0; - } -} +} \ No newline at end of file diff --git a/src/main/java/org/violetmoon/zeta/item/ext/ItemExtensionFactory.java b/src/main/java/org/violetmoon/zeta/item/ext/ItemExtensionFactory.java index 046692a..1ae5ab4 100644 --- a/src/main/java/org/violetmoon/zeta/item/ext/ItemExtensionFactory.java +++ b/src/main/java/org/violetmoon/zeta/item/ext/ItemExtensionFactory.java @@ -7,10 +7,6 @@ public interface ItemExtensionFactory { IZetaItemExtensions getInternal(ItemStack stack); default IZetaItemExtensions get(ItemStack stack) { - if(stack.getItem() instanceof IZetaItemExtensions ext) - return ext; - else - return getInternal(stack); + return stack.getItem() instanceof IZetaItemExtensions ext ? ext : getInternal(stack); } - -} +} \ No newline at end of file diff --git a/src/main/java/org/violetmoon/zeta/mixin/mixins/InvokerIItemStackExtension.java b/src/main/java/org/violetmoon/zeta/mixin/mixins/InvokerIItemStackExtension.java deleted file mode 100644 index 808698b..0000000 --- a/src/main/java/org/violetmoon/zeta/mixin/mixins/InvokerIItemStackExtension.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.violetmoon.zeta.mixin.mixins; - -import net.minecraft.world.item.ItemStack; -import net.neoforged.neoforge.common.extensions.IItemStackExtension; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -@Mixin(IItemStackExtension.class) -public interface InvokerIItemStackExtension { - - @Invoker("self") - ItemStack zeta$getSelf(); -} diff --git a/src/main/java/org/violetmoon/zetaimplforge/block/IForgeBlockBlockExtensions.java b/src/main/java/org/violetmoon/zetaimplforge/block/IForgeBlockBlockExtensions.java index b3967fc..8e77a6d 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/block/IForgeBlockBlockExtensions.java +++ b/src/main/java/org/violetmoon/zetaimplforge/block/IForgeBlockBlockExtensions.java @@ -12,6 +12,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; import net.neoforged.neoforge.common.ItemAbility; +import net.neoforged.neoforge.common.util.TriState; import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.block.ext.IZetaBlockExtensions; @@ -37,8 +38,8 @@ public boolean makesOpenTrapdoorAboveClimbableZeta(BlockState state, LevelReader } @Override - public boolean canSustainPlantZeta(BlockState state, BlockGetter level, BlockPos pos, Direction facing, String plantabletype) { - return false; //TODO thread the IPlantable through + public TriState canSustainPlantZeta(BlockState state, BlockGetter level, BlockPos soilPosition, Direction facing, BlockState plant) { + return TriState.DEFAULT; } @Override diff --git a/src/main/java/org/violetmoon/zetaimplforge/event/play/ForgeZBonemeal.java b/src/main/java/org/violetmoon/zetaimplforge/event/play/ForgeZBonemeal.java index 2dd06ff..0bef5c9 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/event/play/ForgeZBonemeal.java +++ b/src/main/java/org/violetmoon/zetaimplforge/event/play/ForgeZBonemeal.java @@ -1,21 +1,28 @@ package org.violetmoon.zetaimplforge.event.play; import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.neoforged.neoforge.event.entity.player.BonemealEvent; -import org.violetmoon.zeta.event.bus.ZResult; +import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.event.play.ZBonemeal; -import org.violetmoon.zetaimplforge.ForgeZeta; public class ForgeZBonemeal implements ZBonemeal { + private final BonemealEvent e; public ForgeZBonemeal(BonemealEvent e) { this.e = e; } + @Nullable + @Override + public Player getPlayer() { + return e.getPlayer(); + } + @Override public Level getLevel() { return e.getLevel(); @@ -37,12 +44,27 @@ public ItemStack getStack() { } @Override - public boolean getResult() { + public boolean isValidBonemealTarget() { + return e.isValidBonemealTarget(); + } + + @Override + public void setSuccessful(boolean success) { + e.setSuccessful(success); + } + + @Override + public boolean isSuccessful() { return e.isSuccessful(); } @Override - public void setResult(ZResult value) { - e.setResult(ForgeZeta.to(value)); + public boolean isCanceled() { + return e.isCanceled(); + } + + @Override + public void setCanceled(boolean cancel) { + e.setCanceled(cancel); } -} +} \ No newline at end of file diff --git a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/player/ForgeZRightClickBlock.java b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/player/ForgeZRightClickBlock.java index ca6cb85..509a2fd 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/player/ForgeZRightClickBlock.java +++ b/src/main/java/org/violetmoon/zetaimplforge/event/play/entity/player/ForgeZRightClickBlock.java @@ -15,6 +15,7 @@ import org.violetmoon.zetaimplforge.ForgeZeta; public class ForgeZRightClickBlock implements ZRightClickBlock { + private final PlayerInteractEvent.RightClickBlock e; public ForgeZRightClickBlock(PlayerInteractEvent.RightClickBlock e) { @@ -61,29 +62,28 @@ public TriState getUseBlock() { return e.getUseBlock(); } - @Override - public void setCancellationResult(InteractionResult result) { - e.setCancellationResult(result); - } - @Override public boolean isCanceled() { return e.isCanceled(); } @Override - public void setCanceled(boolean cancel) { - e.setCanceled(cancel); + public void setCanceled(boolean canceled) { + e.setCanceled(canceled); + if (canceled) { + e.setUseBlock(TriState.FALSE); + e.setUseItem(TriState.FALSE); + } } @Override - public InteractionResult getResult() { + public InteractionResult getCancellationResult() { return e.getCancellationResult(); } @Override - public void setResult(ZResult value) { - e.setResult(ForgeZeta.to(value)); + public void setCancellationResult(InteractionResult result) { + e.setCancellationResult(result); } public static class Low extends ForgeZRightClickBlock implements ZRightClickBlock.Low { diff --git a/src/main/java/org/violetmoon/zetaimplforge/item/IForgeItemItemExtensions.java b/src/main/java/org/violetmoon/zetaimplforge/item/IForgeItemItemExtensions.java index fdc6fdb..bc61353 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/item/IForgeItemItemExtensions.java +++ b/src/main/java/org/violetmoon/zetaimplforge/item/IForgeItemItemExtensions.java @@ -2,8 +2,8 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; +import net.minecraft.core.HolderLookup; import net.minecraft.world.InteractionResult; -import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.item.ItemEntity; @@ -12,19 +12,16 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.context.UseOnContext; -import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.item.enchantment.Enchantment; +import net.minecraft.world.item.enchantment.ItemEnchantments; import net.minecraft.world.level.LevelReader; import net.neoforged.neoforge.common.ItemAbilities; -import net.neoforged.neoforge.event.EventHooks; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import org.violetmoon.zeta.item.ext.IZetaItemExtensions; -import java.util.Map; import java.util.function.Consumer; public class IForgeItemItemExtensions implements IZetaItemExtensions { + public static final IForgeItemItemExtensions INSTANCE = new IForgeItemItemExtensions(); @Override @@ -38,8 +35,8 @@ public boolean isRepairableZeta(ItemStack stack) { } @Override - public boolean onEntityItemUpdateZeta(ItemStack stack, ItemEntity ent) { - return stack.onEntityItemUpdate(ent); + public boolean onEntityItemUpdateZeta(ItemStack stack, ItemEntity entity) { + return stack.onEntityItemUpdate(entity); } @Override @@ -48,8 +45,8 @@ public boolean doesSneakBypassUseZeta(ItemStack stack, LevelReader level, BlockP } @Override - public boolean canEquipZeta(ItemStack stack, EquipmentSlot armorType, LivingEntity ent) { - return stack.canEquip(armorType, ent); + public boolean canEquipZeta(ItemStack stack, EquipmentSlot armorType, LivingEntity entity) { + return stack.canEquip(armorType, entity); } @Override @@ -57,39 +54,24 @@ public boolean isBookEnchantableZeta(ItemStack stack, ItemStack book) { return stack.isBookEnchantable(book); } - @Override - public @Nullable String getArmorTextureZeta(ItemStack stack, Entity entity, EquipmentSlot slot, String type) { - return stack.getItem().getArmorTexture(stack, entity, slot, type); - } - - @Override - public int getMaxDamageZeta(ItemStack stack) { - return stack.getMaxDamage(); - } - - @Override - public boolean canShearZeta(ItemStack stack) { - return stack.canPerformAction(ItemAbilities.SHEARS_CARVE); - } - @Override public int getEnchantmentValueZeta(ItemStack stack) { return stack.getItem().getEnchantmentValue(stack); } @Override - public boolean canApplyAtEnchantingTableZeta(ItemStack stack, Enchantment enchantment) { - return stack.canApplyAtEnchantingTable(enchantment); + public boolean canShearZeta(ItemStack stack) { + return stack.canPerformAction(ItemAbilities.SHEARS_CARVE); } @Override public int getEnchantmentLevelZeta(ItemStack stack, Holder enchantment) { - return stack.getEnchantmentLevel(enchantment); + return stack.getItem().getEnchantmentValue(stack); } @Override - public Map getAllEnchantmentsZeta(ItemStack stack) { - return stack.getAllEnchantments(registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.ENCHANTMENT)); //todo: We need to get RegistryAccess somehow + public ItemEnchantments getAllEnchantmentsZeta(ItemStack stack, HolderLookup.RegistryLookup lookup) { + return stack.getAllEnchantments(lookup); } @Override @@ -97,11 +79,6 @@ public boolean shouldCauseReequipAnimationZeta(ItemStack oldStack, ItemStack new return oldStack.getItem().shouldCauseReequipAnimation(oldStack, newStack, slotChanged); } - @Override - public int getBurnTimeZeta(ItemStack stack, int burnTime, @Nullable RecipeType recipeType) { - return EventHooks.getItemBurnTime(stack, burnTime, recipeType); - } - @Override public int damageItemZeta(ItemStack stack, int amount, T entity, Consumer onBroken) { return stack.getItem().damageItem(stack, amount, entity, onBroken); @@ -116,9 +93,4 @@ public boolean isEnderMaskZeta(ItemStack stack, Player player, EnderMan enderboy public boolean canElytraFlyZeta(ItemStack stack, LivingEntity entity) { return stack.canElytraFly(entity); } - - @Override - public int getDefaultTooltipHideFlagsZeta(@NotNull ItemStack stack) { - return stack.getItem().getDefaultTooltipHideFlags(stack); //todo: What - } -} +} \ No newline at end of file diff --git a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaBlockMixin_FAKE.java b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaBlockMixin_FAKE.java index 80d9c0b..2c00af1 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaBlockMixin_FAKE.java +++ b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaBlockMixin_FAKE.java @@ -13,6 +13,7 @@ import net.minecraft.world.level.material.FluidState; import net.neoforged.neoforge.common.ItemAbility; import net.neoforged.neoforge.common.extensions.IBlockExtension; +import net.neoforged.neoforge.common.util.TriState; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.violetmoon.zeta.block.*; @@ -63,8 +64,8 @@ public boolean makesOpenTrapdoorAboveClimbable(BlockState state, LevelReader lev } @Override - public boolean canSustainPlant(BlockState state, BlockGetter level, BlockPos pos, Direction facing, IPlantable plantable) { - return canSustainPlantZeta(state, level, pos, facing, plantable.getPlantType(level, pos).getName().toLowerCase(Locale.ROOT)); + public TriState canSustainPlant(BlockState state, BlockGetter level, BlockPos soilPosition, Direction facing, BlockState plant) { + return canSustainPlantZeta(state, level, soilPosition, facing, plant); } @Override diff --git a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaItemMixin_FAKE.java b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaItemMixin_FAKE.java index e3fc733..0880089 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaItemMixin_FAKE.java +++ b/src/main/java/org/violetmoon/zetaimplforge/mixin/mixins/self/IZetaItemMixin_FAKE.java @@ -18,72 +18,64 @@ import net.minecraft.world.level.LevelReader; import net.neoforged.neoforge.common.ItemAbilities; import net.neoforged.neoforge.common.ItemAbility; -import net.neoforged.neoforge.common.extensions.IItemStackExtension; -import org.jetbrains.annotations.NotNull; +import net.neoforged.neoforge.common.extensions.IItemExtension; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.violetmoon.zeta.item.ZetaArmorItem; import org.violetmoon.zeta.item.ZetaBlockItem; import org.violetmoon.zeta.item.ZetaItem; import org.violetmoon.zeta.item.ext.IZetaItemExtensions; -import org.violetmoon.zeta.mixin.mixins.InvokerIItemStackExtension; import java.util.function.Consumer; // Forge can't actually mixin to interfaces, so we fake it by just... mixing in to everyone inheriting the interface. -@Mixin({ - ZetaArmorItem.class, - ZetaBlockItem.class, - ZetaItem.class, -}) +@Mixin({ZetaArmorItem.class, ZetaBlockItem.class, ZetaItem.class}) -// TODO: getArmorTexture() and getMaxDamage() no longer exist -public class IZetaItemMixin_FAKE implements IItemStackExtension, IZetaItemExtensions { +public class IZetaItemMixin_FAKE implements IItemExtension, IZetaItemExtensions { @Override - public InteractionResult onItemUseFirst(UseOnContext context) { - return onItemUseFirstZeta(context); + public InteractionResult onItemUseFirst(ItemStack stack, UseOnContext context) { + return onItemUseFirstZeta(stack, context); } @Override - public boolean isRepairable() { - return isRepairableZeta(); + public boolean isRepairable(ItemStack stack) { + return isRepairableZeta(stack); } @Override - public boolean onEntityItemUpdate(ItemEntity entity) { - return onEntityItemUpdateZeta(entity); + public boolean onEntityItemUpdate(ItemStack stack, ItemEntity entity) { + return onEntityItemUpdateZeta(stack, entity); } @Override - public boolean doesSneakBypassUse(LevelReader level, BlockPos pos, Player player) { - return doesSneakBypassUseZeta(level, pos, player); + public boolean doesSneakBypassUse(ItemStack stack, LevelReader level, BlockPos pos, Player player) { + return doesSneakBypassUseZeta(stack, level, pos, player); } @Override - public boolean canEquip(EquipmentSlot armorType, LivingEntity entity) { - return canEquipZeta(armorType, entity); + public boolean canEquip(ItemStack stack, EquipmentSlot armorType, LivingEntity entity) { + return stack.canEquip(armorType, entity); } @Override - public boolean isBookEnchantable(ItemStack book) { - return isBookEnchantableZeta(book); + public boolean isBookEnchantable(ItemStack stack, ItemStack book) { + return stack.isBookEnchantable(book); } @Override - public boolean canPerformAction(ItemAbility itemAbility) { - ItemStack stack = ((InvokerIItemStackExtension) this).zeta$getSelf(); - return itemAbility == ItemAbilities.SHEARS_CARVE && canShearZeta(stack); + public int getEnchantmentValue(ItemStack stack) { + return getEnchantmentValueZeta(stack); } @Override - public int getEnchantmentValue() { - return getEnchantmentValueZeta(); + public boolean canPerformAction(ItemStack stack, ItemAbility itemAbility) { + return itemAbility == ItemAbilities.SHEARS_CARVE && canShearZeta(stack); } @Override - public int getEnchantmentLevel(Holder enchantment) { - return getEnchantmentLevelZeta(enchantment); + public int getEnchantmentLevel(ItemStack stack, Holder enchantment) { + return getEnchantmentLevelZeta(stack, enchantment); } @Override @@ -97,8 +89,8 @@ public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStac } @Override - public int getBurnTime(ItemStack itemStack, @Nullable RecipeType recipeType) { - return getBurnTimeZeta(itemStack, recipeType); + public int getBurnTime(ItemStack stack, @Nullable RecipeType recipeType) { + return getBurnTimeZeta(stack, recipeType); } @Override @@ -115,10 +107,4 @@ public boolean isEnderMask(ItemStack stack, Player player, EnderMan endermanEnti public boolean canElytraFly(ItemStack stack, LivingEntity entity) { return canElytraFlyZeta(stack, entity); } - - @Override - public int getDefaultTooltipHideFlags(@NotNull ItemStack stack) { - return getDefaultTooltipHideFlagsZeta(stack); - } - -} +} \ No newline at end of file diff --git a/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeCraftingExtensionsRegistry.java b/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeCraftingExtensionsRegistry.java index d37b3d2..95e2654 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeCraftingExtensionsRegistry.java +++ b/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeCraftingExtensionsRegistry.java @@ -1,6 +1,7 @@ package org.violetmoon.zetaimplforge.registry; import com.google.gson.JsonObject; +import com.mojang.serialization.MapCodec; import net.minecraft.core.Holder; import net.minecraft.core.Registry; import net.minecraft.network.FriendlyByteBuf; @@ -8,6 +9,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.crafting.Ingredient; import net.neoforged.neoforge.common.conditions.ICondition; +import net.neoforged.neoforge.common.crafting.CraftingHelper; import org.violetmoon.zeta.recipe.IZetaCondition; import org.violetmoon.zeta.recipe.IZetaConditionSerializer; import org.violetmoon.zeta.recipe.IZetaIngredientSerializer; @@ -69,16 +71,17 @@ public Map>> getAllTags(ResourceKey(T zeta) implements ICondition { - @Override - public ResourceLocation getID() { - return zeta.getID(); - } @Override public boolean test(ICondition.IContext context) { //Wrap the IContext in a class Zeta can refer to, before passing it to Zeta return zeta.test(new Forge2ZetaContext(context)); } + + @Override + public MapCodec codec() { + return null; + } } @Override diff --git a/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeZetaRegistry.java b/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeZetaRegistry.java index f68c5f6..f91dcd2 100644 --- a/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeZetaRegistry.java +++ b/src/main/java/org/violetmoon/zetaimplforge/registry/ForgeZetaRegistry.java @@ -13,25 +13,22 @@ public class ForgeZetaRegistry extends ZetaRegistry { public ForgeZetaRegistry(ForgeZeta z) { super(z); - - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onRegisterEvent); + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onRegisterEvent); // TODO: Is there a reason we can't do this in ForgeZeta#start? } private void onRegisterEvent(RegisterEvent event) { var key = event.getRegistryKey(); ResourceLocation registryRes = key.location(); ResourceKey> keyGeneric = ResourceKey.createRegistryKey(registryRes); - Collection> ourEntries = getDefers(registryRes); - if(ourEntries != null && !ourEntries.isEmpty()) { + if(ourEntries != null && !ourEntries.isEmpty()) { for(Supplier supplier : ourEntries) { Object entry = supplier.get(); ResourceLocation name = internalNames.get(entry); z.log.debug("Registering to " + registryRes + " - " + name); event.register(keyGeneric, e-> e.register(name, entry)); } - clearDeferCache(registryRes); } } diff --git a/src/main/resources/zeta.mixins.json b/src/main/resources/zeta.mixins.json index 8cfd9a7..ad09651 100644 --- a/src/main/resources/zeta.mixins.json +++ b/src/main/resources/zeta.mixins.json @@ -12,7 +12,6 @@ "AccessorLootTable", "AccessorPistonStructureResolver", "InvokerBlockBehavior", - "InvokerIItemStackExtension", "InvokerSpawnPlacements", "PistonBaseBlockMixin", "RegistryDataLoaderMixin",