public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn) { ItemStack itemstack = worldIn.getHeldItem(playerIn); ItemStack itemstack1 = worldIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1); itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_SPLASH_POTION_THROW, SoundCategory.PLAYERS, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!itemStackIn.isRemote) { EntityPotion entitypotion = new EntityPotion(itemStackIn, worldIn, itemstack1); entitypotion.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, -20.0F, 0.5F, 1.0F); itemStackIn.spawnEntityInWorld(entitypotion); } worldIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, itemstack); }
protected void playMoodSoundAndCheckLight(int p_147467_1_, int p_147467_2_, Chunk chunkIn) { super.playMoodSoundAndCheckLight(p_147467_1_, p_147467_2_, chunkIn); if (this.ambienceTicks == 0) { this.updateLCG = this.updateLCG * 3 + 1013904223; int i = this.updateLCG >> 2; int j = i & 15; int k = i >> 8 & 15; int l = i >> 16 & 255; BlockPos blockpos = new BlockPos(j + p_147467_1_, l, k + p_147467_2_); IBlockState iblockstate = chunkIn.getBlockState(blockpos); j = j + p_147467_1_; k = k + p_147467_2_; if (iblockstate.getMaterial() == Material.AIR && this.getLight(blockpos) <= this.rand.nextInt(8) && this.getLightFor(EnumSkyBlock.SKY, blockpos) <= 0 && this.mc.thePlayer != null && this.mc.thePlayer.getDistanceSq((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D) > 4.0D) { this.playSound((double)j + 0.5D, (double)l + 0.5D, (double)k + 0.5D, SoundEvents.AMBIENT_CAVE, SoundCategory.AMBIENT, 0.7F, 0.8F + this.rand.nextFloat() * 0.2F, false); this.ambienceTicks = this.rand.nextInt(12000) + 6000; } } }
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { BlockPos blockpos = pos.up(); IBlockState iblockstate = worldIn.getBlockState(blockpos); if (iblockstate.getBlock() == Blocks.WATER || iblockstate.getBlock() == Blocks.FLOWING_WATER) { worldIn.setBlockToAir(blockpos); worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F); if (worldIn instanceof WorldServer) { ((WorldServer)worldIn).spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.25D, (double)blockpos.getZ() + 0.5D, 8, 0.5D, 0.25D, 0.5D, 0.0D, new int[0]); } } }
@Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer playerIn, EnumHand handIn) { ItemStack iStack = playerIn.getHeldItem(handIn); if (iStack.getItemDamage() < iStack.getMaxDamage()) { double factor = 0.2D * getPressure(iStack); world.playSound(playerIn.posX, playerIn.posY, playerIn.posZ, Sounds.CANNON_SOUND, SoundCategory.PLAYERS, 1.0F, 0.7F + (float) factor * 0.2F, false); EntityVortex vortex = new EntityVortex(world, playerIn); Vec3d directionVec = playerIn.getLookVec().normalize(); vortex.posX += directionVec.x; vortex.posY += directionVec.y; vortex.posZ += directionVec.z; vortex.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 0.0F); vortex.motionX *= factor; vortex.motionY *= factor; vortex.motionZ *= factor; if (!world.isRemote) world.spawnEntity(vortex); iStack.setItemDamage(iStack.getItemDamage() + PneumaticValues.USAGE_VORTEX_CANNON); if (iStack.getItemDamage() > iStack.getMaxDamage()) { iStack.setItemDamage(iStack.getMaxDamage()); } } return ActionResult.newResult(EnumActionResult.SUCCESS, iStack); }
private boolean tryPlace(EntityPlayer player, ItemStack stack, World worldIn, BlockPos pos, int subtype) { IBlockState iblockstate = worldIn.getBlockState(pos); if (iblockstate.getBlock() == this.singleSlab) { int subtype1 = singleSlabCS.getSubtype(iblockstate); if (subtype1 == subtype) { IBlockState stateDouble = this.makeState(subtype1); AxisAlignedBB axisalignedbb = stateDouble == null ? Block.NULL_AABB : stateDouble.getCollisionBoundingBox(worldIn, pos); if (stateDouble != null && axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, stateDouble, 11)) { SoundType soundtype = stateDouble.getBlock().getSoundType(stateDouble, worldIn, pos, player); worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); stack.shrink(1); } return true; } } return false; }
private boolean tryPlace(EntityPlayer player, ItemStack stack, World worldIn, BlockPos pos, Object itemSlabType) { IBlockState iblockstate = worldIn.getBlockState(pos); if (iblockstate.getBlock() == this.singleSlab) { Comparable<?> comparable = iblockstate.getValue(this.singleSlab.getVariantProperty()); if (comparable == itemSlabType) { IBlockState iblockstate1 = this.makeState(this.singleSlab.getVariantProperty(), comparable); AxisAlignedBB axisalignedbb = iblockstate1.getCollisionBoundingBox(worldIn, pos); if (axisalignedbb != Block.NULL_AABB && worldIn.checkNoEntityCollision(axisalignedbb.offset(pos)) && worldIn.setBlockState(pos, iblockstate1, 11)) { SoundType soundtype = this.doubleSlab.getSoundType(iblockstate1, worldIn, pos, player); worldIn.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); --stack.stackSize; } return true; } } return false; }
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn) { ItemStack itemstack = worldIn.getHeldItem(playerIn); if (!worldIn.capabilities.isCreativeMode) { itemstack.func_190918_g(1); } itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!itemStackIn.isRemote) { EntitySnowball entitysnowball = new EntitySnowball(itemStackIn, worldIn); entitysnowball.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, 0.0F, 1.5F, 1.0F); itemStackIn.spawnEntityInWorld(entitysnowball); } worldIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, itemstack); }
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { if (!playerIn.capabilities.isCreativeMode) { --itemStackIn.stackSize; } worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_LINGERINGPOTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { EntityPotion entitypotion = new EntityPotion(worldIn, playerIn, itemStackIn); entitypotion.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F); worldIn.spawnEntityInWorld(entitypotion); } playerIn.addStat(StatList.getObjectUseStats(this)); return new ActionResult(EnumActionResult.SUCCESS, itemStackIn); }
/** * Called when the player finishes using this Item (E.g. finishes eating.). Not called when the player stops using * the Item before the action is complete. */ @Nullable public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityLivingBase entityLiving) { --stack.stackSize; if (entityLiving instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)entityLiving; entityplayer.getFoodStats().addStats(this, stack); worldIn.playSound((EntityPlayer)null, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F); this.onFoodEaten(stack, worldIn, entityplayer); entityplayer.addStat(StatList.getObjectUseStats(this)); } return stack; }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY) { if (!playerIn.capabilities.allowEdit) { return false; } else { state = state.cycleProperty(MODE); float f = state.getValue(MODE) == BlockRedstoneComparator.Mode.SUBTRACT ? 0.55F : 0.5F; worldIn.playSound(playerIn, pos, SoundEvents.BLOCK_COMPARATOR_CLICK, SoundCategory.BLOCKS, 0.3F, f); worldIn.setBlockState(pos, state, 2); this.onStateChange(worldIn, pos, state); return true; } }
@Override public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack heldItem = playerIn.getHeldItem(hand); if (heldItem.isEmpty()) { return super.onItemUse(playerIn, worldIn, pos, hand, facing, hitX, hitY, hitZ); } System.out.println(this.getSaplingState()); if (facing == EnumFacing.UP && playerIn.canPlayerEdit(pos.offset(facing), facing, heldItem) && worldIn.isAirBlock(pos.up()) && worldIn.getBlockState(pos).getBlock().canSustainPlant(worldIn.getBlockState(pos), worldIn, pos, facing, (IPlantable) this.getSaplingState().getBlock())) { worldIn.setBlockState(pos.up(), this.getSaplingState()); worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 1F, 1F); heldItem.shrink(1); return EnumActionResult.SUCCESS; } else { if (playerIn.canPlayerEdit(pos.offset(facing), facing, heldItem) && worldIn.isAirBlock(pos.up()) && worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos)) { worldIn.setBlockState(pos, this.getSaplingState()); worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 1F, 1F); heldItem.shrink(1); return EnumActionResult.SUCCESS; } return EnumActionResult.FAIL; } }
public void openInventory(EntityPlayer player) { if (!player.isSpectator()) { if (this.field_190598_h < 0) { this.field_190598_h = 0; } ++this.field_190598_h; this.world.addBlockEvent(this.pos, this.getBlockType(), 1, this.field_190598_h); if (this.field_190598_h == 1) { this.world.playSound((EntityPlayer)null, this.pos, SoundEvents.field_191262_fB, SoundCategory.BLOCKS, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F); } } }
@Nullable public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { if(inventorySlots.get(slotId) != null) { if(!inventorySlots.get(slotId).getStack().isEmpty()) { if(!player.world.isRemote) { InventoryHelper.spawnItemStack(player.world, inventory.getPos().getX() + 0.5D, inventory.getPos().getY() + 1D, inventory.getPos().getZ() + 0.5D, inventorySlots.get(slotId).getStack()); } player.world.playSound(null, inventory.getPos().getX() + 0.5D, inventory.getPos().getY() + 1D, inventory.getPos().getZ() + 0.5D, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((player.world.rand.nextFloat() - player.world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); inventorySlots.get(slotId).putStack(ItemStack.EMPTY); inventory.setInventorySlotContents(slotId, ItemStack.EMPTY); inventory.markDirty(); } } return super.slotClick(slotId, dragType, clickTypeIn, player); }
/** * Save schematic * @param world Target world * @param name Structure name * @param posX X starting position * @param posY Y starting position * @param posZ Z starting position * @param width X axis size * @param height Y axis size * @param length Z axis size * @return Execution status */ private static String cmdSave(UWorld world, String name, int posX, int posY, int posZ, int width, int height, int length) { Report report = new Report() .post("WORLD FRAGMENT", name) .post("POS", "[X=" + posX + ";Y=" + posY + ";Z=" + posZ + "]") .post("SIZE", "[W=" + width + ";H=" + height + ";L=" + length + "]"); try { Blueprint blueprint = new Blueprint(world, new UBlockPos(posX, posY, posZ), new Volume(width, height, length)); File file = new File(Configurator.getSchematicsSavesFolder(), name + ".schematic"); blueprint.saveSchematic(file); Structures.load(file); report.post("SAVED", file.getPath()); } catch (IOException ioe) { report.post("NOT SAVED", ioe.getMessage()); } report.print(); world.sound(new UBlockPos(posX, posY, posZ), SoundEvents.BLOCK_ENDERCHEST_CLOSE, SoundCategory.BLOCKS, 0.5f); return report.toString(); }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY) { if (worldIn.isRemote) { return true; } else { state = state.cycleProperty(POWERED); worldIn.setBlockState(pos, state, 3); float f = ((Boolean)state.getValue(POWERED)).booleanValue() ? 0.6F : 0.5F; worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.3F, f); worldIn.notifyNeighborsOfStateChange(pos, this, false); EnumFacing enumfacing = ((BlockLever.EnumOrientation)state.getValue(FACING)).getFacing(); worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing.getOpposite()), this, false); return true; } }
/** * Called when a Block is right-clicked with this Item */ public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY) { worldIn = worldIn.offset(hand); ItemStack itemstack = stack.getHeldItem(pos); if (!stack.canPlayerEdit(worldIn, hand, itemstack)) { return EnumActionResult.FAIL; } else { if (playerIn.getBlockState(worldIn).getMaterial() == Material.AIR) { playerIn.playSound(stack, worldIn, SoundEvents.ITEM_FLINTANDSTEEL_USE, SoundCategory.BLOCKS, 1.0F, itemRand.nextFloat() * 0.4F + 0.8F); playerIn.setBlockState(worldIn, Blocks.FIRE.getDefaultState(), 11); } itemstack.damageItem(1, stack); return EnumActionResult.SUCCESS; } }
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); boolean isBlock = stack.getItem() instanceof ItemBlock && stack.getItem() != ModItems.ANGSTROM; if(!world.isRemote && isBlock) { //Replace ItemBlock item = (ItemBlock) stack.getItem(); Block block = Block.getBlockFromItem(item); int meta = item.getMetadata(stack); IBlockState inState = block.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, player, hand); world.setBlockState(pos, inState); block.onBlockPlacedBy(world, pos, inState, player, stack); SoundType sound = block.getSoundType(inState, world, pos, player); world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), sound.getPlaceSound(), SoundCategory.BLOCKS, 0.75F, 0.8F); //Exchange ItemStack drop = new ItemStack(Item.getItemFromBlock(this)); ItemHandlerHelper.giveItemToPlayer(player, drop); if(!player.capabilities.isCreativeMode) { stack.shrink(1); } } return isBlock; }
@Override @SideOnly(Side.CLIENT) public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { for(int i = 0; i <= Math.min(state.getValue(State.POWER), 8); i++) { if(rand.nextFloat() < 0.2F) { Vector3 vec = Vector3.getRandomVec(0.15F); vec.add(BB.getCenter()); vec.add(pos.getX(), pos.getY(), pos.getZ()); ParticleUtil.spawnChargedIce(world, vec, Vector3.ImmutableVector3.NULL, 0xFFFFFF, 45, 0.45F * rand.nextFloat()); } } if(state.getValue(State.POWER) > 0 && world.rand.nextBoolean()) { for(int i = 0; i < 1 + world.rand.nextInt(3); i++) { Vector3 from = Vector3.create(pos).add(0.5D); Vector3 to = Vector3.create(0, 1, 0) .rotate(EnumFacing.Axis.X, world.rand.nextFloat() * 360) .rotate(EnumFacing.Axis.Y, world.rand.nextFloat() * 360) .rotate(EnumFacing.Axis.Z, world.rand.nextFloat() * 360) .add(from); ParticleUtil.spawnBolt(world, from, to, 4, 0.25F, 0x5194FF, true, true); } ((WorldClient) world).playSound(pos, SolarSounds.SPARK, SoundCategory.BLOCKS, 0.05F, 1F, false); } }
public void broadcastSound(int soundID, BlockPos pos, int data) { switch (soundID) { case 1023: case 1028: Entity entity = this.mc.getRenderViewEntity(); if (entity != null) { double d0 = (double)pos.getX() - entity.posX; double d1 = (double)pos.getY() - entity.posY; double d2 = (double)pos.getZ() - entity.posZ; double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); double d4 = entity.posX; double d5 = entity.posY; double d6 = entity.posZ; if (d3 > 0.0D) { d4 += d0 / d3 * 2.0D; d5 += d1 / d3 * 2.0D; d6 += d2 / d3 * 2.0D; } if (soundID == 1023) { this.theWorld.playSound(d4, d5, d6, SoundEvents.ENTITY_WITHER_SPAWN, SoundCategory.HOSTILE, 1.0F, 1.0F, false); } else { this.theWorld.playSound(d4, d5, d6, SoundEvents.ENTITY_ENDERDRAGON_DEATH, SoundCategory.HOSTILE, 5.0F, 1.0F, false); } } default: } }
/** * Called when a Block is right-clicked with this Item */ public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY) { if (hand != EnumFacing.UP) { return EnumActionResult.FAIL; } else { IBlockState iblockstate = playerIn.getBlockState(worldIn); Block block = iblockstate.getBlock(); if (!block.isReplaceable(playerIn, worldIn)) { worldIn = worldIn.offset(hand); } ItemStack itemstack = stack.getHeldItem(pos); if (stack.canPlayerEdit(worldIn, hand, itemstack) && this.block.canPlaceBlockAt(playerIn, worldIn)) { EnumFacing enumfacing = EnumFacing.fromAngle((double)stack.rotationYaw); int i = enumfacing.getFrontOffsetX(); int j = enumfacing.getFrontOffsetZ(); boolean flag = i < 0 && hitY < 0.5F || i > 0 && hitY > 0.5F || j < 0 && facing > 0.5F || j > 0 && facing < 0.5F; placeDoor(playerIn, worldIn, enumfacing, this.block, flag); SoundType soundtype = this.block.getSoundType(); playerIn.playSound(stack, worldIn, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume() + 1.0F) / 2.0F, soundtype.getPitch() * 0.8F); itemstack.func_190918_g(1); return EnumActionResult.SUCCESS; } else { return EnumActionResult.FAIL; } } }
@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); } } } } }
@Nonnull @Override public ItemStack onItemUseFinish(ItemStack stack, @Nullable World worldIn, EntityLivingBase entityLiving) { if (entityLiving instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)entityLiving; entityplayer.getFoodStats().addStats(this, stack); worldIn.playSound(entityplayer, entityplayer.posX, entityplayer.posY, entityplayer.posZ, SoundEvents.ENTITY_PLAYER_BURP, SoundCategory.PLAYERS, 0.5F, worldIn.rand.nextFloat() * 0.1F + 0.9F); this.onFoodEaten(stack, worldIn, entityplayer); entityplayer.addStat(StatList.getObjectUseStats(this)); } return new ItemStack(FCRItems.GLASS_BOTTLE); }
@SubscribeEvent public void quetziMoo(ServerChatEvent event) { if (event.getUsername().equals("Quetzz") && event.getMessage().equals("m00")) { for (int i = 0; i < 4; i++) NetworkHandler.sendTo(new PacketPlaySound(SoundEvents.ENTITY_COW_AMBIENT, SoundCategory.NEUTRAL, event.getPlayer().posX, event.getPlayer().posY, event.getPlayer().posZ, 1, 1, true), event.getPlayer()); } }
public void setVolume(SoundCategory category, float volume) { if (this.loaded) { if (category == SoundCategory.MASTER) { this.sndSystem.setMasterVolume(volume); } else { for (String s : this.categorySounds.get(category)) { ISound isound = (ISound)this.playingSounds.get(s); float f = this.getClampedVolume(isound); if (f <= 0.0F) { this.stopSound(isound); } else { this.sndSystem.setVolume(s, f); } } } } }
private void doBlockHitEffects(World world, RayTraceResult mop) { IBlockState state = world.getBlockState(mop.getBlockPos()); for(int p = 0; p < 8; p ++) { world.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX, this.posY, this.posZ, 0.0F, 0.0F, 0.0F, Block.getStateId(state)); } world.playSound(this.posX, this.posY, this.posZ, state.getBlock().getSoundType(state, world, mop.getBlockPos(), this).getStepSound(), SoundCategory.NEUTRAL, 0.8F, 0.9F, false); }
public WeaponSound(SoundEvent p_i45104_1_, EntityLivingBase entity, int type, WeaponData conf) { super(p_i45104_1_, SoundCategory.NEUTRAL); this.type = type; this.entity = entity; this.conf = conf; this.volume = entity instanceof EntityPlayer ? TF2ConfigVars.gunVolume : TF2ConfigVars.mercenaryVolume; }
@Override public void update() { if (!world.isRemote) { ++tick; final ItemStack bee = getStackInSlot(0); if (!bee.isEmpty() && bee.getItemDamage() < 35) { lookForFlowers(); if (tick % 60 == 0 && world.rand.nextBoolean()) { world.playSound(null, pos, WitchSoundEvents.BUZZ, SoundCategory.BLOCKS, 0.1F, 1F); } if (flowerCount > 0) { if (world.rand.nextInt(3) == 0 && tick % (GEN - flowerCount * 3) == 0) { for (int i = 1; i < 16; i++) { if (!getStackInSlot(i).isEmpty()) { bee.attemptDamageItem(1, world.rand, player); bonemealArea(); itemStacks.set(i, randomItem()); break; } } } flowerCount = 0; } } } }
public void unLitCandle() { if (isLit()) { world.playSound(null, getPos(), SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 1F, 1F); this.lit = false; world.profiler.startSection("checkLight"); world.checkLight(pos); world.profiler.endSection(); } }
/** * Inserts the given itemstack into the players inventory. * If the inventory can't hold it, the item will be dropped in the world at the players position. * * @param player The player to give the item to * @param stack The itemstack to insert */ public static void giveItemToPlayer(EntityPlayer player, ItemStack stack, int preferredSlot) { IItemHandler inventory = new PlayerMainInvWrapper(player.inventory); World world = player.worldObj; // try adding it into the inventory ItemStack remainder = stack; // insert into preferred slot first if(preferredSlot >= 0) { remainder = inventory.insertItem(preferredSlot, stack, false); } // then into the inventory in general if(remainder != null) { remainder = insertItemStacked(inventory, remainder, false); } // play sound if something got picked up if (remainder == null || remainder.stackSize != stack.stackSize) { world.playSound(player, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); } // drop remaining itemstack into the world if (remainder != null && !world.isRemote) { EntityItem entityitem = new EntityItem(world, player.posX, player.posY + 0.5, player.posZ, stack); entityitem.setPickupDelay(40); entityitem.motionX = 0; entityitem.motionZ = 0; world.spawnEntityInWorld(entityitem); } }
public PlaySoundAtEntityEvent(Entity entity, SoundEvent name, SoundCategory category, float volume, float pitch) { super(entity); this.name = name; this.category = category; this.volume = volume; this.pitch = pitch; this.newVolume = volume; this.newPitch = pitch; }
public PositionedSoundRecord(ResourceLocation soundId, SoundCategory categoryIn, float volumeIn, float pitchIn, boolean repeatIn, int repeatDelayIn, ISound.AttenuationType attenuationTypeIn, float xIn, float yIn, float zIn) { super(soundId, categoryIn); this.volume = volumeIn; this.pitch = pitchIn; this.xPosF = xIn; this.yPosF = yIn; this.zPosF = zIn; this.repeat = repeatIn; this.repeatDelay = repeatDelayIn; this.attenuationType = attenuationTypeIn; }
@Override public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityLivingBase entityLiving, int timeLeft) { if(getMaxItemUseDuration(stack) - timeLeft < 10) return; float f = ItemBow.getArrowVelocity(getMaxItemUseDuration(stack) - timeLeft); spawnThrownEntity(worldIn, entityLiving, 3f * f, new HarshenEnderArrow(f), new EntityThrowSpawnData(1).setIgnoreBlocks(true)); worldIn.playSound((EntityPlayer)null, entityLiving.posX, entityLiving.posY, entityLiving.posZ, SoundEvents.ENTITY_ENDERMITE_AMBIENT, SoundCategory.PLAYERS, 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); stack.damageItem(1, entityLiving); }
public SoundGlassAmbience(SoundEvent soundIn, SoundCategory categoryIn, float volume, float pitch, TerminalPlacement placement) { super(soundIn, categoryIn); this.volume = volume; this.pitch = pitch; this.repeat = true; this.repeatDelay = 0; this.xPosF = (float)placement.master.getPos().getX(); this.yPosF = (float)placement.master.getPos().getY(); this.zPosF = (float)placement.master.getPos().getZ(); this.placement = placement; }
/** * Undo all session history * All projections applied insecure to restore data 1:1 * @return Command execution status */ private static String cmdUndo() { if (undo.isEmpty()) { return "§4No undo data"; } for (Projection projection : undo) { projection.project(true).print(); Posture pst = projection.getPosture(); projection.getWorld().sound(new UBlockPos(pst.getPosX(), pst.getPosY(), pst.getPosZ()), SoundEvents.ENTITY_ENDERMEN_TELEPORT, SoundCategory.HOSTILE, 1.0f); } undo.clear(); return "§2Undo done"; }
@Override public void onCollideWithPlayer(EntityPlayer par1EntityPlayer) { if (!this.world.isRemote && item && par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(ModItems.itemTracker, 1, freq))) { //TODO SoundCat for this. this.world.playSound(null, posX, posY, posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); par1EntityPlayer.onItemPickup(this, 1); setDead(); } }
public ReloadSound(SoundEvent soundResource, Entity entity) { super(soundResource, SoundCategory.NEUTRAL); this.xPosF = (float) entity.posX; this.yPosF = (float) entity.posY; this.zPosF = (float) entity.posZ; this.volume = 0.6f; }
protected void triggerMixEffects(World worldIn, BlockPos pos) { double d0 = (double)pos.getX(); double d1 = (double)pos.getY(); double d2 = (double)pos.getZ(); worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F); for (int i = 0; i < 8; ++i) { worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0 + Math.random(), d1 + 1.2D, d2 + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]); } }
public void stop(String p_189567_1_, SoundCategory p_189567_2_) { if (p_189567_2_ != null) { for (String s : this.categorySounds.get(p_189567_2_)) { ISound isound = (ISound)this.playingSounds.get(s); if (p_189567_1_.isEmpty()) { this.stopSound(isound); } else if (isound.getSoundLocation().equals(new ResourceLocation(p_189567_1_))) { this.stopSound(isound); } } } else if (p_189567_1_.isEmpty()) { this.stopAllSounds(); } else { for (ISound isound1 : this.playingSounds.values()) { if (isound1.getSoundLocation().equals(new ResourceLocation(p_189567_1_))) { this.stopSound(isound1); } } } }
@SubscribeEvent public void onRightClick(PlayerInteractEvent.RightClickBlock event) { if (!event.getWorld().isRemote) { EntityPlayer player = event.getEntityPlayer(); IExPPlayer data = IExPPlayer.of(player); if (data.getThirst() < data.getMaxThirst(true) - 200) { RayTraceResult rtr = event.getWorld().rayTraceBlocks(player.getPositionEyes(1), player.getPositionEyes(1).add(player.getLook(1).scale(3)), true, false, false); if (rtr != null && rtr.typeOfHit == Type.BLOCK) { BlockPos pos = rtr.getBlockPos(); IBlockState hit = event.getWorld().getBlockState(pos); if (hit.getBlock() instanceof IWater && !((IWater)hit.getBlock()).isSalt(event.getWorld(), pos)) { int level = hit.getValue(BlockFluidBase.LEVEL); if (level > 0) { event.getWorld().setBlockState(pos, hit.withProperty(BlockFluidBase.LEVEL, level - 1)); } else { event.getWorld().setBlockToAir(pos); } data.setThirst(data.getThirst() + 200, true); event.getWorld().playSound(null, pos, SoundEvents.ENTITY_GENERIC_DRINK, SoundCategory.PLAYERS, 1, 1); } } } } }
/** * Ignites this TNT cart. */ public void ignite() { this.minecartTNTFuse = 80; if (!this.worldObj.isRemote) { this.worldObj.setEntityState(this, (byte)10); if (!this.isSilent()) { this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); } } }