net.minecraftforge.event.ForgeSubscribe Java Examples
The following examples show how to use
net.minecraftforge.event.ForgeSubscribe.
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: AliquoEvents.java From Ex-Aliquo with MIT License | 6 votes |
@ForgeSubscribe public void onLivingDrops(LivingDropsEvent event) { if (event.entityLiving == null) { return; } if (event.entityLiving instanceof EntityDragon) { if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.source.getEntity(); if (!player.worldObj.isRemote) { EntityItem item = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, new ItemStack(Registries.dragonEgg, 1, 0)); player.worldObj.spawnEntityInWorld(item); if (!(player instanceof FakePlayer)) { item.onCollideWithPlayer(player); } } } } }
Example #2
Source File: PlayerEventHandler.java From HexxitGear with GNU General Public License v3.0 | 6 votes |
@ForgeSubscribe public void playerUpdate(LivingEvent.LivingUpdateEvent event) { if (ticks > 16) { if (event.entityLiving != null && event.entityLiving instanceof EntityPlayer) { if (!event.entityLiving.worldObj.isRemote) return; EntityPlayer player = (EntityPlayer) event.entityLiving; String capeUrl = CapeHandler.getCapeUrl(player.username); if (capeUrl != null && !capeUrl.equals(player.cloakUrl)) { player.cloakUrl = capeUrl; FMLClientHandler.instance().getClient().renderEngine.obtainImageData(player.cloakUrl, null); } } ticks = 0; } ticks++; }
Example #3
Source File: TileEntityTerminalFluid.java From ExtraCells1 with MIT License | 6 votes |
@ForgeSubscribe public void onNetworkPatternChange(GridPatternUpdateEvent e) { if (grid != null) { IMEInventoryHandler inventoryHandler = grid.getCraftableArray(); if (inventoryHandler != null) { craftableFluidsInNetwork = new ArrayList<Fluid>(); for (IAEItemStack stack : inventoryHandler.getAvailableItems()) { if (stack.getItem() == FLUIDDISPLAY.getItemInstance()) { craftableFluidsInNetwork.add(FluidRegistry.getFluid(stack.getItemDamage())); } } } } PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket()); }
Example #4
Source File: MoCSounds.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
@ForgeSubscribe public void onSoundsLoaded(SoundLoadEvent event) { SoundManager manager = event.manager; for (String soundName : soundNames) { manager.soundPoolSounds.addSound(soundName, this.getClass().getResource("/drzhark/mocreatures/client/resources/newsound/" + soundName)); } manager.soundPoolStreaming.addSound("shuffling.ogg", this.getClass().getResource("/drzhark/mocreatures/client/resources/streaming/shuffling.ogg")); }
Example #5
Source File: MoCEventHooks.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
@ForgeSubscribe public void peformCustomWorldGenSpawning(PopulateChunkEvent.Populate event) { int par1 = event.chunkX * 16; int par2 = event.chunkZ * 16; List customSpawnList = MoCreatures.myCustomSpawner.getCustomBiomeSpawnList(event.world.getBiomeGenForCoords(par1 + 16, par2 + 16)); CustomSpawner.performWorldGenSpawning(event.world, event.world.getBiomeGenForCoords(par1 + 16, par2 + 16), par1 + 8, par2 + 8, 16, 16, event.rand, customSpawnList); }
Example #6
Source File: ItemSecureStoragePhysicalDecrypted.java From ExtraCells1 with MIT License | 5 votes |
@ForgeSubscribe @Override public ItemStack onItemRightClick(ItemStack i, World w, EntityPlayer p) { if (p.isSneaking()) { ItemStack itemStackDecrypted = p.inventory.getCurrentItem(); ItemStack itemStackEncrypted = new ItemStack(ItemEnum.STORAGEPHYSICALENCRYPTED.getItemInstance(), 1); if (!itemStackEncrypted.hasTagCompound()) { itemStackEncrypted.setTagCompound(new NBTTagCompound()); } if (!itemStackDecrypted.hasTagCompound()) { itemStackDecrypted.setTagCompound(new NBTTagCompound()); } NBTTagCompound tagDecrypted = itemStackDecrypted.getTagCompound(); // copy over content itemStackEncrypted.setTagCompound(tagDecrypted); // set owner itemStackEncrypted.getTagCompound().setString("owner", p.username); p.inventory.setInventorySlotContents(p.inventory.currentItem, itemStackEncrypted); if (!w.isRemote) { p.addChatMessage(StatCollector.translateToLocal("tooltip.storageencrypted")); } } return i; }
Example #7
Source File: ItemSecureStoragePhysicalEncrypted.java From ExtraCells1 with MIT License | 4 votes |
@ForgeSubscribe @Override public ItemStack onItemRightClick(ItemStack stack, World w, EntityPlayer p) { ItemStack itemStackEncrypted = p.inventory.getCurrentItem(); ItemStack itemStackDecrypted = new ItemStack(ItemEnum.STORAGEPHYSICALDECRYPTED.getItemInstance(), 1); if (!itemStackEncrypted.hasTagCompound()) { itemStackEncrypted.setTagCompound(new NBTTagCompound()); } // copy over content NBTTagCompound tagEncrypted = itemStackEncrypted.getTagCompound(); // remove owner String user = tagEncrypted.getString("owner"); if (p.isSneaking()) { if (p.username.equals(user)) { tagEncrypted.removeTag("owner"); itemStackDecrypted.setTagCompound((tagEncrypted)); p.inventory.setInventorySlotContents(p.inventory.currentItem, itemStackDecrypted); if (!w.isRemote) { p.addChatMessage(StatCollector.translateToLocal("tooltip.accessgranted")); } } else { if (!w.isRemote) { p.addChatMessage(StatCollector.translateToLocal("tooltip.notyours")); } } } return stack; }