Search in sources :

Example 1 with SPacketSoundEffect

use of net.minecraft.network.play.server.SPacketSoundEffect 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);
                }
            }
        }
    }
}
Also used : SPacketSoundEffect(net.minecraft.network.play.server.SPacketSoundEffect) SPacketEffect(net.minecraft.network.play.server.SPacketEffect) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) Vector(ValkyrienWarfareBase.API.Vector)

Aggregations

Vector (ValkyrienWarfareBase.API.Vector)1 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 SPacketEffect (net.minecraft.network.play.server.SPacketEffect)1 SPacketSoundEffect (net.minecraft.network.play.server.SPacketSoundEffect)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1