public void playRecord(@Nullable SoundEvent soundIn, BlockPos pos) { ISound isound = (ISound)this.mapSoundPositions.get(pos); if (isound != null) { this.mc.getSoundHandler().stopSound(isound); this.mapSoundPositions.remove(pos); } if (soundIn != null) { ItemRecord itemrecord = ItemRecord.getBySound(soundIn); if (itemrecord != null) { this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal()); } PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.getRecordSoundRecord(soundIn, (float)pos.getX(), (float)pos.getY(), (float)pos.getZ()); this.mapSoundPositions.put(pos, positionedsoundrecord); this.mc.getSoundHandler().playSound(positionedsoundrecord); } }
protected void playEquipSound(ItemStack stack) { if (!stack.func_190926_b()) { SoundEvent soundevent = SoundEvents.ITEM_ARMOR_EQUIP_GENERIC; Item item = stack.getItem(); if (item instanceof ItemArmor) { soundevent = ((ItemArmor)item).getArmorMaterial().getSoundEvent(); } else if (item == Items.ELYTRA) { soundevent = SoundEvents.field_191258_p; } this.playSound(soundevent, 1.0F, 1.0F); } }
@SubscribeEvent public void registerSounds(Register<SoundEvent> event) { IForgeRegistry<SoundEvent> registry = event.getRegistry(); ArcaneMagicSoundHandler.register("spell", registry); ArcaneMagicSoundHandler.register("scepter_1", registry); ArcaneMagicSoundHandler.register("scepter_2", registry); ArcaneMagicSoundHandler.register("scepter_3", registry); ArcaneMagicSoundHandler.register("page_1", registry); ArcaneMagicSoundHandler.register("page_2", registry); ArcaneMagicSoundHandler.register("arcane_transfiguration_success", registry); ArcaneMagicSoundHandler.register("write_1", registry); ArcaneMagicSoundHandler.register("write_2", registry); ArcaneMagicSoundHandler.register("learn_1", registry); ArcaneMagicSoundHandler.register("learn_2", registry); ArcaneMagicSoundHandler.register("reconstruct", registry); ArcaneMagicSoundHandler.register("clack", registry); }
@Override public void notifyDataManagerChange(DataParameter<?> key) { this.adjustSize(); // System.out.println("Watcher update: "+data); if (!this.world.isRemote && key == CONSTRUCTING) { this.setSoundState(this.dataManager.get(CONSTRUCTING) >= this.getConstructionTime()? 0 : 25); } if (this.world.isRemote && key == SOUND_STATE) { SoundEvent sound = this.getSoundNameForState(this.getSoundState()); if (sound != null) { // System.out.println("Playing Sound: "+sound); if (this.buildingSound != null) this.buildingSound.stopPlaying(); this.buildingSound = new BuildingSound(this, sound, this.getSoundState()); ClientProxy.playBuildingSound(buildingSound); } else{ if(this.buildingSound != null) this.buildingSound.stopPlaying(); } } }
@Override public void fromBytes(ByteBuf buffer) { super.fromBytes(buffer); soundEvent = new SoundEvent(new ResourceLocation(ByteBufUtils.readUTF8String(buffer))); category = SoundCategory.values()[buffer.readInt()]; volume = buffer.readFloat(); pitch = buffer.readFloat(); bool = buffer.readBoolean(); }
/** * Takes a filled container and tries to empty it into the given tank. * * @param container The filled container. Will not be modified. * @param fluidDestination The fluid handler to be filled by the container. * @param maxAmount The largest amount of fluid that should be transferred. * @param player Player for making the bucket drained sound. Pass null for no noise. * @param doDrain true if the container should actually be drained, false if it should be simulated. * @return The empty container if successful, null if the fluid handler couldn't be filled. * NOTE The empty container will have a stackSize of 0 when a filled container is consumable, * i.e. it has a "null" empty container but has successfully been emptied. */ @Nullable public static ItemStack tryEmptyContainer(ItemStack container, IFluidHandler fluidDestination, int maxAmount, @Nullable EntityPlayer player, boolean doDrain) { container = container.copy(); // do not modify the input container.stackSize = 1; IFluidHandler containerFluidHandler = getFluidHandler(container); if (containerFluidHandler != null) { FluidStack simulatedTransfer = tryFluidTransfer(fluidDestination, containerFluidHandler, maxAmount, false); if (simulatedTransfer != null) { if (doDrain) { tryFluidTransfer(fluidDestination, containerFluidHandler, maxAmount, true); if (player != null) { SoundEvent soundevent = simulatedTransfer.getFluid().getEmptySound(simulatedTransfer); player.playSound(soundevent, 1f, 1f); } } else { containerFluidHandler.drain(simulatedTransfer, true); } return container; } } return null; }
public void makeHorseRearWithSound() { this.makeHorseRear(); SoundEvent soundevent = this.getAngrySound(); if (soundevent != null) { this.playSound(soundevent, this.getSoundVolume(), this.getSoundPitch()); } }
public void playSound(@Nullable EntityPlayer player, double x, double y, double z, SoundEvent soundIn, SoundCategory category, float volume, float pitch) { if (player == this.mc.player) { this.playSound(x, y, z, soundIn, category, volume, pitch, false); } }
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; }
public void func_190687_dF() { this.makeHorseRear(); SoundEvent soundevent = this.getAngrySound(); if (soundevent != null) { this.playSound(soundevent, this.getSoundVolume(), this.getSoundPitch()); } }
@SubscribeEvent public void onRegisterSound(RegistryEvent.Register<SoundEvent> event) { Torched.soundRPT = new SoundEvent(new ResourceLocation("torched", "rpt")).setRegistryName(new ResourceLocation("torched", "rpt")); Torched.soundTube = new SoundEvent(new ResourceLocation("torched", "tube")).setRegistryName(new ResourceLocation("torched", "tube")); event.getRegistry().register(Torched.soundRPT); event.getRegistry().register(Torched.soundTube); }
public ImmersiveSound(SoundEvent event, World world, BlockPos pos, float baseVolume, boolean repeat) { super(event, SoundCategory.BLOCKS); this.world = world; this.pos = pos; this.xPosF = pos.getX(); this.yPosF = pos.getY(); this.zPosF = pos.getZ(); this.attenuationType = AttenuationType.LINEAR; this.repeat = repeat; this.repeatDelay = 0; this.sound = event; this.baseVolume = baseVolume; }
@Override public void playSound(EntityPlayer player, BlockPos pos, SoundEvent soundIn, SoundCategory category, float volume, float pitch) { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { m_proxyWorld.playSound(player, pos, soundIn, category, volume, pitch); } else if (m_realWorld != null) { m_realWorld.playSound(player, pos, soundIn, category, volume, pitch); } else { super.playSound(player, pos, soundIn, category, volume, pitch); } }
@Override public void playRecord(BlockPos blockPositionIn, SoundEvent soundEventIn) { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { m_proxyWorld.playRecord(blockPositionIn, soundEventIn); } else if (m_realWorld != null) { m_realWorld.playRecord(blockPositionIn, soundEventIn); } else { super.playRecord(blockPositionIn, soundEventIn); } }
@Nullable protected SoundEvent getAngrySound() { this.openHorseMouth(); this.makeHorseRear(); HorseType horsetype = this.getType(); return horsetype.isUndead() ? null : (horsetype.hasMuleEars() ? SoundEvents.ENTITY_DONKEY_ANGRY : SoundEvents.ENTITY_HORSE_ANGRY); }
private static SoundEvent getRegisteredSoundEvent(String id) { SoundEvent soundevent = (SoundEvent)SoundEvent.REGISTRY.getObject(new ResourceLocation(id)); if (soundevent == null) { throw new IllegalStateException("Invalid Sound requested: " + id); } else { return soundevent; } }
@Nullable protected SoundEvent getAmbientSound() { this.openHorseMouth(); if (this.rand.nextInt(10) == 0 && !this.isMovementBlocked()) { this.makeHorseRear(); } return null; }
public void playSound(@Nullable EntityPlayer player, double x, double y, double z, SoundEvent soundIn, SoundCategory category, float volume, float pitch) { for (int i = 0; i < this.eventListeners.size(); ++i) { ((IWorldEventListener)this.eventListeners.get(i)).playSoundToAllNearExcept(player, soundIn, category, x, y, z, volume, pitch); } }
public SPacketSoundEffect(SoundEvent soundIn, SoundCategory categoryIn, double xIn, double yIn, double zIn, float volumeIn, float pitchIn) { Validate.notNull(soundIn, "sound", new Object[0]); this.sound = soundIn; this.category = categoryIn; this.posX = (int)(xIn * 8.0D); this.posY = (int)(yIn * 8.0D); this.posZ = (int)(zIn * 8.0D); this.soundVolume = volumeIn; this.soundPitch = pitchIn; }
/** * Plays living's sound at its position */ public void playLivingSound() { SoundEvent soundevent = this.getAmbientSound(); if (soundevent != null) { this.playSound(soundevent, this.getSoundVolume(), this.getSoundPitch()); } }
private SoundEvent getInstrument(int p_185576_1_) { if (p_185576_1_ < 0 || p_185576_1_ >= INSTRUMENTS.size()) { p_185576_1_ = 0; } return (SoundEvent)INSTRUMENTS.get(p_185576_1_); }
public void playSound(@Nullable EntityPlayer player, double x, double y, double z, SoundEvent soundIn, SoundCategory category, float volume, float pitch) { net.minecraftforge.event.entity.PlaySoundAtEntityEvent event = net.minecraftforge.event.ForgeEventFactory.onPlaySoundAtEntity(player, soundIn, category, volume, pitch); if (event.isCanceled() || event.getSound() == null) return; soundIn = event.getSound(); category = event.getCategory(); volume = event.getVolume(); pitch = event.getPitch(); for (int i = 0; i < this.eventListeners.size(); ++i) { ((IWorldEventListener)this.eventListeners.get(i)).playSoundToAllNearExcept(player, soundIn, category, x, y, z, volume, pitch); } }
protected SoundEvent getHurtSound() { return this.isInWater() ? SoundEvents.ENTITY_ELDER_GUARDIAN_HURT : SoundEvents.ENTITY_ELDER_GUARDIAN_HURT_LAND; }
public SoundEvent getFallSound() { return this.fallSound; }
@Override protected SoundEvent getHurtSound(DamageSource source) { return SoundEvents.ENTITY_HOSTILE_HURT; }
/** * Check whether there are any mobs in the vicinity, and play a sound if there are. * The sound played changes if the mob is targeting the player, and the sound gets more frequent the closer the mob is to the player. */ @Override public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected) { if (!world.isRemote && entity instanceof EntityPlayer) { if (this.timeUntil > 0) { this.timeUntil--; return; } EntityPlayer player = (EntityPlayer)entity; double distance = 100.0D; boolean scary = false; List<EntityMob> mobs = world.getEntitiesWithinAABB(EntityMob.class, player.getEntityBoundingBox().grow(32.0D, 32.0D, 32.0D)); for (EntityMob mob : mobs) { double mobDistance = mob.getDistanceToEntity(player); if (mobDistance < distance) { distance = mobDistance; if (mob.getAttackTarget() != null && mob.getAttackTarget() == player) { scary = true; } } } if (distance <= 32.0D) { SoundEvent soundEvent = (scary ? ModSoundEvents.ITEM_MONSTER_DETECTOR_HIGH : ModSoundEvents.ITEM_MONSTER_DETECTOR_LOW); world.playSound((EntityPlayer)null, player.getPosition(), soundEvent, SoundCategory.NEUTRAL, 0.75F, 1.0F); if (distance >= 24.0D) { this.timeUntil = 40; } else if (distance >= 18.0D) { this.timeUntil = 20; } else if (distance >= 12.0D) { this.timeUntil = 15; } else if (distance >= 6.0D) { this.timeUntil = 10; } else { this.timeUntil = 7; } } else this.timeUntil = 80; } }
protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_SHEEP_HURT; }
public SoundEvent getHitSound() { return this.hitSound; }
protected SoundEvent getDeathSound() { return SoundEvents.ENTITY_PLAYER_DEATH; }
protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_BLAZE_HURT; }
protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_RABBIT_AMBIENT; }
@Override protected SoundEvent getSplashSound() { return SoundEvents.ENTITY_HOSTILE_SPLASH; }
protected SoundEvent getAmbientSound() { return SoundEvents.ENTITY_ENDERDRAGON_AMBIENT; }
protected SoundEvent getAngrySound() { super.getAngrySound(); return SoundEvents.ENTITY_HORSE_ANGRY; }
protected boolean isSoundType(SoundEvent event){ return sound == event; }
@Override protected SoundEvent getHurtSound(DamageSource source) { return ModSoundEvents.ENTITY_HAUNTER_HURT; }
protected SoundEvent getHurtSound() { return SoundEvents.ENTITY_SKELETON_HURT; }
protected SoundEvent getSquishSound() { return this.isSmallSlime() ? SoundEvents.ENTITY_SMALL_MAGMACUBE_SQUISH : SoundEvents.ENTITY_MAGMACUBE_SQUISH; }