当前位置: 首页>>代码示例>>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;未经允许,请勿转载。