use of net.minecraft.network.play.server.SPacketEffect in project Wurst-MC-1.12 by Wurst-Imperium.
the class PlayerFinderMod method onReceivedPacket.
@Override
public void onReceivedPacket(PacketInputEvent event) {
if (WMinecraft.getPlayer() == null)
return;
Packet packet = event.getPacket();
// get packet position
BlockPos newPos = null;
if (packet instanceof SPacketEffect) {
SPacketEffect effect = (SPacketEffect) packet;
newPos = effect.getSoundPos();
} else if (packet instanceof SPacketSoundEffect) {
SPacketSoundEffect sound = (SPacketSoundEffect) packet;
newPos = new BlockPos(sound.getX(), sound.getY(), sound.getZ());
} else if (packet instanceof SPacketSpawnGlobalEntity) {
SPacketSpawnGlobalEntity lightning = (SPacketSpawnGlobalEntity) packet;
newPos = new BlockPos(lightning.getX() / 32D, lightning.getY() / 32D, lightning.getZ() / 32D);
}
if (newPos == null)
return;
// check distance to player
BlockPos playerPos = new BlockPos(WMinecraft.getPlayer());
if (Math.abs(playerPos.getX() - newPos.getX()) > 250 || Math.abs(playerPos.getZ() - newPos.getZ()) > 250)
pos = newPos;
}
use of net.minecraft.network.play.server.SPacketEffect in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class VSNetwork method sendToAllNearExcept.
public static void sendToAllNearExcept(@Nullable EntityPlayer except, double x, double y, double z, double radius, int dimension, Packet<?> packetIn) {
BlockPos pos = new BlockPos(x, y, z);
World worldIn;
if (except == null) {
worldIn = DimensionManager.getWorld(dimension);
} else {
worldIn = except.world;
}
Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(worldIn, pos);
Vector3d packetPosition = new Vector3d(x, y, z);
if (physicsObject.isPresent()) {
physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(packetPosition, TransformType.SUBSPACE_TO_GLOBAL);
// Special treatment for certain packets.
if (packetIn instanceof SPacketSoundEffect) {
SPacketSoundEffect soundEffect = (SPacketSoundEffect) packetIn;
packetIn = new SPacketSoundEffect(soundEffect.sound, soundEffect.category, packetPosition.x, packetPosition.y, packetPosition.z, soundEffect.soundVolume, soundEffect.soundPitch);
}
if (packetIn instanceof SPacketEffect) {
SPacketEffect effect = (SPacketEffect) packetIn;
BlockPos blockpos = new BlockPos(packetPosition.x, packetPosition.y, packetPosition.z);
packetIn = new SPacketEffect(effect.soundType, blockpos, effect.soundData, effect.serverWide);
}
}
List<EntityPlayer> playerEntityList = ((WorldServer) worldIn).playerEntities;
// Original method here.
for (int i = 0; i < playerEntityList.size(); ++i) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) playerEntityList.get(i);
if (entityplayermp != except && entityplayermp.dimension == dimension) {
double d0 = x - entityplayermp.posX;
double d1 = y - entityplayermp.posY;
double d2 = z - entityplayermp.posZ;
double d3 = packetPosition.x - entityplayermp.posX;
double d4 = packetPosition.y - entityplayermp.posY;
double d5 = packetPosition.z - entityplayermp.posZ;
// Cover both cases; if player is in ship space or if player is in world space.
if ((d0 * d0 + d1 * d1 + d2 * d2 < radius * radius) || (d3 * d3 + d4 * d4 + d5 * d5 < radius * radius)) {
entityplayermp.connection.sendPacket(packetIn);
}
}
}
}
use of net.minecraft.network.play.server.SPacketEffect in project SpongeForge by SpongePowered.
the class EntityPlayerMPMixin_Forge method changeDimension.
/**
* @author Zidane - June 2019 - 1.12.2
* @reason Re-route dimension changes to common hook
*/
@Nullable
@Overwrite(remap = false)
public net.minecraft.entity.Entity changeDimension(final int toDimensionId, final ITeleporter teleporter) {
if (!net.minecraftforge.common.ForgeHooks.onTravelToDimension((EntityPlayerMP) (Object) this, toDimensionId)) {
return (EntityPlayerMP) (Object) this;
}
this.invulnerableDimensionChange = true;
if (this.dimension == 0 && toDimensionId == -1) {
this.enteredNetherPosition = new Vec3d(this.posX, this.posY, this.posZ);
} else if (this.dimension != -1 && toDimensionId != 0) {
this.enteredNetherPosition = null;
}
if (this.dimension == 1 && toDimensionId == 1 && teleporter.isVanilla()) {
this.world.removeEntity((EntityPlayerMP) (Object) this);
if (!this.queuedEndExit) {
this.queuedEndExit = true;
this.connection.sendPacket(new SPacketChangeGameState(4, this.seenCredits ? 0.0F : 1.0F));
this.seenCredits = true;
}
return (EntityPlayerMP) (Object) this;
} else {
// this.server.getPlayerList().transferPlayerToDimension(this, dimensionIn, teleporter);
if (EntityUtil.transferPlayerToWorld((EntityPlayerMP) (Object) this, null, this.server.getWorld(toDimensionId), (ForgeITeleporterBridge) teleporter) != null) {
// Sponge end
this.connection.sendPacket(new SPacketEffect(1032, BlockPos.ORIGIN, 0, false));
this.lastExperience = -1;
this.lastHealth = -1.0F;
this.lastFoodLevel = -1;
} else {
this.invulnerableDimensionChange = false;
}
return (EntityPlayerMP) (Object) this;
}
}
Aggregations