Start migration

This commit is contained in:
Aleksey 2021-04-08 21:55:07 +03:00
parent 6630ce0cab
commit 47ed597358
491 changed files with 12045 additions and 11953 deletions

View file

@ -10,9 +10,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.Entity;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.effect.StatusEffectInstance;
import net.minecraft.world.entity.player.PlayerEntity;
import net.minecraft.network.packet.s2c.play.DifficultyS2CPacket;
import net.minecraft.network.packet.s2c.play.EntityStatusEffectS2CPacket;
import net.minecraft.network.packet.s2c.play.PlayerAbilitiesS2CPacket;
@ -21,19 +21,19 @@ import net.minecraft.network.packet.s2c.play.WorldEventS2CPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerPlayerInteractionManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.TeleportTarget;
import net.minecraft.world.World;
import net.minecraft.world.level.Level;
import net.minecraft.world.WorldProperties;
import net.minecraft.world.biome.source.BiomeAccess;
import ru.betterend.interfaces.TeleportingEntity;
import ru.betterend.world.generator.GeneratorOptions;
@Mixin(ServerPlayerEntity.class)
@Mixin(ServerPlayer.class)
public abstract class ServerPlayerEntityMixin extends PlayerEntity implements TeleportingEntity {
@Shadow
@ -55,34 +55,38 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Te
private BlockPos exitPos;
public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile profile) {
public ServerPlayerEntityMixin(Level world, BlockPos pos, float yaw, GameProfile profile) {
super(world, pos, yaw, profile);
}
@Inject(method = "createEndSpawnPlatform", at = @At("HEAD"), cancellable = true)
private void be_createEndSpawnPlatform(ServerWorld world, BlockPos centerPos, CallbackInfo info) {
private void be_createEndSpawnPlatform(ServerLevel world, BlockPos centerPos, CallbackInfo info) {
if (!GeneratorOptions.generateObsidianPlatform()) {
info.cancel();
}
}
@Inject(method = "getTeleportTarget", at = @At("HEAD"), cancellable = true)
protected void be_getTeleportTarget(ServerWorld destination, CallbackInfoReturnable<TeleportTarget> info) {
protected void be_getTeleportTarget(ServerLevel destination, CallbackInfoReturnable<TeleportTarget> info) {
if (beCanTeleport()) {
info.setReturnValue(new TeleportTarget(new Vec3d(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getVelocity(), yaw, pitch));
info.setReturnValue(new TeleportTarget(
new Vec3d(exitPos.getX() + 0.5, exitPos.getY(), exitPos.getZ() + 0.5), getVelocity(), yaw, pitch));
}
}
@Inject(method = "moveToWorld", at = @At("HEAD"), cancellable = true)
public void be_moveToWorld(ServerWorld destination, CallbackInfoReturnable<Entity> info) {
if (beCanTeleport() && world instanceof ServerWorld) {
public void be_moveToWorld(ServerLevel destination, CallbackInfoReturnable<Entity> info) {
if (beCanTeleport() && world instanceof ServerLevel) {
this.inTeleportationState = true;
ServerWorld serverWorld = this.getServerWorld();
ServerLevel serverWorld = this.getServerWorld();
WorldProperties worldProperties = destination.getLevelProperties();
ServerPlayerEntity player = ServerPlayerEntity.class.cast(this);
this.networkHandler.sendPacket(new PlayerRespawnS2CPacket(destination.getDimension(), destination.getRegistryKey(), BiomeAccess.hashSeed(destination.getSeed()),
interactionManager.getGameMode(),interactionManager.getPreviousGameMode(), destination.isDebugWorld(), destination.isFlat(), true));
this.networkHandler.sendPacket(new DifficultyS2CPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked()));
ServerPlayer player = ServerPlayer.class.cast(this);
this.networkHandler.sendPacket(new PlayerRespawnS2CPacket(destination.getDimension(),
destination.dimension(), BiomeAccess.hashSeed(destination.getSeed()),
interactionManager.getGameMode(), interactionManager.getPreviousGameMode(),
destination.isDebugWorld(), destination.isFlat(), true));
this.networkHandler.sendPacket(
new DifficultyS2CPacket(worldProperties.getDifficulty(), worldProperties.isDifficultyLocked()));
PlayerManager playerManager = this.server.getPlayerManager();
playerManager.sendCommandTree(player);
serverWorld.removePlayer(player);
@ -95,7 +99,8 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Te
this.setWorld(destination);
destination.onPlayerChangeDimension(player);
this.setRotation(teleportTarget.yaw, teleportTarget.pitch);
this.refreshPositionAfterTeleport(teleportTarget.position.x, teleportTarget.position.y, teleportTarget.position.z);
this.refreshPositionAfterTeleport(teleportTarget.position.x, teleportTarget.position.y,
teleportTarget.position.z);
serverWorld.getProfiler().pop();
this.worldChanged(serverWorld);
this.interactionManager.setWorld(destination);
@ -104,7 +109,8 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Te
playerManager.sendPlayerStatus(player);
for (StatusEffectInstance statusEffectInstance : this.getStatusEffects()) {
this.networkHandler.sendPacket(new EntityStatusEffectS2CPacket(getEntityId(), statusEffectInstance));
this.networkHandler
.sendPacket(new EntityStatusEffectS2CPacket(getEntityId(), statusEffectInstance));
}
this.networkHandler.sendPacket(new WorldEventS2CPacket(1032, BlockPos.ORIGIN, 0, false));
@ -118,14 +124,14 @@ public abstract class ServerPlayerEntityMixin extends PlayerEntity implements Te
}
@Shadow
abstract ServerWorld getServerWorld();
abstract ServerLevel getServerWorld();
@Shadow
abstract void worldChanged(ServerWorld origin);
abstract void worldChanged(ServerLevel origin);
@Shadow
@Override
protected abstract TeleportTarget getTeleportTarget(ServerWorld destination);
protected abstract TeleportTarget getTeleportTarget(ServerLevel destination);
@Override
public void beSetExitPos(BlockPos pos) {