本文整理汇总了Java中net.minecraftforge.fluids.FluidTank.getFluid方法的典型用法代码示例。如果您正苦于以下问题:Java FluidTank.getFluid方法的具体用法?Java FluidTank.getFluid怎么用?Java FluidTank.getFluid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.fluids.FluidTank
的用法示例。
在下文中一共展示了FluidTank.getFluid方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeToNBT
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setTag("filters", filters.serializeNBT());
NBTTagList tagList = new NBTTagList();
for (int i = 0; i < fluidFilters.length; i++) {
FluidTank filter = fluidFilters[i];
if (filter.getFluid() != null) {
NBTTagCompound t = new NBTTagCompound();
t.setInteger("index", i);
filter.writeToNBT(t);
tagList.appendTag(t);
}
}
tag.setTag("fluidFilters", tagList);
tag.setBoolean("invisible", invisible);
}
示例2: apply
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
/** Applies the recipe to the storage provided, determining whether or not the output should be produced. Optionally
* consumes the items.
*/
public boolean apply(FluidTank tank, IItemHandler inventory, boolean consume) {
if (consume && !apply(tank, inventory, false)) return false; //Always dry-run before destructive ops
if (tank.getFluid()==null) return false;
//Next line shouldn't happen but it pays to plan for the impossible
if (tank.getFluid().getFluid() != FluidRegistry.WATER) return false;
if (tank.getFluidAmount()<water) return false;
FluidStack fluidExtracted = tank.drainInternal(water, consume);
if (fluidExtracted.amount<water) return false;
int remaining = count;
for(int i=0; i<inventory.getSlots(); i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack.isEmpty()) continue;
if (item.apply(stack)) {
ItemStack extracted = inventory.extractItem(i, remaining, !consume);
if (extracted.isEmpty()) continue;
remaining -= extracted.getCount();
}
}
return remaining<=0;
}
示例3: cloneNetworkedObject
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
public static Object cloneNetworkedObject(Object a)
{
// We only need to clone mutable objects
if (a instanceof EnergyStorage)
{
EnergyStorage prevStorage = (EnergyStorage)a;
EnergyStorage storage = new EnergyStorage(prevStorage.getCapacityGC(), prevStorage.getMaxReceive(), prevStorage.getMaxExtract());
storage.setEnergyStored(prevStorage.getEnergyStoredGC());
return storage;
}
else if (a instanceof FluidTank)
{
FluidTank prevTank = (FluidTank)a;
FluidTank tank = new FluidTank(prevTank.getFluid(), prevTank.getCapacity());
return tank;
}
else
{
return a;
}
}
示例4: fillWithGCFuel
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
/**
* Fill Galacticraft entities (e.g. rockets, buggies) with Galacticraft fuel.
* For legacy reasons, accepts either "fuel" or "fuelgc".
* Auto-converts either one to the same type of fuel as is already contained.
*
* @param tank The tank
* @param liquid A FluidStack being the fuel offered
* @param doFill True if this is not a simulation / tank capacity test
* @return The amount filled
*/
public static int fillWithGCFuel(FluidTank tank, FluidStack liquid, boolean doFill)
{
if (liquid != null && testFuel(FluidRegistry.getFluidName(liquid)))
{
final FluidStack liquidInTank = tank.getFluid();
//If the tank is empty, fill it with the current type of GC fuel
if (liquidInTank == null)
{
return tank.fill(new FluidStack(GalacticraftCore.fluidFuel, liquid.amount), doFill);
}
//If the tank already contains something, fill it with more of the same
if (liquidInTank.amount + liquid.amount <= tank.getCapacity())
{
return tank.fill(new FluidStack(liquidInTank, liquid.amount), doFill);
}
}
return 0;
}
示例5: drain
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
@Override
@Nullable
public FluidStack drain(int maxDrain, boolean doDrain) {
if (ItemStackTools.getStackSize(container) != 1) {
return null;
}
FluidTank tank = loadTank(container);
if(tank == null)return null;
boolean infi = container.getMetadata() == TankType.CREATIVE.getMeta();
if(infi){
if(tank.getFluid() == null)return null;
FluidStack fluid = tank.getFluid().copy();
fluid.amount = maxDrain;
return fluid;
}
FluidStack ret = tank.drain(maxDrain, doDrain);
saveTank(container, tank);
return ret;
}
示例6: addInformation
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, World world, List<String> curInfo, ITooltipFlag flag) {
if (stack.hasTagCompound() && stack.getTagCompound().hasKey(PneumaticCraftUtils.SAVED_TANKS, Constants.NBT.TAG_COMPOUND)) {
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(PneumaticCraftUtils.SAVED_TANKS);
for (String s : tag.getKeySet()) {
NBTTagCompound tankTag = tag.getCompoundTag(s);
FluidTank tank = new FluidTank(tankTag.getInteger("Amount"));
tank.readFromNBT(tankTag);
FluidStack fluidStack = tank.getFluid();
if (fluidStack != null && fluidStack.amount > 0) {
curInfo.add(fluidStack.getFluid().getLocalizedName(fluidStack) + ": " + fluidStack.amount + "mB");
}
}
}
if (PneumaticCraftRepressurized.proxy.isSneakingInGui()) {
TileEntity te = createTileEntity(world, getDefaultState());
if (te instanceof TileEntityPneumaticBase) {
float pressure = ((TileEntityPneumaticBase) te).dangerPressure;
curInfo.add(TextFormatting.YELLOW + I18n.format("gui.tooltip.maxPressure", pressure));
}
}
String info = "gui.tab.info." + stack.getUnlocalizedName();
String translatedInfo = I18n.format(info);
if (!translatedInfo.equals(info)) {
if (PneumaticCraftRepressurized.proxy.isSneakingInGui()) {
translatedInfo = TextFormatting.AQUA + translatedInfo.substring(2);
if (!Loader.isModLoaded(ModIds.IGWMOD))
translatedInfo += " \\n \\n" + I18n.format("gui.tab.info.assistIGW");
curInfo.addAll(PneumaticCraftUtils.convertStringIntoList(translatedInfo, 40));
} else {
curInfo.add(TextFormatting.AQUA + I18n.format("gui.tooltip.sneakForInfo"));
}
}
}
示例7: consumeFluids
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
public void consumeFluids(ArrayList<FluidStack> fluids, FluidMixingRecipe recipe) {
for (FluidTank tank : tanks) {
FluidStack tankFluid = tank.getFluid();
boolean doContinue = true;
for (int j = 0; j < recipe.inputs.size() && doContinue; j++) {
FluidStack recipeFluid = recipe.inputs.get(j);
if (recipeFluid != null && tankFluid != null && recipeFluid.getFluid() == tankFluid.getFluid()) {
doContinue = false;
tank.drain(recipeFluid.amount,true);
}
}
}
}
示例8: tryFillContainerFuel
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
/**
*
* @param tank
* @param inventory
* @param slot
*/
public static void tryFillContainerFuel(FluidTank tank, ItemStack[] inventory, int slot)
{
if (FluidUtil.isValidContainer(inventory[slot]))
{
FluidStack liquid = tank.getFluid();
if (liquid != null && liquid.amount > 0)
{
String liquidname = liquid.getFluid().getName();
//Test for the GC fuels (though anything similarly named would also pass here)
if (liquidname.startsWith("fuel"))
{
//Make sure it is the current GC fuel
if (!liquidname.equals(GalacticraftCore.fluidFuel.getName()))
liquid = new FluidStack(GalacticraftCore.fluidFuel, liquid.amount);
//But match any existing fuel fluid in the container
ItemStack stack = inventory[slot];
//(No null check necessary here: it cannot be a null ItemStack thanks to the .isValidContainer() check above
if (stack.getItem() instanceof IFluidContainerItem)
{
FluidStack existingFluid = ((IFluidContainerItem)stack.getItem()).getFluid(stack);
if (existingFluid != null && !existingFluid.getFluid().getName().equals(GalacticraftCore.fluidFuel.getName()))
liquid = new FluidStack(existingFluid, liquid.amount);
}
FluidUtil.tryFillContainer(tank, liquid, inventory, slot, GCItems.fuelCanister);
}
}
}
}
示例9: handleItemState
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
@Override
public net.minecraft.client.renderer.block.model.IBakedModel handleItemState(ItemStack stack, World world, EntityLivingBase entity) {
int type = stack.getMetadata();
FluidStack fluid = null;
if(stack.hasTagCompound()){
FluidTank tank = ItemBlockTank.loadTank(stack.getTagCompound());
if(tank !=null){
fluid = tank.getFluid();
}
}
return new ModelTank(type, fluid);
}
示例10: addInformation
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced)
{
super.addInformation(stack, playerIn, tooltip, advanced);
FluidTank tank = loadTank(stack);
if(tank !=null){
FluidStack fluid = tank.getFluid();
if(fluid != null)tooltip.add(fluid.getLocalizedName()+" "+fluid.amount+" mB / "+tank.getCapacity()+" mB");
}
}
示例11: writeTank
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
public static void writeTank(NBTTagCompound tag, FluidTank tank, String name) {
FluidStack ls = tank.getFluid();
if (ls == null) {
return;
}
NBTTagCompound liquid_tag = new NBTTagCompound();
ls.writeToNBT(liquid_tag);
tag.setTag(name, liquid_tag);
}
示例12: retrieveValue
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
@Override
protected FluidStack retrieveValue(Field field, Object te) throws Exception {
FluidTank tank = (FluidTank) field.get(te);
return tank.getFluid();
}
示例13: update
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void update(TileBarrel barrel) {
// Fluids on top.
if (barrel.getTank().getFluid() != null) {
FluidTank tank = barrel.getTank();
if (tank.getFluid().amount != tank.getCapacity())
return;
Fluid fluidInBarrel = tank.getFluid().getFluid();
BlockPos barrelPos = barrel.getPos();
BlockPos pos = new BlockPos(barrelPos.getX(), barrelPos.getY() + 1, barrelPos.getZ());
Block onTop = barrel.getWorld().getBlockState(pos).getBlock();
Fluid fluidOnTop = null;
if (onTop instanceof BlockLiquid) {
fluidOnTop = onTop.getMaterial(barrel.getWorld().getBlockState(pos)) == Material.WATER
? FluidRegistry.WATER : FluidRegistry.LAVA;
}
if (onTop != null && onTop instanceof IFluidBlock) {
fluidOnTop = ((BlockFluidBase) onTop).getFluid();
}
if (FluidOnTopRegistry.isValidRecipe(fluidInBarrel, fluidOnTop)) {
ItemInfo info = FluidOnTopRegistry.getTransformedBlock(fluidInBarrel, fluidOnTop);
tank.drain(tank.getCapacity(), true);
barrel.setMode("block");
PacketHandler.sendToAllAround(new MessageBarrelModeUpdate("block", barrel.getPos()), barrel);
barrel.getMode().addItem(info.getItemStack(), barrel);
return;
}
// Fluid transforming time!
if (FluidTransformRegistry.containsKey(barrel.getTank().getFluid().getFluid().getName())) {
List<FluidTransformer> transformers = FluidTransformRegistry
.getFluidTransformers(barrel.getTank().getFluid().getFluid().getName());
boolean found = false;
for (int radius = 0; radius <= 2; radius++) {
for (FluidTransformer transformer : transformers) {
if (!BarrelLiquidBlacklistRegistry.isBlacklisted(barrel.getTier(), transformer.getOutputFluid())
&& (Util.isSurroundingBlocksAtLeastOneOf(transformer.getTransformingBlocks(),
barrel.getPos().add(0, -1, 0), barrel.getWorld(), radius)
|| Util.isSurroundingBlocksAtLeastOneOf(transformer.getTransformingBlocks(),
barrel.getPos(), barrel.getWorld(), radius))) {
// Time to start the process.
FluidStack fstack = tank.getFluid();
tank.setFluid(null);
barrel.setMode("fluidTransform");
BarrelModeFluidTransform mode = (BarrelModeFluidTransform) barrel.getMode();
mode.setTransformer(transformer);
mode.setInputStack(fstack);
mode.setOutputStack(FluidRegistry.getFluidStack(transformer.getOutputFluid(), 1000));
PacketHandler.sendNBTUpdate(barrel);
found = true;
}
}
if (found) break;
}
}
}
}
示例14: retrieveValue
import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
@Override
protected FluidStack retrieveValue(Field field, Object te) throws Exception{
FluidTank tank = (FluidTank)field.get(te);
return tank.getFluid();
}