use of pneumaticCraft.common.network.PacketSpawnParticle in project PneumaticCraft by MineMaarten.
the class BlockEnderPlant method executeFullGrownEffect.
@Override
public void executeFullGrownEffect(World world, int x, int y, int z, Random rand) {
if (!world.isRemote) {
for (int i = 0; i < 50; i++) {
int randX = x + rand.nextInt(30) - 15;
int randY = y + rand.nextInt(8);
int randZ = z + rand.nextInt(30) - 15;
Block block = world.getBlock(randX, randY, randZ);
if (!block.getMaterial().blocksMovement()) {
ItemStack seed = new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.ENDER_PLANT_DAMAGE);
EntityItem plant = new EntityItem(world, randX + 0.5D, randY + 0.5D, randZ + 0.5D, seed);
// plant.motionX = plant.motionY = plant.motionZ = 0;
plant.lifespan = 300;
ItemPlasticPlants.markInactive(plant);
world.spawnEntityInWorld(plant);
plant.playSound("mob.endermen.portal", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
short short1 = 128;
for (int j = 0; j < short1; ++j) {
double d6 = j / (short1 - 1.0D);
float f = (rand.nextFloat() - 0.5F) * 0.2F;
float f1 = (rand.nextFloat() - 0.5F) * 0.2F;
float f2 = (rand.nextFloat() - 0.5F) * 0.2F;
double d7 = x + 0.5D + (plant.posX - (x + 0.5D)) * d6 + (rand.nextDouble() - 0.5D);
double d8 = y + 0.5D + (plant.posY - (y + 0.5D)) * d6 + rand.nextDouble();
double d9 = z + 0.5D + (plant.posZ - (z + 0.5D)) * d6 + (rand.nextDouble() - 0.5D);
NetworkHandler.sendToAllAround(new PacketSpawnParticle("portal", d7, d8, d9, f, f1, f2), world);
}
world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 2, 3);
break;
}
}
}
}
use of pneumaticCraft.common.network.PacketSpawnParticle in project PneumaticCraft by MineMaarten.
the class EntityPathNavigateDrone method teleport.
public void teleport() {
Random rand = pathfindingEntity.getRNG();
double width = pathfindingEntity.width;
double height = pathfindingEntity.height;
short short1 = 128;
for (int l = 0; l < short1; ++l) {
double d6 = l / (short1 - 1.0D);
float f = (rand.nextFloat() - 0.5F) * 0.2F;
float f1 = (rand.nextFloat() - 0.5F) * 0.2F;
float f2 = (rand.nextFloat() - 0.5F) * 0.2F;
double d7 = pathfindingEntity.posX + (telX + 0.5 - pathfindingEntity.posX) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D;
double d8 = pathfindingEntity.posY + (telY - pathfindingEntity.posY) * d6 + rand.nextDouble() * height;
double d9 = pathfindingEntity.posZ + (telZ + 0.5 - pathfindingEntity.posZ) * d6 + (rand.nextDouble() - 0.5D) * width * 2.0D;
NetworkHandler.sendToAllAround(new PacketSpawnParticle("portal", d7, d8, d9, f, f1, f2), pathfindingEntity.worldObj);
}
pathfindingEntity.worldObj.playSoundEffect(pathfindingEntity.posX, pathfindingEntity.posY, pathfindingEntity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
pathfindingEntity.playSound("mob.endermen.portal", 1.0F, 1.0F);
pathfindingEntity.setPosition(telX + 0.5, telY + 0.5, telZ + 0.5);
}
use of pneumaticCraft.common.network.PacketSpawnParticle in project PneumaticCraft by MineMaarten.
the class EntityPathNavigateDrone method onUpdateNavigation.
@Override
public void onUpdateNavigation() {
if (isGoingToTeleport()) {
if (teleportCounter == 0 || teleportCounter == 60) {
NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.HUD_INIT, pathfindingEntity.posX, pathfindingEntity.posY, pathfindingEntity.posZ, 0.1F, teleportCounter == 0 ? 0.7F : 1F, true), pathfindingEntity.worldObj);
}
if (teleportCounter < TELEPORT_TICKS - 40) {
Random rand = pathfindingEntity.getRNG();
float f = (rand.nextFloat() - 0.5F) * 0.02F * teleportCounter;
float f1 = (rand.nextFloat() - 0.5F) * 0.02F * teleportCounter;
float f2 = (rand.nextFloat() - 0.5F) * 0.02F * teleportCounter;
NetworkHandler.sendToAllAround(new PacketSpawnParticle("portal", pathfindingEntity.posX, pathfindingEntity.posY, pathfindingEntity.posZ, f, f1, f2), pathfindingEntity.worldObj);
}
if (++teleportCounter > TELEPORT_TICKS) {
if (pathfindingEntity.isBlockValidPathfindBlock(telX, telY, telZ)) {
teleport();
}
teleportCounter = -1;
setPath(null, 0);
pathfindingEntity.getMoveHelper().setMoveTo(telX, telY, telZ, pathfindingEntity.getSpeed());
pathfindingEntity.addAir(null, -10000);
}
} else {
super.onUpdateNavigation();
}
}
use of pneumaticCraft.common.network.PacketSpawnParticle in project PneumaticCraft by MineMaarten.
the class TileEntityPneumaticBase method airLeak.
/**
* Method to release air in the air. It takes air from a specific side, plays a sound effect, and spawns smoke particles.
* @param side
*/
@Override
public void airLeak(ForgeDirection side) {
if (worldObj.isRemote || Math.abs(getPressure(side)) < 0.01F)
return;
double motionX = side.offsetX;
double motionY = side.offsetY;
double motionZ = side.offsetZ;
if (soundCounter <= 0) {
soundCounter = 20;
NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.LEAKING_GAS_SOUND, xCoord, yCoord, zCoord, 0.1F, 1.0F, true), worldObj);
}
if (getPressure(side) < 0) {
double speed = getPressure(side) * 0.1F - 0.1F;
NetworkHandler.sendToAllAround(new PacketSpawnParticle("smoke", xCoord + 0.5D + motionX / 2D, yCoord + 0.5D + motionY / 2D, zCoord + 0.5D + motionZ / 2D, motionX * speed, motionY * speed, motionZ * speed), worldObj);
int dispersedAmount = -(int) (getPressure(side) * PneumaticValues.AIR_LEAK_FACTOR) + 20;
if (getCurrentAir(side) > dispersedAmount)
dispersedAmount = -getCurrentAir(side);
onAirDispersion(dispersedAmount, side);
addAir(dispersedAmount, side);
} else {
double speed = getPressure(side) * 0.1F + 0.1F;
// if(DateEventHandler.isEvent()) {
// DateEventHandler.spawnFirework(worldObj, xCoord + 0.5D + motionX / 2D, yCoord + 0.5D + motionY / 2D, zCoord + 0.5D + motionZ / 2D);
// } else {
NetworkHandler.sendToAllAround(new PacketSpawnParticle("smoke", xCoord + 0.5D + motionX / 2D, yCoord + 0.5D + motionY / 2D, zCoord + 0.5D + motionZ / 2D, motionX * speed, motionY * speed, motionZ * speed), worldObj);
// }
int dispersedAmount = (int) (getPressure(side) * PneumaticValues.AIR_LEAK_FACTOR) + 20;
if (dispersedAmount > getCurrentAir(side))
dispersedAmount = getCurrentAir(side);
onAirDispersion(-dispersedAmount, side);
addAir(-dispersedAmount, side);
}
}
use of pneumaticCraft.common.network.PacketSpawnParticle in project PneumaticCraft by MineMaarten.
the class TileEntityAirCannon method fire.
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;
}
}
Aggregations