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


Java FluidRegistry.WATER屬性代碼示例

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


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

示例1: test_extractFluidsFromTanks

@Test
public void test_extractFluidsFromTanks()
{
    FluidTank tank1 = new FluidTank(FluidRegistry.WATER, 1000, 10000);
    FluidTank tank2 = new FluidTank(FluidRegistry.LAVA, 1000, 10000);

    ItemHelper.extractFluidsFromTanks(Lists.newArrayList(tank1, tank2),
                                      Lists.newArrayList(FluidRegistry.getFluidStack("water", 400),
                                                         FluidRegistry.getFluidStack("lava", 300)));

    assertEquals(600, tank1.getFluidAmount());
    assertEquals(700, tank2.getFluidAmount());

    ItemHelper.extractFluidsFromTanks(Lists.newArrayList(tank1, tank2),
                                      Lists.newArrayList(FluidRegistry.getFluidStack("lava", 400),
                                                         FluidRegistry.getFluidStack("water", 300)));

    assertEquals(300, tank1.getFluidAmount());
    assertEquals(300, tank2.getFluidAmount());
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:20,代碼來源:ItemHelperTests.java

示例2: apply

/** 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;
}
 
開發者ID:elytra,項目名稱:Thermionics,代碼行數:25,代碼來源:MashTunRecipe.java

示例3: getFluid

@Nullable
public FluidStack getFluid()
{
    Item item = container.getItem();
    if (item == Items.WATER_BUCKET)
    {
        return new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME);
    }
    else if (item == Items.LAVA_BUCKET)
    {
        return new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME);
    }
    else if (item == Items.MILK_BUCKET)
    {
        return FluidRegistry.getFluidStack("milk", Fluid.BUCKET_VOLUME);
    }
    else if (item == ForgeModContainer.getInstance().universalBucket)
    {
        return ForgeModContainer.getInstance().universalBucket.getFluid(container);
    }
    else
    {
        return null;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:25,代碼來源:FluidBucketWrapper.java

示例4: setFluid

protected void setFluid(Fluid fluid) {
    if (fluid == null)
    {
        container.deserializeNBT(new ItemStack(Items.BUCKET).serializeNBT());
    }
    else if (fluid == FluidRegistry.WATER)
    {
        container.deserializeNBT(new ItemStack(Items.WATER_BUCKET).serializeNBT());
    }
    else if (fluid == FluidRegistry.LAVA)
    {
        container.deserializeNBT(new ItemStack(Items.LAVA_BUCKET).serializeNBT());
    }
    else if (fluid.getName().equals("milk"))
    {
        container.deserializeNBT(new ItemStack(Items.MILK_BUCKET).serializeNBT());
    }
    else if (FluidRegistry.isUniversalBucketEnabled() && FluidRegistry.getBucketFluids().contains(fluid))
    {
        ItemStack filledBucket = UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, fluid);
        container.deserializeNBT(filledBucket.serializeNBT());
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:FluidBucketWrapper.java

示例5: getStack

@Nullable
private FluidStack getStack(IBlockState blockState)
{
    Material material = blockState.getMaterial();
    if (material == Material.WATER && blockState.getValue(BlockLiquid.LEVEL) == 0)
    {
        return new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME);
    }
    else if (material == Material.LAVA && blockState.getValue(BlockLiquid.LEVEL) == 0)
    {
        return new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME);
    }
    else
    {
        return null;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:BlockLiquidWrapper.java

示例6: update

@Override
public void update()
{
	if (world.isRemote)
		return;

	if (Config.shouldBarrelsFillWithRain && (mode == null || mode.getName() == "fluid")) {
		BlockPos plusY = new BlockPos(pos.getX(), pos.getY()+1, pos.getZ());
		if(world.isRainingAt(plusY)) {
			FluidStack stack = new FluidStack(FluidRegistry.WATER, 2);
			tank.fill(stack, true);
		}
	}
	if (mode != null)
		mode.update(this);
       
	if(getBlockType().getLightValue(world.getBlockState(pos), world, pos) != world.getLight(pos))
       {
           world.checkLight(pos);
           PacketHandler.sendToAllAround(new MessageCheckLight(pos), this);
       }
}
 
開發者ID:MikeLydeamore,項目名稱:ExNihiloAdscensio,代碼行數:22,代碼來源:TileBarrel.java

示例7: checkEvaporation

private void checkEvaporation() {
    float angle = getWorld().getCelestialAngle(1.0f);
    int minutes = (int) (angle * ((24 * 60) - 0.1f));
    int hours = minutes / 60;
    if (hours >= 21 || hours <= 3) {
        if (getWorld().canBlockSeeSky(getPos())) {
            Tank tank = getMultiBlock();
            if (tank.getFluid() == FluidSetup.freshWater || tank.getFluid() == FluidRegistry.WATER) {
                int newContents = tank.getContents() - GeneralConfiguration.tankEvaporation;
                if (newContents < 0) {
                    newContents = 0;
                }
                tank.setContents(newContents);
                ImmersiveCraftHandler.tankNetwork.save(getWorld());
            }
        }
    }
}
 
開發者ID:McJty,項目名稱:AquaMunda,代碼行數:18,代碼來源:TankTE.java

示例8: checkRain

private void checkRain() {
    if (getWorld().canBlockSeeSky(getPos())) {
        Tank tank = getMultiBlock();
        if (tank.getFluid() == null) {
            tank.setFluid(FluidSetup.freshWater);
        }
        if (tank.getFluid() == FluidSetup.freshWater || tank.getFluid() == FluidRegistry.WATER) {
            int newContents = tank.getContents() + GeneralConfiguration.tankCatchesRain;
            if (newContents > tank.getMaxContents()) {
                newContents = tank.getMaxContents();
            }
            tank.setContents(newContents);
            ImmersiveCraftHandler.tankNetwork.save(getWorld());
        }
    }
}
 
開發者ID:McJty,項目名稱:AquaMunda,代碼行數:16,代碼來源:TankTE.java

示例9: getFluid

public Fluid getFluid() {
    Fluid fluid = FluidRegistry.lookupFluidForBlock(getBlockState().getBlock());
    if (fluid != null) return fluid;
    else if (getBlockState().getBlock() == Blocks.FLOWING_LAVA) return FluidRegistry.LAVA;
    else if (getBlockState().getBlock() == Blocks.FLOWING_WATER) return FluidRegistry.WATER;
    return null;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:7,代碼來源:HeatBehaviourLiquid.java

示例10: onLiquidChange

@SuppressWarnings("ConstantConditions")
@Override
public void onLiquidChange() {
	ingredients.clear();
	mode = Mode.NORMAL;
	ritual = null;
	Fluid fluid = inv.getInnerFluid();
	if (fluid != null) {
		int color = (fluid == FluidRegistry.WATER || fluid.getColor() == 0xFFFFFFFF) ? 0x12193b : fluid.getColor();
		setColorRGB(color);
	}
	if (!world.isRemote)
		PacketHandler.updateToNearbyPlayers(world, pos);
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:14,代碼來源:TileCauldron.java

示例11: onItemRightClick

@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn, EnumHand hand) {
	init(stack);
	if (getFluidStored(stack) >= FLUID_CAPACITY) {
		return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
	}
	RayTraceResult ray = rayTrace(worldIn, playerIn, true);
	if (ray == null || ray.typeOfHit == null || hand == null) {
		return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
	}
	if (ray.typeOfHit == RayTraceResult.Type.BLOCK && hand == EnumHand.MAIN_HAND && !worldIn.isRemote) {
		BlockPos blockpos = ray.getBlockPos();
		IBlockState iblockstate = worldIn.getBlockState(blockpos);
		Material material = iblockstate.getMaterial();

		if (material == Material.WATER && iblockstate.getValue(BlockLiquid.LEVEL).intValue() == 0) {
			worldIn.setBlockState(blockpos, Blocks.AIR.getDefaultState(), 11);
			playerIn.addStat(StatList.getObjectUseStats(this));
			playerIn.playSound(SoundEvents.ITEM_BUCKET_FILL, 1.0F, 1.0F);
			addFluid(stack, 1000);
			return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
		}
		else if (iblockstate.getBlock().hasTileEntity(iblockstate) && worldIn.getTileEntity(blockpos).hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, ray.sideHit)) {
			IFluidHandler fluidHandler = worldIn.getTileEntity(blockpos).getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, ray.sideHit);
			for (IFluidTankProperties property : fluidHandler.getTankProperties()) {
				if (property.getContents().getFluid() == FluidRegistry.WATER && property.getContents().amount >= 1000 && property.canDrain()) {
					fluidHandler.drain(new FluidStack(FluidRegistry.WATER, 1000), true);
					addFluid(stack, 1000);
				}
			}
		}

	}
	return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
}
 
開發者ID:p455w0rd,項目名稱:ToughExpansion,代碼行數:35,代碼來源:ItemThirstQuencher.java

示例12: canFillFluidType

public boolean canFillFluidType(FluidStack fluid)
{
    if (fluid.getFluid() == FluidRegistry.WATER || fluid.getFluid() == FluidRegistry.LAVA || fluid.getFluid().getName().equals("milk"))
    {
        return true;
    }
    return FluidRegistry.isUniversalBucketEnabled() && FluidRegistry.getBucketFluids().contains(fluid.getFluid());
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:8,代碼來源:FluidBucketWrapper.java

示例13: BlockAqueductWater

protected BlockAqueductWater() {
    super(FluidRegistry.WATER,Material.WATER);

    String name = "aqueduct_water";

    this.setUnlocalizedName(name);
    this.setRegistryName(new ResourceLocation(Reference.MOD_ID, name));
    this.setCreativeTab(BetterWithAddons.instance.creativeTab);
    this.setTickRandomly(true);
    this.setDefaultState(this.blockState.getBaseState().withProperty(LEVEL, 0));
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:11,代碼來源:BlockAqueductWater.java

示例14: update

@Override
public void update() {
	super.update();

	if(getWorld().isRemote) {
		return;
	}

	if(!isValid()) {
		return;
	}

	FluidStack fluidStack = getTankConfig().getFluidStack();
	if(fluidStack == null) {
		return;
	}

	Fluid fluid = fluidStack.getFluid();
	if(fluid == null) {
		return;
	}

	if(fluid == FluidRegistry.WATER) {
		if(getWorld().isRaining()) {
			int rate = (int) Math.floor(getWorld().rainingStrength * 5 * getWorld().getBiomeForCoordsBody(getPos()).getRainfall());
			if(getPos().getY() == getWorld().getPrecipitationHeight(getPos()).getY() - 1) {
				FluidStack waterStack = fluidStack.copy();
				waterStack.amount = rate * 10;
				getTankConfig().getFluidTank().fill(waterStack, true);
			}
		}
	}
}
 
開發者ID:Lordmau5,項目名稱:FFS,代碼行數:33,代碼來源:TileEntityFluidValve.java

示例15: canFillFluidType

public boolean canFillFluidType(FluidStack fluid)
{
    if (fluid.getFluid() == FluidRegistry.WATER)
    {
        return true;
    }
 
    return false;
}
 
開發者ID:Modding-Legacy,項目名稱:Aether-Legacy,代碼行數:9,代碼來源:FluidSkyrootBucketWrapper.java


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