@SubscribeEvent public void attachCapability(AttachCapabilitiesEvent<Entity> event) { if(event.getObject() instanceof EntityPlayer) { event.addCapability(Util.getResource("piggyback"), new TinkerPiggybackSerializer((EntityPlayer) event.getObject())); } }
@SubscribeEvent public static void attachCapabilities(net.minecraftforge.event.AttachCapabilitiesEvent<TileEntity> evt) { if (evt.getCapabilities().containsKey(KEY)) { return; } TileEntity te = evt.getObject(); if (te instanceof ILegacyPowerReceiver) { evt.addCapability(KEY, new InternalRecieverTileWrapper.RecieverTileCapabilityProvider((ILegacyPowerReceiver) te)); } else if (te instanceof ILegacyPoweredTile) { evt.addCapability(KEY, new InternalPoweredTileWrapper.PoweredTileCapabilityProvider((ILegacyPoweredTile) te)); } }
@SubscribeEvent public static void onAttachCapabilities(AttachCapabilitiesEvent<Chunk> event) { event.addCapability(WIZARDRY_CHUNK_ID, StandardWizardryChunk.create()); }
private ItemCapability<?, ?> getNewInstance() { ItemCapability<?, ?> itemCapability = (ItemCapability<?, ?>)capabilityInstance.getDefaultInstance(); itemCapability.setStack(event.getObject()); itemCapability.init(); return itemCapability; }
/** * Event called to attach capabilities on the world. * * @param event the event. */ @SubscribeEvent public void onAttachingCapabilitiesWorld(@NotNull final AttachCapabilitiesEvent<World> event) { event.addCapability(new ResourceLocation(Constants.MOD_ID, "chunkUpdate"), new MinecoloniesWorldCapabilityProvider()); event.addCapability(new ResourceLocation(Constants.MOD_ID, "colonyManager"), new MinecoloniesWorldColonyManagerCapabilityProvider()); }
private EntityCapability<?, ?, ?> getNewInstance() { EntityCapability<?, ?, ?> entityCapability = (EntityCapability<?, ?, ?>)capabilityInstance.getDefaultInstance(); entityCapability.setEntity(event.getObject()); entityCapability.init(); return entityCapability; }
@SubscribeEvent public void attachSpatialDimensionManager( AttachCapabilitiesEvent<World> event ) { if( AEConfig.instance() .isFeatureEnabled( AEFeature.SPATIAL_IO ) && event.getObject() == DimensionManager.getWorld( AEConfig.instance().getStorageDimensionID() ) ) { event.addCapability( new ResourceLocation( "appliedenergistics2:spatial_dimension_manager" ), new SpatialDimensionManager( event.getObject() ) ); } }
@SubscribeEvent public static void attachCapabilities(@Nonnull AttachCapabilitiesEvent<ItemStack> evt) { if (evt.getCapabilities().containsKey(KEY)) { return; } final ItemStack stack = evt.getObject(); if (stack != null && stack.getItem() instanceof IDarkSteelItem) { EnergyUpgradeCap cap = new EnergyUpgradeCap(stack); evt.addCapability(KEY, cap); } }
/** * Event called to attach capabilities on a chunk. * * @param event the event. */ @SubscribeEvent public void onAttachingCapabilitiesChunk(@NotNull final AttachCapabilitiesEvent<Chunk> event) { event.addCapability(new ResourceLocation(Constants.MOD_ID, "closeColony"), new MinecoloniesChunkCapabilityProvider()); }
@SubscribeEvent @SuppressWarnings("deprecation") public void attachCapabilitiesTile(AttachCapabilitiesEvent<TileEntity> event) { TileEntity entity = event.getObject(); if (entity instanceof TileEntityNote) { event.addCapability(PlethoraCore.PERIPHERAL_HANDLER_KEY, noteblockCap); } else if (entity instanceof TileEntityDaylightDetector) { event.addCapability(PlethoraCore.PERIPHERAL_HANDLER_KEY, daylightSensorCap); } }
@SubscribeEvent public void onAttachCapabilities(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)event.getObject(); for (String identifier : PlayerStatRegistry.getCapabilityMap().keySet()) { ResourceLocation loc = new ResourceLocation(ToughAsNails.MOD_ID, identifier); //Each player should have their own instance for each stat, as associated values may vary if (!event.getCapabilities().containsKey(loc)) event.addCapability(loc, PlayerStatRegistry.createCapabilityProvider(identifier)); } } }
/** * Adds a simple IItemSize capability to an item instance. Call this from an AttachCapabilitiesEvent handler. * This will also override the item's stacksize. If an item uses a custom getStacksize implementation, that will take priority * * @param event The AttachCapabilitiesEvent that was fired * @param item The item to attach the capability to * @param size The item size * @param weight The item weight * @param canStack An override for if this item can stack or not. */ public static void add(AttachCapabilitiesEvent<ItemStack> event, Item item, Size size, Weight weight, boolean canStack) { event.addCapability(ID, new ItemSizeHandler(size, weight, canStack)); item.setMaxStackSize(IItemSize.getStackSize(size, weight, canStack)); }
@SubscribeEvent public static void onWorldCaps(AttachCapabilitiesEvent<World> event) { if (SERVER_REGISTER != null && !event.getObject().isRemote) { event.addCapability(CAP_KEY, instance); } }
@SubscribeEvent public static void attachCapabilities(@Nonnull AttachCapabilitiesEvent<ItemStack> evt) { if (evt.getCapabilities().containsKey(KEY)) { return; } final ItemStack stack = evt.getObject(); if (stack == null) { return; } if (stack.getItem() == Items.GLASS_BOTTLE || stack.getItem() == Items.POTIONITEM) { BottleFluidCapability cap = new BottleFluidCapability(stack); evt.addCapability(KEY, cap); } }
@SubscribeEvent public void onAttachCapabilityEntity(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof EntityCreature) { event.addCapability(REFERENCE.EXTENDED_CREATURE_KEY, ExtendedCreature.createNewCapability((EntityCreature) event.getObject())); } }
public void itemCapabilityAttach(AttachCapabilitiesEvent<ItemStack> event) ItemStack stack = event.getObject(); if (stack.isEmpty() || !(stack.getItem() instanceof IBauble) || stack.hasCapability(BaublesCapabilities.CAPABILITY_ITEM_BAUBLE, null) || event.getCapabilities().values().stream().anyMatch(c -> c.hasCapability(BaublesCapabilities.CAPABILITY_ITEM_BAUBLE, null))) return; event.addCapability(capabilityResourceLocation, new ICapabilityProvider() {
@SubscribeEvent public static void attachCaps(AttachCapabilitiesEvent<Entity> evt) { if (evt.getObject() instanceof EntityPlayer) { evt.addCapability(AlchBagImpl.Provider.NAME, new AlchBagImpl.Provider()); evt.addCapability(KnowledgeImpl.Provider.NAME, new KnowledgeImpl.Provider((EntityPlayer) evt.getObject())); if (evt.getObject() instanceof EntityPlayerMP) { evt.addCapability(InternalTimers.NAME, new InternalTimers.Provider()); evt.addCapability(InternalAbilities.NAME, new InternalAbilities.Provider((EntityPlayerMP) evt.getObject())); } } }
@SubscribeEvent public void onAttachCapability(AttachCapabilitiesEvent<Entity> event) { if (event.getObject() instanceof EntityPlayer) { try { event.addCapability(REFERENCE.FACTION_PLAYER_HANDLER_KEY, FactionPlayerHandler.createNewCapability((EntityPlayer) event.getObject())); event.addCapability(REFERENCE.VAMPIRE_PLAYER_KEY, VampirePlayer.createNewCapability((EntityPlayer) event.getObject())); event.addCapability(REFERENCE.HUNTER_PLAYER_KEY, HunterPlayer.createNewCapability((EntityPlayer) event.getObject())); } catch (Exception e) { VampirismMod.log.e("ModPlayerEventHandler", "Failed to attach capabilities to player. Player: %s", event.getObject()); Throwables.propagate(e); } } }
@SubscribeEvent public void onAttachTileEntityCapabilities(final AttachCapabilitiesEvent<TileEntity> event) { if (event.getObject() instanceof TileEntityCasing) { final TileEntityCasing tileEntity = (TileEntityCasing) event.getObject(); event.addCapability(CapabilityRedstoneEmitter.PROVIDER_REDSTONE_EMITTER, new CapabilityRedstoneEmitter.Provider(tileEntity)); event.addCapability(CapabilityRedstoneReceiver.PROVIDER_REDSTONE_RECEIVER, new CapabilityRedstoneReceiver.Provider(tileEntity)); event.addCapability(CapabilityBundledEmitter.PROVIDER_BUNDLED_EMITTER, new CapabilityBundledEmitter.Provider(tileEntity)); event.addCapability(CapabilityBundledReceiver.PROVIDER_BUNDLED_RECEIVER, new CapabilityBundledReceiver.Provider(tileEntity)); } } }
@SubscribeEvent @SuppressWarnings("deprecation") public void attachCapabilitiesItem(AttachCapabilitiesEvent<ItemStack> event) { Item item = event.getObject().getItem(); if (item == Items.CLOCK) { event.addCapability(PlethoraCore.PERIPHERAL_HANDLER_KEY, clockCap); } else if (item instanceof ItemBlock) { Block block = ((ItemBlock) item).getBlock(); if (block == Blocks.DAYLIGHT_DETECTOR) { event.addCapability(PlethoraCore.PERIPHERAL_HANDLER_KEY, daylightSensorCap); } else if (block == Blocks.NOTEBLOCK) { event.addCapability(PlethoraCore.PERIPHERAL_HANDLER_KEY, noteblockCap); } } }