From 768433d00345d3419f11b08853f84f20377df284 Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com> Date: Fri, 14 Jun 2024 10:53:11 +0200 Subject: [PATCH] feat: Update Forge and NeoForge to 1.21 --- .../forge/mixin/ForgeServerPlayerMixin.java | 58 ------------------- .../netherportalfix.forge.mixins.json | 1 - .../mixin/NeoForgeServerPlayerMixin.java | 58 ------------------- .../netherportalfix.neoforge.mixins.json | 1 - 4 files changed, 118 deletions(-) delete mode 100644 forge/src/main/java/net/blay09/mods/netherportalfix/forge/mixin/ForgeServerPlayerMixin.java delete mode 100644 neoforge/src/main/java/net/blay09/mods/netherportalfix/neoforge/mixin/NeoForgeServerPlayerMixin.java diff --git a/forge/src/main/java/net/blay09/mods/netherportalfix/forge/mixin/ForgeServerPlayerMixin.java b/forge/src/main/java/net/blay09/mods/netherportalfix/forge/mixin/ForgeServerPlayerMixin.java deleted file mode 100644 index 803f6ed..0000000 --- a/forge/src/main/java/net/blay09/mods/netherportalfix/forge/mixin/ForgeServerPlayerMixin.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.blay09.mods.netherportalfix.forge.mixin; - -import net.blay09.mods.netherportalfix.NetherPortalFix; -import net.blay09.mods.netherportalfix.ReturnPortalManager; -import net.blay09.mods.netherportalfix.mixin.LivingEntityAccessor; -import net.minecraft.BlockUtil; -import net.minecraft.core.BlockPos; -import net.minecraft.resources.ResourceKey; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import net.minecraftforge.common.util.ITeleporter; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ServerPlayer.class) -public class ForgeServerPlayerMixin { - - private static final ThreadLocal> fromDimHolder = new ThreadLocal<>(); - - @Inject(remap = false, method = "changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;", at = @At("HEAD")) - public void changeDimensionHead(ServerLevel level, ITeleporter teleporter, CallbackInfoReturnable callbackInfo) { - ServerPlayer player = (ServerPlayer) (Object) this; - fromDimHolder.set(player.level().dimension()); - } - - @Inject(remap = false, method = "changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraftforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;", at = @At("RETURN")) - public void changeDimensionTail(ServerLevel level, ITeleporter teleporter, CallbackInfoReturnable callbackInfo) { - ServerPlayer player = (ServerPlayer) (Object) this; - final ResourceKey fromDim = fromDimHolder.get(); - final ResourceKey toDim = level.dimension(); - final ResourceKey OVERWORLD = Level.OVERWORLD; - final ResourceKey THE_NETHER = Level.NETHER; - if ((fromDim != OVERWORLD || toDim != THE_NETHER) && (fromDim != THE_NETHER || toDim != OVERWORLD)) { - NetherPortalFix.logger.debug("Not storing return portal because it's from {} to {}", fromDim, toDim); - return; - } - - BlockPos lastPos = ((LivingEntityAccessor) player).getLastPos(); - if (lastPos == null) { - NetherPortalFix.logger.debug("Not storing return portal because I just spawned."); - return; - } - - BlockUtil.FoundRectangle fromPortal = ReturnPortalManager.findPortalAt(player, fromDim, lastPos); - BlockPos toPos = player.blockPosition(); - if (fromPortal == null) { - NetherPortalFix.logger.debug("Not storing return portal because I'm not in a portal."); - } else { - ReturnPortalManager.storeReturnPortal(player, toDim, toPos, fromPortal); - NetherPortalFix.logger.debug("Storing return portal from {} to {} in {}", toDim, fromPortal.minCorner, fromDim); - } - } - -} diff --git a/forge/src/main/resources/netherportalfix.forge.mixins.json b/forge/src/main/resources/netherportalfix.forge.mixins.json index 70995f2..40642e5 100644 --- a/forge/src/main/resources/netherportalfix.forge.mixins.json +++ b/forge/src/main/resources/netherportalfix.forge.mixins.json @@ -5,7 +5,6 @@ "compatibilityLevel": "JAVA_17", "refmap": "${mod_id}.refmap.json", "mixins": [ - "ForgeServerPlayerMixin" ], "client": [ ], diff --git a/neoforge/src/main/java/net/blay09/mods/netherportalfix/neoforge/mixin/NeoForgeServerPlayerMixin.java b/neoforge/src/main/java/net/blay09/mods/netherportalfix/neoforge/mixin/NeoForgeServerPlayerMixin.java deleted file mode 100644 index 2afb6d6..0000000 --- a/neoforge/src/main/java/net/blay09/mods/netherportalfix/neoforge/mixin/NeoForgeServerPlayerMixin.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.blay09.mods.netherportalfix.neoforge.mixin; - -import net.blay09.mods.netherportalfix.NetherPortalFix; -import net.blay09.mods.netherportalfix.ReturnPortalManager; -import net.blay09.mods.netherportalfix.mixin.LivingEntityAccessor; -import net.minecraft.BlockUtil; -import net.minecraft.core.BlockPos; -import net.minecraft.resources.ResourceKey; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import net.neoforged.neoforge.common.util.ITeleporter; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(ServerPlayer.class) -public class NeoForgeServerPlayerMixin { - - private static final ThreadLocal> fromDimHolder = new ThreadLocal<>(); - - @Inject(remap = false, method = "changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/neoforged/neoforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;", at = @At("HEAD")) - public void changeDimensionHead(ServerLevel level, ITeleporter teleporter, CallbackInfoReturnable callbackInfo) { - ServerPlayer player = (ServerPlayer) (Object) this; - fromDimHolder.set(player.level().dimension()); - } - - @Inject(remap = false, method = "changeDimension(Lnet/minecraft/server/level/ServerLevel;Lnet/neoforged/neoforge/common/util/ITeleporter;)Lnet/minecraft/world/entity/Entity;", at = @At("RETURN")) - public void changeDimensionTail(ServerLevel level, ITeleporter teleporter, CallbackInfoReturnable callbackInfo) { - ServerPlayer player = (ServerPlayer) (Object) this; - final ResourceKey fromDim = fromDimHolder.get(); - final ResourceKey toDim = level.dimension(); - final ResourceKey OVERWORLD = Level.OVERWORLD; - final ResourceKey THE_NETHER = Level.NETHER; - if ((fromDim != OVERWORLD || toDim != THE_NETHER) && (fromDim != THE_NETHER || toDim != OVERWORLD)) { - NetherPortalFix.logger.debug("Not storing return portal because it's from {} to {}", fromDim, toDim); - return; - } - - BlockPos lastPos = ((LivingEntityAccessor) player).getLastPos(); - if (lastPos == null) { - NetherPortalFix.logger.debug("Not storing return portal because I just spawned."); - return; - } - - BlockUtil.FoundRectangle fromPortal = ReturnPortalManager.findPortalAt(player, fromDim, lastPos); - BlockPos toPos = player.blockPosition(); - if (fromPortal == null) { - NetherPortalFix.logger.debug("Not storing return portal because I'm not in a portal."); - } else { - ReturnPortalManager.storeReturnPortal(player, toDim, toPos, fromPortal); - NetherPortalFix.logger.debug("Storing return portal from {} to {} in {}", toDim, fromPortal.minCorner, fromDim); - } - } - -} diff --git a/neoforge/src/main/resources/netherportalfix.neoforge.mixins.json b/neoforge/src/main/resources/netherportalfix.neoforge.mixins.json index 72a659b..de72517 100644 --- a/neoforge/src/main/resources/netherportalfix.neoforge.mixins.json +++ b/neoforge/src/main/resources/netherportalfix.neoforge.mixins.json @@ -4,7 +4,6 @@ "package": "net.blay09.mods.netherportalfix.neoforge.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ - "NeoForgeServerPlayerMixin" ], "client": [ ],