2020-03-19 19:45:46 +00:00
|
|
|
package com.thebrokenrail.slightlyvanilla.mixin;
|
|
|
|
|
|
|
|
import com.thebrokenrail.slightlyvanilla.SlightlyVanilla;
|
|
|
|
import net.minecraft.block.RespawnAnchorBlock;
|
2020-06-24 22:48:38 +00:00
|
|
|
import net.minecraft.server.network.ServerPlayerEntity;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.world.World;
|
2020-03-19 19:45:46 +00:00
|
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
|
|
import org.spongepowered.asm.mixin.injection.At;
|
2020-06-24 22:48:38 +00:00
|
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
2020-03-19 19:45:46 +00:00
|
|
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
2020-06-24 22:48:38 +00:00
|
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
2020-03-19 19:45:46 +00:00
|
|
|
|
2020-03-19 21:33:44 +00:00
|
|
|
@SuppressWarnings("unused")
|
2020-03-19 19:45:46 +00:00
|
|
|
@Mixin(RespawnAnchorBlock.class)
|
|
|
|
public class MixinRespawnAnchorBlock {
|
2020-06-24 22:48:38 +00:00
|
|
|
@Inject(at = @At("HEAD"), method = "isNether", cancellable = true)
|
|
|
|
private static void isNether(World world, CallbackInfoReturnable<Boolean> info) {
|
2020-03-19 19:45:46 +00:00
|
|
|
if (SlightlyVanilla.getConfig().useRespawnAnchorInAnyDimension) {
|
2020-06-24 22:48:38 +00:00
|
|
|
info.setReturnValue(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;getSpawnPointPosition()Lnet/minecraft/util/math/BlockPos;"), method = "onUse")
|
|
|
|
public BlockPos getSpawnPointPosition(ServerPlayerEntity serverPlayerEntity) {
|
|
|
|
if (SlightlyVanilla.getConfig().useRespawnAnchorInAnyDimension && serverPlayerEntity.getSpawnPointPosition() == null) {
|
|
|
|
return new BlockPos(0, 512, 0);
|
2020-03-19 19:45:46 +00:00
|
|
|
} else {
|
2020-06-24 22:48:38 +00:00
|
|
|
return serverPlayerEntity.getSpawnPointPosition();
|
2020-03-19 19:45:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|