net.minecraft.util.DefaultedList#net.minecraft.sound.SoundEvents源码实例Demo

下面列出了net.minecraft.util.DefaultedList#net.minecraft.sound.SoundEvents 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Galacticraft-Rewoven   文件: CoalGeneratorBlock.java
@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);

    }
}
 
源代码2 项目: the-hallow   文件: HallowedLogBlock.java
@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;
}
 
源代码3 项目: the-hallow   文件: WitchWaterBubbleColumnBlock.java
@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);
		}
	}
}
 
源代码4 项目: the-hallow   文件: ColoredPumpkinBlock.java
@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);
}
 
源代码5 项目: carpet-extra   文件: CarpetDispenserBehaviours.java
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);
    }
}
 
源代码6 项目: patchwork-api   文件: MixinSheepEntity.java
@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;
}
 
@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;
}
 
源代码8 项目: Galacticraft-Rewoven   文件: MoonBerryBushBlock.java
@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);
    }
}
 
源代码9 项目: Galacticraft-Rewoven   文件: TorchBlockMixin.java
@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);
    }
}
 
源代码10 项目: the-hallow   文件: HallowCharmItem.java
@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);
	}
}
 
源代码11 项目: the-hallow   文件: WitchedPumpkinItem.java
@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);
}
 
源代码12 项目: the-hallow   文件: BleedingBlock.java
@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);
	}
}
 
源代码13 项目: Wurst7   文件: AutoFishHack.java
@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;
}
 
源代码14 项目: Wurst7   文件: NavigatorFeatureScreen.java
@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);
}
 
源代码15 项目: multiconnect   文件: Protocol_1_10.java
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");
}
 
源代码16 项目: multiconnect   文件: Protocol_1_14_4.java
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");
}
 
@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();
}
 
源代码18 项目: carpet-extra   文件: WetSpongeBlockMixin.java
@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());
    }
}
 
源代码19 项目: LibGui   文件: WToggleButton.java
@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);
}
 
源代码20 项目: LibGui   文件: WButton.java
@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();
	}
}
 
源代码21 项目: patchwork-api   文件: MixinMooshroomEntity.java
@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;
}
 
源代码22 项目: bleachhack-1.14   文件: Window.java
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));
		}
	}
}
 
源代码23 项目: bleachhack-1.14   文件: Window.java
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));
		}
	}
}
 
源代码24 项目: bleachhack-1.14   文件: Window.java
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));
		}
	}
}
 
源代码25 项目: MineLittlePony   文件: GuiSkinsMineLP.java
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;
}
 
private void playButtonSound() {
    this.client.getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}
 
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();
}
 
@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);
        }
    }
}
 
源代码29 项目: the-hallow   文件: PumpcownEntity.java
@Override
public boolean interactMob(PlayerEntity player, Hand hand) {
	ItemStack stack = player.getStackInHand(hand);
	if (stack.getItem() == Items.SHEARS && this.getBreedingAge() >= 0) {
		this.world.addParticle(ParticleTypes.EXPLOSION, this.getX(), this.getY() + (double) (this.getHeight() / 2.0F), this.getZ(), 0.0D, 0.0D, 0.0D);
		if (!this.world.isClient) {
			this.remove();
			
			if (this.world.getDimension().getType() == HallowedDimensions.THE_HALLOW) {
				this.world.createExplosion(this, this.getX(), this.getY(), this.getZ(), 3.0F, Explosion.DestructionType.BREAK);
			} else {
				CowEntity cow = EntityType.COW.create(this.world);
				cow.updatePositionAndAngles(this.getX(), this.getY(), this.getZ(), this.yaw, this.pitch);
				cow.setHealth(this.getHealth());
				cow.bodyYaw = this.bodyYaw;
				if (this.hasCustomName()) {
					cow.setCustomName(this.getCustomName());
				}
				this.world.spawnEntity(cow);
			}
			
			for (int i = 0; i < 5; ++i) {
				this.world.spawnEntity(new ItemEntity(this.world, this.getX(), this.getY() + (double) this.getHeight(), this.getZ(), new ItemStack(STEM_FEATURE.getBlock())));
			}
			
			stack.damage(1, player, ((player_1) -> {
				player_1.sendToolBreakStatus(hand);
			}));
			this.playSound(SoundEvents.ENTITY_MOOSHROOM_SHEAR, 1.0F, 1.0F);
		}
		return true;
	} else if (stack.getItem() == Items.BOWL && this.getBreedingAge() >= 0 && !player.abilities.creativeMode) {
		stack.decrement(1);
		ItemStack stew = new ItemStack(HallowedItems.PUMPKIN_STEW);
		
		if (stack.isEmpty()) {
			player.setStackInHand(hand, stew);
		} else if (!player.inventory.insertStack(stew)) {
			player.dropItem(stew, false);
		}
		
		this.playSound(SoundEvents.ENTITY_MOOSHROOM_MILK, 1.0F, 1.0F);
		
		return true;
	} else {
		return super.interactMob(player, hand);
	}
}
 
源代码30 项目: the-hallow   文件: CrowEntity.java
@Override
protected float playFlySound(float distanceWalked) {
	this.playSound(SoundEvents.ENTITY_PARROT_FLY, 0.15F, 1.0F);
	return distanceWalked + this.f2 / 2.0F;
}