当前位置: 首页>>代码示例>>Java>>正文


Java CapabilityFluidHandler类代码示例

本文整理汇总了Java中net.minecraftforge.fluids.capability.CapabilityFluidHandler的典型用法代码示例。如果您正苦于以下问题:Java CapabilityFluidHandler类的具体用法?Java CapabilityFluidHandler怎么用?Java CapabilityFluidHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CapabilityFluidHandler类属于net.minecraftforge.fluids.capability包,在下文中一共展示了CapabilityFluidHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEvaluator

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
@Override
protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget) {
    return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase) widget) {

        @Override
        protected boolean evaluate(BlockPos pos) {
            TileEntity te = drone.world().getTileEntity(pos);
            int count = 0;
            if (te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null) ) {
                IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
                for (IFluidTankProperties prop : handler.getTankProperties()) {
                    FluidStack stack = prop.getContents();
                    if (stack != null) {
                        if (ProgWidgetLiquidFilter.isLiquidValid(stack.getFluid(), widget, 1)) {
                            count += stack.amount;
                        }
                    }
                }
            } else {
                Fluid fluid = FluidRegistry.lookupFluidForBlock(drone.world().getBlockState(pos).getBlock());
                if (fluid != null && ProgWidgetLiquidFilter.isLiquidValid(fluid, widget, 1) && FluidUtils.isSourceBlock(drone.world(), pos)) {
                    count += 1000;
                }
            }
            return ((ICondition) widget).getOperator() == ICondition.Operator.EQUALS ?
                    count == ((ICondition) widget).getRequiredCount() :
                    count >= ((ICondition) widget).getRequiredCount();
        }

    };
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:32,代码来源:ProgWidgetLiquidInventoryCondition.java

示例2: addProbeInfo

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
@Override
@Optional.Method(modid = "theoneprobe")
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
    TileEntity te = world.getTileEntity(data.getPos());
    if(te instanceof IInfoForwarder){
        te = ((IInfoForwarder)te).getInfoTileEntity();
    }
    
    if (te instanceof IPneumaticMachine) {
        TOPCallback.handlePneumatic(mode, probeInfo, (IPneumaticMachine)te);
    }
    if (te instanceof IHeatExchanger) {
        TOPCallback.handleHeat(mode, probeInfo, (IHeatExchanger) te);
    }
    if (ConfigHandler.client.topShowsFluids && te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, data.getSideHit())) {
        IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, data.getSideHit());
        TOPCallback.handleFluidTanks(mode, probeInfo, handler);
    }
    if (te instanceof TileEntityBase) {
        TOPCallback.handleRedstoneMode(mode, probeInfo, (TileEntityBase) te);
    }
    if (te instanceof TileEntityPressureTube) {
        TOPCallback.handlePressureTube(mode, probeInfo, (TileEntityPressureTube) te, data.getSideHit());
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:26,代码来源:BlockPneumaticCraft.java

示例3: doFluidInteraction

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
private static boolean doFluidInteraction(TileEntity te, EnumFacing face, EntityPlayer player, EnumHand hand, boolean isInserting) {
    ItemStack stack = player.getHeldItem(hand);
    IFluidHandlerItem stackHandler = FluidUtil.getFluidHandler(stack);
    if (stackHandler != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, face)) {
        int capacity = stackHandler.getTankProperties()[0].getCapacity();
        IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, face);
        PlayerInvWrapper invWrapper = new PlayerInvWrapper(player.inventory);
        FluidActionResult result = isInserting ?
                FluidUtil.tryEmptyContainerAndStow(player.getHeldItem(hand), handler, invWrapper, capacity, player) :
                FluidUtil.tryFillContainerAndStow(player.getHeldItem(hand), handler, invWrapper, capacity, player);
        if (result.isSuccess()) {
            player.setHeldItem(hand, result.getResult());
            return true;
        }
    }
    return false;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:18,代码来源:FluidUtils.java

示例4: preInit

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
@Subscribe
public void preInit(FMLPreInitializationEvent evt)
{
    CapabilityItemHandler.register();
    CapabilityFluidHandler.register();
    CapabilityAnimation.register();
    CapabilityEnergy.register();
    MinecraftForge.EVENT_BUS.register(MinecraftForge.INTERNAL_HANDLER);
    ForgeChunkManager.captureConfig(evt.getModConfigurationDirectory());
    MinecraftForge.EVENT_BUS.register(this);

    if (!ForgeModContainer.disableVersionCheck)
    {
        ForgeVersion.startVersionCheck();
    }

    // Add and register the forge universal bucket, if it's enabled
    if(FluidRegistry.isUniversalBucketEnabled())
    {
        universalBucket = new UniversalBucket();
        universalBucket.setUnlocalizedName("forge.bucketFilled");
        GameRegistry.registerItem(universalBucket, "bucketFilled");
        MinecraftForge.EVENT_BUS.register(universalBucket);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:ForgeModContainer.java

示例5: getCapability

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
@Nullable
@Override
public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) {
    if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
        if (facing == null) return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(playerMainInvHandler);
        switch (facing) {
            case UP:
                return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(playerArmorInvHandler);
            case DOWN:
                return super.getCapability(capability, facing);
            default:
                return dispenserUpgradeInserted ?
                        CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(playerFoodHandler) :
                        CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(playerMainInvHandler);
        }
    } else if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY && dispenserUpgradeInserted) {
        return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(playerExperienceHandler);
    } else if (capability == CapabilityEnergy.ENERGY) {
        return CapabilityEnergy.ENERGY.cast(energyRF);
    }
    return super.getCapability(capability, facing);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:23,代码来源:TileEntityAerialInterface.java

示例6: amountRequested

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
@Override
public int amountRequested(FluidStack stack) {
    int totalRequestingAmount = getTotalRequestedAmount(stack);
    if (totalRequestingAmount > 0) {
        TileEntity te = getTileEntity();
        int count = 0;
        for (EnumFacing facing : EnumFacing.VALUES) {
            if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)) {
                IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing);
                for (IFluidTankProperties properties : handler.getTankProperties()) {
                    FluidStack contents = properties.getContents();
                    if (contents != null && contents.getFluid() == stack.getFluid()) {
                        count += contents.amount;
                    }
                }
                if (count > 0) break;
            }
        }
        if (count == 0) return 0;
        count += getIncomingFluid(stack.getFluid());
        return Math.max(0, Math.min(stack.amount, totalRequestingAmount - count));
    }
    return 0;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:25,代码来源:SemiBlockRequester.java

示例7: getTankProperties

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
@Override
public IFluidTankProperties[] getTankProperties() {
    if(properties == null) { //Fingers crossed
        ArrayList<IFluidTankProperties> importedProperties = new ArrayList<>();

        if (tile != null)
            for (EnumFacing facing : EnumFacing.HORIZONTALS) {
                if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)) {
                    IFluidHandler capability = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing);
                    IFluidTankProperties[] faceProperties = capability.getTankProperties();
                    importedProperties.addAll(Arrays.asList(faceProperties));
                }
            }

        properties = importedProperties.toArray(new IFluidTankProperties[importedProperties.size()]);
    }

    return properties;
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:20,代码来源:CapabilityMixerOutput.java

示例8: drain

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
@Nullable
@Override
public FluidStack drain(FluidStack resource, boolean doDrain) {
    FluidStack drained = null;

    if(tile != null)
    for (EnumFacing facing : EnumFacing.HORIZONTALS) {
        if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,facing))
        {
            IFluidHandler capability = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,facing);
            drained = capability.drain(resource,doDrain);
            if(drained != null)
                break;
        }
    }

    return drained;
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:19,代码来源:CapabilityMixerOutput.java

示例9: drawGuiContainerForegroundLayer

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
	super.drawGuiContainerForegroundLayer(mouseX, mouseY);
	int[] data = ((ContainerBarrel) inventorySlots).data_a;
	this.renderHoveredToolTip(mouseX - guiLeft, mouseY - guiTop);
	if (mouseX > guiLeft + 62 && mouseX < guiLeft + 114 && mouseY > guiTop + 17 && mouseY < guiTop + 33) {
		FluidStack fstack = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null).drain(1000, false);
		if (fstack != null) {
			ArrayList<String> tooltip = new ArrayList<String>(2);
			String color = fstack.getFluid().getTemperature() > 600 ? TextFormatting.GOLD.toString() : fstack.getFluid().getTemperature() < 150 ? TextFormatting.AQUA.toString() : TextFormatting.DARK_AQUA.toString();
			tooltip.add(color + fstack.getLocalizedName());
			tooltip.add(TextFormatting.GRAY + I18n.format("fluid.quantity.mB", fstack.amount));
			drawHoveringText(tooltip, mouseX - guiLeft, mouseY - guiTop);
		} else {
			drawHoveringText(I18n.format("fluid.none"), mouseX - guiLeft, mouseY - guiTop);
		}
	} else if (mouseX > guiLeft + 134 && mouseX < guiLeft + 150 && mouseY > guiTop + 20 && mouseY < guiTop + 36) {
		String text = TextFormatting.YELLOW + I18n.format("tile.barrel.altar.working");
		if (data[3] == 0) text = TextFormatting.GREEN + I18n.format("tile.barrel.altar.none_required");
		else if (te.getAltar(false) == null)
			text = TextFormatting.DARK_RED + I18n.format("tile.barrel.altar.no_altar");
		else if (data[3] == data[1]) text = TextFormatting.GREEN + I18n.format("tile.barrel.altar.done");

		drawHoveringText(text, mouseX - guiLeft, mouseY - guiTop);
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:27,代码来源:GuiBarrel.java

示例10: onFinish

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions")
@Override
public void onFinish(TileCauldron tile, World world, BlockPos pos) {
	for (int i = 0; i < 20; i++) {
		final float x = pos.getX() + 0.2F + MathHelper.clamp(world.rand.nextFloat(), 0F, 0.5F);
		final float y = pos.getY() + 0.2F + world.rand.nextFloat();
		final float z = pos.getZ() + 0.2F + MathHelper.clamp(world.rand.nextFloat(), 0F, 0.5F);

		PacketHandler.spawnParticle(ParticleF.STEAM, world, x, y, z, 10, 0, 0, 0);
	}
	if (!stack.isEmpty()) {
		if (tile.getContainer().isEmpty()) {
			tile.setContainer(stack);
		} else {
			spawnItem(world, pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D);
		}
	}
	world.playSound(null, pos, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1F, 1F);
	IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
	handler.drain(1000, true);
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:22,代码来源:ItemRitual.java

示例11: getCapability

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
@Nullable
@Override
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
    if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY){
        IItemHandler inventory = getInventory(facing);
        if(inventory != null){
            return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(inventory);
        }
    }
    if(capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY){
        IFluidHandler tank = getTank(facing);
        if(tank != null){
            return CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.cast(tank);
        }
    }
    if(capability == CapabilityEnergy.ENERGY){
        IEnergyStorage energy = getEnergy(facing);
        if(energy != null){
            return CapabilityEnergy.ENERGY.cast(energy);
        }
    }
    return null;
}
 
开发者ID:canitzp,项目名称:Metalworks,代码行数:24,代码来源:TileBase.java

示例12: readCapabilities

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
protected void readCapabilities(NBTTagCompound nbt, @Nullable EnumFacing side){
    IItemHandler inventory = this.getInventory(side);
    if(inventory != null && inventory instanceof IItemHandlerModifiable && nbt.hasKey("Inventory")){
        for(int i = 0; i < inventory.getSlots(); i++){ // clear the inventory, otherwise empty stacks doesn't get overriden while syncing. Forge Bug?
            ((IItemHandlerModifiable) inventory).setStackInSlot(i, ItemStack.EMPTY);
        }
        CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(inventory, side, nbt.getTag("Inventory"));
    }
    IFluidHandler tank = getTank(side);
    if(tank != null && tank instanceof IFluidTank && nbt.hasKey("FluidTank")){
        CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.readNBT(tank, side, nbt.getCompoundTag("FluidTank"));
    }
    IEnergyStorage energy = getEnergy(side);
    if(energy != null && energy instanceof EnergyStorage && nbt.hasKey("Energy")){
        CapabilityEnergy.ENERGY.readNBT(energy, side, nbt.getTag("Energy"));
    }
}
 
开发者ID:canitzp,项目名称:Metalworks,代码行数:18,代码来源:TileBase.java

示例13: interactWithFluidItem

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
private boolean interactWithFluidItem(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing)
{
    if (getContent().canInteractWithFluidItem.get(getSubtype(state)).orElse(true))
    {
        TileEntity tile = worldIn.getTileEntity(pos);
        if (tile != null && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing))
        {
            if (worldIn.isRemote)
            {
                return true;
            }

            if (FluidUtil.interactWithFluidHandler(playerIn, hand, worldIn, pos, facing))
            {
                playerIn.inventoryContainer.detectAndSendChanges();
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:22,代码来源:BlockMixin.java

示例14: TileEntityPotStill

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
public TileEntityPotStill() {
	inputTank.listen(this::markDirty);
	outputTank.listen(this::markDirty);
	itemStorage.listen(this::markDirty);
	heat.listen(this::markDirty);
	
	//Always
	inputTank.setCanDrain(false);
	outputTank.setCanFill(false);
	
	//Most of the time
	setTanksLocked(false);
	
	capabilities.registerForAllSides(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, ()->new ValidatedItemHandlerView(itemStorage), ()->itemStorage);
	capabilities.registerForAllSides(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, ()->cap);
	capabilities.registerForAllSides(Thermionics.CAPABILITY_HEATSTORAGE, ()->HeatStorageView.insertOnlyOf(heat));
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:18,代码来源:TileEntityPotStill.java

示例15: readFromNBT

import net.minecraftforge.fluids.capability.CapabilityFluidHandler; //导入依赖的package包/类
@Override
public void readFromNBT(NBTTagCompound tag) {
	super.readFromNBT(tag);
	
	if (tag.hasKey("inputtank")) {
		CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.readNBT(inputTank, null, tag.getTag("inputtank"));
	}
	if (tag.hasKey("outputtank")) {
		CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.readNBT(outputTank, null, tag.getTag("outputtank"));
	}
	if (tag.hasKey("heatstorage")) {
		Thermionics.CAPABILITY_HEATSTORAGE.readNBT(heat, null, tag.getTag("heatstorage"));
	}
	if (tag.hasKey("inventory")) {
		CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(itemStorage, null, tag.getTag("inventory"));
	}
	
	if (tag.hasKey("locked")) {
		tanksLocked = tag.getByte("locked")!=0;
	}
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:22,代码来源:TileEntityPotStill.java


注:本文中的net.minecraftforge.fluids.capability.CapabilityFluidHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。