本文整理汇总了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());
}
示例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;
}
示例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;
}
}
示例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());
}
}
示例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;
}
}
示例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);
}
}
示例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());
}
}
}
}
示例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());
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
示例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));
}
示例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);
}
}
}
}
示例15: canFillFluidType
public boolean canFillFluidType(FluidStack fluid)
{
if (fluid.getFluid() == FluidRegistry.WATER)
{
return true;
}
return false;
}