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


Java ICapabilityProvider.getCapability方法代碼示例

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


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

示例1: forgeFactorize

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
private static void forgeFactorize(LazyEnergyCapProvider lecp) {
	final ICapabilityProvider icp = lecp.getObject();
	Energy[] es = new Energy[7];
	EnumFacing f;
	int[] s = new int[7];
	int x = 0, i;
	M:
	for (i = 0; i < U.FANCY_FACING.length; i++) {
		f = U.FANCY_FACING[i];
		IEnergyStorage ies = icp.getCapability(CapabilityEnergy.ENERGY, f);
		for (int j = 0; j < x; j++) {
			if (es[j].storage == ies) {
				s[i] = j;
				continue M;
			}
		}
		es[x] = new Energy(ies);
		s[i] = x++;
	}
	lecp.update(es, s, null, false);
	if (es[0] != null && es[0].storage != null)
		CloudUtils.reportEnergy(icp.getClass(), es[0].storage.getClass(), "forge");
}
 
開發者ID:Szewek,項目名稱:Minecraft-Flux,代碼行數:24,代碼來源:ForgeFluxCompat.java

示例2: onTileEntityCapabilityAttachEvent

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的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

示例3: exportStackToInventory

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
@Nonnull
public static ItemStack exportStackToInventory(ICapabilityProvider provider, ItemStack stack, EnumFacing side) {
    if (provider.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
        IItemHandler handler = provider.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
        return ItemHandlerHelper.insertItem(handler, stack, false);
    }
    return stack;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:9,代碼來源:PneumaticCraftUtils.java

示例4: insert

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
@Nonnull
public static ItemStack insert(ICapabilityProvider provider, ItemStack itemStack, EnumFacing side, boolean simulate) {
    if (provider.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
        IItemHandler handler = provider.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
        return ItemHandlerHelper.insertItem(handler, itemStack, simulate);
    }
    return ItemStack.EMPTY;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:9,代碼來源:IOHelper.java

示例5: copyInventory

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
private void copyInventory(ICapabilityProvider from, int[][] fromSlotIds, TileEntityIronFurnace to)
{
    FurnaceType type = to.getType();
    int[][] toSlotIds = new int[][] {type.inputSlotIds, type.fuelSlotIds, type.outputSlotIds};

    IItemHandlerModifiable fromHandler = (IItemHandlerModifiable) from.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
    IItemHandlerModifiable toHandler = (IItemHandlerModifiable) to.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
    copyInventory(fromHandler, fromSlotIds, toHandler, toSlotIds);
}
 
開發者ID:cubex2,項目名稱:morefurnaces,代碼行數:10,代碼來源:ItemUpgrade.java

示例6: update

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
@Override
public void update()
{
    if (this.getWorld().isRemote)
        return;

    for (EnumFacing dir : EnumFacing.VALUES)
    {
        EnumFacing side = dir.getOpposite();
        BlockPos pos = this.getPos().offset(dir);

        ICapabilityProvider provider = this.getWorld().getTileEntity(pos);
        if (provider == null)
            continue;

        IEnergyStorage storage = null;
        if (provider.hasCapability(CapabilityEnergy.ENERGY, side))
            storage = provider.getCapability(CapabilityEnergy.ENERGY, side);

        //TODO? Other compatible energy types?

        if (storage == null)
            continue;

        if (storage.canReceive())
            storage.receiveEnergy(POWER_PER_TICK, false);
    }
}
 
開發者ID:LexManos,項目名稱:VoidUtils,代碼行數:29,代碼來源:TileEntityEnergyCell.java

示例7: getCapability

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
@Override
public IEnergyStorage getCapability(@Nullable ICapabilityProvider provider, @Nullable EnumFacing side) {
  if (provider != null) {
    return provider.getCapability(ENERGY_HANDLER, side);
  }
  return null;
}
 
開發者ID:SleepyTrousers,項目名稱:EnderIO,代碼行數:8,代碼來源:ForgeAdapter.java

示例8: getCapability

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
@Override
public IEnergyStorage getCapability(@Nullable ICapabilityProvider provider, @Nullable EnumFacing side) {
  if (provider == null) {
    return null;
  }
  ITeslaHolder capHolder = provider.getCapability(NullHelper.notnull(TeslaCapabilities.CAPABILITY_HOLDER, "Tesla broke"), side);
  ITeslaConsumer capConsumer = provider.getCapability(NullHelper.notnull(TeslaCapabilities.CAPABILITY_CONSUMER, "Tesla broke"), side);
  ITeslaProducer capProducer = provider.getCapability(NullHelper.notnull(TeslaCapabilities.CAPABILITY_PRODUCER, "Tesla broke"), side);
  if (capHolder == null && capConsumer == null && capProducer == null) {
    return null;
  }
  return new TeslaToForgeAdapter(capHolder, capConsumer, capProducer);
}
 
開發者ID:SleepyTrousers,項目名稱:EnderIO,代碼行數:14,代碼來源:TeslaAdapter.java

示例9: getCapability

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
@Nullable
public static <T> T getCapability(@Nullable ICapabilityProvider provider, Capability<T> capability, @Nullable EnumFacing facing) 
{
	return provider != null && provider.hasCapability(capability, facing) ? provider.getCapability(capability, facing) : null;
}
 
開發者ID:TheXFactor117,項目名稱:Loot-Slash-Conquer,代碼行數:6,代碼來源:CapabilityUtils.java

示例10: getCapability

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
@Nullable
public static <T> T getCapability(@Nullable ICapabilityProvider provider, Capability<T> capability, @Nullable EnumFacing facing) {
	return provider != null && provider.hasCapability(capability, facing) ? provider.getCapability(capability, facing) : null;
}
 
開發者ID:bookerthegeek,項目名稱:Mob-Option-Redux,代碼行數:5,代碼來源:CapabilityProvider.java

示例11: getFluidHandler

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
public static IFluidHandler getFluidHandler(ICapabilityProvider capProvider, EnumFacing side)
{
	return capProvider.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
}
 
開發者ID:einsteinsci,項目名稱:BetterBeginningsReborn,代碼行數:5,代碼來源:CapUtils.java

示例12: getItemHandler

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
public static IItemHandler getItemHandler(ICapabilityProvider capProvider, EnumFacing side)
{
	return capProvider.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
}
 
開發者ID:einsteinsci,項目名稱:BetterBeginningsReborn,代碼行數:5,代碼來源:CapUtils.java

示例13: getFluidHandlerCapability

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
public static IFluidHandler getFluidHandlerCapability(@Nullable ICapabilityProvider provider, EnumFacing side) {
    if (provider != null && provider.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side)) {
      return provider.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, side);
    }
    return getLegacyHandler(provider, side);
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:7,代碼來源:FluidUtil.java

示例14: ContainerConveyorSmallInventory

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
public ContainerConveyorSmallInventory(InventoryPlayer inventoryPlayer, ICapabilityProvider te, EnumFacing side) {
	this(inventoryPlayer, te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side));
}
 
開發者ID:Team-IO,項目名稱:taam,代碼行數:4,代碼來源:ContainerConveyorSmallInventory.java

示例15: getTeslaHolder

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入方法依賴的package包/類
/**
 * Gets an ITeslaHolder implementation from the capability provider.
 * 
 * @param provider The provider to get the capability from.
 * @param side The side to access;
 * @return A Tesla holder implementation, or null if none could be found.
 */
public static ITeslaHolder getTeslaHolder (ICapabilityProvider provider, EnumFacing side) {
    
    return (ITeslaHolder) provider.getCapability(TeslaCapabilities.CAPABILITY_HOLDER, side);
}
 
開發者ID:Herobone,項目名稱:HeroUtils,代碼行數:12,代碼來源:TeslaUtils.java


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