net.minecraft.sound.SoundCategory Java Examples
The following examples show how to use
net.minecraft.sound.SoundCategory.
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: CoalGeneratorBlock.java From Galacticraft-Rewoven with MIT License | 6 votes |
@Environment(EnvType.CLIENT) @Override public void randomDisplayTick(BlockState state, World world, BlockPos blockPos_1, Random rand) { if (world.getBlockEntity(blockPos_1) instanceof CoalGeneratorBlockEntity && ((CoalGeneratorBlockEntity) world.getBlockEntity(blockPos_1)).status == CoalGeneratorBlockEntity.CoalGeneratorStatus.ACTIVE || ((CoalGeneratorBlockEntity) world.getBlockEntity(blockPos_1)).status == CoalGeneratorBlockEntity.CoalGeneratorStatus.WARMING) { double x = (double) blockPos_1.getX() + 0.5D; double y = blockPos_1.getY(); double z = (double) blockPos_1.getZ() + 0.5D; if (rand.nextDouble() < 0.1D) { world.playSound(x, y, z, SoundEvents.BLOCK_FURNACE_FIRE_CRACKLE, SoundCategory.BLOCKS, 1.0F, 1.0F, false); } Direction direction_1 = state.get(FACING); Direction.Axis direction$Axis_1 = direction_1.getAxis(); double d = rand.nextDouble() * 0.6D - 0.3D; double xo = direction$Axis_1 == Direction.Axis.X ? (double) direction_1.getOffsetX() * 0.52D : d; double yo = rand.nextDouble() * 6.0D / 16.0D; double zo = direction$Axis_1 == Direction.Axis.Z ? (double) direction_1.getOffsetZ() * 0.52D : d; world.addParticle(ParticleTypes.SMOKE, x + xo, y + yo, z + zo, 0.0D, 0.0D, 0.0D); world.addParticle(ParticleTypes.FLAME, x + xo, y + yo, z + zo, 0.0D, 0.0D, 0.0D); } }
Example #2
Source File: CarpetDispenserBehaviours.java From carpet-extra with GNU Lesser General Public License v3.0 | 6 votes |
private ItemStack defaultBehaviour(BlockPointer source, ItemStack stack) { if (this.minecartType == AbstractMinecartEntity.Type.TNT) { World world = source.getWorld(); BlockPos pos = source.getBlockPos().offset((Direction) source.getBlockState().get(DispenserBlock.FACING)); TntEntity tntEntity = new TntEntity(world, (double)pos.getX() + 0.5D, (double)pos.getY(), (double)pos.getZ() + 0.5D, (LivingEntity)null); world.spawnEntity(tntEntity); world.playSound((PlayerEntity)null, tntEntity.getX(), tntEntity.getY(), tntEntity.getZ(), SoundEvents.ENTITY_TNT_PRIMED, SoundCategory.BLOCKS, 1.0F, 1.0F); stack.decrement(1); return stack; } else { return super.dispenseSilently(source, stack); } }
Example #3
Source File: ColoredPumpkinBlock.java From the-hallow with MIT License | 6 votes |
@Override public ActionResult onUse(BlockState blockState, World world, BlockPos blockPos, PlayerEntity playerEntity, Hand hand, BlockHitResult blockHitResult) { ItemStack stack = playerEntity.getStackInHand(hand); if (stack.getItem() == Items.SHEARS) { if (!world.isClient) { Direction side = blockHitResult.getSide(); Direction facingTowardPlayer = side.getAxis() == Direction.Axis.Y ? playerEntity.getHorizontalFacing().getOpposite() : side; world.playSound(null, blockPos, SoundEvents.BLOCK_PUMPKIN_CARVE, SoundCategory.BLOCKS, 1.0F, 1.0F); world.setBlockState(blockPos, HallowedBlocks.CARVED_PUMPKIN_COLORS.get(this.color).getDefaultState().with(CarvedPumpkinBlock.FACING, facingTowardPlayer), 11); ItemEntity itemEntity = new ItemEntity(world, blockPos.getX() + 0.5D + facingTowardPlayer.getOffsetX() * 0.65D, blockPos.getY() + 0.1D, blockPos.getZ() + 0.5D + facingTowardPlayer.getOffsetZ() * 0.65D, new ItemStack(Items.PUMPKIN_SEEDS, 4)); itemEntity.setVelocity(0.05D * (double) facingTowardPlayer.getOffsetX() + world.random.nextDouble() * 0.02D, 0.05D, 0.05D * (double) facingTowardPlayer.getOffsetZ() + world.random.nextDouble() * 0.02D); world.spawnEntity(itemEntity); stack.damage(1, playerEntity, (playerEntityVar) -> { playerEntityVar.sendToolBreakStatus(hand); }); } return ActionResult.SUCCESS; } return super.onUse(blockState, world, blockPos, playerEntity, hand, blockHitResult); }
Example #4
Source File: HallowedLogBlock.java From the-hallow with MIT License | 6 votes |
@SuppressWarnings("deprecation") @Override public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { ItemStack stack = player.getStackInHand(hand); if (stack.isEmpty() || !(stack.getItem() instanceof MiningToolItem)) { return ActionResult.PASS; } MiningToolItem tool = (MiningToolItem) stack.getItem(); if (stripped != null && (tool.isEffectiveOn(state) || tool.getMiningSpeed(stack, state) > 1.0F)) { world.playSound(player, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); if (!world.isClient) { BlockState target = stripped.getDefaultState().with(LogBlock.AXIS, state.get(LogBlock.AXIS)); world.setBlockState(pos, target); stack.damage(1, player, consumedPlayer -> consumedPlayer.sendToolBreakStatus(hand)); } return ActionResult.SUCCESS; } return ActionResult.PASS; }
Example #5
Source File: WitchWaterBubbleColumnBlock.java From the-hallow with MIT License | 6 votes |
@Override @Environment(EnvType.CLIENT) public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random rand) { double x = pos.getX(); double y = pos.getY(); double z = pos.getZ(); if (state.get(DRAG)) { world.addImportantParticle(ParticleTypes.CURRENT_DOWN, x + 0.5D, y + 0.8D, z, 0.0D, 0.0D, 0.0D); if (rand.nextInt(200) == 0) { world.playSound(x, y, z, SoundEvents.BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false); } } else { world.addImportantParticle(ParticleTypes.BUBBLE_COLUMN_UP, x + 0.5D, y, z + 0.5D, 0.0D, 0.04D, 0.0D); world.addImportantParticle(ParticleTypes.BUBBLE_COLUMN_UP, x + (double) rand.nextFloat(), y + (double) rand.nextFloat(), z + (double) rand.nextFloat(), 0.0D, 0.04D, 0.0D); if (rand.nextInt(200) == 0) { world.playSound(x, y, z, SoundEvents.BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT, SoundCategory.BLOCKS, 0.2F + rand.nextFloat() * 0.2F, 0.9F + rand.nextFloat() * 0.15F, false); } } }
Example #6
Source File: NotebotUtils.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
private static void play(SoundEvent sound, float pitch) { if (MinecraftClient.getInstance().world != null && MinecraftClient.getInstance().player != null) { MinecraftClient.getInstance().world.playSound(MinecraftClient.getInstance().player, MinecraftClient.getInstance().player.getBlockPos(), sound, SoundCategory.RECORDS, 3.0F, pitch); } else { MinecraftClient.getInstance().getSoundManager().play( new PositionedSoundInstance(sound, SoundCategory.RECORDS, 3.0F, pitch, 0F, 0F, 0F)); } }
Example #7
Source File: NotebotUtils.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
private static void play(SoundEvent sound, float pitch) { if (MinecraftClient.getInstance().world != null && MinecraftClient.getInstance().player != null) { MinecraftClient.getInstance().world.playSound(MinecraftClient.getInstance().player, MinecraftClient.getInstance().player.getBlockPos(), sound, SoundCategory.RECORDS, 3.0F, pitch); } else { MinecraftClient.getInstance().getSoundManager().play( new PositionedSoundInstance(sound, SoundCategory.RECORDS, 3.0F, pitch, 0F, 0F, 0F)); } }
Example #8
Source File: NotebotUtils.java From bleachhack-1.14 with GNU General Public License v3.0 | 5 votes |
private static void play(SoundEvent sound, float pitch) { if (MinecraftClient.getInstance().world != null && MinecraftClient.getInstance().player != null) { MinecraftClient.getInstance().world.playSound(MinecraftClient.getInstance().player, MinecraftClient.getInstance().player.getBlockPos(), sound, SoundCategory.RECORDS, 3.0F, pitch); } else { MinecraftClient.getInstance().getSoundManager().play( new PositionedSoundInstance(sound, SoundCategory.RECORDS, 3.0F, pitch, 0F, 0F, 0F)); } }
Example #9
Source File: WetSpongeBlockMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onPlaced(World world_1, BlockPos blockPos_1, BlockState blockState_1, LivingEntity livingEntity_1, ItemStack itemStack_1) { super.onPlaced(world_1, blockPos_1, blockState_1, livingEntity_1, itemStack_1); if (world_1.dimension.isNether() && CarpetExtraSettings.spongesDryInTheNether) { world_1.playSound(null, blockPos_1, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world_1.random.nextFloat() - world_1.random.nextFloat()) * 0.8F); world_1.setBlockState(blockPos_1, Blocks.SPONGE.getDefaultState()); } }
Example #10
Source File: FarmerVillagerTask_wartFarmMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 5 votes |
@Redirect(method = "keepRunning", at = @At( value = "INVOKE", target = "Lnet/minecraft/inventory/BasicInventory;getInvSize()I" )) private int plantWart(BasicInventory basicInventory, ServerWorld serverWorld, VillagerEntity villagerEntity, long l) { if (isFarmingCleric) // fill cancel that for loop by setting length to 0 { for(int i = 0; i < basicInventory.getInvSize(); ++i) { ItemStack itemStack = basicInventory.getInvStack(i); boolean bl = false; if (!itemStack.isEmpty()) { if (itemStack.getItem() == Items.NETHER_WART) { serverWorld.setBlockState(currentTarget, Blocks.NETHER_WART.getDefaultState(), 3); bl = true; } } if (bl) { serverWorld.playSound(null, currentTarget.getX(), currentTarget.getY(), this.currentTarget.getZ(), SoundEvents.ITEM_NETHER_WART_PLANT, SoundCategory.BLOCKS, 1.0F, 1.0F); itemStack.decrement(1); if (itemStack.isEmpty()) { basicInventory.setInvStack(i, ItemStack.EMPTY); } break; } } return 0; } return basicInventory.getInvSize(); }
Example #11
Source File: BleedingBlock.java From the-hallow with MIT License | 5 votes |
@SuppressWarnings("deprecation") @Override public void randomTick(BlockState state, ServerWorld world, BlockPos pos1, Random rand) { BlockPos pos2 = pos1.up(); if (world.getFluidState(pos1).matches(HallowedTags.Fluids.WITCH_WATER)) { world.playSound(null, pos1, SoundEvents.ENTITY_DROWNED_HURT_WATER, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F); world.spawnParticles(ParticleTypes.CURRENT_DOWN, (double) pos2.getX() + 0.5D, (double) pos2.getY() + 0.25D, (double) pos2.getZ() + 0.5D, 8, 0.5D, 0.25D, 0.5D, 0.0D); } }
Example #12
Source File: WitchedPumpkinItem.java From the-hallow with MIT License | 5 votes |
@Override public ItemStack finishUsing(ItemStack stack, World world, LivingEntity entity) { if (isFood() && !world.isClient && entity instanceof PlayerEntity) { ServerSidePacketRegistry.INSTANCE.sendToPlayer((PlayerEntity) entity, HallowedNetworking.SHOW_FLOATING_ITEM_S2C, HallowedNetworking.createShowFloatingItemPacket(this)); ((PlayerEntity) entity).playSound(SoundEvents.ENTITY_ILLUSIONER_CAST_SPELL, SoundCategory.PLAYERS, 0.5f, 1f); } return super.finishUsing(stack, world, entity); }
Example #13
Source File: TorchBlockMixin.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override @Deprecated public void onBlockAdded(BlockState state, World world, BlockPos pos, BlockState oldState, boolean moved) { super.onBlockAdded(state, world, pos, oldState, moved); if (CelestialBodyType.getByDimType(world.getRegistryKey()).isPresent() && !CelestialBodyType.getByDimType(world.getRegistryKey()).get().getAtmosphere().getComposition().containsKey(AtmosphericGas.OXYGEN)) { if (state.getBlock() == Blocks.TORCH) { world.setBlockState(pos, GalacticraftBlocks.UNLIT_TORCH.getDefaultState()); } else if (state.getBlock() == Blocks.WALL_TORCH) { world.setBlockState(pos, GalacticraftBlocks.UNLIT_WALL_TORCH.getDefaultState().with(WallTorchBlock.FACING, state.get(WallTorchBlock.FACING))); } world.addParticle(ParticleTypes.SMOKE, pos.getX(), pos.getY(), pos.getZ(), 0.0D, 0.0D, 0.0D); world.playSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_GENERIC_EXTINGUISH_FIRE, SoundCategory.BLOCKS, 1.0F, 0.9F, false); } }
Example #14
Source File: MoonBerryBushBlock.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public ActionResult onUse(BlockState blockState, World world, BlockPos blockPos, PlayerEntity playerEntity, Hand hand, BlockHitResult blockHitResult) { int age = blockState.get(AGE); boolean mature = age == 3; if (mature) { int amount = 1 + world.random.nextInt(3); dropStack(world, blockPos, new ItemStack(GalacticraftItems.MOON_BERRIES, amount)); world.playSound(null, blockPos, SoundEvents.ITEM_SWEET_BERRIES_PICK_FROM_BUSH, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F); world.setBlockState(blockPos, blockState.with(AGE, 1), 2); return ActionResult.SUCCESS; } else { return super.onUse(blockState, world, blockPos, playerEntity, hand, blockHitResult); } }
Example #15
Source File: CavernousVineBlockPoisonous.java From Galacticraft-Rewoven with MIT License | 5 votes |
@Override public ActionResult onUse(BlockState blockState, World world, BlockPos blockPos, PlayerEntity playerEntity, Hand hand, BlockHitResult blockHitResult) { if (playerEntity.getStackInHand(hand).getItem() instanceof ShearsItem) { world.setBlockState(blockPos, GalacticraftBlocks.CAVERNOUS_VINE.getDefaultState().with(VINES, blockState.get(VINES))); world.playSound(blockPos.getX(), blockPos.getY(), blockPos.getZ(), SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.BLOCKS, 1f, 1f, true); return ActionResult.SUCCESS; } return ActionResult.SUCCESS; }
Example #16
Source File: InfusionAltarBlock.java From the-hallow with MIT License | 4 votes |
@Environment(EnvType.CLIENT) public void createSound(InfusionAltarBlockEntity altarEntity) { altarEntity.getWorld().playSound(MinecraftClient.getInstance().player, altarEntity.getPos(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 1.0F, 1.0F); }
Example #17
Source File: CrowEntity.java From the-hallow with MIT License | 4 votes |
@Override public SoundCategory getSoundCategory() { return SoundCategory.NEUTRAL; }
Example #18
Source File: DropperBlock_craftingMixin.java From carpet-extra with GNU Lesser General Public License v3.0 | 4 votes |
@Inject(method = "dispense", at = @At("HEAD"), cancellable = true) private void tryCraft(World world_1, BlockPos blockPos_1, CallbackInfo ci) { if (!CarpetExtraSettings.autoCraftingDropper) return; BlockPos front = blockPos_1.offset(world_1.getBlockState(blockPos_1).get(DispenserBlock.FACING)); if (world_1.getBlockState(front).getBlock() != Blocks.CRAFTING_TABLE) return; DispenserBlockEntity dispenserBlockEntity_1 = (DispenserBlockEntity) world_1.getBlockEntity(blockPos_1); if (dispenserBlockEntity_1 == null) return; CraftingInventory craftingInventory = new CraftingInventory(new VoidContainer(), 3, 3); for (int i=0; i < 9; i++) craftingInventory.setInvStack(i, dispenserBlockEntity_1.getInvStack(i)); CraftingRecipe recipe = world_1.getRecipeManager().getFirstMatch(RecipeType.CRAFTING, craftingInventory, world_1).orElse(null); if (recipe == null) return; // crafting it Vec3d target = new Vec3d(front).add(0.5, 0.2, 0.5); ItemStack result = recipe.craft(craftingInventory); spawn(world_1, target.x, target.y, target.z, result); // copied from CraftingResultSlot.onTakeItem() DefaultedList<ItemStack> defaultedList_1 = world_1.getRecipeManager().getRemainingStacks(RecipeType.CRAFTING, craftingInventory, world_1); for(int int_1 = 0; int_1 < defaultedList_1.size(); ++int_1) { ItemStack itemStack_2 = dispenserBlockEntity_1.getInvStack(int_1); ItemStack itemStack_3 = defaultedList_1.get(int_1); if (!itemStack_2.isEmpty()) { dispenserBlockEntity_1.takeInvStack(int_1, 1); itemStack_2 = dispenserBlockEntity_1.getInvStack(int_1); } if (!itemStack_3.isEmpty()) { if (itemStack_2.isEmpty()) { dispenserBlockEntity_1.setInvStack(int_1, itemStack_3); } else if (ItemStack.areItemsEqualIgnoreDamage(itemStack_2, itemStack_3) && ItemStack.areTagsEqual(itemStack_2, itemStack_3)) { itemStack_3.increment(itemStack_2.getCount()); dispenserBlockEntity_1.setInvStack(int_1, itemStack_3); } else { spawn(world_1, target.x, target.y, target.z, itemStack_3); } } } Vec3d vec = new Vec3d(blockPos_1).add(0.5, 0.5, 0.5); ServerWorld world = (ServerWorld) world_1; world.playSound(null, blockPos_1, SoundEvents.ENTITY_VILLAGER_WORK_MASON, SoundCategory.BLOCKS, 0.2f, 2.0f); ci.cancel(); }
Example #19
Source File: CompressorBlockEntity.java From Galacticraft-Rewoven with MIT License | 4 votes |
@Override public void tick() { if (this.disabled()) { return; } InventoryWrapper inv = new InventoryWrapper() { @Override public InventoryComponent getComponent() { return getInventory(); } @Override public int size() { return 9; } }; if (this.fuelTime <= 0) { ItemStack fuel = getInventory().getStack(FUEL_INPUT_SLOT); if (fuel.isEmpty()) { // Machine out of fuel and no fuel present. status = CompressorStatus.IDLE; progress = 0; return; } else if (isValidRecipe(inv) && canPutStackInResultSlot(getResultFromRecipeStack(inv))) { this.maxFuelTime = AbstractFurnaceBlockEntity.createFuelTimeMap().get(fuel.getItem()); this.fuelTime = maxFuelTime; decrement(FUEL_INPUT_SLOT, 1); status = CompressorStatus.PROCESSING; } else { // Can't start processing any new materials anyway, don't waste fuel. status = CompressorStatus.IDLE; progress = 0; return; } } this.fuelTime--; if (status == CompressorStatus.PROCESSING && !isValidRecipe(inv)) { status = CompressorStatus.IDLE; } if (status == CompressorStatus.PROCESSING && isValidRecipe(inv) && canPutStackInResultSlot(getResultFromRecipeStack(inv))) { ItemStack resultStack = getResultFromRecipeStack(inv); this.progress++; if (this.progress % 40 == 0 && this.progress > maxProgress / 2) { this.world.playSound(null, this.getPos(), SoundEvents.BLOCK_ANVIL_LAND, SoundCategory.BLOCKS, 0.3F, this.world.random.nextFloat() * 0.1F + 0.9F); } if (this.progress == maxProgress) { this.progress = 0; craftItem(resultStack); } } }
Example #20
Source File: ElectricCompressorBlockEntity.java From Galacticraft-Rewoven with MIT License | 4 votes |
public void tick() { if (disabled() || world.isClient) { if (disabled()) { idleEnergyDecrement(true); } return; } Inventory inv = new InventoryWrapper() { @Override public InventoryComponent getComponent() { return getInventory(); } @Override public int size() { return 9; } }; attemptChargeFromStack(FUEL_INPUT_SLOT); if (getCapacitatorComponent().getCurrentEnergy() < 1) { status = ElectricCompressorStatus.IDLE; } else if (isValidRecipe(inv) && canPutStackInResultSlot(getResultFromRecipeStack(inv))) { status = ElectricCompressorStatus.PROCESSING; } else { status = ElectricCompressorStatus.IDLE; } if (status == ElectricCompressorStatus.PROCESSING) { ItemStack resultStack = getResultFromRecipeStack(inv); this.getCapacitatorComponent().extractEnergy(GalacticraftEnergy.GALACTICRAFT_JOULES, getEnergyUsagePerTick(), ActionType.PERFORM); this.progress++; if (this.progress % 40 == 0 && this.progress > maxProgress / 2) { this.world.playSound(null, this.getPos(), SoundEvents.BLOCK_ANVIL_LAND, SoundCategory.BLOCKS, 0.3F, this.world.random.nextFloat() * 0.1F + 0.9F); } if (this.progress == maxProgress) { this.progress = 0; craftItem(resultStack); } } else if (status == ElectricCompressorStatus.IDLE) { if (progress > 0) { progress--; } } else { idleEnergyDecrement(false); if (progress > 0) { progress--; } } trySpreadEnergy(); }