use of net.minecraft.network.protocol.game.ClientboundLevelEventPacket in project SpongeCommon by SpongePowered.
the class ServerPlayerMixin method impl$postPortalForceChangeTasks.
@Override
protected final void impl$postPortalForceChangeTasks(final Entity entity, final net.minecraft.server.level.ServerLevel targetWorld, final boolean isNetherPortal) {
// Standard vanilla processing
this.gameMode.setLevel(targetWorld);
this.connection.send(new ClientboundPlayerAbilitiesPacket(this.abilities));
final PlayerList playerlist = this.server.getPlayerList();
playerlist.sendLevelInfo((net.minecraft.server.level.ServerPlayer) (Object) this, targetWorld);
playerlist.sendAllPlayerInfo((net.minecraft.server.level.ServerPlayer) (Object) this);
// Sponge Start: teleport here after all data is sent to avoid any potential "stuttering" due to slow packets.
final net.minecraft.world.phys.Vec3 finalPos = this.shadow$position();
this.shadow$moveTo(finalPos.x, finalPos.y, finalPos.z);
for (final MobEffectInstance effectinstance : this.shadow$getActiveEffects()) {
this.connection.send(new ClientboundUpdateMobEffectPacket(this.shadow$getId(), effectinstance));
}
if (isNetherPortal) {
// Sponge: only play the sound if we've got a vanilla teleporter that reports a nether portal
this.connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false));
}
// Sponge: end if
this.lastSentExp = -1;
this.lastSentHealth = -1.0F;
this.lastSentFood = -1;
}
use of net.minecraft.network.protocol.game.ClientboundLevelEventPacket in project SpongeCommon by SpongePowered.
the class EntityUtil method performPostChangePlayerWorldLogic.
public static void performPostChangePlayerWorldLogic(final ServerPlayer player, final ServerLevel fromWorld, final ServerLevel originalToWorld, final ServerLevel toWorld, final boolean isPortal) {
// Sponge Start - Send any platform dimension data
((ServerPlayerBridge) player).bridge$sendDimensionData(player.connection.connection, toWorld.dimensionType(), toWorld.dimension());
// Sponge End
final LevelData worldinfo = toWorld.getLevelData();
// We send dimension change for portals before loading chunks
if (!isPortal) {
// Sponge Start - Allow the platform to handle how dimension changes are sent down
((ServerPlayerBridge) player).bridge$sendChangeDimension(toWorld.dimensionType(), toWorld.dimension(), BiomeManager.obfuscateSeed(toWorld.getSeed()), player.gameMode.getGameModeForPlayer(), player.gameMode.getPreviousGameModeForPlayer(), toWorld.isDebug(), toWorld.isFlat(), true);
}
// Sponge End
player.connection.send(new ClientboundChangeDifficultyPacket(worldinfo.getDifficulty(), worldinfo.isDifficultyLocked()));
final PlayerList playerlist = player.getServer().getPlayerList();
playerlist.sendPlayerPermissionLevel(player);
// Sponge Start - Have the platform handle removing the entity from the world. Move this to after the event call so
// that we do not remove the player from the world unless we really have teleported..
((PlatformServerLevelBridge) fromWorld).bridge$removeEntity(player, true);
((PlatformEntityBridge) player).bridge$revive();
// Sponge End
player.setLevel(toWorld);
toWorld.addDuringPortalTeleport(player);
if (isPortal) {
((ServerPlayerAccessor) player).invoker$triggerDimensionChangeTriggers(toWorld);
}
player.gameMode.setLevel(toWorld);
player.connection.send(new ClientboundPlayerAbilitiesPacket(player.abilities));
playerlist.sendLevelInfo(player, toWorld);
playerlist.sendAllPlayerInfo(player);
for (final MobEffectInstance effectinstance : player.getActiveEffects()) {
player.connection.send(new ClientboundUpdateMobEffectPacket(player.getId(), effectinstance));
}
if (isPortal) {
player.connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false));
}
((ServerLevelBridge) fromWorld).bridge$getBossBarManager().onPlayerDisconnect(player);
((ServerLevelBridge) toWorld).bridge$getBossBarManager().onPlayerDisconnect(player);
((ServerPlayerAccessor) player).accessor$lastSentExp(-1);
((ServerPlayerAccessor) player).accessor$lastSentHealth(-1.0f);
((ServerPlayerAccessor) player).accessor$lastSentFood(-1);
if (!isPortal) {
player.connection.teleport(player.getX(), player.getY(), player.getZ(), player.yRot, player.xRot);
player.connection.resetPosition();
}
if (player.containerMenu != player.inventoryMenu) {
player.closeContainer();
}
// Sponge Start - Call event
Sponge.eventManager().post(SpongeEventFactory.createChangeEntityWorldEventPost(PhaseTracker.getCauseStackManager().currentCause(), (org.spongepowered.api.entity.Entity) player, (ServerWorld) fromWorld, (ServerWorld) originalToWorld, (ServerWorld) toWorld));
// Sponge End
}
use of net.minecraft.network.protocol.game.ClientboundLevelEventPacket in project SpongeCommon by SpongePowered.
the class SpongeMusicDisc method createPacket.
public static ClientboundLevelEventPacket createPacket(final Vector3i position, @Nullable final MusicDisc recordType) {
checkNotNull(position, "position");
final BlockPos pos = new BlockPos(position.x(), position.y(), position.z());
return new ClientboundLevelEventPacket(SpongeMusicDisc.EFFECT_ID, pos, recordType == null ? 0 : ((SpongeMusicDisc) recordType).getId(), false);
}
Aggregations