Java Code Examples for net.minecraftforge.fluids.FluidRegistry#WATER

The following examples show how to use net.minecraftforge.fluids.FluidRegistry#WATER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BRLoader.java    From BigReactors with MIT License 6 votes vote down vote up
@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	BigReactors.registerOres(0, true);
	BigReactors.registerIngots(0);
	BigReactors.registerFuelRods(0, true);
	BigReactors.registerReactorPartBlocks(0, true);
	BigReactors.registerTurbineParts();
	BigReactors.registerDevices(0,  true);
	BigReactors.registerFluids(0,  true);
	BigReactors.registerCreativeParts(0, true);
	BigReactors.registerItems();

	StandardReactants.register();
	
	BigReactors.eventHandler = new BREventHandler();
	MinecraftForge.EVENT_BUS.register(BigReactors.eventHandler);
	MinecraftForge.EVENT_BUS.register(proxy);
	
	multiblockEventHandler = new MultiblockEventHandler();
	MinecraftForge.EVENT_BUS.register(multiblockEventHandler);
	
	proxy.preInit();
	
	Fluid waterFluid = FluidRegistry.WATER; // Force-load water to prevent startup crashes
}
 
Example 2
Source File: ItemHelperTests.java    From customstuff4 with GNU General Public License v3.0 6 votes vote down vote up
@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());
}
 
Example 3
Source File: TileBarrel.java    From ExNihiloAdscensio with MIT License 6 votes vote down vote up
@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);
       }
}
 
Example 4
Source File: RecipeHandlerCyaniteReprocessor.java    From NEI-Integration with MIT License 5 votes vote down vote up
public CachedCyaniteReprocessorRecipe(ItemStack input, ItemStack output) {
    input = input.copy();
    input.stackSize = 2;
    this.input = new PositionedStack(input, 36, 25);
    this.output = new PositionedStack(output, 108, 25);
    this.water = new PositionedFluidTank(new FluidStack(FluidRegistry.WATER, 1000), 5000, new Rectangle(1, 1, 16, 62), "neiintegration:textures/overlays.png", new Point(18, 97));
}
 
Example 5
Source File: HeatBehaviourLiquid.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public Fluid getFluid(){
    Fluid fluid = FluidRegistry.lookupFluidForBlock(getBlock());
    if(fluid != null) return fluid;
    else if(getBlock() == Blocks.flowing_lava) return FluidRegistry.LAVA;
    else if(getBlock() == Blocks.flowing_water) return FluidRegistry.WATER;
    return null;
}
 
Example 6
Source File: RenderUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * @param stack The fluid stack to render
 * @return The icon of the fluid
 */
public static TextureAtlasSprite prepareFluidRender(FluidStack stack, int alpha) {
    GlStateManager.disableLighting();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    Fluid fluid = stack.getFluid();
    CCRenderState.setColour(fluid.getColor(stack) << 8 | alpha);
    CCRenderState.changeTexture(TextureMap.locationBlocksTexture);

    String iconName = null;
    if (fluid == FluidRegistry.LAVA) iconName = "minecraft:blocks/lava_still";
    else if (fluid == FluidRegistry.WATER) iconName = "minecraft:blocks/water_still";
    return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(iconName);
}
 
Example 7
Source File: TileEntityTank.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
public FluidStack drain(int amount, boolean doDrain) {
    // Validate input.
    if (amount < 0) {
        // Apparently this can happen, if the IFluidHandler interface is abused.
        AgriCore.getLogger("agricraft").error("Cannot drain a negative amount ({0} mB) from a fluid component!", amount);
        
        // Do nothing and return an empty fluid stack.
        return new FluidStack(FluidRegistry.WATER, 0);
    }
    
    // The amount consumed.
    final int drainedAmount;

    // Determine amount consumed.
    if (this.getFluidAmount() > amount) {
        drainedAmount = amount;
    } else {
        drainedAmount = this.getFluidAmount();
    }

    // If the remainder doesn't equal input, and we are not simulating, then we need to update.
    if (doDrain && drainedAmount > 0) {
        // Update the fluid amount.
        this.setFluidAmount(this.getFluidAmount() - drainedAmount);
        // Mark the component as dirty as it changed.
        this.world.markChunkDirty(pos, this);
    }

    // Return a new fluid stack with consumed amount.
    return new FluidStack(FluidRegistry.WATER, drainedAmount);
}
 
Example 8
Source File: TileEntityTank.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
public FluidStack drain(FluidStack fs, boolean doDrain) {
    if (fs.getFluid() == FluidRegistry.WATER) {
        return drain(fs.amount, doDrain);
    } else {
        return new FluidStack(fs.getFluid(), 0);
    }
}
 
Example 9
Source File: TileEntitySprinkler.java    From AgriCraft with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
private void spawnLiquidSpray(double xOffset, double zOffset, Vec3d vector) {
    final double sx = this.xCoord() + 0.5f + xOffset;
    final double sy = this.yCoord() + 8 * Constants.UNIT;
    final double sz = this.zCoord() + 0.5f + zOffset;
    final LiquidSprayFX spray = new LiquidSprayFX(this.getWorld(), FluidRegistry.WATER, sx, sy, sz, 0.3F, 0.7F, vector);
    Minecraft.getMinecraft().effectRenderer.addEffect(spray);
}
 
Example 10
Source File: BlockWaterPad.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
public FluidStack drain(World world, BlockPos pos, IBlockState state, int amount, boolean doDrain) {
    if ((AgriProperties.POWERED.getValue(state)) && (amount >= 1000)) {
        if (doDrain) {
            world.setBlockState(pos, AgriProperties.POWERED.applyToBlockState(state, false));
        }
        return new FluidStack(FluidRegistry.WATER, 1000);
    } else {
        return null;
    }
}
 
Example 11
Source File: BlockWaterPad.java    From AgriCraft with MIT License 5 votes vote down vote up
@Override
public FluidStack drain(World world, BlockPos pos, IBlockState state, FluidStack fluid, boolean doDrain) {
    if ((AgriProperties.POWERED.getValue(state)) && (fluid != null) && (fluid.amount >= 1000) && (fluid.getFluid().equals(FluidRegistry.WATER))) {
        if (doDrain) {
            world.setBlockState(pos, AgriProperties.POWERED.applyToBlockState(state, false));
        }
        return new FluidStack(FluidRegistry.WATER, 1000);
    } else {
        return null;
    }
}
 
Example 12
Source File: TileRollingMachine.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void registerRecipes() {
	FluidStack water = new FluidStack(FluidRegistry.WATER, 100);
	//Tanks
       RecipesMachine.getInstance().addRecipe(TileRollingMachine.class, new ItemStack(AdvancedRocketryItems.itemPressureTank, 1, 0), 100, 1, "sheetIron", "sheetIron", water);
       RecipesMachine.getInstance().addRecipe(TileRollingMachine.class, new ItemStack(AdvancedRocketryItems.itemPressureTank, 1, 1), 200, 2, "sheetSteel", "sheetSteel", water);
       RecipesMachine.getInstance().addRecipe(TileRollingMachine.class, new ItemStack(AdvancedRocketryItems.itemPressureTank, 1, 2), 100, 1, "sheetAluminum", "sheetAluminum", water);
       RecipesMachine.getInstance().addRecipe(TileRollingMachine.class, new ItemStack(AdvancedRocketryItems.itemPressureTank, 1, 3), 1000, 8, "sheetTitanium", "sheetTitanium", water);
}
 
Example 13
Source File: RenderUtil.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static int getFluidColor(FluidStack fluidStack) {
    if (fluidStack.getFluid() == FluidRegistry.WATER)
        return 0x3094CF;
    else if (fluidStack.getFluid() == FluidRegistry.LAVA)
        return 0xFFD700;
    return fluidStack.getFluid().getColor(fluidStack);
}
 
Example 14
Source File: RecipeHandlerCyaniteReprocessor.java    From NEI-Integration with MIT License 4 votes vote down vote up
@Override
public void loadUsageRecipes(FluidStack ingredient) {
    if (ingredient.getFluid() == FluidRegistry.WATER) {
        this.loadAllRecipes();
    }
}
 
Example 15
Source File: RecipeHandlerMoistener.java    From NEI-Integration with MIT License 4 votes vote down vote up
@Override
public void loadUsageRecipes(FluidStack ingredient) {
    if (ingredient.getFluid() == FluidRegistry.WATER) {
        this.loadAllRecipes();
    }
}
 
Example 16
Source File: SakuraRecipeRegister.java    From Sakura_mod with MIT License 4 votes vote down vote up
private static FluidStack getWater(int amount){
  	if(Loader.isModLoaded("tfc"))
  		return new FluidStack(FluidsTFC.FRESH_WATER.get(), amount);
return new FluidStack(FluidRegistry.WATER, amount);
  }
 
Example 17
Source File: BarrelModeFluid.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
@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;
			}
		}
	}
}
 
Example 18
Source File: ModHandler.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Returns a Liquid Stack with given amount of Water.
 */
public static FluidStack getWater(int amount) {
    return new FluidStack(FluidRegistry.WATER, amount);
}
 
Example 19
Source File: Hydroponic.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
        EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {

    if (worldIn.isRemote) {
        return true;
    }

    HydroponicTileEntity tileEntity = (HydroponicTileEntity) worldIn.getTileEntity(pos);
    ItemStack itemStackHeld = playerIn.getHeldItemMainhand();
    Item itemHeld = itemStackHeld.getItem();

    if (itemHeld == Items.WATER_BUCKET || itemHeld == Items.LAVA_BUCKET) {

        Fluid fluid = itemHeld == Items.WATER_BUCKET ? FluidRegistry.WATER : FluidRegistry.LAVA;

        int waterFilled = tileEntity.fluidHandler.fill(new FluidStack(fluid, 1000), true);
        
        if (waterFilled > 0 && !playerIn.isCreative()) {
            playerIn.setHeldItem(EnumHand.MAIN_HAND, new ItemStack(Items.BUCKET));
        }

    } else if (itemHeld instanceof UniversalBucket) {

        UniversalBucket bucket = (UniversalBucket) itemHeld;
        FluidStack fluidStack = bucket.getFluid(itemStackHeld);

        if (tileEntity.fluidHandler.canFillFluidType(fluidStack)) {
            tileEntity.fluidHandler.fill(fluidStack, true);
            playerIn.setHeldItem(EnumHand.MAIN_HAND, bucket.getEmpty());
        }

    } else if (HydroponicHelper.isItemStackValid(itemStackHeld) && tileEntity.itemHandler.getStackInSlot(0).isEmpty()) {

        ItemStack remainder = tileEntity.itemHandler.insertItem(0, itemStackHeld.copy(), false);

        if (!playerIn.isCreative()) {
            playerIn.setHeldItem(EnumHand.MAIN_HAND, remainder);
        }

        return true;

    } else if (PlantHelper.isPlantItem(itemHeld) && facing == EnumFacing.UP) {

        return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);

        // Otherwise open the gui
    } else {
        playerIn.openGui(EmergingTechnology.instance, Reference.GUI_HYDROPONIC, worldIn, pos.getX(), pos.getY(),
                pos.getZ());
        return true;
    }

    return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
 
Example 20
Source File: FluidStorageHandler.java    From EmergingTechnology with MIT License 4 votes vote down vote up
@Override
public boolean canFillFluidType(FluidStack fluid) {

    return fluid.getFluid() == FluidRegistry.WATER;
}