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


Java FluidUtil.getFluidContained方法代码示例

本文整理汇总了Java中net.minecraftforge.fluids.FluidUtil.getFluidContained方法的典型用法代码示例。如果您正苦于以下问题:Java FluidUtil.getFluidContained方法的具体用法?Java FluidUtil.getFluidContained怎么用?Java FluidUtil.getFluidContained使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.fluids.FluidUtil的用法示例。


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

示例1: onBlockActivated

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
/**
 * with thanks and gratitude @KnightMiner https://github.com/KnightMiner/Ceramics/blob/1.11/src/main/java/knightminer/ceramics/blocks/BlockBarrel.java
 * 
 * 
 */
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
  // check the TE
  TileEntityHydrator te = (TileEntityHydrator) world.getTileEntity(pos);
  FluidStack bucket = FluidUtil.getFluidContained(player.getHeldItem(hand));
  boolean success = false;
  if (bucket == null || bucket.getFluid() == FluidRegistry.WATER) {//THEN let fluid insert happen
    success = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side);
  }
  if (te != null) {
    if (!world.isRemote) {
      int currentFluid = te.getField(Fields.FLUID.ordinal());
      UtilChat.sendStatusMessage(player, UtilChat.lang("cyclic.fluid.amount") + currentFluid);
    }
  }
  // otherwise return true if it is a fluid handler to prevent in world placement
  return success || FluidUtil.getFluidHandler(player.getHeldItem(hand)) != null || super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ);
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:24,代码来源:BlockHydrator.java

示例2: update

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public void update()
{
    ItemStack stack = inventory.get(0);
    if(!stack.isEmpty() && stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, EnumFacing.DOWN))
    {
        IFluidHandlerItem fh = FluidUtil.getFluidHandler(stack);
        FluidStack fluid = FluidUtil.getFluidContained(stack);
        if(fh != null && fluid != null)
        {
            int amountFilled = fluidTanks[0].fillInternal(fluid, false);
            FluidStack amountDrained = fh.drain(amountFilled, true);

            if(amountDrained != null && amountDrained.amount > 0)
            {
                fluidTanks[0].fillInternal(amountDrained, true);
                inventory.set(0, fh.getContainer());
            }
        }
    }
    super.update();
}
 
开发者ID:Lumaceon,项目名称:ClockworkPhase2,代码行数:23,代码来源:TileClockworkCrystallizer.java

示例3: getNameFromStack

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
/**
 * TODO: raise a PR to get this into IGW.  This adds support for Forge filled buckets (use "item/bucket/{fluid_name}")
 *
 * @param stack
 * @return
 */
static String getNameFromStack(ItemStack stack) {
    if (stack.getItem().getRegistryName().toString().equals("forge:bucketfilled")) {
        FluidStack fluidStack = FluidUtil.getFluidContained(stack);
        if (fluidStack != null) {
            return "item/bucket/" + fluidStack.getFluid().getName();
        } else {
            return "item/bucket";
        }
    }
    return stack.getUnlocalizedName().replace("tile.", "block/").replace("item.", "item/");
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:18,代码来源:IGWHandler.java

示例4: scanForFluids

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
private static void scanForFluids(ShapedOreRecipe recipe) {
    for (int i = 0; i < recipe.getIngredients().size(); i++) {
        Ingredient ingredient = recipe.getIngredients().get(i);
        for (ItemStack stack : ingredient.getMatchingStacks()) {
            FluidStack fluid = FluidUtil.getFluidContained(stack);
            if (fluid != null) {
                ForgeRegistries.RECIPES.register(new RecipeFluid(recipe, i));
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:12,代码来源:CraftingRegistrator.java

示例5: RecipeFluid

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
public RecipeFluid(ShapedOreRecipe recipe, int fluidIndex) {
    super("fluid_recipe_" + recipeIndex++);
    this.recipe = recipe;
    Ingredient ingredient = recipe.getIngredients().get(fluidIndex);
    originalStack = ingredient.getMatchingStacks()[0];
    fluidStack = FluidUtil.getFluidContained(originalStack);
    if (fluidStack == null)
        throw new IllegalArgumentException("Recipe doesn't have fluid item at index " + fluidIndex + ". Item: " + originalStack);
    this.fluidIndex = fluidIndex;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:11,代码来源:RecipeFluid.java

示例6: handleFuelEvent

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@SubscribeEvent
public void handleFuelEvent(FurnaceFuelBurnTimeEvent event) {
    FluidStack fluidStack = FluidUtil.getFluidContained(event.getItemStack());
    if (fluidStack != null) {
        int value = PneumaticCraftAPIHandler.getInstance().liquidFuels.getOrDefault(fluidStack.getFluid().getName(), -1);
        event.setBurnTime(value > 0 ? (int)(value * ConfigHandler.general.fuelBucketEfficiencyMultiplier) : -1);
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:9,代码来源:EventHandlerPneumaticCraft.java

示例7: getCaskLiquid

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
public CaskLiquid getCaskLiquid(ItemStack stack) {
    FluidStack fluid = FluidUtil.getFluidContained(stack);
    if(fluid != null) {
        CaskLiquid liquid = CaskManager.getFromFluid(fluid.getFluid());
        return liquid;
    }
    return null;
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:9,代码来源:ItemMug.java

示例8: getItemStackDisplayName

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public String getItemStackDisplayName(ItemStack stack) {
    FluidStack fluid = FluidUtil.getFluidContained(stack);
    if(fluid != null)
        return I18n.translateToLocalFormatted("item.mug.name",fluid.getLocalizedName());
    else
        return I18n.translateToLocal("item.mug.empty.name");
}
 
开发者ID:DaedalusGame,项目名称:Soot,代码行数:9,代码来源:ItemMug.java

示例9: isEmptyFluidContainer

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
public static boolean isEmptyFluidContainer(ItemStack stack)
   {
//If the stack has a fluid cap, but no contained fluid, it's probably empty
if(stack != null && CapUtils.hasFluidHandler(stack) && FluidUtil.getFluidContained(stack) == null)
    return true;
else
    return false;
   }
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:9,代码来源:Util.java

示例10: handleItemState

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public IBakedModel handleItemState(IBakedModel originalModel, ItemStack stack, World world, EntityLivingBase entity)
{
    FluidStack fluidStack = FluidUtil.getFluidContained(stack);

    // not a fluid item apparently
    if (fluidStack == null)
    {
        // empty bucket
        return originalModel;
    }

    BakedDynBucket model = (BakedDynBucket)originalModel;

    Fluid fluid = fluidStack.getFluid();
    String name = fluid.getName();

    if (!model.cache.containsKey(name))
    {
        IModel parent = model.parent.process(ImmutableMap.of("fluid", name));
        Function<ResourceLocation, TextureAtlasSprite> textureGetter;
        textureGetter = new Function<ResourceLocation, TextureAtlasSprite>()
        {
            public TextureAtlasSprite apply(ResourceLocation location)
            {
                return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
            }
        };

        IBakedModel bakedModel = parent.bake(new SimpleModelState(model.transforms), model.format, textureGetter);
        model.cache.put(name, bakedModel);
        return bakedModel;
    }

    return model.cache.get(name);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:37,代码来源:ModelDynBucket.java

示例11: apply

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean apply(@Nullable ItemStack stack)
{
	if (stack == null)
	{
		return false;
	}
	else
	{
		FluidStack fluidStack = FluidUtil.getFluidContained(stack);
		return fluidStack == null && this.fluid == null || fluidStack != null && fluidStack.containsFluid(fluid);
	}
}
 
开发者ID:TeamWizardry,项目名称:Wizardry,代码行数:14,代码来源:IngredientFluidStack.java

示例12: setInventorySlotContents

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public void setInventorySlotContents(int index, ItemStack stack) {
	if (index < 0 || index >= this.getSizeInventory())
		return;

	if (!stack.isEmpty() && stack.getCount() > this.getInventoryStackLimit())
		stack.setCount(this.getInventoryStackLimit());

	if (!stack.isEmpty() && stack.getCount() == 0)
		stack = ItemStack.EMPTY;

	ItemStack emptyContainer = ItemStack.EMPTY;
	if (!stack.isEmpty()) {
		FluidStack fluid = FluidUtil.getFluidContained(stack);
		if (fluid != null) {
			FluidActionResult result = FluidUtil.tryEmptyContainer(stack, new FluidTank(Integer.MAX_VALUE), 1000,
					null, true);
			if (result.success)
				emptyContainer = result.getResult();					
		}
		if (stack.getItem() == Items.WATER_BUCKET) {
			emptyContainer = new ItemStack(Items.BUCKET);
		}
		if (stack.getItem() == Items.LAVA_BUCKET) {
			emptyContainer = new ItemStack(Items.BUCKET);
		}
		if (stack.getItem() == Items.MILK_BUCKET) {
			emptyContainer = new ItemStack(Items.BUCKET);
		}
	}

	if (!emptyContainer.isEmpty())
		this.inventory.set(index, emptyContainer);
	else
		this.inventory.set(index, stack);
	this.markDirty();

}
 
开发者ID:Bartz24,项目名称:UsefulNullifiers,代码行数:39,代码来源:FluidVoidInventory.java

示例13: tryFillTankFromItems

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
public void tryFillTankFromItems() {
  ItemStack maybeBucket = this.getStackInSlot(SLOT_INFLUID);
  FluidStack f = FluidUtil.getFluidContained(maybeBucket);
  IFluidHandlerItem bucketHandler = FluidUtil.getFluidHandler(maybeBucket);
  if (f != null && bucketHandler != null && f.getFluid().equals(FluidRegistry.WATER)) {
    //https://github.com/BluSunrize/ImmersiveEngineering/blob/fc022675bb550318cbadc879b3f28dde511e29c3/src/main/java/blusunrize/immersiveengineering/common/blocks/wooden/TileEntityWoodenBarrel.java
    FluidActionResult r = FluidUtil.tryEmptyContainer(maybeBucket, tank, Fluid.BUCKET_VOLUME, null, true);
    //in the case of a full bucket, it becomes empty. 
    //also supports any other fluid holding item, simply draining that fixed amount each round
    if (r.success) {
      this.setInventorySlotContents(SLOT_INFLUID, r.result);
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:15,代码来源:TileEntityHydrator.java

示例14: addFilledBucket

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
public ContainerBucketFillHandler addFilledBucket(ItemStack filledBucket) {
	FluidStack containedFluid = FluidUtil.getFluidContained(filledBucket);
	if (containedFluid != null) {
		buckets.add(Pair.of(containedFluid.copy(), filledBucket.copy()));
	} else {
		Log.warn("Item %s is not a filled bucket", filledBucket);
	}
	return this;
}
 
开发者ID:OpenMods,项目名称:OpenModsLib,代码行数:10,代码来源:ContainerBucketFillHandler.java

示例15: isItemValid

import net.minecraftforge.fluids.FluidUtil; //导入方法依赖的package包/类
@Override
public boolean isItemValid(@Nonnull ItemStack stack) {
    FluidStack fluidStack = FluidUtil.getFluidContained(stack);
    return fluidStack != null && fluidStack.amount > 0;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:6,代码来源:SlotFullFluidContainer.java


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