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


Java FluidRegistry.lookupFluidForBlock方法代碼示例

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


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

示例1: getEvaluator

import net.minecraftforge.fluids.FluidRegistry; //導入方法依賴的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: suckLiquid

import net.minecraftforge.fluids.FluidRegistry; //導入方法依賴的package包/類
private boolean suckLiquid() {
    Block block = world.getBlockState(getPos().offset(EnumFacing.DOWN, currentDepth + 1)).getBlock();
    Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
    if (fluid == null) {
        pumpingLake = null;
        return false;
    }

    FluidStack fluidStack = new FluidStack(fluid, 1000);
    if (tank.fill(fluidStack, false) == 1000) {
        if (pumpingLake == null) {
            findLake(block);
        }
        BlockPos curPos = null;
        boolean foundSource = false;
        while (pumpingLake.size() > 0) {
            curPos = pumpingLake.get(0);
            if (getWorld().getBlockState(curPos).getBlock() == block && FluidUtils.isSourceBlock(getWorld(), curPos)) {
                foundSource = true;
                break;
            }
            pumpingLake.remove(0);
        }
        if (pumpingLake.size() == 0) {
            pumpingLake = null;
        } else if (foundSource) {
            getWorld().setBlockToAir(curPos);
            tank.fill(fluidStack, true);
            addAir(-100);
            status = Status.PUMPING;
        }
    }
    return true;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:35,代碼來源:TileEntityGasLift.java

示例3: emptyTank

import net.minecraftforge.fluids.FluidRegistry; //導入方法依賴的package包/類
private boolean emptyTank(BlockPos pos, boolean simulate) {
    if (drone.getTank().getFluidAmount() == drone.getTank().getCapacity()) {
        drone.addDebugEntry("gui.progWidget.liquidImport.debug.fullDroneTank");
        abort();
        return false;
    } else {
        TileEntity te = drone.world().getTileEntity(pos);
        if (te != null) {
            for (int i = 0; i < 6; i++) {
                if (((ISidedWidget) widget).getSides()[i] && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.getFront(i))) {
                    IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.getFront(i));
                    FluidStack importedFluid = handler.drain(Integer.MAX_VALUE, false);
                    if (importedFluid != null && ((ILiquidFiltered) widget).isFluidValid(importedFluid.getFluid())) {
                        int filledAmount = drone.getTank().fill(importedFluid, false);
                        if (filledAmount > 0) {
                            if (((ICountWidget) widget).useCount())
                                filledAmount = Math.min(filledAmount, getRemainingCount());
                            if (!simulate) {
                                decreaseCount(drone.getTank().fill(handler.drain(filledAmount, true), true));
                            }
                            return true;
                        }
                    }
                }
            }
            drone.addDebugEntry("gui.progWidget.liquidImport.debug.emptiedToMax", pos);
        } else if (!((ICountWidget) widget).useCount() || getRemainingCount() >= 1000) {
            Fluid fluid = FluidRegistry.lookupFluidForBlock(drone.world().getBlockState(pos).getBlock());
            if (fluid != null && ((ILiquidFiltered) widget).isFluidValid(fluid) && drone.getTank().fill(new FluidStack(fluid, 1000), false) == 1000 && FluidUtils.isSourceBlock(drone.world(), pos)) {
                if (!simulate) {
                    decreaseCount(1000);
                    drone.getTank().fill(new FluidStack(fluid, 1000), true);
                    drone.world().setBlockToAir(pos);
                }
                return true;
            }
        }
        return false;
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:41,代碼來源:DroneAILiquidImport.java

示例4: getFluid

import net.minecraftforge.fluids.FluidRegistry; //導入方法依賴的package包/類
public Fluid getFluid() {
    Fluid fluid = FluidRegistry.lookupFluidForBlock(getBlockState().getBlock());
    if (fluid != null) return fluid;
    else if (getBlockState().getBlock() == Blocks.FLOWING_LAVA) return FluidRegistry.LAVA;
    else if (getBlockState().getBlock() == Blocks.FLOWING_WATER) return FluidRegistry.WATER;
    return null;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:8,代碼來源:HeatBehaviourLiquid.java

示例5: work

import net.minecraftforge.fluids.FluidRegistry; //導入方法依賴的package包/類
@Override
public float work() {
    if (WorkUtils.isDisabled(this.getBlockType()) || isWorkFinished) return 0;
    if (tank.getFluidAmount() + 1000 <= tank.getCapacity()) {
        if (blocks == null) {
            blocks = new PriorityQueue<>(Comparator.comparingDouble(value -> (this.pos).distanceSq(((BlockPos) value).getX(), this.pos.getY() - 1, ((BlockPos) value).getZ())));
            BlockUtils.getBlockPosInAABB(getWorkingArea()).stream().filter(pos1 -> !this.world.isOutsideBuildHeight(pos1) && FluidRegistry.lookupFluidForBlock(this.world.getBlockState(pos1).getBlock()) != null && FluidRegistry.lookupFluidForBlock(this.world.getBlockState(pos1).getBlock()).getName().equals(fluid)).forEach(pos1 -> blocks.add(pos1));
        }
        if (blocks.isEmpty()) {
            isWorkFinished = true;
            blocks = null;
            return 0;
        }
        BlockPos peeked = blocks.peek();
        while (!blocks.isEmpty() && (this.world.isOutsideBuildHeight(peeked) || FluidRegistry.lookupFluidForBlock(this.world.getBlockState(peeked).getBlock()) == null || !FluidRegistry.lookupFluidForBlock(this.world.getBlockState(peeked).getBlock()).getName().equals(fluid) || this.world.getBlockState(peeked).getBlock().getMetaFromState(this.world.getBlockState(peeked)) != 0)) {
            blocks.poll();
            if (!blocks.isEmpty()) peeked = blocks.peek();
        }
        if (blocks.isEmpty()) {
            blocks = null;
            return 0;
        }
        while (this.world.getBlockState(peeked).getBlock().equals(this.world.getBlockState(peeked.add(0, -1, 0)).getBlock())) {
            peeked = peeked.add(0, -1, 0);
        }
        FluidStack stack = new FluidStack(FluidRegistry.lookupFluidForBlock(this.world.getBlockState(peeked).getBlock()), 1000);
        tank.fill(stack, true);
        this.world.setBlockState(peeked, Blocks.COBBLESTONE.getDefaultState());
        return 1;
    }
    return 0;
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:33,代碼來源:FluidPumpTile.java

示例6: phaseBucket

import net.minecraftforge.fluids.FluidRegistry; //導入方法依賴的package包/類
public static ItemStack phaseBucket(Block block)
{
	if(block instanceof BlockLiquid || block instanceof IFluidBlock)
	{
		Fluid fluid = block instanceof BlockLiquid ? FluidRegistry.lookupFluidForBlock(block) : ((IFluidBlock)block).getFluid();
		if(fluid == null)
			return new ItemStack(block);
		ItemStack stack = FluidUtil.getFilledBucket(new FluidStack(fluid, 1000));
		return stack.isEmpty() ? new ItemStack(block) : stack; 
	}
	
	return new ItemStack(block);
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:14,代碼來源:HarshenUtils.java

示例7: isOilBlock

import net.minecraftforge.fluids.FluidRegistry; //導入方法依賴的package包/類
private boolean isOilBlock(EntityPlayer player, World world, int x, int y, int z, boolean doDrain)
{
    Block block = world.getBlock(x, y, z);

    if (block instanceof IFluidBlock)
    {
        IFluidBlock fluidBlockHit = (IFluidBlock) block;
        boolean flag = false;
        if (block == GCBlocks.crudeOil)
        {
        	flag = true;
        }
        else
        {
        	Fluid fluidHit = FluidRegistry.lookupFluidForBlock(block);

        	if (fluidHit != null)
        	{
        		if (fluidHit.getName().startsWith("oil"))
        		{
        			flag = true;
        		}
        	}
        }

        if (flag)
        {
        	FluidStack stack = fluidBlockHit.drain(world, x, y, z, doDrain);
        	return stack != null && stack.amount > 0;
        }
    }

    return false;
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:35,代碼來源:ItemOilExtractor.java

示例8: protectedUpdate

import net.minecraftforge.fluids.FluidRegistry; //導入方法依賴的package包/類
@Override
public void protectedUpdate() {
    super.protectedUpdate();
    if (fluid == null && FluidRegistry.lookupFluidForBlock(this.world.getBlockState(this.pos.add(0, -1, 0)).getBlock()) != null)
        fluid = FluidRegistry.lookupFluidForBlock(this.world.getBlockState(this.pos.add(0, -1, 0)).getBlock()).getName();
}
 
開發者ID:Buuz135,項目名稱:Industrial-Foregoing,代碼行數:7,代碼來源:FluidPumpTile.java

示例9: tickStructure

import net.minecraftforge.fluids.FluidRegistry; //導入方法依賴的package包/類
default boolean tickStructure(World world, EntityPlayer player, BlockPos pos) {
	if (world.isRemote) return true;

	for (Template.BlockInfo info : getStructure().blockInfos()) {
		if (info.blockState == null) continue;

		BlockPos realPos = info.pos.add(pos).subtract(offsetToCenter());
		IBlockState state = world.getBlockState(realPos);
		if (state.getBlock() != info.blockState.getBlock()) {

			if (state.getBlock() == ModBlocks.CREATIVE_MANA_BATTERY && info.blockState.getBlock() == ModBlocks.MANA_BATTERY) {
				continue;
			}

			if (player.isCreative()) {
				world.setBlockState(realPos, info.blockState);
			} else {
				if (world.isAirBlock(realPos)) {
					ItemStack requiredStack = new ItemStack(info.blockState.getBlock());
					ItemStack stack = findItemInventoryFromItem(player, requiredStack);

					if (stack.isEmpty()) {
						ItemStack outputItem = craftItemFromInventory(player, requiredStack);

						if (outputItem.isEmpty()) continue;
						outputItem.shrink(1);
						player.inventory.addItemStackToInventory(outputItem);
						player.inventory.markDirty();
						world.setBlockState(realPos, info.blockState);
						return true;
					} else {
						stack.shrink(1);
						world.setBlockState(realPos, info.blockState);
						return true;
					}
				}
			}
		} else if (world.getBlockState(realPos) != info.blockState) {
			if (player.isCreative() || !info.blockState.getMaterial().isLiquid()) {
				world.setBlockState(realPos, info.blockState);
				return true;
			} else {
				FluidStack fluidStack = new FluidStack(FluidRegistry.lookupFluidForBlock(info.blockState.getBlock()), 1);
				ItemStack fluidBucket = findItemInventoryFromItem(player, FluidUtil.getFilledBucket(fluidStack));
				if (!fluidBucket.isEmpty()) {
					fluidBucket.shrink(1);
					player.addItemStackToInventory(new ItemStack(Items.BUCKET));
					player.inventory.markDirty();
					world.setBlockState(realPos, info.blockState);
					return true;
				}
			}
		}
	}
	return true;
}
 
開發者ID:TeamWizardry,項目名稱:Wizardry,代碼行數:57,代碼來源:IStructure.java

示例10: ComponentStructureList

import net.minecraftforge.fluids.FluidRegistry; //導入方法依賴的package包/類
public ComponentStructureList(Structure structure) {
	super(0, 0, 200, 300);
	Deque<Block> sorted = new ArrayDeque<>();
	HashMap<Block, Integer> ingredients = new HashMap<>();
	HashMap<Block, IBlockState> access = new HashMap<>();

	for (Template.BlockInfo info : structure.blockInfos()) {
		if (info.blockState.getBlock() == Blocks.AIR) continue;

		ingredients.putIfAbsent(info.blockState.getBlock(), 0);
		ingredients.put(info.blockState.getBlock(), ingredients.get(info.blockState.getBlock()) + 1);
		access.putIfAbsent(info.blockState.getBlock(), info.blockState);

		if (!sorted.contains(info.blockState.getBlock())) sorted.add(info.blockState.getBlock());
	}


	ComponentVoid recipe = new ComponentVoid(0, 0, 200, 300);
	recipe.getTransform().setScale(2);
	add(recipe);

	ComponentText text = new ComponentText(0, 3, ComponentText.TextAlignH.LEFT, ComponentText.TextAlignV.TOP);
	text.setSize(new Vec2d(200, 16));
	text.getText().setValue(" " + LibrarianLib.PROXY.translate("wizardry.misc.structure_materials"));
	recipe.add(text);

	ComponentSprite lineBreak = new ComponentSprite(BookGui.LINE_BREAK, (int) (getSize().getX() / 2.0 - 177.0 / 2.0), 30, 177, 2);
	add(lineBreak);

	int i = 0;
	int row = 0;
	while (!sorted.isEmpty() && sorted.peek() != null) {

		Block nextBlock = sorted.pop();
		ItemStack stack;
		if (FluidRegistry.lookupFluidForBlock(nextBlock) != null) {
			stack = FluidUtil.getFilledBucket(new FluidStack(FluidRegistry.lookupFluidForBlock(nextBlock), 1));
			stack = new ItemStack(stack.getItem(), ingredients.get(nextBlock), stack.getMetadata(), stack.getTagCompound());
		} else {
			NonNullList<ItemStack> itemStacks = NonNullList.create();
			nextBlock.getDrops(itemStacks, structure.getBlockAccess(), null, access.get(nextBlock), 0);
			if (itemStacks.isEmpty())
				stack = new ItemStack(nextBlock, ingredients.get(nextBlock));
			else {
				stack = itemStacks.get(0);
				stack.setCount(ingredients.get(nextBlock));
			}
		}

		ComponentStack componentStack = new ComponentStack(i * 16, 20 + row * 16);
		componentStack.getStack().setValue(stack);
		recipe.add(componentStack);

		if (i++ > 4) {
			i = 0;
			row++;
		}
	}
}
 
開發者ID:TeamWizardry,項目名稱:Wizardry,代碼行數:60,代碼來源:ComponentStructureList.java


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