use of pneumaticCraft.common.network.PacketPlaySound 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.PacketPlaySound in project PneumaticCraft by MineMaarten.
the class BlockCreeperPlant method executeFullGrownEffect.
@Override
public void executeFullGrownEffect(World world, int x, int y, int z, Random rand) {
if (world.getBlockMetadata(x, y, z) == 14) {
if (!world.isRemote) {
world.createExplosion(null, x + 0.5D, y + 0.5D, z + 0.5D, 0.5F, false);
EntityItem item = new EntityItem(world, x + 0.5D, y + 0.5D, z + 0.5D, new ItemStack(Itemss.plasticPlant, 1, ItemPlasticPlants.CREEPER_PLANT_DAMAGE));
item.motionX = (rand.nextGaussian() - 0.5D) / 2;
item.motionY = rand.nextDouble();
item.motionZ = (rand.nextGaussian() - 0.5D) / 2;
item.lifespan = 300;
ItemPlasticPlants.markInactive(item);
world.spawnEntityInWorld(item);
world.setBlock(x, y, z, this, world.getBlockMetadata(x, y, z) - 2, 3);
}
} else {
world.setBlockMetadataWithNotify(x, y, z, 14, 3);
NetworkHandler.sendToAllAround(new PacketPlaySound("creeper.primed", x + 0.5D, y + 0.5D, z + 0.5D, 1.0F, 1.0F, true), world);
world.scheduleBlockUpdate(x, y, z, this, 60);
}
}
use of pneumaticCraft.common.network.PacketPlaySound in project PneumaticCraft by MineMaarten.
the class HeatBehaviourLiquidTransition method onLiquidTransition.
protected void onLiquidTransition(int x, int y, int z) {
NetworkHandler.sendToAllAround(new PacketPlaySound("random.fizz", x + 0.5, y + 0.5, z + 0.5, 0.5F, 2.6F + (getWorld().rand.nextFloat() - getWorld().rand.nextFloat()) * 0.8F, true), getWorld());
for (int i = 0; i < 8; i++) {
double randX = x + getWorld().rand.nextDouble();
double randZ = z + getWorld().rand.nextDouble();
NetworkHandler.sendToAllAround(new PacketSpawnParticle("largesmoke", randX, y + 1, randZ, 0, 0, 0), getWorld());
}
}
use of pneumaticCraft.common.network.PacketPlaySound in project PneumaticCraft by MineMaarten.
the class ItemPneumaticWrench method onItemUseFirst.
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS
*/
@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitVecX, float hitVecY, float hitVecZ) {
if (!world.isRemote) {
Block block = world.getBlock(x, y, z);
IPneumaticWrenchable wrenchable = null;
if (block instanceof IPneumaticWrenchable) {
wrenchable = (IPneumaticWrenchable) block;
} else {
wrenchable = ModInteractionUtils.getInstance().getWrenchable(world.getTileEntity(x, y, z));
}
if (wrenchable != null && ((ItemPneumaticWrench) Itemss.pneumaticWrench).getPressure(stack) > 0) {
if (wrenchable.rotateBlock(world, player, x, y, z, ForgeDirection.getOrientation(side))) {
if (!player.capabilities.isCreativeMode)
((ItemPneumaticWrench) Itemss.pneumaticWrench).addAir(stack, -PneumaticValues.USAGE_PNEUMATIC_WRENCH);
NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.PNEUMATIC_WRENCH, x, y, z, 1.0F, 1.0F, false), world);
return true;
}
} else if (block != null) {
//rotating normal blocks doesn't cost energy.
if (block.rotateBlock(world, x, y, z, ForgeDirection.getOrientation(side))) {
NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.PNEUMATIC_WRENCH, x, y, z, 1.0F, 1.0F, false), world);
return true;
}
}
return false;
} else {
return false;
}
}
use of pneumaticCraft.common.network.PacketPlaySound 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