Java Code Examples for net.minecraftforge.event.AttachCapabilitiesEvent#getObject()
The following examples show how to use
net.minecraftforge.event.AttachCapabilitiesEvent#getObject() .
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: WorldEventsCommon.java From Valkyrien-Skies with Apache License 2.0 | 7 votes |
@SubscribeEvent public void onAttachCapabilityEventItem(AttachCapabilitiesEvent event) { if (event.getObject() instanceof ItemStack) { ItemStack stack = (ItemStack) event.getObject(); Item item = stack.getItem(); if (item instanceof ItemValkyriumCrystal) { event.addCapability( new ResourceLocation(ValkyrienSkiesWorld.MOD_ID, "AntiGravityValue"), new AntiGravityCapabilityProvider(VSConfig.valkyriumCrystalForce)); } if (stack.getItem() instanceof ItemBlock) { ItemBlock blockItem = (ItemBlock) stack.getItem(); if (blockItem.getBlock() instanceof BlockValkyriumOre) { event.addCapability( new ResourceLocation(ValkyrienSkiesWorld.MOD_ID, "AntiGravityValue"), new AntiGravityCapabilityProvider(VSConfig.valkyriumOreForce)); } } } }
Example 2
Source File: PlayerPropertyEvents.java From YouTubeModdingTutorial with MIT License | 5 votes |
@SubscribeEvent public void onEntityConstructing(AttachCapabilitiesEvent<Entity> event){ if (event.getObject() instanceof EntityPlayer) { if (!event.getObject().hasCapability(PlayerProperties.PLAYER_MANA, null)) { event.addCapability(new ResourceLocation(MyMod.MODID, "Mana"), new PropertiesDispatcher()); } } }
Example 3
Source File: ModCapabilities.java From Wizardry with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public static void attachEntity(AttachCapabilitiesEvent<Entity> e) { if (e.getObject() instanceof EntityPlayer) { ManaCapabilityProvider manaCap = new ManaCapabilityProvider(new DefaultManaCapability()); e.addCapability(new ResourceLocation(Wizardry.MODID, "capability_mana"), manaCap); MiscCapabilityProvider miscCap = new MiscCapabilityProvider(new DefaultMiscCapability()); e.addCapability(new ResourceLocation(Wizardry.MODID, "capability_misc"), miscCap); } }
Example 4
Source File: CivilizationHandlers.java From ToroQuest with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void onEntityLoad(AttachCapabilitiesEvent<Entity> event) { if (!(event.getObject() instanceof EntityPlayer)) { return; } EntityPlayer player = (EntityPlayer) event.getObject(); event.addCapability(new ResourceLocation(ToroQuest.MODID, "playerCivilization"), new PlayerCivilizationCapabilityProvider(player)); syncClientCapability(player); }
Example 5
Source File: ItemBreakingTracker.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 5 votes |
@SubscribeEvent public void attachCapabilities(AttachCapabilitiesEvent<Entity> e) { if (!ConfigManager.SERVER.enableScraping.get()) return; final Entity entity = e.getObject(); if (!(entity instanceof ServerPlayerEntity)) return; if (entity.world == null || entity.world.isRemote) return; e.addCapability(PROP_KEY, new ICapabilityProvider() { ItemBreakingTracker cap = new ItemBreakingTracker(); LazyOptional<ItemBreakingTracker> cap_provider = LazyOptional.of(() -> cap); { cap.init(entity, entity.world); } @SuppressWarnings("unchecked") @Override public <T> LazyOptional<T> getCapability(Capability<T> capability, @Nullable Direction facing) { if (capability == TRACKER) return cap_provider.cast(); return LazyOptional.empty(); } }); }
Example 6
Source File: BlockHandler.java From BetterChests with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public void initTe(AttachCapabilitiesEvent<TileEntity> event) { if (event.getObject() instanceof TileEntityBBarrel) { TileEntityBBarrel chest = (TileEntityBBarrel) event.getObject(); event.addCapability(rl, new CapabilityHandler(chest)); } }
Example 7
Source File: BlockHandler.java From BetterChests with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public void initTe(AttachCapabilitiesEvent<TileEntity> event) { if (event.getObject() instanceof IUpgradableBlock && event.getObject() instanceof TileEntityBase) { TileEntityBase chest = (TileEntityBase) event.getObject(); chest.addElement(new IC2EnergyElement(chest)); } }
Example 8
Source File: EventHandler.java From Signals with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void onCapabilityAttachmentEntity(AttachCapabilitiesEvent<Entity> event){ if(event.getObject() instanceof EntityMinecart) { event.addCapability(new ResourceLocation(Constants.MOD_ID, "minecartDestinationCapability"), new CapabilityMinecartDestination.Provider()); } }
Example 9
Source File: EntityXpHandler.java From TinkersToolLeveling with MIT License | 4 votes |
@SubscribeEvent public void onCapabilityAttach(AttachCapabilitiesEvent<Entity> event) { if(event.getObject() instanceof EntityLivingBase && event.getObject().isEntityAlive()) { event.addCapability(CAPABILITY_KEY, new DamageXpHandler()); } }
Example 10
Source File: StatCapabilityHandler.java From GokiStats with MIT License | 4 votes |
@SubscribeEvent public void attachCapability(AttachCapabilitiesEvent<Entity> event) { if (!(event.getObject() instanceof EntityPlayer)) return; event.addCapability(new ResourceLocation(Reference.MODID, "stat_container"), new CapabilityStat.Provider()); }