本文整理匯總了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");
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
}
示例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();
}
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}
示例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"));
}
示例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"));
}
示例12: getFluid
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Nullable
public FluidStack getFluid(@Nonnull ItemStack container)
{
return FluidStack.loadFluidStackFromNBT(container.getSubCompound("Fluid"));
}
示例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;
}