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


Java FluidTank.setFluid方法代码示例

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


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

示例1: readFluidTank

import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
public static FluidTank readFluidTank(ByteBuf buffer) throws IOException
{
    int capacity = buffer.readInt();
    int fluidID = buffer.readInt();
    FluidTank fluidTank = new FluidTank(capacity);
    int amount = buffer.readInt();

    if (fluidID == -1)
    {
        fluidTank.setFluid(null);
    }
    else
    {
        Fluid fluid = FluidRegistry.getFluid(fluidID);
        fluidTank.setFluid(new FluidStack(fluid, amount));
    }

    return fluidTank;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:20,代码来源:NetworkUtil.java

示例2: loadTank

import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
public static FluidTank loadTank(NBTTagCompound nbtRoot) {
	int tankType = nbtRoot.hasKey("tankType") ? nbtRoot.getInteger("tankType") : 0;
	tankType = MathHelper.clamp(tankType, 0, BlockTank.tankCaps.length);
	int cap = BlockTank.tankCaps[tankType]*Fluid.BUCKET_VOLUME;
    FluidTank ret = new FluidTank(cap);
    
    if(nbtRoot.hasKey(FluidHandlerItemStack.FLUID_NBT_KEY)) {
      FluidStack fl = FluidStack.loadFluidStackFromNBT((NBTTagCompound) nbtRoot.getTag(FluidHandlerItemStack.FLUID_NBT_KEY));
      ret.setFluid(fl);
    } else {
      ret.setFluid(null);
    }
    return ret;
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:15,代码来源:ItemBlockTank.java

示例3: readCustomNBT

import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
@Override
	public void readCustomNBT(NBTTagCompound nbtRoot) {
super.readCustomNBT(nbtRoot);
  	tank = new FluidTank(capacities[nbtRoot.getInteger("Type") % capacities.length]);
  	oMode = OutputMode.values()[nbtRoot.getByte("OMode")];
  	outputAmt = nbtRoot.getInteger("OAmt");
  	if(nbtRoot.hasKey("tankContents")) {
  	FluidStack fl = FluidStack.loadFluidStackFromNBT((NBTTagCompound) nbtRoot.getTag("tankContents"));
    	tank.setFluid(fl);
  	} else {
  	tank.setFluid(null);
  	}
	}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:14,代码来源:TileEntityFluidManager.java

示例4: readFromStack

import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
public void readFromStack(ItemStack stack){
	NBTTagCompound nbt = ItemNBTHelper.getCompound(stack);
	tank = new FluidTank(capacities[nbt.getInteger("Type") % capacities.length]);
	oMode = OutputMode.values()[nbt.getByte("OMode")];
	outputAmt = nbt.getInteger("OAmt");
	if(nbt.hasKey("tankContents")) {
		FluidStack fl = FluidStack.loadFluidStackFromNBT((NBTTagCompound) nbt.getTag("tankContents"));
  		tank.setFluid(fl);
	} else {
		tank.setFluid(null);
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:13,代码来源:TileEntityFluidManager.java

示例5: injectValue

import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
@Override
protected void injectValue(Field field, Object te, FluidStack value) throws Exception {
    FluidTank tank = (FluidTank) field.get(te);
    tank.setFluid(value);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:6,代码来源:SyncedField.java

示例6: TileEntityTreeTap

import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
public TileEntityTreeTap() {
	tank = new FluidTank(1);
	tank.setFluid(RESIN);
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:5,代码来源:TileEntityTreeTap.java

示例7: 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;
			}
		}
	}
}
 
开发者ID:MikeLydeamore,项目名称:ExNihiloAdscensio,代码行数:70,代码来源:BarrelModeFluid.java

示例8: update

import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
@Override
public void update(TileBarrel barrel) {
	if (transformer == null) {
		transformer = FluidTransformRegistry.getFluidTransformer(inputStack
				.getFluid().getName(), outputStack.getFluid().getName());
	}
	if (transformer == null)
		return;
	if (progress < 1) {
		int numberOfBlocks = Util.getNumSurroundingBlocksAtLeastOneOf(
				transformer.getTransformingBlocks(),
				barrel.getPos().add(0, -1, 0), barrel.getWorld())
				+ Util.getNumSurroundingBlocksAtLeastOneOf(
						transformer.getTransformingBlocks(),
						barrel.getPos(), barrel.getWorld());
		if (numberOfBlocks > 0) {
			progress += numberOfBlocks * 1.0 / transformer.getDuration();

			if (barrel.getWorld().rand.nextDouble() < 0.005) {
				boolean spawned = false;
				ArrayList<BlockInfo> blockList = new ArrayList<BlockInfo>(
						Arrays.asList(transformer.getTransformingBlocks()));
				for (int xShift = -1; xShift <= 1; xShift++) {
					for (int zShift = -1; zShift <= 1; zShift++) {
						if (!spawned) {
							BlockPos testPos = barrel.getPos().add(xShift,
									-1, zShift);
							if (blockList.contains(new BlockInfo(barrel
									.getWorld().getBlockState(testPos)))
									&& barrel.getWorld().isAirBlock(
											testPos.add(0, 1, 0))) {
								BlockInfo[] toSpawn = transformer
										.getBlocksToSpawn();
								if (toSpawn != null && toSpawn.length > 0) {
									barrel.getWorld()
											.setBlockState(
													testPos.add(0, 1, 0),
													toSpawn[barrel
															.getWorld().rand
															.nextInt(toSpawn.length)]
															.getBlockState());
									spawned = true;
								}
							}
						}
					}
				}
			}
		}
		PacketHandler.sendNBTUpdate(barrel);
	}

	if (progress >= 1) {
		barrel.setMode("fluid");
		FluidTank tank = barrel.getMode().getFluidHandler(barrel);
		Fluid fluid = FluidRegistry.getFluid(transformer.getOutputFluid());
		tank.setFluid(new FluidStack(fluid, 1000));
		PacketHandler.sendNBTUpdate(barrel);
	}
}
 
开发者ID:MikeLydeamore,项目名称:ExNihiloAdscensio,代码行数:61,代码来源:BarrelModeFluidTransform.java

示例9: injectValue

import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
@Override
protected void injectValue(Field field, Object te, FluidStack value) throws Exception{

    FluidTank tank = (FluidTank)field.get(te);
    tank.setFluid(value);
}
 
开发者ID:MineMaarten,项目名称:Signals,代码行数:7,代码来源:SyncedField.java

示例10: readTank

import net.minecraftforge.fluids.FluidTank; //导入方法依赖的package包/类
public static void readTank(NBTTagCompound tag, FluidTank tank, String name) {
    NBTTagCompound liquid_tag = tag.getCompoundTag(name);
    FluidStack ls = FluidStack.loadFluidStackFromNBT(liquid_tag);
    tank.setFluid(ls);
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:6,代码来源:DataUtil.java


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