net.minecraftforge.fluids.Fluid Java Examples
The following examples show how to use
net.minecraftforge.fluids.Fluid.
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: CommonProxy.java From Moo-Fluids with GNU General Public License v3.0 | 6 votes |
@Override public void initContainableFluids() { if (FluidRegistry.isUniversalBucketEnabled()) { if (FluidRegistry.getBucketFluids().size() > 0) { for (final Fluid fluid : FluidRegistry.getBucketFluids()) { final String fluidName = fluid.getName(); if (!EntityHelper.hasContainableFluid(fluidName)) { EntityHelper.setContainableFluid(fluidName, fluid); if (ModInformation.DEBUG_MODE) { LogHelper.info(String.format(fluidName, "%s has been added as an containable (i.e. bucketable) fluid")); } } } } else { LogHelper.error("No registered fluids found"); } } else { throw new UnsupportedOperationException("Forge UniversalBucket must be enabled"); } }
Example #2
Source File: EnderIO.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void postInit(){ Fluid hootch = FluidRegistry.getFluid("hootch"); Fluid rocketFuel = FluidRegistry.getFluid("rocket_fuel"); Fluid fireWater = FluidRegistry.getFluid("fire_water"); if(hootch != null) { PneumaticRegistry.getInstance().registerFuel(hootch, 60 * 6000); } else { Log.warning("Couldn't find a fluid with name 'hootch' even though EnderIO is in the instance. It hasn't been registered as fuel!"); } if(rocketFuel != null) { PneumaticRegistry.getInstance().registerFuel(rocketFuel, 160 * 7000); } else { Log.warning("Couldn't find a fluid with name 'rocket_fuel' even though EnderIO is in the instance. It hasn't been registered as fuel!"); } if(fireWater != null) { PneumaticRegistry.getInstance().registerFuel(fireWater, 80 * 15000); } else { Log.warning("Couldn't find a fluid with name 'fire_water' even though EnderIO is in the instance. It hasn't been registered as fuel!"); } }
Example #3
Source File: MultiblockTurbineSimulator.java From reactor_simulator with MIT License | 6 votes |
public boolean canFill(int tank, Fluid fluid) { if (tank < 0 || tank >= NUM_TANKS) { return false; } FluidStack fluidStack = tanks[tank].getFluid(); if (fluidStack != null) { return fluidStack.getFluid().getID() == fluid.getID(); } else if (tank == TANK_INPUT) { // TODO: Input tank can only be filled with compatible fluids from a registry return fluid.getName().equals("steam"); } else { // Output tank can be filled with anything. Don't be a dumb. return true; } }
Example #4
Source File: TileEntityEnderFurnace.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
/** * Uses one dose (1000 mB) of fluid fuel, returns the amount of burn time that was gained from it. * @param stack * @return burn time gained, in ticks */ private static int consumeFluidFuelDosage(ItemStack stack) { if (itemContainsFluidFuel(stack) == false) { return 0; } // All the null checks happened already in itemContainsFluidFuel() IFluidHandler handler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null); // Consume max 1000 mB per use. FluidStack fluidStack = handler.drain(new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME), true); //System.out.printf("consumeFluidFuelDosageFluidCapability: %s - %d\n", (fluidStack != null ? fluidStack.getFluid().getName() : "null"), fluidStack != null ? fluidStack.amount : 0); // 1.5 times vanilla lava fuel value (150 items per bucket) return fluidStack != null ? (fluidStack.amount * 15 * COOKTIME_DEFAULT / 100) : 0; }
Example #5
Source File: TileEntityEnderFurnace.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
/** * Checks if the given ItemStack contains a valid fluid fuel source for the furnace. * Valid fuels are currently just lava. * @param stack * @return */ private static boolean itemContainsFluidFuel(ItemStack stack) { if (stack.isEmpty() || stack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null) == false) { return false; } IFluidHandler handler = stack.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null); if (handler == null) { return false; } FluidStack fluidStack = handler.drain(Fluid.BUCKET_VOLUME, false); //System.out.printf("itemContainsFluidFuelFluidCapability: %s - %d\n", (fluidStack != null ? fluidStack.getFluid().getName() : "null"), fluidStack != null ? fluidStack.amount : 0); if (fluidStack == null || fluidStack.amount <= 0) { return false; } return fluidStack.getFluid() == FluidRegistry.LAVA; }
Example #6
Source File: RecipeHandlerFluidRegistry.java From NEI-Integration with MIT License | 6 votes |
public List<Fluid> getFluids() { List<Fluid> fluids = new LinkedList<Fluid>(); for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) { if (fluid != null) { fluids.add(fluid); } } Collections.sort(fluids, new Comparator<Fluid>() { @Override public int compare(Fluid f1, Fluid f2) { if (f1 == null || f2 == null) { return 0; } return Integer.compare(f1.getID(), f2.getID()); } }); return fluids; }
Example #7
Source File: MultiblockTurbine.java From BigReactors with MIT License | 6 votes |
public boolean canFill(int tank, Fluid fluid) { if(tank < 0 || tank >= NUM_TANKS) { return false; } FluidStack fluidStack = tanks[tank].getFluid(); if(fluidStack != null) { return fluidStack.getFluid().getID() == fluid.getID(); } else if(tank == TANK_INPUT) { // TODO: Input tank can only be filled with compatible fluids from a registry return fluid.getName().equals("steam"); } else { // Output tank can be filled with anything. Don't be a dumb. return true; } }
Example #8
Source File: SplitFluidStorageHandler.java From EmergingTechnology with MIT License | 6 votes |
@Override public int fill(FluidStack resource, boolean doFill) { Fluid fluid = resource.getFluid(); if (fluid == null) return 0; for (String fluidName : fluidNames) { if (fluid.getName().equalsIgnoreCase(fluidName)) { return fluidTank.fill(resource, doFill); } } for (String gasName : gasNames) { if (fluid.getName().equalsIgnoreCase(gasName)) { return gasTank.fill(resource, doFill); } } return 0; }
Example #9
Source File: BlockBTank.java From BetterChests with GNU Lesser General Public License v3.0 | 6 votes |
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack original = player.getHeldItem(hand); if (!original.isEmpty()) { ItemStack stack = original.copy(); stack.setCount(1); TileEntity tank = getTileEntity(world, pos); if (tank instanceof TileEntityBTank) { IFluidHandler handler = ((TileEntityBTank) tank).getFluidHandler(); FluidActionResult result = FluidUtil.tryEmptyContainer(stack, handler, Fluid.BUCKET_VOLUME, player, true); if (!result.success) { result = FluidUtil.tryFillContainer(stack, handler, Fluid.BUCKET_VOLUME, player, true); } if (result.success) { original.setCount(original.getCount() - 1); stack = InvUtil.putStackInInventory(result.result, player.inventory, true, false, false, null); if (!stack.isEmpty()) { WorldUtil.dropItemsRandom(world, stack, player.getPosition()); } return true; } } } return super.onBlockActivated(world, pos, state, player, hand, facing, hitX, hitY, hitZ); }
Example #10
Source File: FluidDumper.java From NEI-Integration with MIT License | 6 votes |
@Override public Iterable<String[]> dump(int mode) { List<String[]> list = new LinkedList<String[]>(); List<Fluid> fluids = new ArrayList<Fluid>(); fluids.addAll(FluidRegistry.getRegisteredFluids().values()); Collections.sort(fluids, new Comparator<Fluid>() { @Override public int compare(Fluid f1, Fluid f2) { return Integer.compare(f1.getID(), f2.getID()); } }); for (Fluid f : fluids) { list.add(new String[] { String.valueOf(f.getID()), f.getName(), f.getLocalizedName(new FluidStack(f, 1000)), String.valueOf(f.getTemperature()), String.valueOf(f.getLuminosity()), String.valueOf(f.getDensity()), String.valueOf(f.getViscosity()), String.valueOf(f.canBePlacedInWorld()), f.getBlock() != null ? Block.blockRegistry.getNameForObject(f.getBlock()) : null, f.getBlock() != null ? f.getBlock().getClass().getName() : null }); } return list; }
Example #11
Source File: Fluids.java From BaseMetals with GNU Lesser General Public License v2.1 | 6 votes |
@SideOnly(Side.CLIENT) public static void bakeModels(String modID){ for(Fluid fluid : fluidBlocks.keySet()){ BlockFluidBase block = fluidBlocks.get(fluid); Item item = Item.getItemFromBlock(block); final ModelResourceLocation fluidModelLocation = new ModelResourceLocation( modID.toLowerCase() + ":" + fluidBlockNames.get(block), "fluid"); ModelBakery.registerItemVariants(item); ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { public ModelResourceLocation getModelLocation(ItemStack stack) { return fluidModelLocation; } }); ModelLoader.setCustomStateMapper(block, new StateMapperBase() { protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return fluidModelLocation; } }); } }
Example #12
Source File: DimensionProperties.java From AdvancedRocketry with MIT License | 6 votes |
public DimensionProperties(int id) { name = "Temp"; resetProperties(); planetId = id; parentPlanet = -1; childPlanets = new HashSet<Integer>(); orbitalPhi = 0; ringColor = new float[] {.4f, .4f, .7f}; oceanBlock = null; fillerBlock = null; allowedBiomes = new LinkedList<BiomeManager.BiomeEntry>(); terraformedBiomes = new LinkedList<BiomeManager.BiomeEntry>(); satallites = new HashMap<>(); requiredArtifacts = new LinkedList<ItemStack>(); tickingSatallites = new HashMap<Long,SatelliteBase>(); isNativeDimension = true; isGasGiant = false; hasRings = false; customIcon = ""; harvestableAtmosphere = new LinkedList<Fluid>(); beaconLocations = new HashSet<HashedBlockPosition>(); sealevel = 63; generatorType = 0; }
Example #13
Source File: FluidFuelManager.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static void registerFuels(){ for(Fluid fluid : FluidRegistry.getRegisteredFluids().values()) { if(fluid.getTemperature() > 305) { PneumaticRegistry.getInstance().registerFuel(fluid, (fluid.getTemperature() - 295) * 40); } } }
Example #14
Source File: HydroponicTileEntity.java From EmergingTechnology with MIT License | 5 votes |
public Fluid getFluid() { if (this.fluidHandler.getFluid() != null) { return this.fluidHandler.getFluid().getFluid(); } else { return null; } }
Example #15
Source File: DroneAILiquidImport.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
private boolean emptyTank(ChunkPosition pos, boolean simulate){ if(drone.getTank().getFluidAmount() == drone.getTank().getCapacity()) { drone.addDebugEntry("gui.progWidget.liquidImport.debug.fullDroneTank"); abort(); return false; } else { TileEntity te = drone.getWorld().getTileEntity(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ); if(te instanceof IFluidHandler) { IFluidHandler tank = (IFluidHandler)te; for(int i = 0; i < 6; i++) { if(((ISidedWidget)widget).getSides()[i]) { FluidStack importedFluid = tank.drain(ForgeDirection.getOrientation(i), Integer.MAX_VALUE, false); if(importedFluid != null && ((ILiquidFiltered)widget).isFluidValid(importedFluid.getFluid())) { int filledAmount = drone.getTank().fill(importedFluid, false); if(filledAmount > 0) { if(((ICountWidget)widget).useCount()) filledAmount = Math.min(filledAmount, getRemainingCount()); if(!simulate) { decreaseCount(drone.getTank().fill(tank.drain(ForgeDirection.getOrientation(i), filledAmount, true), true)); } return true; } } } } drone.addDebugEntry("gui.progWidget.liquidImport.debug.emptiedToMax", pos); } else if(!((ICountWidget)widget).useCount() || getRemainingCount() >= 1000) { Fluid fluid = FluidRegistry.lookupFluidForBlock(drone.getWorld().getBlock(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)); if(fluid != null && ((ILiquidFiltered)widget).isFluidValid(fluid) && drone.getTank().fill(new FluidStack(fluid, 1000), false) == 1000 && FluidUtils.isSourceBlock(drone.getWorld(), pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ)) { if(!simulate) { decreaseCount(1000); drone.getTank().fill(new FluidStack(fluid, 1000), true); drone.getWorld().setBlockToAir(pos.chunkPosX, pos.chunkPosY, pos.chunkPosZ); } return true; } } return false; } }
Example #16
Source File: AlgaeBioreactorRecipes.java From EmergingTechnology with MIT License | 5 votes |
public static boolean isValidGas(Fluid fluid) { if (fluid == null) return false; for (String name : gasNames) { if (name.equalsIgnoreCase(fluid.getName())) { return true; } } return false; }
Example #17
Source File: TileEntityReactorFuelRod.java From BigReactors with MIT License | 5 votes |
private float getConductivityFromBlock(Block block, int metadata) { ReactorInteriorData interiorData = null; if(block == Blocks.iron_block) { interiorData = ReactorInterior.getBlockData("blockIron"); } else if(block == Blocks.gold_block) { interiorData = ReactorInterior.getBlockData("blockGold"); } else if(block == Blocks.diamond_block) { interiorData = ReactorInterior.getBlockData("blockDiamond"); } else if(block == Blocks.emerald_block) { interiorData = ReactorInterior.getBlockData("blockEmerald"); } else { interiorData = ReactorInterior.getBlockData(ItemHelper.oreProxy.getOreName(new ItemStack(block, 1, metadata))); if(interiorData == null && block instanceof IFluidBlock) { Fluid fluid = ((IFluidBlock)block).getFluid(); if(fluid != null) { interiorData = ReactorInterior.getFluidData(fluid.getName()); } } } if(interiorData == null) { interiorData = RadiationHelper.airData; } return interiorData.heatConductivity; }
Example #18
Source File: CoolantContainer.java From BigReactors with MIT License | 5 votes |
@Override protected boolean isFluidValidForStack(int stackIdx, Fluid fluid) { switch(stackIdx) { case COLD: return isAcceptedCoolant(fluid); case HOT: return true; default: return false; } }
Example #19
Source File: GT_TileEntity_DEHP.java From bartworks with MIT License | 5 votes |
private long getWaterFromHatches(boolean onlyDistilled) { Fluid toConsume1 = FluidRegistry.WATER; Fluid toConsume2 = GT_ModHandler.getDistilledWater(1L).getFluid(); if (onlyDistilled) toConsume1 = toConsume2; long ret = 0; for (GT_MetaTileEntity_Hatch_Input ih : this.mInputHatches) { if (ih.getFluid().getFluid().equals(toConsume1) || ih.getFluid().getFluid().equals(toConsume2)) ret += ih.getFluidAmount(); } return ret; }
Example #20
Source File: Reactants.java From BigReactors with MIT License | 5 votes |
/** * Register a fluid as a valid reactant for the reactor. * Currently unused. * This method enforces a 1:1 ratio for fluid mB to reactant mB. * @param fluid The input fluid to convert to reactant. * @param reactantName The name of the created reactant. */ public static void registerFluid(Fluid fluid, String reactantName) { if(!_reactants.containsKey(reactantName)) { throw new IllegalArgumentException("Unknown reactantName " + reactantName); } FluidToReactantMapping mapping = new FluidToReactantMapping(fluid, reactantName); SourceProductMapping reverseMapping = mapping.getReverse(); _fluidToReactant.put(mapping.getSource(), mapping); mapReactant(reverseMapping.getSource(), reverseMapping, _reactantToFluid); }
Example #21
Source File: GuiLiquidCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
private List<String> getAllFuels(){ List<String> fuels = new ArrayList<String>(); fuels.add("L/Bucket | Fluid"); for(Map.Entry<String, Integer> map : sortByValue(PneumaticCraftAPIHandler.getInstance().liquidFuels).entrySet()) { String value = map.getValue() / 1000 + ""; while(fontRendererObj.getStringWidth(value) < 25) { value = value + " "; } Fluid fluid = FluidRegistry.getFluid(map.getKey()); fuels.add(value + "| " + fluid.getLocalizedName(new FluidStack(fluid, 1))); } return fuels; }
Example #22
Source File: ProgWidgetLiquidFilter.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static boolean isLiquidValid(Fluid fluid, IProgWidget mainWidget, int filterIndex){ ProgWidgetLiquidFilter widget = (ProgWidgetLiquidFilter)mainWidget.getConnectedParameters()[mainWidget.getParameters().length + filterIndex]; while(widget != null) { if(!widget.isLiquidValid(fluid)) return false; widget = (ProgWidgetLiquidFilter)widget.getConnectedParameters()[0]; } widget = (ProgWidgetLiquidFilter)mainWidget.getConnectedParameters()[filterIndex]; if(widget == null) return true; while(widget != null) { if(widget.isLiquidValid(fluid)) return true; widget = (ProgWidgetLiquidFilter)widget.getConnectedParameters()[0]; } return false; }
Example #23
Source File: Fluids.java From BaseMetals with GNU Lesser General Public License v2.1 | 5 votes |
private static Fluid newFluid(String modID, String name, int density, int viscosity, int temperature, int luminosity, int tintColor) { Fluid f = new CustomFluid(name,new ResourceLocation(modID+":blocks/"+name+"_still"),new ResourceLocation(modID+":blocks/"+name+"_flow"),tintColor); f.setDensity(density); f.setViscosity(viscosity); f.setTemperature(temperature); f.setLuminosity(luminosity); f.setUnlocalizedName(modID+"."+name); FluidRegistry.registerFluid(f); return f; }
Example #24
Source File: ItemEnderBucket.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public EnumActionResult useBucketOnBlock(World world, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) { // Adjust the target block position to be the block touching the side of the block we targeted pos = pos.offset(side); if (this.isTargetUsable(world, pos, side, player, stack) == false) { return EnumActionResult.PASS; } // Check if there is a fluid block on the side of the targeted block if (world.getBlockState(pos).getMaterial().isLiquid()) { // Note: the side is technically wrong unless we ray trace it again, but it won't matter with fluid blocks... right? return this.useBucketOnFluidBlock(world, pos, side, player, stack); } // There was no fluid block where we are targeting // Get the stored fluid, if any FluidStack fluidStack = this.getFluid(stack, player); int storedFluidAmount = fluidStack != null ? fluidStack.amount : 0; // target block is not fluid, try to place a fluid block in world in the adjusted block position if (storedFluidAmount >= Fluid.BUCKET_VOLUME && BucketMode.fromStack(stack) != BucketMode.FILL) { fluidStack = this.drain(stack, Fluid.BUCKET_VOLUME, false, player); if (fluidStack != null && fluidStack.amount == Fluid.BUCKET_VOLUME && this.tryPlaceFluidBlock(world, pos, fluidStack)) { this.drain(stack, Fluid.BUCKET_VOLUME, true, player); return EnumActionResult.SUCCESS; } } return EnumActionResult.PASS; }
Example #25
Source File: FluidOnTopRegistry.java From ExNihiloAdscensio with MIT License | 5 votes |
public static boolean isValidRecipe(Fluid fluidInBarrel, Fluid fluidOnTop) { if (fluidInBarrel == null || fluidOnTop == null) return false; for (FluidFluidBlock fBlock : registry) { if (fBlock.getFluidInBarrel().equals(fluidInBarrel.getName()) && fBlock.getFluidOnTop().equals(fluidOnTop.getName())) return true; } return false; }
Example #26
Source File: ExtendedFluidCollection.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 5 votes |
private static void populateCompressedNitrogen() { Fluid tCompressedNitrogenFluid = ModFluidManager.GetNewFluid("CompressedNitrogen"); tCompressedNitrogenFluid.setGaseous(true); tCompressedNitrogenFluid.setViscosity(1); tCompressedNitrogenFluid.setDensity(1); tCompressedNitrogenFluid.setLuminosity(0); tCompressedNitrogenFluid.setTemperature(295); tCompressedNitrogenFluid.setRarity(EnumRarity.epic); // The rarity of the fluid. Used primarily in tool tips. _mCompressedNitrogen = new ModSimpleBaseFluid(tCompressedNitrogenFluid, Material.water); // Add potion effects to the fluid if player steps into a pool // Syntax is: new PotionEffect(<potionID>, <duration in ticks>, <level>) // Level 0: Potion Level I // Level 1: Potion Level II // ... // For the duration: Set it low to vanish the effect as soon as the player leaves the pool // If you set the duration to 200, the potion timer will start to tick for 10 seconds after // the player has left the pool. _mCompressedNitrogen.addPotionEffect(new PotionEffect(Potion.weakness.id, 20, 3)); // Same for stacking potion effects, except that you want to set the duration to the amount which will be // ADDED about each 0,5 seconds. So this poison-effect will increase as long as the player has contact with the // fluid block _mCompressedNitrogen.addStackingPotionEffect(new PotionEffect(Potion.weakness.id, 20, 3)); _mCompressedNitrogen.setRegisterBucket(false); // don't register a bucket }
Example #27
Source File: ProgWidgetCC.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
private ProgWidgetLiquidFilter getFilterForArgs(String fluidName) throws IllegalArgumentException{ Fluid fluid = FluidRegistry.getFluid(fluidName); if(fluid == null) throw new IllegalArgumentException("Can't find fluid for the name \"" + fluidName + "\"!"); ProgWidgetLiquidFilter filter = new ProgWidgetLiquidFilter(); filter.setFluid(fluid); return filter; }
Example #28
Source File: EntityHelper.java From Moo-Fluids with GNU General Public License v3.0 | 4 votes |
public static void setContainableFluid(final String fluidName, final Fluid fluid) { containableFluids.put(fluidName, fluid); }
Example #29
Source File: FluidToReactantMapping.java From BigReactors with MIT License | 4 votes |
public FluidToReactantMapping(Fluid fluid, int fluidAmount, String reactantName, int reactantAmount) { super(fluid.getName(), fluidAmount, reactantName, reactantAmount); }
Example #30
Source File: GTMaterialGen.java From GT-Classic with GNU Lesser General Public License v3.0 | 4 votes |
/** How to get a GT Gas/Fluid Fluid Instance **/ public static Fluid getFluid(GTMaterial mat) { return getFluidStack(mat).getFluid(); }