public static int getStillFluidLevel(Block block) { return block instanceof BlockFluidBase ? ((BlockFluidBase) block).getMaxRenderHeightMeta() : 0; }
public static void initPotionFluids() { MinecraftForge.EVENT_BUS.register(new PotionFluids()); for(ResourceLocation registryName : ForgeRegistries.POTION_TYPES.getKeys()) { if(registryName.getResourceDomain().equals("minecraft") && registryName.getResourcePath().equals("empty")) continue; PotionType potion = ForgeRegistries.POTION_TYPES.getValue(registryName); Preconditions.checkNotNull(potion); Fluid potionFluid; if(potion != PotionTypes.WATER) { String fluidName = String.format("potion.%s.%s", registryName.getResourceDomain(), registryName.getResourcePath()); potionFluid = new Fluid(fluidName, AUTO_GENERATED_FLUID_TEXTURE, AUTO_GENERATED_FLUID_TEXTURE) { @Override public String getUnlocalizedName() { return potion.getNamePrefixed("potion.effect."); } }; potionFluid.setColor(GTUtility.convertRGBtoOpaqueRGBA_MC(PotionUtils.getPotionColor(potion))); FluidRegistry.registerFluid(potionFluid); FluidRegistry.addBucketForFluid(potionFluid); BlockFluidBase fluidBlock = new BlockPotionFluid(potionFluid, potion); fluidBlock.setRegistryName("fluid." + fluidName); MetaBlocks.FLUID_BLOCKS.add(fluidBlock); } else { potionFluid = FluidRegistry.WATER; } potionFluidMap.put(potion.getRegistryName(), potionFluid); } }
@SubscribeEvent @SideOnly(Side.CLIENT) public static void registerColorHandlerBlocks(ColorHandlerEvent.Block event) { BlockColors blockcolors = event.getBlockColors(); blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) -> worldIn != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : ColorizerGrass.getGrassColor(0.5D, 1.0D), BlocksTFC.getAllBlockRockVariants().stream().filter(x -> x.type.isGrass).toArray(BlockRockVariant[]::new)); blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) -> BlockFarmlandTFC.TINT[state.getValue(BlockFarmlandTFC.MOISTURE)], BlocksTFC.getAllBlockRockVariants().stream().filter(x -> x.type == Rock.Type.FARMLAND).toArray(BlockRockVariant[]::new)); blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) -> worldIn != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : ColorizerGrass.getGrassColor(0.5D, 1.0D), BlocksTFC.PEAT_GRASS); blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) -> worldIn != null && pos != null ? BiomeColorHelper.getWaterColorAtPos(worldIn, pos) : 0, BlocksTFC.getAllFluidBlocks().stream().filter(x -> x.getDefaultState().getMaterial() == Material.WATER).toArray(BlockFluidBase[]::new)); blockcolors.registerBlockColorHandler((state, worldIn, pos, tintIndex) -> worldIn != null && pos != null ? BiomeColorHelper.getFoliageColorAtPos(worldIn, pos) : ColorizerFoliage.getFoliageColorBasic(), BlocksTFC.getAllLeafBlocks().toArray(new Block[0])); }
event.getToolTip().add("Fluid: " + ((BlockFluidBase) currentBlock).getFluid().getName());
fluidBlock.setRegistryName("fluid." + materialName); MetaBlocks.FLUID_BLOCKS.add(fluidBlock);