Java Code Examples for net.minecraftforge.fluids.FluidRegistry

The following are top voted examples for showing how to use net.minecraftforge.fluids.FluidRegistry. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: pnc-repressurized   File: ProgWidgetLiquidInventoryCondition.java   View source code 7 votes vote down vote up
@Override
protected DroneAIBlockCondition getEvaluator(IDroneBase drone, IProgWidget widget) {
    return new DroneAIBlockCondition(drone, (ProgWidgetAreaItemBase) widget) {

        @Override
        protected boolean evaluate(BlockPos pos) {
            TileEntity te = drone.world().getTileEntity(pos);
            int count = 0;
            if (te != null && te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null) ) {
                IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null);
                for (IFluidTankProperties prop : handler.getTankProperties()) {
                    FluidStack stack = prop.getContents();
                    if (stack != null) {
                        if (ProgWidgetLiquidFilter.isLiquidValid(stack.getFluid(), widget, 1)) {
                            count += stack.amount;
                        }
                    }
                }
            } else {
                Fluid fluid = FluidRegistry.lookupFluidForBlock(drone.world().getBlockState(pos).getBlock());
                if (fluid != null && ProgWidgetLiquidFilter.isLiquidValid(fluid, widget, 1) && FluidUtils.isSourceBlock(drone.world(), pos)) {
                    count += 1000;
                }
            }
            return ((ICondition) widget).getOperator() == ICondition.Operator.EQUALS ?
                    count == ((ICondition) widget).getRequiredCount() :
                    count >= ((ICondition) widget).getRequiredCount();
        }

    };
}
 
Example 2
Project: pnc-repressurized   File: GuiProgWidgetLiquidFilter.java   View source code 6 votes vote down vote up
private void addValidFluids() {

        List<Fluid> fluids = new ArrayList<Fluid>();

        for (Fluid fluid : FluidRegistry.getRegisteredFluids().values()) {
            if (fluid.getLocalizedName(new FluidStack(fluid, 1)).toLowerCase().contains(searchField.getText())) {
                fluids.add(fluid);
            }
        }
        fluids.sort(Comparator.comparing(Fluid::getName));

        scrollbar.setStates(Math.max(0, (fluids.size() - GRID_WIDTH * GRID_HEIGHT + GRID_WIDTH - 1) / GRID_WIDTH));

        int offset = scrollbar.getState() * GRID_WIDTH;
        for (IGuiWidget widget : widgets) {
            if (widget.getID() >= 0 && widget instanceof WidgetFluidFilter) {
                int idWithOffset = widget.getID() + offset;
                ((WidgetFluidFilter) widget).setFluid(idWithOffset >= 0 && idWithOffset < fluids.size() ? fluids.get(idWithOffset) : null);
            }
        }
    }
 
Example 3
Project: pnc-repressurized   File: EnderIO.java   View source code 6 votes vote down vote up
@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 4
Project: pnc-repressurized   File: CoFHCore.java   View source code 6 votes vote down vote up
@Override
public void init() {
    // gasoline is equivalent to Thermal Foundation refined fuel @ 2,000,000
    // "oil" gets added by CoFH so no need to do it here
    ThermalExpansionHelper.addCompressionFuel(Fluids.DIESEL.getName(), 1000000);
    ThermalExpansionHelper.addCompressionFuel(Fluids.KEROSENE.getName(), 1500000);
    ThermalExpansionHelper.addCompressionFuel(Fluids.GASOLINE.getName(), 2000000);
    ThermalExpansionHelper.addCompressionFuel(Fluids.LPG.getName(), 2500000);
    PneumaticCraftRepressurized.logger.info("Added PneumaticCraft: Repressurized fuels to CoFH Compression Dynamo");

    registerCoFHfuel("creosote", 75000);
    registerCoFHfuel("coal", 300000);
    registerCoFHfuel("tree_oil", 750000);
    registerCoFHfuel("refined_oil", 937500);
    registerCoFHfuel("refined_fuel", 1500000);

    Fluid crudeOil = FluidRegistry.getFluid("crude_oil");
    if (crudeOil != null) {
        PneumaticCraftAPIHandler.getInstance().registerRefineryInput(crudeOil);
        PneumaticCraftRepressurized.logger.info("Added CoFH Crude Oil as a Refinery input");
    }
}
 
Example 5
Project: pnc-repressurized   File: HeatExchangerManager.java   View source code 6 votes vote down vote up
public void init() {
    registerBlockExchanger(Blocks.ICE, 263, 500);
    registerBlockExchanger(Blocks.PACKED_ICE, 263, 500);
    registerBlockExchanger(Blocks.SNOW, 268, 1000);
    registerBlockExchanger(Blocks.TORCH, 1700, 100000);
    registerBlockExchanger(Blocks.FIRE, 1700, 1000);

    Map<String, Fluid> fluids = FluidRegistry.getRegisteredFluids();
    for (Fluid fluid : fluids.values()) {
        if (fluid.getBlock() != null) {
            registerBlockExchanger(fluid.getBlock(), fluid.getTemperature(), FLUID_RESISTANCE);
        }
    }
    registerBlockExchanger(Blocks.FLOWING_WATER, FluidRegistry.WATER.getTemperature(), 500);
    registerBlockExchanger(Blocks.FLOWING_LAVA, FluidRegistry.LAVA.getTemperature(), 500);
}
 
Example 6
Project: pnc-repressurized   File: TileEntityGasLift.java   View source code 6 votes vote down vote up
private boolean suckLiquid() {
    Block block = world.getBlockState(getPos().offset(EnumFacing.DOWN, currentDepth + 1)).getBlock();
    Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
    if (fluid == null) {
        pumpingLake = null;
        return false;
    }

    FluidStack fluidStack = new FluidStack(fluid, 1000);
    if (tank.fill(fluidStack, false) == 1000) {
        if (pumpingLake == null) {
            findLake(block);
        }
        BlockPos curPos = null;
        boolean foundSource = false;
        while (pumpingLake.size() > 0) {
            curPos = pumpingLake.get(0);
            if (getWorld().getBlockState(curPos).getBlock() == block && FluidUtils.isSourceBlock(getWorld(), curPos)) {
                foundSource = true;
                break;
            }
            pumpingLake.remove(0);
        }
        if (pumpingLake.size() == 0) {
            pumpingLake = null;
        } else if (foundSource) {
            getWorld().setBlockToAir(curPos);
            tank.fill(fluidStack, true);
            addAir(-100);
            status = Status.PUMPING;
        }
    }
    return true;
}
 
Example 7
Project: pnc-repressurized   File: PneumaticCraftRepressurized.java   View source code 6 votes vote down vote up
@EventHandler
public void validateFluids(FMLServerStartedEvent event) {
    if (ConfigHandler.general.oilGenerationChance > 0) {
        Fluid oil = FluidRegistry.getFluid(Fluids.OIL.getName());
        if (oil.getBlock() == null) {
            String modName = FluidRegistry.getDefaultFluidName(oil).split(":")[0];
            Log.error(String.format("Oil fluid does not have a block associated with it. The fluid is owned by [%s]. " +
                    "This might be fixable by creating the world with having this mod loaded after PneumaticCraft.", modName));
            Log.error(String.format("This can be done by adding a injectedDependencies.json inside the config folder containing: " +
                    "[{\"modId\": \"%s\",\"deps\": [{\"type\":\"after\",\"target\":\"%s\"}]}]", modName, Names.MOD_ID));
            Log.error(String.format("Alternatively, you can disable PneumaticCraft oil generation by setting 'D:oilGenerationChance=0.0' " +
                    "in the config file pneumaticcraft.cfg, and use the the oil from [%s].", modName));
            throw new IllegalStateException("Oil fluid does not have a block associated with it (see errors above for more information)");
        }
    }
}
 
Example 8
Project: Firma   File: BaseLiquid.java   View source code 6 votes vote down vote up
public BaseLiquid(String fluidName, Consumer<Fluid> f, int col) {
	super(fluidName, new ResourceLocation(FirmaMod.MODID + ":blocks/water_still"), new ResourceLocation(FirmaMod.MODID + ":blocks/water_flow"));
	this.setUnlocalizedName(FirmaMod.MODID + ":fluid." + fluidName);
	FluidRegistry.registerFluid(this);
	f.accept(this);
	block = new BaseBlockLiquid(this, Material.WATER);
	block.setRegistryName(FirmaMod.MODID + ":fluid." + fluidName);
	block.setUnlocalizedName(FirmaMod.MODID + ":fluid." + fluidName);
	block.setCreativeTab(FirmaMod.blockTab);
	block.setLightOpacity(3);
	block.setLightLevel(0);
	
	GameRegistry.register(block);
	i = new ItemBlock(block);
	i.setRegistryName(FirmaMod.MODID+":fluid."+fluidName);
	i.setUnlocalizedName(FirmaMod.MODID+":fluid."+fluidName);
	GameRegistry.register(i);
	FirmaMod.allFluids.add(this);
	this.col = col;
}
 
Example 9
Project: Soot   File: Registry.java   View source code 6 votes vote down vote up
public static void registerFluids()
{
    //For creating alcohol. All made in Melter, so very hot.
    FluidRegistry.registerFluid(BOILING_WORT = new Fluid("boiling_wort",new ResourceLocation(Soot.MODID,"blocks/wort"),new ResourceLocation(Soot.MODID,"blocks/wort_flowing")).setTemperature(500));
    FluidRegistry.registerFluid(BOILING_POTATO_JUICE = new Fluid("boiling_potato_juice",new ResourceLocation(Soot.MODID,"blocks/potato_juice"),new ResourceLocation(Soot.MODID,"blocks/potato_juice_flowing")).setTemperature(500));
    FluidRegistry.registerFluid(BOILING_WORMWOOD = new Fluid("boiling_wormwood",new ResourceLocation(Soot.MODID,"blocks/verdigris"),new ResourceLocation(Soot.MODID,"blocks/verdigris_flowing")).setTemperature(500));
    FluidRegistry.registerFluid(BOILING_BEETROOT_SOUP = new Fluid("boiling_beetroot_soup",new ResourceLocation(Soot.MODID,"blocks/beetroot_soup"),new ResourceLocation(Soot.MODID,"blocks/beetroot_soup_flowing")).setTemperature(500));
    //Alcohol itself. Cold.
    FluidRegistry.registerFluid(ALE = new Fluid("ale",new ResourceLocation(Soot.MODID,"blocks/ale"),new ResourceLocation(Soot.MODID,"blocks/ale_flowing")));
    FluidRegistry.registerFluid(VODKA = new Fluid("vodka",new ResourceLocation(Soot.MODID,"blocks/vodka"),new ResourceLocation(Soot.MODID,"blocks/vodka_flowing")));
    FluidRegistry.registerFluid(INNER_FIRE = new Fluid("inner_fire",new ResourceLocation(Soot.MODID,"blocks/inner_fire"),new ResourceLocation(Soot.MODID,"blocks/inner_fire_flowing")));
    FluidRegistry.registerFluid(UMBER_ALE = new Fluid("umber_ale",new ResourceLocation(Soot.MODID,"blocks/umber_ale"),new ResourceLocation(Soot.MODID,"blocks/umber_ale_flowing")));
    FluidRegistry.registerFluid(METHANOL = new Fluid("methanol",new ResourceLocation(Soot.MODID,"blocks/methanol"),new ResourceLocation(Soot.MODID,"blocks/methanol_flowing")));
    FluidRegistry.registerFluid(ABSINTHE = new Fluid("absinthe",new ResourceLocation(Soot.MODID,"blocks/absinthe"),new ResourceLocation(Soot.MODID,"blocks/absinthe_flowing")));
    //Alchemy Fluids
    FluidRegistry.registerFluid(MOLTEN_ANTIMONY = new FluidMolten("antimony",new ResourceLocation(Soot.MODID,"blocks/molten_antimony"),new ResourceLocation(Soot.MODID,"blocks/molten_antimony_flowing")));
    FluidRegistry.registerFluid(MOLTEN_SUGAR = new FluidMolten("sugar",new ResourceLocation(Soot.MODID,"blocks/molten_sugar"),new ResourceLocation(Soot.MODID,"blocks/molten_sugar_flowing")));
}
 
Example 10
Project: Industrial-Foregoing   File: WaterResourcesCollectorTile.java   View source code 6 votes vote down vote up
@Override
public float work() {
    if (WorkUtils.isDisabled(this.getBlockType())) return 0;
    if (this.world.rand.nextBoolean() && this.world.rand.nextBoolean()) return 1;
    List<BlockPos> blockPos = BlockUtils.getBlockPosInAABB(getWorkingArea());
    boolean allWaterSources = true;
    for (BlockPos pos : blockPos) {
        IBlockState state = this.world.getBlockState(pos);
        if (!(state.getBlock().equals(FluidRegistry.WATER.getBlock()) && state.getBlock().getMetaFromState(state) == 0))
            allWaterSources = false;
    }
    if (allWaterSources) {
        LootContext.Builder lootcontext = new LootContext.Builder((WorldServer) this.world);
        List<ItemStack> items = this.world.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING).generateLootForPools(this.world.rand, lootcontext.build());
        for (ItemStack stack : items) {
            ItemHandlerHelper.insertItem(outFish, stack, false);
        }
        return 1;
    }
    return 1;
}
 
Example 11
Project: Bewitchment   File: TileCauldron.java   View source code 6 votes vote down vote up
@SuppressWarnings("ConstantConditions")
public void collideItem(EntityItem entityItem) {
	final ItemStack dropped = entityItem.getItem();
	if (dropped.isEmpty() || entityItem.isDead)
		return;

	if (inv.hasFluid()) {
		if (!inv.hasFluid(FluidRegistry.LAVA)) {
			boolean splash = false;
			if (getContainer().isEmpty() && isBoiling()) {
				splash = recipeDropLogic(dropped);
			}
			if (splash) {
				play(SoundEvents.ENTITY_GENERIC_SPLASH, 0.5F, 0.5F);
			}
		} else {
			play(SoundEvents.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
			entityItem.setDead();
			return;
		}
		if (dropped.getCount() == 0)
			entityItem.setDead();
	}
}
 
Example 12
Project: Bewitchment   File: TileCauldron.java   View source code 6 votes vote down vote up
public boolean recipeDropLogic(ItemStack dropped) {
	if (mode == Mode.NORMAL && changeMode(dropped.getItem())) {
		play(SoundEvents.ENTITY_FIREWORK_TWINKLE, 0.2F, 1F);
		dropped.setCount(0);
		return true;
	}
	switch (mode) {
		case NORMAL:
			return processingLogic(dropped) || (inv.hasFluid(FluidRegistry.WATER) && acceptIngredient(dropped));
		case POTION:
			return acceptIngredient(dropped);
		case CUSTOM:
			return acceptIngredient(dropped);
		default:
	}
	return false;
}
 
Example 13
Project: Bewitchment   File: Fluids.java   View source code 6 votes vote down vote up
private static <T extends Block & IFluidBlock> Fluid createFluid(String name, boolean hasFlowIcon, Consumer<Fluid> fluidPropertyApplier, Function<Fluid, T> blockFactory, boolean hasBucket) {
	final ResourceLocation still = new ResourceLocation(LibMod.MOD_ID + ":blocks/fluid/" + name + "_still");
	final ResourceLocation flowing = hasFlowIcon ? new ResourceLocation(LibMod.MOD_ID + ":blocks/fluid/" + name + "_flow") : still;

	Fluid fluid = new Fluid(name, still, flowing);
	final boolean useOwnFluid = FluidRegistry.registerFluid(fluid);

	if (useOwnFluid) {
		fluidPropertyApplier.accept(fluid);
		MOD_FLUID_BLOCKS.add(blockFactory.apply(fluid));
		if (hasBucket)
			FluidRegistry.addBucketForFluid(fluid);
	} else {
		fluid = FluidRegistry.getFluid(name);
	}

	return fluid;
}
 
Example 14
Project: Metalworks   File: Registry.java   View source code 6 votes vote down vote up
@SubscribeEvent
public static void registerGeoBurnables(RegistryEvent.Register<IGeoburnable> event){
    IForgeRegistry<IGeoburnable> reg = event.getRegistry();
    reg.register(new BlockGeoburnable(Blocks.MAGMA, 40, 1));
    reg.register(new BlockGeoburnable(Blocks.FIRE, 80, 2){
        @Override
        public ItemStack getJEIIcon() {
            return new ItemStack(Items.FLINT_AND_STEEL);
        }
    });
    reg.register(new BlockGeoburnable(Blocks.LAVA, 160, 3){
        @Override
        public ItemStack getJEIIcon() {
            return FluidUtil.getFilledBucket(new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME));
        }
    });
}
 
Example 15
Project: CharcoalPit   File: TileActivePile.java   View source code 6 votes vote down vote up
@Override
public void update() {
	if(!this.world.isRemote){
		checkValid();
		if(burnTime>0){
			burnTime--;
		}else{
			if(itemsLeft>0){
				itemsLeft--;
				creosote.fill(FluidRegistry.getFluidStack("creosote", isCoke?Config.CokeCreosote:Config.CharcoalCreosote), true);
				burnTime=isCoke?Config.CokeTime/10:Config.CharcoalTime/10;
			}else{
				this.world.setBlockState(this.pos, isCoke?BlocksRegistry.cokePile.getDefaultState():BlocksRegistry.charcoalPile.getDefaultState());
			}
		}
		if(creosote.getFluidAmount()>0){
			if(this.world.getTileEntity(this.pos.offset(EnumFacing.DOWN))instanceof TileActivePile){
				TileActivePile down=(TileActivePile)this.world.getTileEntity(this.pos.offset(EnumFacing.DOWN));
				creosote.drain(down.creosote.fill(creosote.getFluid(), true), true);
			}
		}
	}
}
 
Example 16
Project: CharcoalPit   File: FluidsRegistry.java   View source code 6 votes vote down vote up
public static void registerFluids(){
	if(!FluidRegistry.isFluidRegistered("creosote")){
		Creosote=new FluidCreosote("creosote", new ResourceLocation(Constants.MODID, "blocks/creosote_still"), new ResourceLocation(Constants.MODID, "blocks/creosote_flow"));
		Creosote.setViscosity(2000);
		FluidRegistry.registerFluid(Creosote);
		FluidRegistry.addBucketForFluid(Creosote);
		BlockCreosote=new BlockFluidCreosote();
		Creosote.setBlock(BlockCreosote);
	}else{
		Creosote=FluidRegistry.getFluid("creosote");
		if(Creosote.getBlock()==null){
			BlockCreosote=new BlockFluidCreosote();
			Creosote.setBlock(BlockCreosote);
		}
	}
}
 
Example 17
Project: customstuff4   File: ItemFluidContainer.java   View source code 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void getSubItems(@Nullable CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems)
{
    if (isInCreativeTab(tab))
    {
        subItems.add(new ItemStack(this));

        for (Fluid fluid : FluidRegistry.getRegisteredFluids().values())
        {
            if (!fluid.getName().equals("milk"))
            {
                // add all fluids that the bucket can be filled  with
                FluidStack fs = new FluidStack(fluid, content.capacity);
                ItemStack stack = new ItemStack(this);
                IFluidHandlerItem fluidHandler = new FluidHandlerItemStack(stack, content.capacity);
                if (fluidHandler.fill(fs, true) == fs.amount)
                {
                    ItemStack filled = fluidHandler.getContainer();
                    subItems.add(filled);
                }
            }
        }
    }
}
 
Example 18
Project: customstuff4   File: ItemHelperTests.java   View source code 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 19
Project: Thermionics   File: MashTunRecipe.java   View source code 6 votes vote down vote up
/** 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;
}
 
Example 20
Project: BetterBeginningsReborn   File: PacketNetherBrickOvenFuelLevel.java   View source code 6 votes vote down vote up
@Override
public void fromBytes(ByteBuf buf)
{
	pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());

	int level = buf.readInt();
	String fluidId = ByteBufUtils.readUTF8String(buf);

	if (level != 0)
	{
		fluidStack = new FluidStack(FluidRegistry.getFluid(fluidId), level);
	}
	else
	{
		fluidStack = null;
	}
}
 
Example 21
Project: BetterBeginningsReborn   File: TileEntityNetherBrickOven.java   View source code 6 votes vote down vote up
public int getFuelNeededForSmelt()
{
	if (fuelTank.getFluid() == null)
	{
		return 0;
	}

	float temperature = (float)fuelTank.getFluid().getFluid().getTemperature();

	// Math!
	float precise = FUELFORLAVA * FluidRegistry.LAVA.getTemperature() / temperature;

	int result = (int)precise;

	if (result <= 0)
	{
		result = 1; // No free smelting if you have blazing pyrotheum or something even hotter.
	}

	return result;
}
 
Example 22
Project: CustomWorldGen   File: FluidBucketWrapper.java   View source code 6 votes vote down vote up
@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;
    }
}
 
Example 23
Project: CustomWorldGen   File: FluidBucketWrapper.java   View source code 6 votes vote down vote up
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());
    }
}
 
Example 24
Project: CustomWorldGen   File: BlockLiquidWrapper.java   View source code 6 votes vote down vote up
@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;
    }
}
 
Example 25
Project: CustomWorldGen   File: ModelDynBucket.java   View source code 6 votes vote down vote up
/**
 * Sets the liquid in the model.
 * fluid - Name of the fluid in the FluidRegistry
 * flipGas - If "true" the model will be flipped upside down if the liquid is a gas. If "false" it wont
 * <p/>
 * If the fluid can't be found, water is used
 */
@Override
public ModelDynBucket process(ImmutableMap<String, String> customData)
{
    String fluidName = customData.get("fluid");
    Fluid fluid = FluidRegistry.getFluid(fluidName);

    if (fluid == null) fluid = this.fluid;

    boolean flip = flipGas;
    if (customData.containsKey("flipGas"))
    {
        String flipStr = customData.get("flipGas");
        if (flipStr.equals("true")) flip = true;
        else if (flipStr.equals("false")) flip = false;
        else
            throw new IllegalArgumentException(String.format("DynBucket custom data \"flipGas\" must have value \'true\' or \'false\' (was \'%s\')", flipStr));
    }

    // create new model with correct liquid
    return new ModelDynBucket(baseLocation, liquidLocation, coverLocation, fluid, flip);
}
 
Example 26
Project: CustomWorldGen   File: ForgeMessage.java   View source code 6 votes vote down vote up
@Override
void fromBytes(ByteBuf bytes)
{
    int listSize = bytes.readInt();
    for (int i = 0; i < listSize; i++) {
        String fluidName = ByteBufUtils.readUTF8String(bytes);
        int fluidId = bytes.readInt();
        fluidIds.put(FluidRegistry.getFluid(fluidName), fluidId);
    }
    // do we have a defaults list?

    if (bytes.isReadable())
    {
        for (int i = 0; i < listSize; i++)
        {
            defaultFluids.add(ByteBufUtils.readUTF8String(bytes));
        }
    }
    else
    {
        FMLLog.getLogger().log(Level.INFO, "Legacy server message contains no default fluid list - there may be problems with fluids");
        defaultFluids.clear();
    }
}
 
Example 27
Project: CustomWorldGen   File: ForgeModContainer.java   View source code 6 votes vote down vote up
@Subscribe
public void preInit(FMLPreInitializationEvent evt)
{
    CapabilityItemHandler.register();
    CapabilityFluidHandler.register();
    CapabilityAnimation.register();
    CapabilityEnergy.register();
    MinecraftForge.EVENT_BUS.register(MinecraftForge.INTERNAL_HANDLER);
    ForgeChunkManager.captureConfig(evt.getModConfigurationDirectory());
    MinecraftForge.EVENT_BUS.register(this);

    if (!ForgeModContainer.disableVersionCheck)
    {
        ForgeVersion.startVersionCheck();
    }

    // Add and register the forge universal bucket, if it's enabled
    if(FluidRegistry.isUniversalBucketEnabled())
    {
        universalBucket = new UniversalBucket();
        universalBucket.setUnlocalizedName("forge.bucketFilled");
        GameRegistry.registerItem(universalBucket, "bucketFilled");
        MinecraftForge.EVENT_BUS.register(universalBucket);
    }
}
 
Example 28
Project: CustomWorldGen   File: MinecraftForge.java   View source code 6 votes vote down vote up
/**
 * Method invoked by FML before any other mods are loaded.
 */
public static void initialize()
{
    FMLLog.info("MinecraftForge v%s Initialized", ForgeVersion.getVersion());

    OreDictionary.getOreName(0);

    UsernameCache.load();
    // Load before all the mods, so MC owns the MC fluids
    FluidRegistry.validateFluidRegistry();
    ForgeHooks.initTools();

    //For all the normal CrashReport classes to be defined. We're in MC's classloader so this should all be fine
    new CrashReport("ThisIsFake", new Exception("Not real"));
}
 
Example 29
Project: FoodCraft-Reloaded   File: EnumLoader.java   View source code 6 votes vote down vote up
/**
     * Attempt to register all entries from {@link #enumInstanceMap} to {@link ForgeRegistries}.
     * @see ForgeRegistries
     */
    public void register() {
        enumInstanceMap.forEach((instanceClass, enumMap) -> {
            if (IForgeRegistryEntry.class.isAssignableFrom(instanceClass))
                enumMap.values().stream().map(o -> (IForgeRegistryEntry<? extends IForgeRegistryEntry<?>>) o)
//                    .map(o -> new RegisterHandler(o))
                    .forEach(o -> {
//                    TODO RegisterManager.getInstance().putRegister(o);
                        if (o instanceof Item) {
                            ForgeRegistries.ITEMS.register((Item) o);
                            if (o instanceof OreDictated)
                                Arrays.stream(((OreDictated) o).getOreDictNames()).forEach(s -> OreDictionary.registerOre(s, (Item) o));
                        }
                        else if (o instanceof Block) {
                            ForgeRegistries.BLOCKS.register((Block) o);
                            if (o instanceof OreDictated)
                                Arrays.stream(((OreDictated) o).getOreDictNames()).forEach(s -> OreDictionary.registerOre(s, (Block) o));
                        }
                    });
            else if (Fluid.class.isAssignableFrom(instanceClass))
                enumMap.values().stream().map(o -> (Fluid) o).forEach(fluid -> {
                    FluidRegistry.registerFluid(fluid);
                    FluidRegistry.addBucketForFluid(fluid);
                });
        });
    }
 
Example 30
Project: ExtraUtilities   File: TileEntityGeneratorRedFlux.java   View source code 6 votes vote down vote up
@Override
public boolean processInput() {
    final double c = this.getFuelBurn(this.getTanks()[0].getFluid());
    if (c > 0.0 && this.getTanks()[0].getFluidAmount() >= this.fluidAmmount() && this.addCoolDown(c, true)) {
        if ("lava".equals(FluidRegistry.getFluidName(this.getTanks()[0].getFluid()))) {
            final double d = this.getFuelBurn(this.inv.getStackInSlot(0));
            if (d <= 0.0) {
                return false;
            }
            this.inv.decrStackSize(0, 1);
            this.curLevel = 80;
        }
        else {
            this.curLevel = 80;
        }
        this.addCoolDown(c, false);
        this.getTanks()[0].drain(this.fluidAmmount(), true);
        this.markDirty();
        return true;
    }
    return false;
}
 
Example 31
Project: 4Space-5   File: Gas.java   View source code 6 votes vote down vote up
/**
 * Registers a new fluid out of this Gas or gets one from the FluidRegistry.
 * @return this Gas object
 */
public Gas registerFluid()
{
	if(fluid == null)
	{
		if(FluidRegistry.getFluid(getName()) == null)
		{
			fluid = new Fluid(getName()).setGaseous(true);
			FluidRegistry.registerFluid(fluid);
		}
		else {
			fluid = FluidRegistry.getFluid(getName());
		}
	}

	return this;
}
 
Example 32
Project: 4Space-5   File: EntityParachest.java   View source code 6 votes vote down vote up
private boolean placeChest(int x, int y, int z)
{
    this.worldObj.setBlock(x, y, z, GCBlocks.parachest, 0, 3);
    final TileEntity te = this.worldObj.getTileEntity(x, y, z);

    if (te instanceof TileEntityParaChest && this.cargo != null)
    {
        final TileEntityParaChest chest = (TileEntityParaChest) te;

        chest.chestContents = new ItemStack[this.cargo.length + 1];

        for (int i = 0; i < this.cargo.length; i++)
        {
            chest.chestContents[i] = this.cargo[i];
        }

        chest.fuelTank.fill(FluidRegistry.getFluidStack(GalacticraftCore.fluidFuel.getName().toLowerCase(), this.fuelLevel), true);

        return true;
    }

    this.placedChest = true;

    return true;
}
 
Example 33
Project: 4Space-5   File: FluidUtil.java   View source code 6 votes vote down vote up
/**
 *  Fill Galacticraft entities (e.g. rockets, buggies) with Galacticraft fuel.
 *  For legacy reasons, accepts either "fuel" or "fuelgc".
 *  Auto-converts either one to the same type of fuel as is already contained.
 *    
 * @param tank    The tank
 * @param liquid   A FluidStack being the fuel offered
 * @param doFill   True if this is not a simulation / tank capacity test
 * @return         The amount filled
 */
public static int fillWithGCFuel(FluidTank tank, FluidStack liquid, boolean doFill)
{
	if (liquid != null && testFuel(FluidRegistry.getFluidName(liquid)))
	{
		final FluidStack liquidInTank = tank.getFluid();
		
		//If the tank is empty, fill it with the current type of GC fuel
		if (liquidInTank == null)
		{
			return tank.fill(new FluidStack(GalacticraftCore.fluidFuel, liquid.amount), doFill);
		}
		
		//If the tank already contains something, fill it with more of the same 
		if (liquidInTank.amount + liquid.amount <= tank.getCapacity())
		{
			return tank.fill(new FluidStack(liquidInTank, liquid.amount), doFill);
		}
	}
	
	return 0;
}
 
Example 34
Project: CrystalMod   File: CrystalInfusionManager.java   View source code 6 votes vote down vote up
public static void initRecipes() {
	for(InfusionRecipe recipe : CauldronRecipeManager.getRecipes()){
		recipes.add(new InfusionMachineRecipe(recipe.getInput(), recipe.getFluidInput(), recipe.getOutput().copy(), 1600));
	}
	
	recipes.add(new InfusionMachineRecipe(new ItemStack(ModItems.machineFrame, 1, FrameType.BASIC.getMetadata()), new FluidStack(ModFluids.fluidEnder, 1000), new ItemStack(ModItems.machineFrame, 1, FrameType.ENDER.getMetadata()), 1600));

	recipes.add(new InfusionMachineRecipe(new ItemStack(Items.GLASS_BOTTLE), new FluidStack(ModFluids.fluidXpJuice, XpUtil.LIQUID_PER_XP_BOTTLE), new ItemStack(Items.EXPERIENCE_BOTTLE), 800));

	recipes.add(new InfusionMachineRecipe(new ItemStack(Blocks.COBBLESTONE), new FluidStack(FluidRegistry.WATER, 125), new ItemStack(Blocks.MOSSY_COBBLESTONE), 1600));
	recipes.add(new InfusionMachineRecipe(new ItemStack(Blocks.COBBLESTONE), new FluidStack(FluidRegistry.LAVA, 125), new ItemStack(Blocks.NETHERRACK), 1600));
	//Molten Block
	recipes.add(new InfusionMachineRecipe(new ItemStack(Blocks.NETHERRACK), new FluidStack(FluidRegistry.LAVA, 125), new ItemStack(Blocks.MAGMA), 1600));
	recipes.add(new InfusionMachineRecipe(new ItemStack(Blocks.NETHERRACK), new FluidStack(ModFluids.fluidEnder, 125), new ItemStack(Blocks.END_STONE), 1600));
	

	recipes.add(new InfusionMachineRecipe(new ItemStack(Items.GLASS_BOTTLE), new FluidStack(ModFluids.fluidEnder, 250), new ItemStack(ModItems.enderbottle), 1600));
}
 
Example 35
Project: TRHS_Club_Mod_2016   File: ForgeMessage.java   View source code 6 votes vote down vote up
@Override
void fromBytes(ByteBuf bytes)
{
    int listSize = bytes.readInt();
    for (int i = 0; i < listSize; i++) {
        String fluidName = ByteBufUtils.readUTF8String(bytes);
        int fluidId = bytes.readInt();
        fluidIds.put(FluidRegistry.getFluid(fluidName), fluidId);
    }
    // do we have a defaults list?

    if (bytes.isReadable())
    {
        for (int i = 0; i < listSize; i++)
        {
            defaultFluids.add(ByteBufUtils.readUTF8String(bytes));
        }
    }
    else
    {
        FMLLog.getLogger().log(Level.INFO, "Legacy server message contains no default fluid list - there may be problems with fluids");
        defaultFluids.clear();
    }
}
 
Example 36
Project: AquaMunda   File: TankTE.java   View source code 6 votes vote down vote up
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());
            }
        }
    }
}
 
Example 37
Project: Qbar   File: QBarFluids.java   View source code 6 votes vote down vote up
public static final void registerFluids()
{
    QBarFluids.fluidSteam = new Fluid("steam", new ResourceLocation(QBarConstants.MODID +
            ":blocks/fluid/steam_still"), new ResourceLocation(QBarConstants.MODID + ":blocks/fluid/steam_flow"))
            .setDensity(-1000).setViscosity(500).setGaseous(true);
    if (!FluidRegistry.registerFluid(QBarFluids.fluidSteam))
        QBarFluids.fluidSteam = FluidRegistry.getFluid("steam");
    FluidRegistry.addBucketForFluid(QBarFluids.fluidSteam);

    QBarFluids.blockFluidSteam = new BlockQBarFluid(QBarFluids.fluidSteam, Material.WATER, "blockfluidsteam");
    QBarBlocks.registerBlock(QBarFluids.blockFluidSteam);

    QBarMaterials.metals.stream().filter(metal -> !FluidRegistry.isFluidRegistered("molten" + metal))
            .forEach(metal ->
            {
                Fluid moltenMetal = new Fluid("molten" + metal,
                        new ResourceLocation(QBarConstants.MODID + ":blocks/fluid/" + metal + "_still"),
                        new ResourceLocation(QBarConstants.MODID + ":blocks/fluid/" + metal + "_flow"));
                FluidRegistry.registerFluid(moltenMetal);
                FluidRegistry.addBucketForFluid(moltenMetal);

                QBarBlocks.registerBlock(new BlockQBarFluid(moltenMetal, Material.LAVA, "blockmolten" + metal));
            });
}
 
Example 38
Project: Mekfarm   File: FluidsRegistry.java   View source code 6 votes vote down vote up
public static final void createFluids() {
        FluidRegistry.enableUniversalBucket();

        FluidsRegistry.sewage = new SewageFluid();
        FluidsRegistry.sewage.register();

        (FluidsRegistry.liquidXP = new LiquidXPFluid()).register();

//        Fluid liquidXP = null;
////        for(Fluid f : FluidRegistry.getRegisteredFluids().values()) {
////            if (Objects.equals(f.getUnlocalizedName(), "eio.xpjuice")) {
////                liquidXP = f;
////                break;
////            }
////        }
//        if (null == (FluidsRegistry.liquidXP = liquidXP)) {
//            FluidsRegistry.liquidXP = new Fluid("liquidxp",
//                    new ResourceLocation(MekfarmMod.MODID, "blocks/liquidxp_still"),
//                    new ResourceLocation(MekfarmMod.MODID, "blocks/liquidxp_flow"))
//                    .setLuminosity(10)
//                    .setDensity(800)
//                    .setViscosity(1500);
//            FluidRegistry.registerFluid(FluidsRegistry.liquidXP);
//            FluidRegistry.addBucketForFluid(FluidsRegistry.liquidXP);
//        }
    }
 
Example 39
Project: AquaMunda   File: DesalinationBoilerBlock.java   View source code 6 votes vote down vote up
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
    super.getWailaBody(itemStack, currenttip, accessor, config);

    DesalinationBoilerTE te = (DesalinationBoilerTE) accessor.getTileEntity();

    long time = System.currentTimeMillis();
    if ((time - lastUpdateTime) > 200) {
        lastUpdateTime = time;
        PacketHandler.INSTANCE.sendToServer(new PacketGetInfoFromServer(new BoilerContentsInfoPacketServer(te.getPos())));
    }

    DecimalFormat decimalFormat = new DecimalFormat("#.#");

    currenttip.add(TextFormatting.GREEN + "Liquid: " + FluidRegistry.getFluidName(te.getSupportedFluid()));
    currenttip.add(TextFormatting.GREEN + "Contents: " + te.getContents() + " (" + DesalinationBoilerTE.MAX_CONTENTS + ")");
    currenttip.add(TextFormatting.GREEN + "Temperature: " + decimalFormat.format(te.getTemperature()));
    return currenttip;
}
 
Example 40
Project: ExNihiloAdscensio   File: MessageFluidUpdate.java   View source code 6 votes vote down vote up
@Override
public IMessage onMessage(final MessageFluidUpdate msg, MessageContext ctx)
{
	Minecraft.getMinecraft().addScheduledTask(new Runnable() {
		@Override
		public void run()
		{
			TileEntity entity =  Minecraft.getMinecraft().player.world.getTileEntity(new BlockPos(msg.x, msg.y, msg.z));
			if (entity instanceof TileBarrel)
			{
				TileBarrel te = (TileBarrel) entity;
				Fluid fluid = FluidRegistry.getFluid(msg.fluidName);
				FluidStack f = fluid == null ? null : new FluidStack(fluid, msg.fillAmount);
				te.getTank().setFluid(f);
			}
		}
	});
	return null;
}