當前位置: 首頁>>代碼示例>>Java>>正文


Java AttachCapabilitiesEvent.addCapability方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.AttachCapabilitiesEvent.addCapability方法的典型用法代碼示例。如果您正苦於以下問題:Java AttachCapabilitiesEvent.addCapability方法的具體用法?Java AttachCapabilitiesEvent.addCapability怎麽用?Java AttachCapabilitiesEvent.addCapability使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.AttachCapabilitiesEvent的用法示例。


在下文中一共展示了AttachCapabilitiesEvent.addCapability方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: registerCapability

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public static void registerCapability(AttachCapabilitiesEvent<Entity> event) {
    Entity obj = event.getObject();
    if (obj instanceof EntityPlayer && !(obj instanceof FakePlayer)) {
        EntityPlayer player = (EntityPlayer) obj;
        AbstractPlayerDamageModel damageModel;
        if (player.world.isRemote)
            damageModel = FirstAid.activeDamageConfig == null ? PlayerDamageModel.createTemp() : PlayerDamageModel.create();
        else {
            FirstAid.activeDamageConfig = FirstAidConfig.damageSystem;
            FirstAid.activeHealingConfig = FirstAidConfig.externalHealing;
            FirstAid.scaleMaxHealth = FirstAidConfig.scaleMaxHealth;
            damageModel = PlayerDamageModel.create();
        }
        event.addCapability(CapProvider.IDENTIFIER, new CapProvider(player, damageModel));
        //replace the data manager with our wrapper to grab absorption
        player.dataManager = new DataManagerWrapper(player, player.dataManager);
    }
}
 
開發者ID:ichttt,項目名稱:FirstAid,代碼行數:20,代碼來源:EventHandler.java

示例2: onAttach

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onAttach(AttachCapabilitiesEvent event)
{
	Map<ResourceLocation, ICapabilityProvider> map = Maps.newHashMap();
	if (event instanceof AttachCapabilitiesEvent.Item)
		handle(map, event.getObject(), ((AttachCapabilitiesEvent.Item) event).getItemStack());
	else if (event instanceof AttachCapabilitiesEvent.Entity)
		handle(map, event.getObject(), ((AttachCapabilitiesEvent.Entity) event).getEntity());
	else if (event instanceof AttachCapabilitiesEvent.TileEntity)
		handle(map, event.getObject(), ((AttachCapabilitiesEvent.TileEntity) event).getTileEntity());
	else
		handle(map, event.getObject(), event.getObject());
	for (ICapabilityProvider iCapabilityProvider : event.getCapabilities().values())
		handle(map, iCapabilityProvider, event.getObject());
	for (Map.Entry<ResourceLocation, ICapabilityProvider> entry : map.entrySet())
		event.addCapability(entry.getKey(), entry.getValue());
}
 
開發者ID:InfinityStudio,項目名稱:InspiringWorld,代碼行數:18,代碼來源:CapabilityInterfaceInject.java

示例3: onTileEntityCapabilityAttachEvent

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
public void onTileEntityCapabilityAttachEvent(AttachCapabilitiesEvent<TileEntity> event){
    ICapabilityProvider provider = new CapabilityDestinationProvider.Provider();
    boolean requiresCap = false;

    CapabilityDestinationProvider cap = provider.getCapability(CapabilityDestinationProvider.INSTANCE, null);
    for(IDestinationProvider destinationProvider : destinationProviders) {
        if(destinationProvider.isTileEntityApplicable(event.getObject())) {
            try {
                cap.addDestinationProvider(destinationProvider.getClass().newInstance());
                if(!requiresCap) {
                    requiresCap = true;
                    event.addCapability(new ResourceLocation(Constants.MOD_ID, "destinationProviderCapability"), provider);
                }
            } catch(Exception e) {
                e.printStackTrace();
            }
        }
    }
}
 
開發者ID:MineMaarten,項目名稱:Signals,代碼行數:20,代碼來源:RailManager.java

示例4: onAddCapabilitiesEntity

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onAddCapabilitiesEntity(AttachCapabilitiesEvent<Entity> event) {
    if (canHaveAttributes(event.getObject())) {
        EntityLivingBase ent = (EntityLivingBase) event.getObject();
        if (ent instanceof EntityPlayer) {
            event.addCapability(new ResourceLocation(main.MODID + ":radiation_capability"), new RadsFactoryProvider());
            event.addCapability(new ResourceLocation(main.MODID + ":water_capability"), new WaterFactoryProvider());
            event.addCapability(new ResourceLocation(main.MODID + ":spechial_capability"), new SpechialFactoryProvider());
            event.addCapability(new ResourceLocation(main.MODID + ":skills_capability"), new SkillsFactoryProvider());
            event.addCapability(new ResourceLocation(main.MODID + ":level_capability"), new LevelFactoryProvider());
            event.addCapability(new ResourceLocation(main.MODID + ":ftj_capability"), new FTJFactoryProvider());
            event.addCapability(new ResourceLocation(main.MODID + ":adv_inv_capability"), new IAdvProvider());
            event.addCapability(new ResourceLocation(main.MODID + ":trigger_cap"), new ITrigger_item_Provider());

        }
    }
}
 
開發者ID:Hoijima,項目名稱:Fallout_Equestria,代碼行數:18,代碼來源:EventHandlerPre.java

示例5: attachCapability

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public static void attachCapability(AttachCapabilitiesEvent<Entity> event)
{
    //Attach our capabilities to all players
    Entity entity = event.getObject();
    if(entity instanceof EntityPlayer)
    {
        for(Capability cap : MHCapabilities.getCapabilities())
        {
            ICapability icap = getDefaultICapability(cap);
            if(icap == null) continue;
            if(!entity.hasCapability(cap, null))
                event.addCapability(icap.getKey(), icap.getProvider());
        }
    }
}
 
開發者ID:alxnns1,項目名稱:MobHunter,代碼行數:17,代碼來源:CapabilityHandler.java

示例6: onEntityCapabilityAttach

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityCapabilityAttach(AttachCapabilitiesEvent<Entity> event)
{
    Entity entity = event.getObject();
    if(entity instanceof EntityPlayer)
    {
        if(!entity.hasCapability(TEMPORAL_TOOLBELT, EnumFacing.DOWN))
        {
            event.addCapability(new ResourceLocation(Reference.MOD_ID + ":temporal_toolbelt"), new CapabilityTemporalToolbelt.TemporalToolbeltGenericProvider());
        }
        else if(!entity.hasCapability(STASIS_CAPABILITY, EnumFacing.DOWN))
        {
            event.addCapability(new ResourceLocation(Reference.MOD_ID + ":stasis"), new CapabilityStasis.StasisGenericProvider());
        }
    }
    else if(entity instanceof EntityLiving)
    {
        if(!entity.hasCapability(CUSTOM_BEHAVIOR, EnumFacing.DOWN))
        {
            event.addCapability(new ResourceLocation(Reference.MOD_ID + ":customBehavior"), new CapabilityStasis.StasisGenericProvider());
        }
    }
}
 
開發者ID:Lumaceon,項目名稱:ClockworkPhase2,代碼行數:24,代碼來源:CapabilityAttachHandler.java

示例7: attachCapabilities

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void attachCapabilities(AttachCapabilitiesEvent<Entity> event) 
{
	if (event.getObject() instanceof EntityMob) 
	{
		final EnemyLevel enemyLevel = new EnemyLevel((EntityMob) event.getObject());
		event.addCapability(ID, createProvider(enemyLevel));
	}
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:10,代碼來源:CapabilityEnemyLevel.java

示例8: onCapabilitiesWorld

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onCapabilitiesWorld(AttachCapabilitiesEvent<World> evt)
{
	if (!(evt.getObject().getWorldType() instanceof WorldTypeExP))
	{
		ExPMisc.modLogger.log(LogLevel.Debug, "The world initialized without ExPetrum world type! Have you forgot to set it in advanced world settings?");
	}
	
	handleWorldSettings(evt.getObject());
	evt.addCapability(ExPWorldCapability.KEY, this.createCapabilityProviderOfIExPWorld(evt.getObject()));
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:12,代碼來源:ExPHandlerServer.java

示例9: attachCapabilities

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void attachCapabilities(AttachCapabilitiesEvent<Entity> event) 
{
	if (event.getObject() instanceof EntityPlayer) 
	{
		final PlayerInformation playerInfo = new PlayerInformation((EntityPlayer) event.getObject());
		
		event.addCapability(ID, createProvider(playerInfo));
	}
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:11,代碼來源:CapabilityPlayerInformation.java

示例10: attachCapabilityEnt

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void attachCapabilityEnt(AttachCapabilitiesEvent<Entity> event) {
	if (event.getObject() instanceof EntityPlayer || event.getObject() instanceof EntityTF2Character) {
		event.addCapability(new ResourceLocation(TF2weapons.MOD_ID, "weaponcapability"), new WeaponsCapability((EntityLivingBase) event.getObject()));
	}
	if (event.getObject() instanceof EntityPlayer) {
		event.addCapability(new ResourceLocation(TF2weapons.MOD_ID, "playercapability"), new TF2PlayerCapability((EntityPlayer) event.getObject()));
	}
	if (event.getObject() instanceof EntityPlayer && !event.getObject().hasCapability(TF2weapons.INVENTORY_CAP, null)) {
		final InventoryWearables inv=new InventoryWearables((EntityPlayer) event.getObject());
		
		event.addCapability(new ResourceLocation(TF2weapons.MOD_ID, "wearablescapability"), inv);
		
	}
}
 
開發者ID:rafradek,項目名稱:Mods,代碼行數:16,代碼來源:TF2EventsCommon.java

示例11: onAttachCapability

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public static void onAttachCapability(AttachCapabilitiesEvent<Entity> ev)
{
	if (ev.getObject() instanceof EntityPlayer)
	{
		ev.addCapability(new ResourceLocation(ArcaneMagic.MODID, "notebook_storage"), new NotebookInfo());
	}
}
 
開發者ID:raphydaphy,項目名稱:ArcaneMagic,代碼行數:9,代碼來源:ModEvents.java

示例12: onEntityCaps

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public static void onEntityCaps(AttachCapabilitiesEvent<Entity> e)
{
    if (e.getObject() instanceof EntityPlayer)
    {
        e.addCapability(CapabilityRegistry.ENTRY_STORE_NAME, new IfEntryStoreProvider());
        e.addCapability(CapabilityRegistry.AURA_CONTAINER_NAME, new AuraContainerProvider());
    }
}
 
開發者ID:PearXTeam,項目名稱:PurificatiMagicae,代碼行數:10,代碼來源:CapabilityEvents.java

示例13: attachCapabilities

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public static void attachCapabilities(final AttachCapabilitiesEvent<Entity> event) {
	if (event.getObject() instanceof EntityMob) {
		final Stats stats = new Stats((EntityMob) event.getObject());
		event.addCapability(HEALTH_ID, createProvider((IHealth) stats));
		event.addCapability(ATTACK_ID, createProvider((IAttack) stats));
		event.addCapability(FOLLOW_ID, createProvider((IFollow) stats));
	}
}
 
開發者ID:bookerthegeek,項目名稱:Mob-Option-Redux,代碼行數:10,代碼來源:CapabilityStats.java

示例14: attachCapabilities

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
/**
 * Attach the {@link ITurn} capability to all living entities.
 *
 * @param event The event
 */
@SubscribeEvent
public void attachCapabilities(AttachCapabilitiesEvent<Entity> e) {
	if (e.getObject() instanceof EntityPlayer) {
		final PlayerTurn playerTurn = new PlayerTurn((EntityPlayer) e.getObject());
		e.addCapability(ID, createProvider(playerTurn));
	}
}
 
開發者ID:stuebz88,項目名稱:modName,代碼行數:13,代碼來源:CapPlayerTurn.java

示例15: attachCapabiltiesEvent

import net.minecraftforge.event.AttachCapabilitiesEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void attachCapabiltiesEvent(AttachCapabilitiesEvent<Entity> event)
{
	if (event.getObject() instanceof EntityPlayer)
	{
		event.addCapability(ExPPlayerCapability.KEY, createCapabilityProviderOfIExPPlayer((EntityPlayer) event.getObject()));
	}
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:9,代碼來源:ExPHandlerServer.java


注:本文中的net.minecraftforge.event.AttachCapabilitiesEvent.addCapability方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。