use of me.desht.pneumaticcraft.common.network.PacketPlaySound in project pnc-repressurized by TeamPneumatic.
the class AirHandler method airLeak.
@Override
public void airLeak(EnumFacing side) {
if (getWorld().isRemote || Math.abs(getPressure()) < 0.01F)
return;
double motionX = side.getFrontOffsetX();
double motionY = side.getFrontOffsetY();
double motionZ = side.getFrontOffsetZ();
if (soundCounter <= 0) {
soundCounter = 20;
NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.LEAKING_GAS_SOUND, SoundCategory.BLOCKS, getPos().getX(), getPos().getY(), getPos().getZ(), 0.1F, 1.0F, true), getWorld());
}
if (getPressure() < 0) {
double speed = getPressure() * 0.1F - 0.1F;
NetworkHandler.sendToAllAround(new PacketSpawnParticle(EnumParticleTypes.SMOKE_NORMAL, getPos().getX() + 0.5D + motionX / 2D, getPos().getY() + 0.5D + motionY / 2D, getPos().getZ() + 0.5D + motionZ / 2D, motionX * speed, motionY * speed, motionZ * speed), getWorld());
int dispersedAmount = -(int) (getPressure() * PneumaticValues.AIR_LEAK_FACTOR) + 20;
if (getAir() > dispersedAmount)
dispersedAmount = -getAir();
onAirDispersion(side, dispersedAmount);
addAir(dispersedAmount);
} else {
double speed = getPressure() * 0.1F + 0.1F;
// if(DateEventHandler.isEvent()) {
// DateEventHandler.spawnFirework(getWorld(), getPos().getX() + 0.5D + motionX / 2D, getPos().getY() + 0.5D + motionY / 2D, getPos().getZ() + 0.5D + motionZ / 2D);
// } else {
NetworkHandler.sendToAllAround(new PacketSpawnParticle(EnumParticleTypes.SMOKE_NORMAL, getPos().getX() + 0.5D + motionX / 2D, getPos().getY() + 0.5D + motionY / 2D, getPos().getZ() + 0.5D + motionZ / 2D, motionX * speed, motionY * speed, motionZ * speed), getWorld());
// }
int dispersedAmount = (int) (getPressure() * PneumaticValues.AIR_LEAK_FACTOR) + 20;
if (dispersedAmount > getAir())
dispersedAmount = getAir();
onAirDispersion(side, -dispersedAmount);
addAir(-dispersedAmount);
}
}
use of me.desht.pneumaticcraft.common.network.PacketPlaySound in project pnc-repressurized by TeamPneumatic.
the class BlockPressureTube method tryPlaceModule.
public boolean tryPlaceModule(EntityPlayer player, World world, BlockPos pos, EnumFacing side, boolean simulate) {
if (player.getHeldItemMainhand().getItem() instanceof ItemTubeModule) {
TileEntity te = getTE(world, pos);
TileEntityPressureTube pressureTube = ModInteractionUtils.getInstance().getTube(te);
if (pressureTube.modules[side.ordinal()] == null && !pressureTube.sidesClosed[side.ordinal()] && ModInteractionUtils.getInstance().occlusionTest(boundingBoxes[side.ordinal()], te)) {
TubeModule module = ModuleRegistrator.getModule(((ItemTubeModule) player.getHeldItemMainhand().getItem()).moduleName);
if (simulate)
module.markFake();
pressureTube.setModule(module, side);
if (!simulate) {
neighborChanged(world.getBlockState(pos), world, pos, this, pos.offset(side));
world.notifyNeighborsOfStateChange(pos, this, true);
if (!player.capabilities.isCreativeMode)
player.getHeldItemMainhand().shrink(1);
NetworkHandler.sendToAllAround(new PacketPlaySound(SoundType.GLASS.getStepSound(), SoundCategory.BLOCKS, pos.getX(), pos.getY(), pos.getZ(), SoundType.GLASS.getVolume() * 5.0f, SoundType.GLASS.getPitch() * 0.9f, false), world);
}
return true;
}
} else if (player.getHeldItemMainhand().getItem() == Itemss.ADVANCED_PCB && !simulate) {
TubeModule module = BlockPressureTube.getLookedModule(world, pos, player);
if (module != null && !module.isUpgraded() && module.canUpgrade()) {
if (!world.isRemote) {
module.upgrade();
if (!player.capabilities.isCreativeMode)
player.getHeldItemMainhand().shrink(1);
}
return true;
}
}
return false;
}
use of me.desht.pneumaticcraft.common.network.PacketPlaySound in project pnc-repressurized by TeamPneumatic.
the class HeatBehaviourTransition method onTransition.
protected void onTransition(BlockPos pos) {
NetworkHandler.sendToAllAround(new PacketPlaySound(SoundEvents.ENTITY_GENERIC_EXTINGUISH_FIRE, SoundCategory.AMBIENT, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 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 = pos.getX() + getWorld().rand.nextDouble();
double randZ = pos.getZ() + getWorld().rand.nextDouble();
NetworkHandler.sendToAllAround(new PacketSpawnParticle(EnumParticleTypes.SMOKE_LARGE, randX, pos.getY() + 1, randZ, 0, 0, 0), getWorld());
}
}
use of me.desht.pneumaticcraft.common.network.PacketPlaySound in project pnc-repressurized by TeamPneumatic.
the class ItemCamoApplicator method onItemUseFirst.
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if (!world.isRemote) {
if (player.isSneaking()) {
// copy blockstate of clicked block
IBlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockPneumaticCraftCamo) {
NetworkHandler.sendToAllAround(new PacketPlaySound(SoundEvents.BLOCK_COMPARATOR_CLICK, SoundCategory.PLAYERS, pos, 1.0F, 2.0F, false), world);
player.sendStatusMessage(new TextComponentTranslation("message.camo.invalidBlock", getCamoStateDisplayName(state)), true);
} else {
setCamoState(stack, state);
}
} else {
// either apply saved camo, or remove current camo from block
TileEntity te = world.getTileEntity(pos);
if (!(te instanceof ICamouflageableTE)) {
return EnumActionResult.PASS;
}
IBlockState camoState = getCamoState(stack);
float pressure = getPressure(stack);
if (pressure < 0.1 && !player.capabilities.isCreativeMode) {
// not enough pressure
return EnumActionResult.FAIL;
}
// make sure player has enough of the camo item
if (camoState != null && !player.capabilities.isCreativeMode) {
ItemStack camoStack = ICamouflageableTE.getStackForState(camoState);
if (!PneumaticCraftUtils.consumeInventoryItem(player.inventory, camoStack)) {
String name = camoStack.getDisplayName();
player.sendStatusMessage(new TextComponentTranslation("message.camo.notEnoughBlocks", name), true);
NetworkHandler.sendToAllAround(new PacketPlaySound(SoundEvents.BLOCK_COMPARATOR_CLICK, SoundCategory.PLAYERS, pos, 1.0F, 2.0F, false), world);
return EnumActionResult.FAIL;
}
}
// return any existing camouflage on the block/TE
IBlockState existingCamo = ((ICamouflageableTE) te).getCamouflage();
if (existingCamo != null && !player.capabilities.isCreativeMode) {
ItemStack camoStack = ICamouflageableTE.getStackForState(existingCamo);
EntityItem entity = new EntityItem(world, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, camoStack);
world.spawnEntity(entity);
entity.onCollideWithPlayer(player);
}
// and apply the new camouflage
addAir(stack, -PneumaticValues.USAGE_CAMO_APPLICATOR);
((ICamouflageableTE) te).setCamouflage(camoState);
NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.SHORT_HISS, SoundCategory.PLAYERS, pos, 1.0F, 1.0F, false), world);
return EnumActionResult.SUCCESS;
}
} else {
return EnumActionResult.SUCCESS;
}
return super.onItemUseFirst(player, world, pos, side, hitX, hitY, hitZ, hand);
}
use of me.desht.pneumaticcraft.common.network.PacketPlaySound in project pnc-repressurized by TeamPneumatic.
the class EntityPathNavigateDrone method onUpdateNavigation.
@Override
public void onUpdateNavigation() {
if (isGoingToTeleport()) {
if (teleportCounter == 0 || teleportCounter == 60) {
NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.HUD_INIT, SoundCategory.PLAYERS, pathfindingEntity.posX, pathfindingEntity.posY, pathfindingEntity.posZ, 0.1F, teleportCounter == 0 ? 0.7F : 1F, true), pathfindingEntity.world);
}
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(EnumParticleTypes.PORTAL, pathfindingEntity.posX, pathfindingEntity.posY, pathfindingEntity.posZ, f, f1, f2), pathfindingEntity.world);
}
if (++teleportCounter > TELEPORT_TICKS) {
if (pathfindingEntity.isBlockValidPathfindBlock(telPos)) {
teleport();
}
teleportCounter = -1;
setPath(null, 0);
pathfindingEntity.getMoveHelper().setMoveTo(telPos.getX(), telPos.getY(), telPos.getZ(), pathfindingEntity.getSpeed());
pathfindingEntity.addAir(null, -10000);
}
} else {
// super.onUpdateNavigation();
if (!noPath()) {
pathFollow();
if (!noPath()) {
Vec3d vec32 = currentPath.getPosition(entity);
if (vec32 != null) {
entity.getMoveHelper().setMoveTo(vec32.x, vec32.y, vec32.z, speed);
}
}
}
}
}
Aggregations