cpw.mods.fml.common.network.NetworkRegistry.TargetPoint Java Examples

The following examples show how to use cpw.mods.fml.common.network.NetworkRegistry.TargetPoint. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
public void entityHurtEvent(LivingHurtEvent event) {
	if (!EtFuturum.enableDmgIndicator)
		return;
	int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F);
	if (amount <= 0)
		return;

	// If the attacker is a player spawn the hearts aligned and facing it
	if (event.source instanceof EntityDamageSource) {
		EntityDamageSource src = (EntityDamageSource) event.source;
		Entity attacker = src.getSourceOfDamage();
		if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) {
			EntityPlayer player = (EntityPlayer) attacker;
			Vec3 look = player.getLookVec();
			look.rotateAroundY((float) Math.PI / 2);
			for (int i = 0; i < amount; i++) {
				double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord;
				double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05;
				double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord;
				EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64));
			}
		}
	}
}
 
Example #2
Source File: ShipHandlerServer.java    From archimedes-ships with MIT License 6 votes vote down vote up
@Override
public void onChunkUpdate()
{
	super.onChunkUpdate();
	Collection<ChunkPosition> list = ((MobileChunkServer) ship.getShipChunk()).getSendQueue();
	if (firstChunkUpdate)
	{
		ship.getCapabilities().spawnSeatEntities();
	} else
	{
		MsgChunkBlockUpdate msg = new MsgChunkBlockUpdate(ship, list);
		ArchimedesShipMod.instance.pipeline.sendToAllAround(msg, new TargetPoint(ship.worldObj.provider.dimensionId, ship.posX, ship.posY, ship.posZ, 64D));
	}
	list.clear();
	firstChunkUpdate = false;
}
 
Example #3
Source File: LivingTickHandler.java    From SimplyJetpacks with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onLivingTick(LivingUpdateEvent evt) {
    if (!evt.entityLiving.worldObj.isRemote) {
        ParticleType jetpackState = null;
        ItemStack armor = evt.entityLiving.getEquipmentInSlot(3);
        Jetpack jetpack = null;
        if (armor != null && armor.getItem() instanceof ItemJetpack) {
            jetpack = ((ItemJetpack) armor.getItem()).getPack(armor);
            if (jetpack != null) {
                jetpackState = jetpack.getDisplayParticleType(armor, (ItemJetpack) armor.getItem(), evt.entityLiving);
            }
        }
        
        if (jetpackState != lastJetpackState.get(evt.entityLiving.getEntityId())) {
            if (jetpackState == null) {
                lastJetpackState.remove(evt.entityLiving.getEntityId());
            } else {
                lastJetpackState.put(evt.entityLiving.getEntityId(), jetpackState);
            }
            PacketHandler.instance.sendToAllAround(new MessageJetpackSync(evt.entityLiving.getEntityId(), jetpackState != null ? jetpackState.ordinal() : -1), new TargetPoint(evt.entityLiving.dimension, evt.entityLiving.posX, evt.entityLiving.posY, evt.entityLiving.posZ, 256));
        } else if (jetpack != null && evt.entityLiving.worldObj.getTotalWorldTime() % 160L == 0) {
            PacketHandler.instance.sendToAllAround(new MessageJetpackSync(evt.entityLiving.getEntityId(), jetpackState != null ? jetpackState.ordinal() : -1), new TargetPoint(evt.entityLiving.dimension, evt.entityLiving.posX, evt.entityLiving.posY, evt.entityLiving.posZ, 256));
        }
        
        if (evt.entityLiving.worldObj.getTotalWorldTime() % 200L == 0) {
            Iterator<Integer> itr = lastJetpackState.keySet().iterator();
            while (itr.hasNext()) {
                int entityId = itr.next();
                if (evt.entityLiving.worldObj.getEntityByID(entityId) == null) {
                    itr.remove();
                }
            }
        }
    }
}
 
Example #4
Source File: TileEntityAntibuilder.java    From Artifacts with MIT License 5 votes vote down vote up
protected void drawParticleLine(double srcX, double srcY, double srcZ, double destX, double destY, double destZ)
 {
 	if(this.worldObj.isRemote) {
 		return;
 	}
 	
 	int particles = 16;
 	int r = worldObj.rand.nextInt(8);
 	for (int i = 0; i < particles; i++)
 	{
 		double trailFactor = i / (particles - 1.0D);

 		double tx = srcX + (destX - srcX) * trailFactor + rand.nextFloat() * 0.005D;
 		double ty = srcY + (destY - srcY) * trailFactor + rand.nextFloat() * 0.005D;
 		double tz = srcZ + (destZ - srcZ) * trailFactor + rand.nextFloat() * 0.005D;
try
{
	PacketBuffer out = new PacketBuffer(Unpooled.buffer());
	out.writeInt(PacketHandlerClient.ANTI_BUILDER);
	out.writeDouble(tx);
	out.writeDouble(ty);
	out.writeDouble(tz);
	out.writeInt(i-r);
	SToCMessage packet = new SToCMessage(out);
	DragonArtifacts.artifactNetworkWrapper.sendToAllAround(packet, new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 32));
}
catch (Exception ex)
{
	ex.printStackTrace();
	System.out.println("couldnt send packet!");
}
 		//worldObj.spawnParticle("reddust", tx, ty, tz, 0.0D, 0.0D, 0.0D);
 		//Minecraft.getMinecraft().effectRenderer.addEffect(new RadarParticle(worldObj, tx, ty, tz, 3, 20));
 	}
 }
 
Example #5
Source File: NetworkHandler.java    From AdvancedMod with GNU General Public License v3.0 4 votes vote down vote up
public static void sendToAllAround(IMessage message, TargetPoint point){
    INSTANCE.sendToAllAround(message, point);
}
 
Example #6
Source File: TileEntityAirCannon.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
private synchronized boolean fire(){
    Entity itemShot = getCloseEntityIfUpgraded();
    if(getPressure(ForgeDirection.UNKNOWN) >= PneumaticValues.MIN_PRESSURE_AIR_CANNON && (itemShot != null || inventory[0] != null)) {
        double[] velocity = getVelocityVector(heightAngle, rotationAngle, getForce());
        addAir((int)(-500 * getForce()), ForgeDirection.UNKNOWN);
        boolean shootingInventory = false;
        if(itemShot == null) {
            shootingInventory = true;
            itemShot = getPayloadEntity();

            if(itemShot instanceof EntityItem) {
                inventory[0] = null;
                if(getUpgrades(ItemMachineUpgrade.UPGRADE_BLOCK_TRACKER) > 0) {
                    trackedItems.add((EntityItem)itemShot);
                }
            } else {
                inventory[0].stackSize--;
                if(inventory[0].stackSize <= 0) inventory[0] = null;
            }
        } else if(itemShot instanceof EntityPlayer) {
            EntityPlayerMP entityplayermp = (EntityPlayerMP)itemShot;
            if(entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen()) {
                entityplayermp.setPositionAndUpdate(xCoord + 0.5D, yCoord + 1.8D, zCoord + 0.5D);
            }
        }

        if(itemShot.isRiding()) {
            itemShot.mountEntity((Entity)null);
        }

        itemShot.setPosition(xCoord + 0.5D, yCoord + 1.8D, zCoord + 0.5D);
        NetworkHandler.sendToAllAround(new PacketSetEntityMotion(itemShot, velocity[0], velocity[1], velocity[2]), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, 64));

        if(itemShot instanceof EntityFireball) {
            velocity[0] *= 0.05D;
            velocity[1] *= 0.05D;
            velocity[2] *= 0.05D;
        }

        itemShot.motionX = velocity[0];
        itemShot.motionY = velocity[1];
        itemShot.motionZ = velocity[2];

        itemShot.onGround = false;
        itemShot.isCollided = false;
        itemShot.isCollidedHorizontally = false;
        itemShot.isCollidedVertically = false;
        if(itemShot instanceof EntityLivingBase) ((EntityLivingBase)itemShot).setJumping(true);

        if(shootingInventory && !worldObj.isRemote) worldObj.spawnEntityInWorld(itemShot);

        for(int i = 0; i < 10; i++) {
            double velX = velocity[0] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
            double velY = velocity[1] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
            double velZ = velocity[2] * 0.4D + (rand.nextGaussian() - 0.5D) * 0.05D;
            NetworkHandler.sendToAllAround(new PacketSpawnParticle("largesmoke", xCoord + 0.5D, yCoord + 0.7D, zCoord + 0.5D, velX, velY, velZ), worldObj);
        }
        NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.CANNON_SOUND, xCoord, yCoord, zCoord, 1.0F, rand.nextFloat() / 4F + 0.75F, true), worldObj);
        return true;
    } else {
        return false;
    }
}
 
Example #7
Source File: TileEntityBase.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
public void sendDescPacket(double maxPacketDistance){
    NetworkHandler.sendToAllAround(new PacketDescription(this), new TargetPoint(worldObj.provider.dimensionId, xCoord, yCoord, zCoord, maxPacketDistance));
}
 
Example #8
Source File: NetworkHandler.java    From AdvancedMod with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Will send the given packet to every player within 64 blocks of the XYZ of the XYZ packet.
 * @param message
 * @param world
 */
public static void sendToAllAround(MessageXYZ message, World world){
    INSTANCE.sendToAllAround(message, new TargetPoint(world.provider.dimensionId, message.x, message.y, message.z, 64D));
}