use of net.minecraft.network.play.server.SPacketEffect in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class CallRunner method onSendToAllNearExcept.
/* public static boolean onSpawnEntityInWorld(World world, Entity entity) {
BlockPos posAt = new BlockPos(entity);
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, posAt);
if (!(entity instanceof EntityFallingBlock) && wrapper != null && wrapper.wrapping.coordTransform != null) {
if (entity instanceof EntityMountingWeaponBase || entity instanceof EntityArmorStand || entity instanceof EntityPig || entity instanceof EntityBoat) {
// entity.startRiding(wrapper);
wrapper.wrapping.fixEntity(entity, new Vector(entity));
wrapper.wrapping.queueEntityForMounting(entity);
}
RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, entity);
}
return world.spawnEntityInWorld(entity);
}*/
public static void onSendToAllNearExcept(PlayerList list, @Nullable EntityPlayer except, double x, double y, double z, double radius, int dimension, Packet<?> packetIn) {
BlockPos pos = new BlockPos(x, y, z);
World worldIn = null;
if (except == null) {
worldIn = DimensionManager.getWorld(dimension);
} else {
worldIn = except.worldObj;
}
PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
Vector packetPosition = new Vector(x, y, z);
if (wrapper != null && wrapper.wrapping.coordTransform != null) {
wrapper.wrapping.coordTransform.fromLocalToGlobal(packetPosition);
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);
}
}
x = packetPosition.X;
y = packetPosition.Y;
z = packetPosition.Z;
for (int i = 0; i < list.playerEntityList.size(); ++i) {
EntityPlayerMP entityplayermp = (EntityPlayerMP) list.playerEntityList.get(i);
if (entityplayermp != except && entityplayermp.dimension == dimension) {
// NOTE: These are set to use the last variables for a good reason; dont change them
double d0 = x - entityplayermp.posX;
double d1 = y - entityplayermp.posY;
double d2 = z - entityplayermp.posZ;
if (d0 * d0 + d1 * d1 + d2 * d2 < radius * radius) {
entityplayermp.connection.sendPacket(packetIn);
} else {
d0 = x - entityplayermp.lastTickPosX;
d1 = y - entityplayermp.lastTickPosY;
d2 = z - entityplayermp.lastTickPosZ;
if (d0 * d0 + d1 * d1 + d2 * d2 < radius * radius) {
entityplayermp.connection.sendPacket(packetIn);
}
}
}
}
}
use of net.minecraft.network.play.server.SPacketEffect in project SpongeCommon by SpongePowered.
the class SpongeRecordType method createPacket.
public static SPacketEffect createPacket(Vector3i position, @Nullable RecordType recordType) {
checkNotNull(position, "position");
final BlockPos pos = new BlockPos(position.getX(), position.getY(), position.getZ());
return new SPacketEffect(EFFECT_ID, pos, recordType == null ? 0 : ((SpongeRecordType) recordType).getInternalId(), false);
}
use of net.minecraft.network.play.server.SPacketEffect in project SpongeCommon by SpongePowered.
the class EntityUtil method teleportPlayerToDimension.
/**
* A relative copy paste of {@link EntityPlayerMP#changeDimension(int)} where instead we direct all processing
* to the appropriate areas for throwing events and capturing world changes during the transfer.
*
* @param mixinEntityPlayerMP The player being teleported
* @param suggestedDimensionId The suggested dimension
* @return The player object, not re-created
*/
@Nullable
public static Entity teleportPlayerToDimension(EntityPlayerMP entityPlayerMP, int suggestedDimensionId) {
// Fire teleport event here to support Forge's EntityTravelDimensionEvent
// This also prevents sending client wrong data if event is cancelled
WorldServer toWorld = SpongeImpl.getServer().getWorld(suggestedDimensionId);
MoveEntityEvent.Teleport.Portal event = EntityUtil.handleDisplaceEntityPortalEvent(entityPlayerMP, suggestedDimensionId, toWorld.getDefaultTeleporter());
if (event == null || event.isCancelled()) {
return entityPlayerMP;
}
entityPlayerMP.invulnerableDimensionChange = true;
boolean sameDimension = entityPlayerMP.dimension == suggestedDimensionId;
// If leaving The End via End's Portal
// Sponge Start - Check the provider, not the world's dimension
final WorldServer fromWorldServer = (WorldServer) event.getFromTransform().getExtent();
if (fromWorldServer.provider instanceof WorldProviderEnd && suggestedDimensionId == 1) {
// if (this.dimension == 1 && dimensionIn == 1)
// Sponge End
fromWorldServer.removeEntity(entityPlayerMP);
if (!entityPlayerMP.queuedEndExit) {
entityPlayerMP.queuedEndExit = true;
entityPlayerMP.connection.sendPacket(new SPacketChangeGameState(4, entityPlayerMP.seenCredits ? 0.0F : 1.0F));
entityPlayerMP.seenCredits = true;
}
return entityPlayerMP;
}
// else { // Sponge - Remove unecessary
final WorldServer toWorldServer = (WorldServer) event.getToTransform().getExtent();
// not being loaded then short-circuit to prevent unnecessary logic from running
if (!sameDimension && fromWorldServer == toWorldServer) {
return entityPlayerMP;
}
transferPlayerToDimension(event, entityPlayerMP);
entityPlayerMP.connection.sendPacket(new SPacketEffect(1032, BlockPos.ORIGIN, 0, false));
// Sponge End
return entityPlayerMP;
}
use of net.minecraft.network.play.server.SPacketEffect in project minecolonies by Minecolonies.
the class TeleportToColony method teleportPlayer.
/**
* Method used to teleport the player.
*
* @param colID the senders colony ID.
* @param playerToTeleport the player which shall be teleported.
*/
private static void teleportPlayer(final EntityPlayer playerToTeleport, final int colID, final ICommandSender sender) {
final Colony colony = ColonyManager.getColony(colID);
final BuildingTownHall townHall = colony.getBuildingManager().getTownHall();
if (townHall == null) {
sender.sendMessage(new TextComponentString(NO_TOWNHALL));
return;
}
playerToTeleport.sendMessage(new TextComponentString("We got places to go, kid..."));
final BlockPos position = townHall.getLocation();
final int dimension = playerToTeleport.getEntityWorld().provider.getDimension();
final int colonyDimension = townHall.getColony().getDimension();
if (colID < MIN_COLONY_ID) {
playerToTeleport.sendMessage(new TextComponentString(CANT_FIND_COLONY));
return;
}
final EntityPlayerMP entityPlayerMP = (EntityPlayerMP) sender;
if (dimension != colonyDimension) {
playerToTeleport.sendMessage(new TextComponentString("Buckle up buttercup, this ain't no joy ride!!!"));
final MinecraftServer server = sender.getEntityWorld().getMinecraftServer();
final WorldServer worldServer = server.getWorld(colonyDimension);
// Vanilla does that as well.
entityPlayerMP.connection.sendPacket(new SPacketEffect(SOUND_TYPE, BlockPos.ORIGIN, 0, false));
entityPlayerMP.addExperience(0);
entityPlayerMP.setPlayerHealthUpdated();
playerToTeleport.sendMessage(new TextComponentString("Hold onto your pants, we're going Inter-Dimensional!"));
worldServer.getMinecraftServer().getPlayerList().transferPlayerToDimension(entityPlayerMP, colonyDimension, new Teleporter(worldServer));
if (dimension == 1) {
worldServer.spawnEntity(playerToTeleport);
worldServer.updateEntityWithOptionalForce(playerToTeleport, false);
}
}
entityPlayerMP.connection.setPlayerLocation(position.getX(), position.getY() + 2.0, position.getZ(), entityPlayerMP.rotationYaw, entityPlayerMP.rotationPitch);
}
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;
}
Aggregations