diff --git a/build.gradle b/build.gradle index 5a0cb90..18bb7fd 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,10 @@ archivesBaseName = project.archives_base_name+"-"+project.minecraft_version version = project.mod_version group = project.maven_group +loom { + accessWidenerPath = file("src/main/resources/extraalchemy.accesswidener") +} + repositories { mavenLocal() maven { diff --git a/gradle.properties b/gradle.properties index 6fbd8e7..762e0d7 100755 --- a/gradle.properties +++ b/gradle.properties @@ -1,21 +1,21 @@ org.gradle.jvmargs=-Xmx1G -minecraft_version=1.20.6 -yarn_mappings=1.20.6+build.3 -loader_version=0.16.2 +minecraft_version=1.21 +yarn_mappings=1.21+build.9 +loader_version=0.16.9 -fabric_version=0.100.8+1.20.6 +fabric_version=0.102.0+1.21 #fabric_kotlin_version=1.10.8+kotlin.1.9.0 -modmenu_version=10.0.0 -clothconfig_version=14.0.129 -rei_version=15.0.753 -pehkui_version=3.8.2 -trinkets_version=3.9.0 -patchouli_version=1.20.6-87-FABRIC-SNAPSHOT +modmenu_version=11.0.2 +clothconfig_version=15.0.140 +rei_version=16.0.788 +pehkui_version=3.8.3 +trinkets_version=3.10.0 +#patchouli_version=1.20.6-87-FABRIC-SNAPSHOT #inventorio_version=5134138 -cardinal_components_version=6.0.0 +cardinal_components_version=6.1.1 #nbttt_version=3595757 #flk_version=3364215 diff --git a/src/main/java/zabi/minecraft/extraalchemy/client/tooltip/PotionTooltipData.java b/src/main/java/zabi/minecraft/extraalchemy/client/tooltip/PotionTooltipData.java index 9ed4990..b24f322 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/client/tooltip/PotionTooltipData.java +++ b/src/main/java/zabi/minecraft/extraalchemy/client/tooltip/PotionTooltipData.java @@ -1,7 +1,7 @@ package zabi.minecraft.extraalchemy.client.tooltip; -import net.minecraft.client.item.TooltipData; import net.minecraft.item.ItemStack; +import net.minecraft.item.tooltip.TooltipData; public class PotionTooltipData implements TooltipData { diff --git a/src/main/java/zabi/minecraft/extraalchemy/compat/pehkui/PehkuiPotions.java b/src/main/java/zabi/minecraft/extraalchemy/compat/pehkui/PehkuiPotions.java index cf31ffc..111065d 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/compat/pehkui/PehkuiPotions.java +++ b/src/main/java/zabi/minecraft/extraalchemy/compat/pehkui/PehkuiPotions.java @@ -24,9 +24,9 @@ public class PehkuiPotions { public static int registerEffects() { Log.i("Registering pehkui effects"); - Identifier id_grow = new Identifier(LibMod.MOD_ID, "growing"); + Identifier id_grow = LibMod.id("growing"); Registry.register(Registries.STATUS_EFFECT, id_grow, growing.onRegister()); - Identifier id_shrink = new Identifier(LibMod.MOD_ID, "shrinking"); + Identifier id_shrink = LibMod.id("shrinking"); Registry.register(Registries.STATUS_EFFECT, id_shrink, shrinking.onRegister()); return 2; } diff --git a/src/main/java/zabi/minecraft/extraalchemy/crafting/PotionRingRecipe.java b/src/main/java/zabi/minecraft/extraalchemy/crafting/PotionRingRecipe.java index b191dd9..c2db5dc 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/crafting/PotionRingRecipe.java +++ b/src/main/java/zabi/minecraft/extraalchemy/crafting/PotionRingRecipe.java @@ -9,7 +9,6 @@ import net.minecraft.entity.effect.StatusEffect; import net.minecraft.entity.effect.StatusEffectInstance; -import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; @@ -19,6 +18,7 @@ import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.SpecialCraftingRecipe; import net.minecraft.recipe.book.CraftingRecipeCategory; +import net.minecraft.recipe.input.CraftingRecipeInput; import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryWrapper.WrapperLookup; import net.minecraft.util.Identifier; @@ -66,16 +66,18 @@ public PotionRingRecipe(Optional level, int cost, int length, int renew } @Override - public boolean matches(RecipeInputInventory inv, World world) { + public boolean matches(CraftingRecipeInput input, World world) { if (!ModConfig.INSTANCE.enableRings) { //Globally disabled and specifically disabled return false; } boolean foundEffect = false; boolean foundRing = false; + + List inv = input.getStacks(); for (int i = 0; i < inv.size(); i++) { - ItemStack is = inv.getStack(i); + ItemStack is = input.getStackInSlot(i); Item s = is.getItem(); if (s.equals(Items.POTION)) { if (foundEffect || !doesPotionMatch(PotionUtilities.getEffects(is))) { @@ -97,8 +99,8 @@ public boolean matches(RecipeInputInventory inv, World world) { } @Override - public ItemStack craft(RecipeInputInventory inv, WrapperLookup wl) { - return getResult(wl); + public ItemStack craft(CraftingRecipeInput input, WrapperLookup lookup) { + return getResult(lookup); } @Override @@ -157,7 +159,7 @@ public PotionRingRecipe decode(RegistryByteBuf buf) { int renew = buf.readInt(); int level = buf.readInt(); String potion_name = buf.readString(); - StatusEffect effect = Registries.STATUS_EFFECT.get(new Identifier(potion_name)); + StatusEffect effect = Registries.STATUS_EFFECT.get(Identifier.of(potion_name)); return new PotionRingRecipe(Optional.of(level), cost, length, renew, Optional.of(effect), Optional.empty()); } @@ -179,4 +181,5 @@ public MapCodec codec() { } } + } diff --git a/src/main/java/zabi/minecraft/extraalchemy/crafting/PotionVialRecipe.java b/src/main/java/zabi/minecraft/extraalchemy/crafting/PotionVialRecipe.java index e53eafd..9c5e3fc 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/crafting/PotionVialRecipe.java +++ b/src/main/java/zabi/minecraft/extraalchemy/crafting/PotionVialRecipe.java @@ -1,12 +1,12 @@ package zabi.minecraft.extraalchemy.crafting; -import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.recipe.RecipeSerializer; import net.minecraft.recipe.SpecialCraftingRecipe; import net.minecraft.recipe.book.CraftingRecipeCategory; +import net.minecraft.recipe.input.CraftingRecipeInput; import net.minecraft.registry.RegistryWrapper.WrapperLookup; import net.minecraft.world.World; import zabi.minecraft.extraalchemy.config.ModConfig; @@ -20,7 +20,17 @@ public PotionVialRecipe(CraftingRecipeCategory category) { } @Override - public boolean matches(RecipeInputInventory inv, World world) { + public boolean fits(int width, int height) { + return width > 1 || height > 1; + } + + @Override + public RecipeSerializer getSerializer() { + return CraftingRecipes.FILL_VIAL_SERIALIZER; + } + + @Override + public boolean matches(CraftingRecipeInput input, World world) { if (!ModConfig.INSTANCE.enableVials) { return false; } @@ -28,8 +38,8 @@ public boolean matches(RecipeInputInventory inv, World world) { boolean splash = false; boolean vial = false; - for (int i = 0; i < inv.size(); i++) { - Item s = inv.getStack(i).getItem(); + for (int i = 0; i < input.getSize(); i++) { + Item s = input.getStackInSlot(i).getItem(); if (s.equals(Items.SPLASH_POTION)) { if (splash) { return false; @@ -50,19 +60,9 @@ public boolean matches(RecipeInputInventory inv, World world) { } @Override - public boolean fits(int width, int height) { - return width > 1 || height > 1; - } - - @Override - public RecipeSerializer getSerializer() { - return CraftingRecipes.FILL_VIAL_SERIALIZER; - } - - @Override - public ItemStack craft(RecipeInputInventory inv, WrapperLookup wl) { - for (int i = 0; i < inv.size(); i++) { - ItemStack is = inv.getStack(i); + public ItemStack craft(CraftingRecipeInput input, WrapperLookup lookup) { + for (int i = 0; i < input.getSize(); i++) { + ItemStack is = input.getStackInSlot(i); if (is.getItem().equals(Items.SPLASH_POTION)) { ItemStack result = new ItemStack(ModItems.POTION_VIAL); PotionUtilities.cloneEffectsToStack(is, result); diff --git a/src/main/java/zabi/minecraft/extraalchemy/items/EmptyRingItem.java b/src/main/java/zabi/minecraft/extraalchemy/items/EmptyRingItem.java index 0d70785..db0edea 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/items/EmptyRingItem.java +++ b/src/main/java/zabi/minecraft/extraalchemy/items/EmptyRingItem.java @@ -4,9 +4,9 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.item.TooltipType; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.tooltip.TooltipType; import net.minecraft.text.Text; import zabi.minecraft.extraalchemy.config.ModConfig; diff --git a/src/main/java/zabi/minecraft/extraalchemy/items/EmptyVialItem.java b/src/main/java/zabi/minecraft/extraalchemy/items/EmptyVialItem.java index f2c7080..dec0e95 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/items/EmptyVialItem.java +++ b/src/main/java/zabi/minecraft/extraalchemy/items/EmptyVialItem.java @@ -4,13 +4,13 @@ import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.item.TooltipType; import net.minecraft.entity.ItemEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.item.tooltip.TooltipType; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; diff --git a/src/main/java/zabi/minecraft/extraalchemy/items/ModComponents.java b/src/main/java/zabi/minecraft/extraalchemy/items/ModComponents.java index f0a4b19..41aa7ad 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/items/ModComponents.java +++ b/src/main/java/zabi/minecraft/extraalchemy/items/ModComponents.java @@ -2,7 +2,7 @@ import com.mojang.serialization.codecs.PrimitiveCodec; -import net.minecraft.component.DataComponentType; +import net.minecraft.component.ComponentType; import net.minecraft.network.codec.PacketCodecs; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; @@ -11,17 +11,17 @@ public class ModComponents { - public static final DataComponentType DISABLED = DataComponentType.builder() + public static final ComponentType DISABLED = ComponentType.builder() .codec(PrimitiveCodec.BOOL) .packetCodec(PacketCodecs.BOOL) .build(); - public static final DataComponentType POTION_RING_DATA = DataComponentType.builder() + public static final ComponentType POTION_RING_DATA = ComponentType.builder() .codec(PotionRingData.CODEC) // .packetCodec(PacketCodecs.BOOL) .build(); - public static final DataComponentType SELECTION_MODE = DataComponentType.builder() + public static final ComponentType SELECTION_MODE = ComponentType.builder() .codec(PotionBagItem.SelectionMode.CODEC) .build(); diff --git a/src/main/java/zabi/minecraft/extraalchemy/items/PotionBagItem.java b/src/main/java/zabi/minecraft/extraalchemy/items/PotionBagItem.java index 8f331da..87b01b0 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/items/PotionBagItem.java +++ b/src/main/java/zabi/minecraft/extraalchemy/items/PotionBagItem.java @@ -5,7 +5,6 @@ import com.mojang.serialization.Codec; -import net.minecraft.client.item.TooltipType; import net.minecraft.component.DataComponentTypes; import net.minecraft.component.type.ContainerComponent; import net.minecraft.component.type.DyedColorComponent; @@ -16,6 +15,7 @@ import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.tooltip.TooltipType; import net.minecraft.potion.Potion; import net.minecraft.registry.Registries; import net.minecraft.registry.tag.TagKey; @@ -170,10 +170,10 @@ public UseAction getUseAction(ItemStack stack) { } @Override - public int getMaxUseTime(ItemStack stack) { + public int getMaxUseTime(ItemStack stack, LivingEntity user) { return 20; } - + @Override public boolean hasGlint(ItemStack stack) { return getSelectedPotion(stack).isPresent(); diff --git a/src/main/java/zabi/minecraft/extraalchemy/items/PotionRingItem.java b/src/main/java/zabi/minecraft/extraalchemy/items/PotionRingItem.java index d6e423c..dc3a16c 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/items/PotionRingItem.java +++ b/src/main/java/zabi/minecraft/extraalchemy/items/PotionRingItem.java @@ -7,7 +7,6 @@ import com.mojang.serialization.Codec; import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.client.item.TooltipType; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffect; @@ -15,6 +14,7 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.tooltip.TooltipType; import net.minecraft.registry.Registries; import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.text.Text; diff --git a/src/main/java/zabi/minecraft/extraalchemy/mixin/client/MixinShowPotionIcon.java b/src/main/java/zabi/minecraft/extraalchemy/mixin/client/MixinShowPotionIcon.java index a42e9c0..626eb45 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/mixin/client/MixinShowPotionIcon.java +++ b/src/main/java/zabi/minecraft/extraalchemy/mixin/client/MixinShowPotionIcon.java @@ -7,9 +7,9 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import net.minecraft.client.item.TooltipData; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.tooltip.TooltipData; import zabi.minecraft.extraalchemy.client.tooltip.PotionTooltipData; import zabi.minecraft.extraalchemy.client.tooltip.StatusEffectContainer; diff --git a/src/main/java/zabi/minecraft/extraalchemy/potion/ModPotionRegistry.java b/src/main/java/zabi/minecraft/extraalchemy/potion/ModPotionRegistry.java index 852b4fd..559e6d2 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/potion/ModPotionRegistry.java +++ b/src/main/java/zabi/minecraft/extraalchemy/potion/ModPotionRegistry.java @@ -33,7 +33,7 @@ public static void registerAll() { int registered = 0; for (Field field:ModPotionRegistry.class.getDeclaredFields()) { if (ModPotion.class.isAssignableFrom(field.getType())) { - Identifier id = new Identifier(LibMod.MOD_ID, field.getName()); + Identifier id = LibMod.id(field.getName()); Log.d("Registering potion "+id); registered += ((ModPotion) field.get(null)).registerTree(LibMod.MOD_ID, field.getName()); } diff --git a/src/main/java/zabi/minecraft/extraalchemy/statuseffect/ModEffectRegistry.java b/src/main/java/zabi/minecraft/extraalchemy/statuseffect/ModEffectRegistry.java index 1f4b0a6..3458285 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/statuseffect/ModEffectRegistry.java +++ b/src/main/java/zabi/minecraft/extraalchemy/statuseffect/ModEffectRegistry.java @@ -52,7 +52,7 @@ public static void registerAll() { int registered = 0; for (Field field:ModEffectRegistry.class.getDeclaredFields()) { if (ModStatusEffect.class.isAssignableFrom(field.getType())) { - Identifier id = new Identifier(LibMod.MOD_ID, field.getName()); + Identifier id = LibMod.id(field.getName()); Registry.register(Registries.STATUS_EFFECT, id, ((ModStatusEffect) field.get(null)).onRegister()); Log.d("Registered potion "+id); registered++; @@ -75,7 +75,7 @@ public static class Utils { public static StatusEffect magnetism_disabled = null; public static void register() { - magnetism_disabled = Registry.register(Registries.STATUS_EFFECT, new Identifier(LibMod.MOD_ID, "magnetism_disabled"), new ModStatusEffect(StatusEffectCategory.BENEFICIAL, MAGNETISM_COLOR, magnetism.isInstant()).onRegister()); + magnetism_disabled = Registry.register(Registries.STATUS_EFFECT, LibMod.id("magnetism_disabled"), new ModStatusEffect(StatusEffectCategory.BENEFICIAL, MAGNETISM_COLOR, magnetism.isInstant()).onRegister()); Log.i("Registered dummy effects"); } } diff --git a/src/main/java/zabi/minecraft/extraalchemy/statuseffect/effects/RecallStatusEffect.java b/src/main/java/zabi/minecraft/extraalchemy/statuseffect/effects/RecallStatusEffect.java index 9d5c19e..6a05e9d 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/statuseffect/effects/RecallStatusEffect.java +++ b/src/main/java/zabi/minecraft/extraalchemy/statuseffect/effects/RecallStatusEffect.java @@ -1,6 +1,5 @@ package zabi.minecraft.extraalchemy.statuseffect.effects; -import net.fabricmc.fabric.api.dimension.v1.FabricDimensions; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffectCategory; import net.minecraft.entity.player.PlayerEntity; @@ -39,7 +38,8 @@ public boolean applyUpdateEffect(LivingEntity entity, int i) { if (!pos.getWorldId().equals(entity.getEntityWorld().getRegistryKey().getValue())) { if (i > 0) { ServerWorld destinationWorld = (ServerWorld) pos.getWorld(entity.getServer()); - ent = FabricDimensions.teleport(entity, destinationWorld, new TeleportTarget(new Vec3d(pos.getX(), pos.getY(), pos.getZ()), Vec3d.ZERO, ent.getYaw(), ent.getPitch())); + TeleportTarget destination = new TeleportTarget(destinationWorld, new Vec3d(pos.getX(), pos.getY(), pos.getZ()), Vec3d.ZERO, ent.getYaw(), ent.getPitch(), TeleportTarget.NO_OP); + ent = (LivingEntity) entity.teleportTo(destination); } else { ent.damage(entity.getEntityWorld().getDamageSources().magic(), 1f); if (ent instanceof PlayerEntity player) { @@ -47,7 +47,7 @@ public boolean applyUpdateEffect(LivingEntity entity, int i) { } } } else { - ent.teleport(pos.getX(), pos.getY(), pos.getZ()); + ent.teleport(pos.getX(), pos.getY(), pos.getZ(), true); } } } finally { diff --git a/src/main/java/zabi/minecraft/extraalchemy/statuseffect/effects/ReturnStatusEffect.java b/src/main/java/zabi/minecraft/extraalchemy/statuseffect/effects/ReturnStatusEffect.java index dd26b9f..2e8f725 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/statuseffect/effects/ReturnStatusEffect.java +++ b/src/main/java/zabi/minecraft/extraalchemy/statuseffect/effects/ReturnStatusEffect.java @@ -1,13 +1,14 @@ package zabi.minecraft.extraalchemy.statuseffect.effects; +import java.util.Optional; + import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.effect.StatusEffectCategory; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; -import zabi.minecraft.extraalchemy.config.ModConfig; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.TeleportTarget; import zabi.minecraft.extraalchemy.statuseffect.ModStatusEffect; public class ReturnStatusEffect extends ModStatusEffect { @@ -18,13 +19,13 @@ public ReturnStatusEffect(StatusEffectCategory type, int color, boolean isInstan @Override public void applyInstantEffect(Entity source, Entity attacker, LivingEntity target, int amplifier, double d) { - if (target instanceof ServerPlayerEntity) { - ServerPlayerEntity player = (ServerPlayerEntity) target; + if (target instanceof ServerPlayerEntity player) { BlockPos respawnPos = player.getSpawnPointPosition(); - if (respawnPos != null) { - PlayerEntity.findRespawnPosition((ServerWorld) target.getEntityWorld(), respawnPos, player.getYaw(), player.isSpawnForced(), !ModConfig.INSTANCE.useAnchorChargesWithReturnPotion).ifPresent(v3d -> { - player.requestTeleport(v3d.x, v3d.y, v3d.z); - }); + Optional pos = ServerPlayerEntity.findRespawnPosition(player.getServerWorld(), respawnPos, 0, false, true); + if (pos.isPresent()) { + target.getWorldSpawnPos(player.getServerWorld(), respawnPos); + TeleportTarget teleportTarget = new TeleportTarget(player.getServerWorld(), Vec3d.of(respawnPos), Vec3d.ZERO, player.getYaw(), player.getPitch(), TeleportTarget.NO_OP); + player.teleportTo(teleportTarget); } } } diff --git a/src/main/java/zabi/minecraft/extraalchemy/utils/LibMod.java b/src/main/java/zabi/minecraft/extraalchemy/utils/LibMod.java index 84570c4..7104980 100644 --- a/src/main/java/zabi/minecraft/extraalchemy/utils/LibMod.java +++ b/src/main/java/zabi/minecraft/extraalchemy/utils/LibMod.java @@ -8,7 +8,7 @@ public class LibMod { public static final String MOD_ID = "extraalchemy"; public static Identifier id(String name) { - return new Identifier(MOD_ID, name); + return Identifier.of(MOD_ID, name); } } diff --git a/src/main/resources/extraalchemy.accesswidener b/src/main/resources/extraalchemy.accesswidener new file mode 100644 index 0000000..454d758 --- /dev/null +++ b/src/main/resources/extraalchemy.accesswidener @@ -0,0 +1,4 @@ +accessWidener v2 named + +accessible method net/minecraft/server/network/ServerPlayerEntity findRespawnPosition (Lnet/minecraft/server/world/ServerWorld;Lnet/minecraft/util/math/BlockPos;FZZ)Ljava/util/Optional; +accessible class net/minecraft/server/network/ServerPlayerEntity$RespawnPos \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 7866b54..1006e20 100755 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -63,6 +63,7 @@ "minecraft": ">=1.20.5", "java": ">=21" }, + "accessWidener": "extraalchemy.accesswidener", "custom": { "lithium:options": { "mixin.world.block_entity_ticking.sleeping.brewing_stand": false