Fix mixin crashes on 1.16.5

This commit is contained in:
s809
2024-09-18 01:06:06 +05:00
parent cd74e33c54
commit 00b69dcc68
8 changed files with 104 additions and 7 deletions
@@ -0,0 +1,38 @@
#if MC_VER == MC_1_16_5
package com.seibel.distanthorizons.fabric.mixins.server;
import com.seibel.distanthorizons.common.wrappers.misc.IMixinServerPlayer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
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.CallbackInfo;
@Mixin(Entity.class)
public class MixinEntity
{
@Inject(at = @At("TAIL"), method = "setLevel")
public void setLevel(Level level, CallbackInfo ci)
{
if (this instanceof IMixinServerPlayer)
{
((IMixinServerPlayer) this).distantHorizons$setDimensionChangeDestination((ServerLevel) level);
}
}
}
#else
package com.seibel.distanthorizons.fabric.mixins.server;
import net.minecraft.world.entity.Entity;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(Entity.class)
public class MixinEntity
{
}
#endif
@@ -48,6 +48,12 @@ public class MixinServerPlayer implements IMixinServerPlayer
public ServerLevel distantHorizons$getDimensionChangeDestination()
{ return this.dimensionChangeDestination; }
#if MC_VER == MC_1_16_5
@Override
public void distantHorizons$setDimensionChangeDestination(ServerLevel dimensionChangeDestination)
{ this.dimensionChangeDestination = dimensionChangeDestination; }
#endif
@Inject(at = @At("HEAD"), method = "changeDimension")
#if MC_VER >= MC_1_21_1
public void changeDimension(DimensionTransition dimensionTransition, CallbackInfoReturnable<Entity> cir)
@@ -60,10 +66,11 @@ public class MixinServerPlayer implements IMixinServerPlayer
#if MC_VER >= MC_1_20_1
@Inject(at = @At("RETURN"), method = "setServerLevel")
public void setServerLevel(ServerLevel level, CallbackInfo ci)
#else
{ this.dimensionChangeDestination = null; }
#elif MC_VER >= MC_1_17_1
@Inject(at = @At("RETURN"), method = "setLevel")
public void setLevel(ServerLevel level, CallbackInfo ci)
#endif
{ this.dimensionChangeDestination = null; }
#endif
}
@@ -6,7 +6,8 @@
"server.MixinChunkGenerator",
"server.MixinChunkMap",
"server.MixinUtilBackgroundThread",
"server.MixinServerPlayer"
"server.MixinServerPlayer",
"server.MixinEntity"
],
"client": [
"client.MixinClientLevel",