net.minecraftforge.event.entity.PlaySoundAtEntityEvent Java Examples
The following examples show how to use
net.minecraftforge.event.entity.PlaySoundAtEntityEvent.
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: AntiBatsMod.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent public void onPlaySound(PlaySoundAtEntityEvent event) { if (event.getSound().equals(SoundEvents.ENTITY_BAT_AMBIENT) || event.getSound().equals(SoundEvents.ENTITY_BAT_DEATH) || event.getSound().equals(SoundEvents.ENTITY_BAT_HURT) || event.getSound().equals(SoundEvents.ENTITY_BAT_LOOP) || event.getSound().equals(SoundEvents.ENTITY_BAT_TAKEOFF)) { event.setVolume(0.f); event.setPitch(0.f); event.setCanceled(true); } }
Example #2
Source File: ItemCyberlimb.java From Cyberware with MIT License | 5 votes |
@SubscribeEvent public void handleSound(PlaySoundAtEntityEvent event) { Entity e = event.getEntity(); if (e instanceof EntityPlayer && event.getSound() == SoundEvents.ENTITY_PLAYER_HURT && e.worldObj.isRemote) { if (didFall.contains(e.getEntityId())) { int numLegs = 0; if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 2))) { numLegs++; } if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 3))) { numLegs++; } if (numLegs > 0) { event.setSound(SoundEvents.ENTITY_IRONGOLEM_HURT); event.setPitch(event.getPitch() + 1F); didFall.remove((Integer) e.getEntityId()); } } } }
Example #3
Source File: IntegrationThaumicHorizions.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) public void on(AttackEntityEvent e) { EntityPlayer player = e.entityPlayer; if(!e.target.worldObj.isRemote && e.target instanceof EntityGolemTH && player.isSneaking()) { e.setCanceled(true); ItemStack stack = player.getCurrentEquippedItem(); if (stack != null && stack.getItem().onLeftClickEntity(stack, player, e.target) && e.target.isDead) { CommonProxy.EVENT_HANDLER_GOLEM.on(new PlaySoundAtEntityEvent(e.target, "thaumcraft:zap", 0.5f, 1.0f)); } } }
Example #4
Source File: EventHandlerGolem.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true) public void on(PlaySoundAtEntityEvent event) { if(!event.entity.worldObj.isRemote && event.entity instanceof EntityGolemBase && event.name.equals("thaumcraft:zap") && event.volume == 0.5F && event.pitch == 1.0F) { EntityGolemBase golem = (EntityGolemBase) event.entity; if(markedGolems.containsKey(golem)) { EntityPlayer player = markedGolems.get(golem); markedGolems.remove(golem); AdditionalGolemCore core = GadomancyApi.getAdditionalGolemCore(golem); boolean movedPlacer = false; boolean movedCore = core == null || !player.isSneaking(); for(EntityItem entityItem : golem.capturedDrops) { ItemStack item = entityItem.getEntityItem(); if(!movedCore && item.getItem() == ConfigItems.itemGolemCore) { entityItem.setEntityItemStack(core.getItem()); } if(!movedPlacer && item.getItem() instanceof ItemGolemPlacer || item.getItem() instanceof ItemAdditionalGolemPlacer) { //move persistent data to item NBTTagCompound persistent = (NBTTagCompound) NBTHelper.getPersistentData(golem).copy(); if(player.isSneaking()) { persistent.removeTag("Core"); } NBTHelper.getData(item).setTag(Gadomancy.MODID, persistent); event.entity.setDead(); entityItem.setEntityItemStack(item); MinecraftForge.EVENT_BUS.post(new GolemDropPlacerEvent(player, entityItem, golem)); movedPlacer = true; } event.entity.worldObj.spawnEntityInWorld(entityItem); } golem.capturedDrops.clear(); golem.captureDrops = false; } } }