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


Java ICapabilityProvider類代碼示例

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


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

示例1: onAttach

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

示例2: lookFor

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入依賴的package包/類
@Override
public void lookFor(LazyEnergyCapProvider lecp, FluxCompat.Registry r) {
	final ICapabilityProvider icp = lecp.getObject();
	if (icp == null) return;
	EnumFacing f = null;
	try {
		for (int i = 0; i < U.FANCY_FACING.length; i++) {
			f = U.FANCY_FACING[i];
			if (TeslaUtils.hasTeslaSupport(icp, f)) {
				r.register(EnergyType.TESLA, TeslaFluxCompat::factorize);
			}
		}
	} catch (Exception e) {
		MCFluxReport.addErrMsg(new ErrMsg.BadImplementation("TESLA", icp.getClass(), e, f));
	}
}
 
開發者ID:Szewek,項目名稱:Minecraft-Flux,代碼行數:17,代碼來源:TeslaFluxCompat.java

示例3: lookFor

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入依賴的package包/類
@Override
public void lookFor(LazyEnergyCapProvider lecp, FluxCompat.Registry r) {
	final ICapabilityProvider icp = lecp.getObject();
	if (icp == null || icp instanceof TileEntityFluxGen || blacklist(icp)) return;
	EnumFacing f = null;
	try {
		for (int i = 0; i < U.FANCY_FACING.length; i++) {
			f = U.FANCY_FACING[i];
			if (icp.hasCapability(CapabilityEnergy.ENERGY, f)) {
				r.register(EnergyType.FORGE_ENERGY, ForgeFluxCompat::forgeFactorize);
			}
		}
	} catch (Exception e) {
		MCFluxReport.addErrMsg(new ErrMsg.BadImplementation("Forge Energy", icp.getClass(), e, f));
	}
}
 
開發者ID:Szewek,項目名稱:Minecraft-Flux,代碼行數:17,代碼來源:ForgeFluxCompat.java

示例4: 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

示例5: onPlayerClone

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入依賴的package包/類
@SubscribeEvent
@SuppressWarnings("unused")
public void onPlayerClone(PlayerEvent.Clone event) {
    EntityPlayer oldPlayer = event.getOriginal();
    EntityPlayer newPlayer = event.getEntityPlayer();
    if(oldPlayer != null && newPlayer != null && !oldPlayer.getEntityWorld().isRemote) {
        List<ICapabilityImplementation<ICapabilityProvider, ? extends ISerializable>> list = this.map.get(oldPlayer.getClass());
        if(list == null) {
            return;
        }
        list.stream()
                .filter(impl -> EntityPlayer.class.isAssignableFrom(impl.getCarrierClass()))
                .filter(impl -> oldPlayer.hasCapability(impl.getCapability(), null))
                .forEach(impl -> {
                    ISerializable oldProps = oldPlayer.getCapability(impl.getCapability(), null);
                    ISerializable newProps = oldPlayer.getCapability(impl.getCapability(), null);
                    if(newProps != null && oldProps != null) {
                        newProps.readFromNBT(oldProps.writeToNBT());
                    }
                });
    }
}
 
開發者ID:InfinityRaider,項目名稱:InfinityLib,代碼行數:23,代碼來源:CapabilityHandler.java

示例6: 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

示例7: 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

示例8: 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

示例9: initCapabilities

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入依賴的package包/類
@Override
public ICapabilityProvider initCapabilities(@Nonnull ItemStack stack, @Nullable NBTTagCompound nbt) {
    return new FluidHandlerItemStack(stack,capacity)
    {
        @Override
        public int fill(FluidStack resource, boolean doFill) {
            if(resource == null || resource.amount < capacity)
                return 0;

            return super.fill(resource, doFill);
        }
    };
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:14,代碼來源:ItemMug.java

示例10: initCapabilities

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入依賴的package包/類
@Nullable
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
    FluidHandlerItemStack handlerItemStack = new FluidHandlerItemStack(stack, 128000) {
        @Override
        public boolean canFillFluidType(FluidStack fluid) {
            return fluid.getFluid().equals(FluidsRegistry.MEAT);
        }

    };
    handlerItemStack.fill(new FluidStack(FluidsRegistry.MEAT, 0), true);
    return handlerItemStack;
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:14,代碼來源:MeatFeederItem.java

示例11: initCapabilities

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入依賴的package包/類
@Override
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
    if(!stack.hasTagCompound()){
        stack.setTagCompound(new NBTTagCompound());
    }
    return new CapProviderItem(Pair.of(CapabilityEnergy.ENERGY, new ItemEnergyStorage(stack, this.maxEnergy, this.maxReceive, this.maxTransmit)));
}
 
開發者ID:canitzp,項目名稱:Metalworks,代碼行數:8,代碼來源:ItemBlockEnergetic.java

示例12: initCapabilities

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入依賴的package包/類
@Override
public ICapabilityProvider initCapabilities() {
	if(m_realProvider != null) {
		return m_realProvider.initCapabilities();
	} else {
		return super.initCapabilities();
	}
}
 
開發者ID:orbwoi,項目名稱:UniversalRemote,代碼行數:9,代碼來源:WorldProviderProxyClient.java

示例13: initCapabilities

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入依賴的package包/類
@Override
public ICapabilityProvider initCapabilities() {
	if (m_proxyProvider != null && Util.isPrefixInCallStack(m_modPrefix)) {
		return m_proxyProvider.initCapabilities();
	} else if (m_realProvider != null) {
		return m_realProvider.initCapabilities();
	} else {
		return super.initCapabilities();
	}
}
 
開發者ID:orbwoi,項目名稱:UniversalRemote,代碼行數:11,代碼來源:WorldProviderProxyServer.java

示例14: 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

示例15: hasCapability

import net.minecraftforge.common.capabilities.ICapabilityProvider; //導入依賴的package包/類
@Override
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
{
    return sender instanceof ICapabilityProvider
            && ((ICapabilityProvider) sender).hasCapability(capability, facing);

}
 
開發者ID:Ivorforce,項目名稱:MCOpts,代碼行數:8,代碼來源:DelegatingSender.java


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