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


Java FluidStack.loadFluidStackFromNBT方法代碼示例

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


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

示例1: addInformation

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean isAdvanced) {

	if (stack.hasTagCompound()) {
		NBTTagCompound tag = stack.stackTagCompound;
		FluidStack fluid = null;
		if (tag.hasKey("Fluid")) {
			fluid = FluidStack.loadFluidStackFromNBT((NBTTagCompound) tag.getTag("Fluid"));
			tooltip.add("Fluid " + ": " + fluid.getLocalizedName());
		}
		int amount = (fluid != null) ? fluid.amount : 0;
		tooltip.add("Amount" + ": " + amount + " / " + 8000 + " mB");

	}
	else
		tooltip.add("Item Error");
}
 
開發者ID:grand-mine-inc,項目名稱:Steam-and-Steel,代碼行數:19,代碼來源:ItemBlockGlassTank.java

示例2: renderItem

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
	
	RenderBlocks renderblocks = (RenderBlocks) data[0];
	Block block = Block.getBlockFromItem(item.getItem());
	if (item.hasTagCompound()) {
		NBTTagCompound tag = item.stackTagCompound;
		if (tag.hasKey("Fluid")) {
			FluidStack liquid = FluidStack.loadFluidStackFromNBT(item.getTagCompound().getCompoundTag("Fluid"));
			if (liquid != null) {
				GL11.glEnable(GL11.GL_BLEND);
				float height = ((float) liquid.amount / (float) 8000 * (float) 0.99);
				renderblocks.setRenderBounds(0.01, 0.01, 0.01, 0.99, height, 0.99);
				Utils.renderInventoryBlock(renderblocks, GrandFluidTank.renderblocks, liquid.getFluid());
				GL11.glDisable(GL11.GL_BLEND);
			}
		}

		GL11.glEnable(GL11.GL_ALPHA_TEST);
		renderblocks.setRenderBounds(0, 0, 0, 1, 1, 1);
		Utils.renderInventoryBlock(renderblocks, block, GrandFluidTank.glassfluidtank.getIcon(0, 0));
		GL11.glDisable(GL11.GL_ALPHA_TEST);

	}
}
 
開發者ID:grand-mine-inc,項目名稱:Steam-and-Steel,代碼行數:26,代碼來源:RenderItemBlockGlassTank.java

示例3: getLiquidFromStack

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
public static CauldronLiquid getLiquidFromStack(ItemStack key)
{
	if(key.getItem() instanceof UniversalBucket && FluidStack.loadFluidStackFromNBT(key.getTagCompound()) != null &&
			FORGE_BUCKET_MAP.containsKey(FluidStack.loadFluidStackFromNBT(key.getTagCompound()).getFluid()))
		return FORGE_BUCKET_MAP.get(FluidStack.loadFluidStackFromNBT(key.getTagCompound()).getFluid());
	return HarshenUtils.getObjectFromItemMap(HarshenUtils.getObjectFromItemMap(INPUT_MAP, key) != null ? INPUT_MAP : ITEMLIQUID_MAP, key);
}
 
開發者ID:kenijey,項目名稱:harshencastle,代碼行數:8,代碼來源:HarshenRegistry.java

示例4: onBlockPlacedBy

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
	
	if (stack.hasTagCompound()) {
		TileGlassFluidTank tank = (TileGlassFluidTank) world.getTileEntity(x, y, z);
		if (tank != null) {
			NBTTagCompound tagFluid = stack.getTagCompound().getCompoundTag("Fluid");
			if (tagFluid != null) {
				FluidStack liquid = FluidStack.loadFluidStackFromNBT(tagFluid);
				tank.tank.setFluid(liquid);
			}

		}
	}
	}
 
開發者ID:grand-mine-inc,項目名稱:Steam-and-Steel,代碼行數:16,代碼來源:GlassFluidTank.java

示例5: readFromNBT

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound compound) {
	super.readFromNBT(compound);
	sapInBucket = FluidStack.loadFluidStackFromNBT(compound);
	if (sapInBucket != null) {
		direction = EnumFacing.values()[compound.getInteger("direction")];
		LIQUID_AMOUNT = compound.getInteger("sappertick");
		hasBucket = true;
	} else {
		reset();
	}
}
 
開發者ID:MinecraftModDevelopmentMods,項目名稱:Got-Wood,代碼行數:13,代碼來源:TileEntityTreeTap.java

示例6: readFluidStack

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
public static FluidStack readFluidStack(ByteBuf dataIn) {
    PacketBuffer buf = new PacketBuffer(dataIn);
    try {
        NBTTagCompound nbt = PacketBufferTools.readCompoundTag(buf);
        return FluidStack.loadFluidStackFromNBT(nbt);
    } catch (IOException e) {
        InteractionWheel.logger.log(Level.ERROR, "Error reading fluid stack", e);
    }
    return null;
}
 
開發者ID:McJty,項目名稱:interactionwheel,代碼行數:11,代碼來源:NetworkTools.java

示例7: fromBytes

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public void fromBytes(ByteBuf buf)
{
    windowId = buf.readByte();
    tank = buf.readByte();

    NBTTagCompound fluidNbt = ByteBufUtils.readTag(buf);
    fluid = FluidStack.loadFluidStackFromNBT(fluidNbt);
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:10,代碼來源:PacketSyncContainerFluid.java

示例8: getFluid

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Nullable
public FluidStack getFluid()
{
    NBTTagCompound tagCompound = container.getTagCompound();
    if (tagCompound == null || !tagCompound.hasKey(FLUID_NBT_KEY))
    {
        return null;
    }
    return FluidStack.loadFluidStackFromNBT(tagCompound.getCompoundTag(FLUID_NBT_KEY));
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:11,代碼來源:FluidHandlerItemStackSimple.java

示例9: drain

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) {

    if (container.getTagCompound() == null) {
        container.setTagCompound(new NBTTagCompound());
    }
    if (!container.getTagCompound().hasKey("Fluid") || maxDrain == 0) {
        return null;
    }
    FluidStack stack = FluidStack.loadFluidStackFromNBT(container.getTagCompound().getCompoundTag("Fluid"));

    if (stack == null) {
        return null;
    }
    int drained = Math.min(stack.amount, maxDrain);

    if (doDrain && ItemHelper.getItemDamage(container) != CREATIVE) {
        if (maxDrain >= stack.amount) {
            container.getTagCompound().removeTag("Fluid");
            return stack;
        }
        NBTTagCompound fluidTag = container.getTagCompound().getCompoundTag("Fluid");
        fluidTag.setInteger("Amount", fluidTag.getInteger("Amount") - drained);
        container.getTagCompound().setTag("Fluid", fluidTag);
    }
    stack.amount = drained;
    return stack;
}
 
開發者ID:ImbaKnugel,項目名稱:Whoosh,代碼行數:29,代碼來源:ItemTransporter.java

示例10: getFluid

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public FluidStack getFluid(ItemStack container) {

    if (container.getTagCompound() == null) {
        container.setTagCompound(new NBTTagCompound());
    }
    if (!container.getTagCompound().hasKey("Fluid")) {
        return null;
    }
    return FluidStack.loadFluidStackFromNBT(container.getTagCompound().getCompoundTag("Fluid"));
}
 
開發者ID:ImbaKnugel,項目名稱:Whoosh,代碼行數:12,代碼來源:ItemTransporter.java

示例11: readFromNBT

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);
    CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getStorage().readNBT(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, itemStackHandler, null, tag.getTag("Items"));
    progress = tag.getInteger("progress");
    fuel = tag.getInteger("fuel");
    output = new ItemStack(tag.getCompoundTag("output"));
    fluidStack = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("fluidOutput"));
}
 
開發者ID:LasmGratel,項目名稱:FoodCraft-Reloaded,代碼行數:10,代碼來源:TileEntitySmeltingDrinkMachine.java

示例12: getFluid

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Nullable
public FluidStack getFluid(@Nonnull ItemStack container)
{
    return FluidStack.loadFluidStackFromNBT(container.getSubCompound("Fluid"));
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:6,代碼來源:ItemFluidContainer.java

示例13: getContents

import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public FluidStack getContents()
{
	return this.getContainer().hasTagCompound() && this.getContainer().getTagCompound().hasKey("exp.wateringCanFluidStackTag") ? FluidStack.loadFluidStackFromNBT(this.getContainer().getTagCompound().getCompoundTag("exp.wateringCanFluidStackTag")) : null;
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:6,代碼來源:WateringCanCapability.java


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