2020-01-18 20:00:24 +00:00
|
|
|
package party._2a03.mc.mixin;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.PlayerEntity;
|
|
|
|
import net.minecraft.server.network.ServerPlayerEntity;
|
2020-06-24 20:07:12 +00:00
|
|
|
import net.minecraft.util.registry.RegistryKey;
|
|
|
|
import net.minecraft.world.World;
|
2020-01-18 20:00:24 +00:00
|
|
|
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;
|
2020-06-24 20:07:12 +00:00
|
|
|
import org.spongepowered.asm.mixin.Shadow;
|
2020-08-17 01:22:31 +00:00
|
|
|
import party._2a03.mc.util.Config;
|
|
|
|
import party._2a03.mc.util.PlayerPosition;
|
2020-01-18 20:00:24 +00:00
|
|
|
|
|
|
|
@Mixin(ServerPlayerEntity.class)
|
|
|
|
public abstract class MixinServerPlayerEntity extends PlayerEntity {
|
2020-06-24 20:07:12 +00:00
|
|
|
@Shadow
|
|
|
|
private RegistryKey<World> spawnPointDimension;
|
|
|
|
|
2020-01-18 20:00:24 +00:00
|
|
|
public MixinServerPlayerEntity() {
|
2020-06-24 20:07:12 +00:00
|
|
|
super(null, null, null);
|
2020-01-18 20:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Inject(method = "moveToSpawn", at = @At("HEAD"), cancellable = true)
|
|
|
|
private void OnServerPlayerSpawn(CallbackInfo ci) {
|
|
|
|
PlayerPosition position = new PlayerPosition(Config.getData("spawn"));
|
2020-06-24 20:07:12 +00:00
|
|
|
if (position.registrykey == this.spawnPointDimension) {
|
2020-05-29 07:26:18 +00:00
|
|
|
this.updatePositionAndAngles(position.x, position.y, position.z, position.yaw, position.pitch);
|
2020-01-18 20:00:24 +00:00
|
|
|
ci.cancel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|