package party._2a03.mc.mixin; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.GameMode; import net.minecraft.world.World; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import party._2a03.mc.util.Config; import party._2a03.mc.util.PlayerPosition; @Mixin(ServerPlayerEntity.class) public abstract class MixinServerPlayerEntity extends PlayerEntity { @Shadow private RegistryKey spawnPointDimension; public MixinServerPlayerEntity() { super(null, null, 0, null); } @Inject(method = "moveToSpawn", at = @At("HEAD"), cancellable = true) private void OnServerPlayerSpawn(CallbackInfo ci) { PlayerPosition position = new PlayerPosition(Config.getData("spawn")); if (position.registrykey == this.spawnPointDimension) { this.updatePositionAndAngles(position.x, position.y, position.z, position.yaw, position.pitch); ci.cancel(); } } /*@Inject(method = "setGameMode", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/network/ServerPlayerEntity;sendAbilitiesUpdate()V")) public void disableFlightIfSafe(GameMode gameMode, CallbackInfo ci) { if (gameMode != GameMode.CREATIVE && gameMode != GameMode.SPECTATOR) { this.abilities.allowFlying = false; this.abilities.flying = false; } }*/ }