net.minecraft.sound.SoundEvents Java Examples

The following examples show how to use net.minecraft.sound.SoundEvents. 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: CarpetDispenserBehaviours.java    From carpet-extra with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #2
Source File: ColoredPumpkinBlock.java    From the-hallow with MIT License 6 votes vote down vote up
@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 #3
Source File: WitchWaterBubbleColumnBlock.java    From the-hallow with MIT License 6 votes vote down vote up
@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 #4
Source File: HallowedLogBlock.java    From the-hallow with MIT License 6 votes vote down vote up
@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: CoalGeneratorBlock.java    From Galacticraft-Rewoven with MIT License 6 votes vote down vote up
@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 #6
Source File: MixinSheepEntity.java    From patchwork-api with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public List<ItemStack> onSheared(ItemStack item, IWorld world, BlockPos pos, int fortune) {
	List<ItemStack> drops = new java.util.ArrayList<>();

	if (!this.world.isClient) {
		this.setSheared(true);

		int count = 1 + this.random.nextInt(3);
		ItemConvertible wool = DROPS.get(this.getColor());

		for (int i = 0; i < count; i++) {
			drops.add(new ItemStack(wool));
		}
	}

	this.playSound(SoundEvents.ENTITY_SHEEP_SHEAR, 1.0F, 1.0F);
	return drops;
}
 
Example #7
Source File: WToggleButton.java    From LibGui with MIT License 5 votes vote down vote up
@Environment(EnvType.CLIENT)
@Override
public void onClick(int x, int y, int button) {
	super.onClick(x, y, button);
	
	MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));

	this.isOn = !this.isOn;
	onToggle(this.isOn);
}
 
Example #8
Source File: WetSpongeBlockMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #9
Source File: FarmerVillagerTask_wartFarmMixin.java    From carpet-extra with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 #10
Source File: Window.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public void onMousePressed(int x, int y) {
	if (x > x1 + 2 && x < x2 - 2 && y > y1 + 2 && y < y1 + 12) {
		dragging = true;
		dragOffX = x - x1;
		dragOffY = y - y1;
	}
	
	for (WindowButton w: buttons) {
		if (x >= x1 + w.x1 && x <= x1 + w.x2 && y >= y1 + w.y1 && y <= y1 + w.y2) {
			w.action.run();
			MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
		}
	}
}
 
Example #11
Source File: Protocol_1_14_4.java    From multiconnect with MIT License 5 votes vote down vote up
private void mutateSoundEventRegistry(ISimpleRegistry<SoundEvent> registry) {
    registry.unregister(SoundEvents.ENTITY_BEE_DEATH);
    registry.unregister(SoundEvents.ENTITY_BEE_HURT);
    registry.unregister(SoundEvents.ENTITY_BEE_LOOP_AGGRESSIVE);
    registry.unregister(SoundEvents.ENTITY_BEE_LOOP);
    registry.unregister(SoundEvents.ENTITY_BEE_STING);
    registry.unregister(SoundEvents.ENTITY_BEE_POLLINATE);
    registry.unregister(SoundEvents.BLOCK_BEEHIVE_DRIP);
    registry.unregister(SoundEvents.BLOCK_BEEHIVE_ENTER);
    registry.unregister(SoundEvents.BLOCK_BEEHIVE_EXIT);
    registry.unregister(SoundEvents.BLOCK_BEEHIVE_SHEAR);
    registry.unregister(SoundEvents.BLOCK_BEEHIVE_WORK);
    registry.unregister(SoundEvents.BLOCK_HONEY_BLOCK_BREAK);
    registry.unregister(SoundEvents.BLOCK_HONEY_BLOCK_FALL);
    registry.unregister(SoundEvents.BLOCK_HONEY_BLOCK_HIT);
    registry.unregister(SoundEvents.BLOCK_HONEY_BLOCK_PLACE);
    registry.unregister(SoundEvents.BLOCK_HONEY_BLOCK_SLIDE);
    registry.unregister(SoundEvents.BLOCK_HONEY_BLOCK_STEP);
    registry.unregister(SoundEvents.ITEM_HONEY_BOTTLE_DRINK);
    registry.unregister(SoundEvents.ENTITY_IRON_GOLEM_DAMAGE);
    registry.unregister(SoundEvents.ENTITY_IRON_GOLEM_REPAIR);

    insertAfter(registry, SoundEvents.ENTITY_PARROT_IMITATE_ENDER_DRAGON, SoundEvents_1_14_4.ENTITY_PARROT_IMITATE_ENDERMAN, "entity.parrot.imitate.enderman");
    insertAfter(registry, SoundEvents.ENTITY_PARROT_IMITATE_MAGMA_CUBE, SoundEvents_1_14_4.ENTITY_PARROT_IMITATE_PANDA, "entity.parrot.imitate.panda");
    insertAfter(registry, SoundEvents.ENTITY_PARROT_IMITATE_PILLAGER, SoundEvents_1_14_4.ENTITY_PARROT_IMITATE_POLAR_BEAR, "entity.parrot.imitate.polar_bear");
    insertAfter(registry, SoundEvents.ENTITY_PARROT_IMITATE_WITHER_SKELETON, SoundEvents_1_14_4.ENTITY_PARROT_IMITATE_WOLF, "entity.parrot.imitate.wolf");
    insertAfter(registry, SoundEvents.ENTITY_PARROT_IMITATE_ZOMBIE, SoundEvents_1_14_4.ENTITY_PARROT_IMITATE_ZOMBIE_PIGMAN, "entity.parrot.imitate.zombie_pigman");
}
 
Example #12
Source File: Protocol_1_10.java    From multiconnect with MIT License 5 votes vote down vote up
private void mutateSoundEventRegistry(ISimpleRegistry<SoundEvent> registry) {
    registry.unregister(SoundEvents.BLOCK_SHULKER_BOX_CLOSE);
    registry.unregister(SoundEvents.BLOCK_SHULKER_BOX_OPEN);
    registry.unregister(SoundEvents.ENTITY_ELDER_GUARDIAN_FLOP);
    registry.unregister(SoundEvents.ENTITY_EVOKER_FANGS_ATTACK);
    registry.unregister(SoundEvents.ENTITY_EVOKER_AMBIENT);
    registry.unregister(SoundEvents.ENTITY_EVOKER_CAST_SPELL);
    registry.unregister(SoundEvents.ENTITY_EVOKER_DEATH);
    registry.unregister(SoundEvents.ENTITY_EVOKER_HURT);
    registry.unregister(SoundEvents.ENTITY_EVOKER_PREPARE_ATTACK);
    registry.unregister(SoundEvents.ENTITY_EVOKER_PREPARE_SUMMON);
    registry.unregister(SoundEvents.ENTITY_EVOKER_PREPARE_WOLOLO);
    registry.unregister(SoundEvents.ENTITY_LLAMA_AMBIENT);
    registry.unregister(SoundEvents.ENTITY_LLAMA_ANGRY);
    registry.unregister(SoundEvents.ENTITY_LLAMA_CHEST);
    registry.unregister(SoundEvents.ENTITY_LLAMA_DEATH);
    registry.unregister(SoundEvents.ENTITY_LLAMA_EAT);
    registry.unregister(SoundEvents.ENTITY_LLAMA_HURT);
    registry.unregister(SoundEvents.ENTITY_LLAMA_SPIT);
    registry.unregister(SoundEvents.ENTITY_LLAMA_STEP);
    registry.unregister(SoundEvents.ENTITY_LLAMA_SWAG);
    registry.unregister(SoundEvents.ENTITY_MULE_CHEST);
    registry.unregister(SoundEvents.ENTITY_VEX_AMBIENT);
    registry.unregister(SoundEvents.ENTITY_VEX_CHARGE);
    registry.unregister(SoundEvents.ENTITY_VEX_DEATH);
    registry.unregister(SoundEvents.ENTITY_VEX_HURT);
    registry.unregister(SoundEvents.ENTITY_VINDICATOR_AMBIENT);
    registry.unregister(SoundEvents.ENTITY_VINDICATOR_DEATH);
    registry.unregister(SoundEvents.ENTITY_VINDICATOR_HURT);
    registry.unregister(SoundEvents.ITEM_ARMOR_EQUIP_ELYTRA);
    registry.unregister(SoundEvents.ITEM_BOTTLE_EMPTY);
    registry.unregister(SoundEvents.ITEM_TOTEM_USE);

    insertAfter(registry, SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundEvents_1_10.ENTITY_EXPERIENCE_ORB_TOUCH, "entity.experience_orb.touch");
}
 
Example #13
Source File: NavigatorFeatureScreen.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onMouseClick(double x, double y, int button)
{
	// popups
	if(WurstClient.INSTANCE.getGui().handleNavigatorPopupClick(
		x - middleX + 154, y - 60 - scroll + 13, button))
		return;
	
	Rectangle area = new Rectangle(width / 2 - 154, 60, 308, height - 103);
	if(!area.contains(x, y))
		return;
	
	// buttons
	if(activeButton != null)
	{
		client.getSoundManager().play(
			PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1));
		activeButton.press();
		WurstClient.INSTANCE.getNavigator()
			.addPreference(feature.getName());
		return;
	}
	
	// component settings
	WurstClient.INSTANCE.getGui().handleNavigatorMouseClick(
		x - middleX + 154, y - 60 - scroll - window.getY(), button, window);
}
 
Example #14
Source File: WButton.java    From LibGui with MIT License 5 votes vote down vote up
@Environment(EnvType.CLIENT)
@Override
public void onClick(int x, int y, int button) {
	super.onClick(x, y, button);
	
	if (enabled && isWithinBounds(x, y)) {
		MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));

		if (onClick!=null) onClick.run();
	}
}
 
Example #15
Source File: AutoFishHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onReceivedPacket(PacketInputEvent event)
{
	ClientPlayerEntity player = MC.player;
	if(player == null || player.fishHook == null)
		return;
	
	if(!(event.getPacket() instanceof PlaySoundS2CPacket))
		return;
	
	// check sound type
	PlaySoundS2CPacket sound = (PlaySoundS2CPacket)event.getPacket();
	if(!SoundEvents.ENTITY_FISHING_BOBBER_SPLASH.equals(sound.getSound()))
		return;
	
	if(debugDraw.isChecked())
		lastSoundPos = new Vec3d(sound.getX(), sound.getY(), sound.getZ());
	
	// check position
	FishingBobberEntity bobber = player.fishHook;
	if(Math.abs(sound.getX() - bobber.getX()) > validRange.getValue()
		|| Math.abs(sound.getZ() - bobber.getZ()) > validRange.getValue())
		return;
	
	// catch fish
	rightClick();
	castRodTimer = 15;
}
 
Example #16
Source File: MixinMooshroomEntity.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public List<ItemStack> onSheared(ItemStack item, IWorld world, BlockPos pos, int fortune) {
	List<ItemStack> drops = new ArrayList<>();
	this.world.addParticle(ParticleTypes.EXPLOSION, this.x, this.y + (double) (this.getHeight() / 2.0F), this.z, 0.0D, 0.0D, 0.0D);

	if (!this.world.isClient) {
		this.remove();

		CowEntity cow = EntityType.COW.create(this.world);
		cow.refreshPositionAndAngles(this.x, this.y, this.z, this.yaw, this.pitch);
		cow.setHealth(this.getHealth());
		cow.field_6283 = this.field_6283;

		if (this.hasCustomName()) {
			cow.setCustomName(this.getCustomName());
		}

		this.world.spawnEntity(cow);
		Block mushroom = this.getMooshroomType().getMushroomState().getBlock();

		// TODO: Fixes forge bug where shearing brown mooshrooms always drop red mushrooms (Fixed in 1.15)
		for (int i = 0; i < 5; ++i) {
			drops.add(new ItemStack(mushroom));
		}

		this.playSound(SoundEvents.ENTITY_MOOSHROOM_SHEAR, 1.0F, 1.0F);
	}

	return drops;
}
 
Example #17
Source File: Window.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public void onMousePressed(int x, int y) {
	if (x > x1 + 2 && x < x2 - 2 && y > y1 + 2 && y < y1 + 12) {
		dragging = true;
		dragOffX = x - x1;
		dragOffY = y - y1;
	}
	
	for (WindowButton w: buttons) {
		if (x >= x1 + w.x1 && x <= x1 + w.x2 && y >= y1 + w.y1 && y <= y1 + w.y2) {
			w.action.run();
			MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
		}
	}
}
 
Example #18
Source File: BleedingBlock.java    From the-hallow with MIT License 5 votes vote down vote up
@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 #19
Source File: WitchedPumpkinItem.java    From the-hallow with MIT License 5 votes vote down vote up
@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 #20
Source File: HallowCharmItem.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity player, Hand hand) {
	if (world.getDimension().getType() == HallowedDimensions.THE_HALLOW) {
		player.setCurrentHand(hand);
		player.playSound(SoundEvents.BLOCK_PORTAL_TRIGGER, 1F, 1F);
		return new TypedActionResult<>(ActionResult.SUCCESS, player.getActiveItem());
	} else {
		return ITrinket.equipTrinket(player, hand);
	}
}
 
Example #21
Source File: Window.java    From bleachhack-1.14 with GNU General Public License v3.0 5 votes vote down vote up
public void onMousePressed(int x, int y) {
	if (x > x1 + 2 && x < x2 - 2 && y > y1 + 2 && y < y1 + 12) {
		dragging = true;
		dragOffX = x - x1;
		dragOffY = y - y1;
	}
	
	for (WindowButton w: buttons) {
		if (x >= x1 + w.x1 && x <= x1 + w.x2 && y >= y1 + w.y1 && y <= y1 + w.y2) {
			w.action.run();
			MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
		}
	}
}
 
Example #22
Source File: TorchBlockMixin.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@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 #23
Source File: MoonBerryBushBlock.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@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 #24
Source File: CavernousVineBlockPoisonous.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@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 #25
Source File: GuiSkinsMineLP.java    From MineLittlePony with MIT License 5 votes vote down vote up
protected int setWet(int wet) {
    playSound(SoundEvents.BLOCK_BREWING_STAND_BREW);

    isWet = wet == 1;

    previewer.getLocal().getTextures().release();;

    if (previewer instanceof PonyPreview) {
        ((PonyPreview)previewer).setWet(isWet);
    }
    return wet;
}
 
Example #26
Source File: ClickGuiScreen.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public void render(MatrixStack matrix, int mX, int mY, float float_1) {
	this.renderBackground(matrix);
	textRenderer.draw(matrix, "BleachHack-1.16-" + BleachHack.VERSION, 3, 3, 0x305090);
	textRenderer.draw(matrix, "BleachHack-1.16-" + BleachHack.VERSION, 2, 2, 0x6090d0);
	textRenderer.drawWithShadow(matrix, "Hover over a bind setting and press a key to change a bind" , 2, height-10, 0xff9999);
	textRenderer.drawWithShadow(matrix, "Use .guireset to reset the gui" , 2, height-20, 0x9999ff);
	
	super.render(matrix, mX, mY, float_1);
	
	mouseX = mX;
	mouseY = mY;
	
	len = Math.max(50, (int) Math.round(ModuleManager.getModule(ClickGui.class).getSettings().get(0).toSlider().getValue()));
	for (Window w: windows) {
		if (w instanceof ModuleWindow) {
			ModuleWindow mw = (ModuleWindow) w;
			
			int x = mw.x1 + 1;
			int y = mw.y1 + 13;
			mw.x2 = x + len + 1;
			
			if (rmDown && mouseOver(x, y-12, x+len, y)) {
				client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
				mw.hiding = !mw.hiding;
			}
			
			if (mw.hiding) {
				mw.y2 = y;
				continue;
			} else {
				mw.y2 = y + mw.getHeight();
			}
			
			int count = 0;
			for (Entry<Module, Boolean> m: new LinkedHashMap<>(mw.mods).entrySet()) {
				if (m.getValue()) fillReverseGrey(matrix, x, y+(count*12), x+len-1, y+12+(count*12));
				fill(matrix, x, y+(count*12), x+len, y+12+(count*12),
						mouseOver(x, y+(count*12), x+len, y+12+(count*12)) ? 0x70303070 : 0x00000000);
				
				textRenderer.drawWithShadow(matrix, cutText(m.getKey().getName(), len),
						x+2, y+2+(count*12), m.getKey().isToggled() ? 0x70efe0 : 0xc0c0c0);
				
				//fill(m.getValue() ? x+len-2 : x+len-1, y+(count*12), 
				//		x+len, y+12+(count*12), m.getValue() ? 0x9f70fff0 : 0x5f70fff0);
				
				/* Set which module settings show on */
				if (mouseOver(x, y+(count*12), x+len, y+12+(count*12))) {
					GL11.glTranslated(0, 0, 300);
					/* Match lines to end of words */
			        Matcher mat = Pattern.compile("\\b.{1,22}\\b\\W?").matcher(m.getKey().getDesc());

			        int c2 = 0;
			        int c3 = 0;
			        while(mat.find()) { c2++; } mat.reset();
			        
			        while(mat.find()) {
			        	fill(matrix, x+len+3, y-1+(count*12)-(c2 * 10)+(c3 * 10),
			        			x+len+6+textRenderer.getWidth(mat.group().trim()), y+(count*12)-(c2 * 10)+(c3 * 10)+9,
								0x90000000);
			        	textRenderer.drawWithShadow(matrix, mat.group(), x+len+5, y+(count*12)-(c2 * 10)+(c3 * 10), -1);
						c3++;
					}
					if (lmDown) m.getKey().toggle();
					if (rmDown) mw.mods.replace(m.getKey(), !m.getValue());
					if (lmDown || rmDown) client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
					GL11.glTranslated(0, 0, -300);
				}
				
				/* draw settings */
				if (m.getValue()) {
					for (SettingBase s: m.getKey().getSettings()) {
						count++;
						if (s instanceof SettingMode) drawModeSetting(matrix, s.toMode(), x, y+(count*12));
						if (s instanceof SettingToggle) drawToggleSetting(matrix, s.toToggle(), x, y+(count*12));
						if (s instanceof SettingSlider) drawSliderSetting(matrix, s.toSlider(), x, y+(count*12));
						//fill(x+len-1, y+(count*12), x+len, y+12+(count*12), 0x9f70fff0);
					}
					count++;
					drawBindSetting(matrix, m.getKey(), keyDown, x, y+(count*12));
					//fill(x+len-1, y+(count*12), x+len, y+12+(count*12), 0x9f70fff0);
				}
				count++;
			}
		}
	}
	
	lmDown = false;
	rmDown = false;
	keyDown = -1;
}
 
Example #27
Source File: BleachCheckbox.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public void onPress() {
	MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
	checked = !checked;
}
 
Example #28
Source File: ModuleWindowLight.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public void draw(int mX, int mY, int leng) {
	mouseX = mX; mouseY = mY; len = leng;
	font = MinecraftClient.getInstance().textRenderer;
	
	Screen.fill(posX, posY-10, posX+len, posY, 
			mouseOver(posX, posY-10, posX+len, posY) ? 0x704060cf : 0x704040ff);
	font.drawWithShadow(name, posX+(len/2)-(font.getStringWidth(name)/2), posY-9, 0xffaaff);
	
	/* window dragging */
	if (mouseOver(posX, posY-10, posX+len, posY)) {
		if (rmDown) hiding = !hiding;
		if (lmDown) dragging = true;
	}
	
	if (!lmHeld) dragging = false;
	if (dragging) {
		posX = mouseX-(prevmX - posX);
		posY = mouseY-(prevmY - posY);
	}
	
	prevmX = mouseX;
	prevmY = mouseY;
	
	/* Draw Modules */
	if (hiding) {
		font.drawWithShadow("-", posX+len-8, posY-9, 0xffaaff);
		return;
	} else font.drawWithShadow("+", posX+len-8, posY-9, 0xffaaff);
		
	int count = 0;
	for (Entry<Module, Boolean> m: new LinkedHashMap<>(mods).entrySet()) {
		Screen.fill(posX, posY+(count*12), posX+len, posY+12+(count*12),
				mouseOver(posX, posY+(count*12), posX+len, posY+12+(count*12)) ? 0x70303070 : 0x70000000);
		font.drawWithShadow(cutText(m.getKey().getName(), len),
				posX+2, posY+2+(count*12), m.getKey().isToggled() ? 0x6060ff : 0xffffff);
		
		Screen.fill(m.getValue() ? posX+len-2 : posX+len-1, posY+(count*12), 
				posX+len, posY+12+(count*12), m.getValue() ? 0x9fffffff : 0x5fffffff);
		
		/* Set which module settings show on */
		if (mouseOver(posX, posY+(count*12), posX+len, posY+12+(count*12))) {
			GL11.glTranslated(0, 0, 300);
			/* Match lines to end of words */
	        Matcher mat = Pattern.compile("\\b.{1,22}\\b\\W?").matcher(m.getKey().getDesc());

	        int c2 = 0;
	        int c3 = 0;
	        while(mat.find()) { c2++; } mat.reset();
	        
	        while(mat.find()) {
	        	Screen.fill(posX+len+3, posY-1+(count*12)-(c2 * 10)+(c3 * 10),
						posX+len+6+font.getStringWidth(mat.group().trim()), posY+(count*12)-(c2 * 10)+(c3 * 10)+9,
						0x90000000);
	        	font.drawWithShadow(mat.group(), posX+len+5, posY+(count*12)-(c2 * 10)+(c3 * 10), -1);
				c3++;
			}
			if (lmDown) m.getKey().toggle();
			if (rmDown) mods.replace(m.getKey(), !m.getValue());
			if (lmDown || rmDown) MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
			GL11.glTranslated(0, 0, -300);
		}
		
		/* draw settings */
		if (m.getValue()) {
			for (SettingBase s: m.getKey().getSettings()) {
				count++;
				if (s instanceof SettingMode) drawModeSetting(s.toMode(), posX, posY+(count*12));
				if (s instanceof SettingToggle) drawToggleSetting(s.toToggle(), posX, posY+(count*12));
				if (s instanceof SettingSlider) drawSliderSetting(s.toSlider(), posX, posY+(count*12));
				Screen.fill(posX+len-1, posY+(count*12), posX+len, posY+12+(count*12), 0x9fffffff);
			}
			count++;
			drawBindSetting(m.getKey(), keyDown, posX, posY+(count*12));
			Screen.fill(posX+len-1, posY+(count*12), posX+len, posY+12+(count*12), 0x9fffffff);
		}
		count++;
	}
	
	lmDown = false;
	rmDown = false;
	keyDown = -1;
}
 
Example #29
Source File: ClickGuiScreen.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public void render(int mX, int mY, float float_1) {
	this.renderBackground();
	font.draw("BleachHack-1.15-" + BleachHack.VERSION, 3, 3, 0x305090);
	font.draw("BleachHack-1.15-" + BleachHack.VERSION, 2, 2, 0x6090d0);
	font.drawWithShadow("Hover over a bind setting and press a key to change a bind" , 2, height-10, 0xff9999);
	font.drawWithShadow("Use .guireset to reset the gui" , 2, height-20, 0x9999ff);
	
	super.render(mX, mY, float_1);
	
	mouseX = mX;
	mouseY = mY;
	
	len = Math.max(50, (int) Math.round(ModuleManager.getModule(ClickGui.class).getSettings().get(0).toSlider().getValue()));
	for (Window w: windows) {
		if (w instanceof ModuleWindow) {
			ModuleWindow mw = (ModuleWindow) w;
			
			int x = mw.x1 + 1;
			int y = mw.y1 + 13;
			mw.x2 = x + len + 1;
			
			if (rmDown && mouseOver(x, y-12, x+len, y)) {
				minecraft.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
				mw.hiding = !mw.hiding;
			}
			
			if (mw.hiding) {
				mw.y2 = y;
				continue;
			} else {
				mw.y2 = y + mw.getHeight();
			}
			
			int count = 0;
			for (Entry<Module, Boolean> m: new LinkedHashMap<>(mw.mods).entrySet()) {
				if (m.getValue()) fillReverseGrey(x, y+(count*12), x+len-1, y+12+(count*12));
				fill(x, y+(count*12), x+len, y+12+(count*12),
						mouseOver(x, y+(count*12), x+len, y+12+(count*12)) ? 0x70303070 : 0x00000000);
				
				font.drawWithShadow(cutText(m.getKey().getName(), len),
						x+2, y+2+(count*12), m.getKey().isToggled() ? 0x70efe0 : 0xc0c0c0);
				
				//fill(m.getValue() ? x+len-2 : x+len-1, y+(count*12), 
				//		x+len, y+12+(count*12), m.getValue() ? 0x9f70fff0 : 0x5f70fff0);
				
				/* Set which module settings show on */
				if (mouseOver(x, y+(count*12), x+len, y+12+(count*12))) {
					GL11.glTranslated(0, 0, 300);
					/* Match lines to end of words */
			        Matcher mat = Pattern.compile("\\b.{1,22}\\b\\W?").matcher(m.getKey().getDesc());

			        int c2 = 0;
			        int c3 = 0;
			        while(mat.find()) { c2++; } mat.reset();
			        
			        while(mat.find()) {
			        	fill(x+len+3, y-1+(count*12)-(c2 * 10)+(c3 * 10),
			        			x+len+6+font.getStringWidth(mat.group().trim()), y+(count*12)-(c2 * 10)+(c3 * 10)+9,
								0x90000000);
			        	font.drawWithShadow(mat.group(), x+len+5, y+(count*12)-(c2 * 10)+(c3 * 10), -1);
						c3++;
					}
					if (lmDown) m.getKey().toggle();
					if (rmDown) mw.mods.replace(m.getKey(), !m.getValue());
					if (lmDown || rmDown) minecraft.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
					GL11.glTranslated(0, 0, -300);
				}
				
				/* draw settings */
				if (m.getValue()) {
					for (SettingBase s: m.getKey().getSettings()) {
						count++;
						if (s instanceof SettingMode) drawModeSetting(s.toMode(), x, y+(count*12));
						if (s instanceof SettingToggle) drawToggleSetting(s.toToggle(), x, y+(count*12));
						if (s instanceof SettingSlider) drawSliderSetting(s.toSlider(), x, y+(count*12));
						//fill(x+len-1, y+(count*12), x+len, y+12+(count*12), 0x9f70fff0);
					}
					count++;
					drawBindSetting(m.getKey(), keyDown, x, y+(count*12));
					//fill(x+len-1, y+(count*12), x+len, y+12+(count*12), 0x9f70fff0);
				}
				count++;
			}
		}
	}
	
	lmDown = false;
	rmDown = false;
	keyDown = -1;
}
 
Example #30
Source File: ModuleWindowFuture.java    From bleachhack-1.14 with GNU General Public License v3.0 4 votes vote down vote up
public void draw(int mX, int mY, int leng) {
	mouseX = mX; mouseY = mY; len = leng;
	font = MinecraftClient.getInstance().textRenderer;
	
	Screen.fill(posX, posY-12, posX+len, posY, 
			mouseOver(posX, posY-12, posX+len, posY) ? 0x70cf3030 : 0x70ff3030);
	font.drawWithShadow(name, posX+3, posY-10, -1);
	
	/* window dragging */
	if (mouseOver(posX, posY-12, posX+len, posY)) {
		if (rmDown) hiding = !hiding;
		if (lmDown) dragging = true;
	}
	
	if (!lmHeld) dragging = false;
	if (dragging) {
		posX = mouseX-(prevmX - posX);
		posY = mouseY-(prevmY - posY);
	}
	
	prevmX = mouseX;
	prevmY = mouseY;
	
	/* Draw Modules */
	if (hiding) {
		font.drawWithShadow("-", posX+len-8, posY-10, -1);
		return;
	} else font.drawWithShadow("+", posX+len-8, posY-10, -1);
		
	int count = 0;
	for (Entry<Module, Boolean> m: new LinkedHashMap<>(mods).entrySet()) {
		if (m.getKey().isToggled()) Screen.fill(posX, posY+(count*14), posX+len, posY+14+(count*14), 0xffff0000);
		Screen.fill(posX, posY+(count*14), posX+len, posY+14+(count*14),
				mouseOver(posX, posY+(count*14), posX+len, posY+14+(count*14)) ? 0x70303030 : 0x70000000);
		font.drawWithShadow(cutText(m.getKey().getName(), len),
				posX+2, posY+3+(count*14), 0xffffff);
		
		Screen.fill(posX+len-1, posY+(count*14), posX+len, posY+14+(count*14), m.getValue() ? 0xafffffff : 0x5fffffff);
		
		/* Set which module settings show on */
		if (mouseOver(posX, posY+(count*14), posX+len, posY+14+(count*14))) {
			GL11.glTranslated(0, 0, 300);
			/* Match lines to end of words */
	        Matcher mat = Pattern.compile("\\b.{1,22}\\b\\W?").matcher(m.getKey().getDesc());

	        int c2 = 0;
	        int c3 = 0;
	        while(mat.find()) { c2++; } mat.reset();
	        
	        while(mat.find()) {
	        	Screen.fill(posX+len+3, posY-1+(count*14)-(c2 * 10)+(c3 * 10),
						posX+len+6+font.getStringWidth(mat.group().trim()), posY+(count*14)-(c2 * 10)+(c3 * 10)+9,
						0x90000000);
	        	font.drawWithShadow(mat.group(), posX+len+5, posY+(count*14)-(c2 * 10)+(c3 * 10), -1);
				c3++;
			}
			if (lmDown) m.getKey().toggle();
			if (rmDown) mods.replace(m.getKey(), !m.getValue());
			if (lmDown || rmDown) MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
			GL11.glTranslated(0, 0, -300);
		}
		
		/* draw settings */
		if (m.getValue()) {
			for (SettingBase s: m.getKey().getSettings()) {
				count++;
				if (s instanceof SettingMode) drawModeSetting(s.toMode(), posX, posY+(count*14));
				if (s instanceof SettingToggle) drawToggleSetting(s.toToggle(), posX, posY+(count*14));
				if (s instanceof SettingSlider) drawSliderSetting(s.toSlider(), posX, posY+(count*14));
			}
			count++;
			drawBindSetting(m.getKey(), keyDown, posX, posY+(count*14));
		}
		count++;
	}
	
	lmDown = false;
	rmDown = false;
	keyDown = -1;
}