當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。