Java 类net.minecraftforge.fluids.FluidRegistry 实例源码

项目:pnc-repressurized    文件:ProgWidgetLiquidInventoryCondition.java   
@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();
        }

    };
}
项目:pnc-repressurized    文件:GuiProgWidgetLiquidFilter.java   
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);
            }
        }
    }
项目:pnc-repressurized    文件:EnderIO.java   
@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!");
    }
}
项目:pnc-repressurized    文件:CoFHCore.java   
@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");
    }
}
项目:pnc-repressurized    文件:HeatExchangerManager.java   
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);
}
项目:pnc-repressurized    文件:TileEntityGasLift.java   
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;
}
项目:pnc-repressurized    文件:PneumaticCraftRepressurized.java   
@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)");
        }
    }
}
项目:Firma    文件:BaseLiquid.java   
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;
}
项目:Soot    文件:Registry.java   
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")));
}
项目:Industrial-Foregoing    文件:WaterResourcesCollectorTile.java   
@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;
}
项目:Bewitchment    文件:TileCauldron.java   
@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();
    }
}
项目:Bewitchment    文件:TileCauldron.java   
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;
}
项目:Bewitchment    文件:Fluids.java   
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;
}
项目:Metalworks    文件:Registry.java   
@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));
        }
    });
}
项目:CharcoalPit    文件:TileActivePile.java   
@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);
            }
        }
    }
}
项目:CharcoalPit    文件:FluidsRegistry.java   
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);
        }
    }
}
项目:customstuff4    文件:ItemFluidContainer.java   
@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);
                }
            }
        }
    }
}
项目:customstuff4    文件:ItemHelperTests.java   
@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());
}
项目:Thermionics    文件:MashTunRecipe.java   
/** 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;
}
项目:BetterBeginningsReborn    文件:PacketNetherBrickOvenFuelLevel.java   
@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;
    }
}
项目:BetterBeginningsReborn    文件:TileEntityNetherBrickOven.java   
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;
}
项目:CustomWorldGen    文件:FluidBucketWrapper.java   
@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;
    }
}
项目:CustomWorldGen    文件:FluidBucketWrapper.java   
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());
    }
}
项目:CustomWorldGen    文件:BlockLiquidWrapper.java   
@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;
    }
}
项目:CustomWorldGen    文件:ModelDynBucket.java   
/**
 * 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);
}
项目:CustomWorldGen    文件:ForgeMessage.java   
@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();
    }
}
项目:CustomWorldGen    文件:ForgeModContainer.java   
@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);
    }
}
项目:CustomWorldGen    文件:MinecraftForge.java   
/**
 * 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"));
}
项目:FoodCraft-Reloaded    文件:EnumLoader.java   
/**
     * 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);
                });
        });
    }
项目:ExtraUtilities    文件:TileEntityGeneratorRedFlux.java   
@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;
}
项目:4Space-5    文件:Gas.java   
/**
 * 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;
}
项目:4Space-5    文件:EntityParachest.java   
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;
}
项目:4Space-5    文件:FluidUtil.java   
/**
 *  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;
}
项目:CrystalMod    文件:CrystalInfusionManager.java   
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));
}
项目:TRHS_Club_Mod_2016    文件:ForgeMessage.java   
@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();
    }
}
项目:AquaMunda    文件:TankTE.java   
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());
            }
        }
    }
}
项目:Qbar    文件:QBarFluids.java   
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));
            });
}
项目:Mekfarm    文件:FluidsRegistry.java   
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);
//        }
    }
项目:AquaMunda    文件:DesalinationBoilerBlock.java   
@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;
}
项目:ExNihiloAdscensio    文件:MessageFluidUpdate.java   
@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;
}