Java 类net.minecraft.world.biome.BiomeColorHelper 实例源码

项目:NaturalTrees    文件:ClientProxy.java   
@Override
public void init()
{

    Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(
            new IBlockColor()
            {
                public int colorMultiplier(IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex)
                {
                    if (world != null && pos != null)
                        return BiomeColorHelper.getFoliageColorAtPos(world, pos);
                    else
                        return ColorizerFoliage.getFoliageColorBasic();
                }
            }, NaturalTrees.branchOak, NaturalTrees.branchBirch,
            NaturalTrees.branchSpruce, NaturalTrees.branchJungle,
            NaturalTrees.branchDarkOak, NaturalTrees.branchAcacia);
}
项目:modName    文件:GrassColours.java   
public static void doImmenseEvil() throws Exception {
    // de-finalise the grass colour field
    Field grass_color = ReflectionHelper.findField(BiomeColorHelper.class, GRASS_COLOR);
    grass_color.setAccessible(true);

    Field modifiers = Field.class.getDeclaredField("modifiers");

    AccessController.doPrivileged((PrivilegedAction) () -> {
        modifiers.setAccessible(true);
        return null;
    });

    modifiers.setInt(grass_color, grass_color.getModifiers() & ~Modifier.FINAL);

    // get the interface
    Class colorResolver = ReflectionHelper.getClass(Minecraft.class.getClassLoader(), COLOR_RESOLVER);

    // get what the field was so it can be wrapped
    Object wrappedResolver = grass_color.get(null);

    // get the version of the method used by the object to be wrapped - avoids exceptions for calling an abstract method
    Class wrappedResolverClass = wrappedResolver.getClass();
    Method wrappedGetColorAtPos = ReflectionHelper.findMethod(wrappedResolverClass, "getColorAtPos", "func_180283_a", Biome.class, BlockPos.class);

    // build a proxy
    Method getColorAtPos = ReflectionHelper.findMethod(colorResolver, "getColorAtPos", "func_180283_a", Biome.class, BlockPos.class);
    Object proxy = Proxy.newProxyInstance(colorResolver.getClassLoader(), new Class[] { colorResolver }, new GrassHandler(getColorAtPos, wrappedResolver, wrappedGetColorAtPos) );

    // set the field
    grass_color.set(null, proxy);
}
项目:ExNihiloAdscensio    文件:TileInfestedLeaves.java   
@SideOnly(Side.CLIENT)
public int getColor()
{
    if (world == null || pos == null)
    {
        return Util.whiteColor.toInt();
    }
    else
    {
        Color green = new Color(BiomeColorHelper.getFoliageColorAtPos(world, pos));
        return Color.average(green, Util.whiteColor, (float) Math.pow(progress, 2)).toInt();
    }
}
项目:TechStack-s-HeavyMachineryMod    文件:ClientProxy.java   
@Override
public void Init() {
    final BlockColors blockcolors = Minecraft.getMinecraft().getBlockColors();
    blockcolors.registerBlockColorHandler(new IBlockColor() {
        public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
            return worldIn != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : ColorizerGrass.getGrassColor(0.5D, 1.0D);
        }
    }, ModBlocks.machinemowedgrass);
}
项目:DecompiledMinecraft    文件:BlockDoublePlant.java   
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = this.getVariant(worldIn, pos);
    return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN ? 16777215 : BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
}
项目:DecompiledMinecraft    文件:BlockLeaves.java   
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    return BiomeColorHelper.getFoliageColorAtPos(worldIn, pos);
}
项目:DecompiledMinecraft    文件:BlockLiquid.java   
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    return this.blockMaterial == Material.water ? BiomeColorHelper.getWaterColorAtPos(worldIn, pos) : 16777215;
}
项目:DecompiledMinecraft    文件:BlockGrass.java   
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
}
项目:VoidApi    文件:VoidClient.java   
@Override
public int getClientGrassColor(IBlockAccess w, BlockPos pos)
{
    return BiomeColorHelper.getGrassColorAtPos(w, pos);
}
项目:BaseClient    文件:BlockDoublePlant.java   
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = this.getVariant(worldIn, pos);
    return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN ? 16777215 : BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
}
项目:BaseClient    文件:BlockLeaves.java   
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    return BiomeColorHelper.getFoliageColorAtPos(worldIn, pos);
}
项目:BaseClient    文件:BlockLiquid.java   
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) {
    return this.blockMaterial == Material.water ? BiomeColorHelper.getWaterColorAtPos(worldIn, pos) : 16777215;
}
项目:BaseClient    文件:BlockGrass.java   
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
}
项目:BaseClient    文件:BlockDoublePlant.java   
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = this.getVariant(worldIn, pos);
    return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN ? 16777215 : BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
}
项目:BaseClient    文件:BlockLeaves.java   
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    return BiomeColorHelper.getFoliageColorAtPos(worldIn, pos);
}
项目:BaseClient    文件:BlockLiquid.java   
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    return this.blockMaterial == Material.water ? BiomeColorHelper.getWaterColorAtPos(worldIn, pos) : 16777215;
}
项目:BaseClient    文件:BlockGrass.java   
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
}
项目:customstuff4    文件:ClientProxy.java   
@Override
public BlockTint getFoliageTint()
{
    return BiomeColorHelper::getFoliageColorAtPos;
}
项目:customstuff4    文件:ClientProxy.java   
@Override
public BlockTint getGrassTint()
{
    return BiomeColorHelper::getGrassColorAtPos;
}
项目:customstuff4    文件:ClientProxy.java   
@Override
public BlockTint getWaterTint()
{
    return BiomeColorHelper::getWaterColorAtPos;
}
项目:BetterWithAddons    文件:ColorHandlers.java   
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex)
{
    return world != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(world, pos) : ColorizerGrass.getGrassColor(0.5D, 1.0D);
}
项目:Wizardry    文件:BlockWisdomLeaves.java   
@Nullable
@Override
public Function4<IBlockState, IBlockAccess, BlockPos, Integer, Integer> getBlockColorFunction() {
    return (iBlockState, iBlockAccess, blockPos, integer) -> iBlockAccess != null && blockPos != null ? BiomeColorHelper.getFoliageColorAtPos(iBlockAccess, blockPos) : ColorizerFoliage.getFoliageColorBasic();
}
项目:DynamicSurroundings    文件:MoteBase.java   
public static Color getBiomeWaterColor(final World world, final double x, final double y, final double z) {
    return new Color(BiomeColorHelper.getWaterColorAtPos(world, new BlockPos(x, y, z)));
}
项目:ARKCraft    文件:ClientProxy.java   
private void registerRenderers()
{
    // TODO update this a bit + make client component to init manager
    registerBlockRenderer();
    InitializationManager.instance().getRegistry().forEachEntry((RegistryEntry<?> r) -> {
        if (r.standardRender) {
            r.forEachMeta((Integer meta) -> {
                Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(r.content, meta, new ModelResourceLocation(ARKCraft.MODID + ":" + r.modelLocationPrefix + r.name, "inventory"));
            });
        }
        Collection<String> v = new ArrayList<>(Arrays.asList(r.getVariants()));
        v.add(ARKCraft.MODID + ":" + r.modelLocationPrefix + r.name);
        ModelLoader.registerItemVariants(r.content, CollectionUtil.convert(v, (e) -> new ResourceLocation(e)).toArray(new ResourceLocation[0]));
    });

    // TODO this can also render other item's models for this one!
    Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ARKCraftItems.blueprint, new ItemMeshDefinition() {
        @Override
        public ModelResourceLocation getModelLocation(ItemStack stack)
        {
            return new ModelResourceLocation(ARKCraft.instance().modid() + ":blueprint/" + ItemBlueprint.getEngram(stack).getName(), "inventory");
        }
    });

    // Register models for entities
    registerEntityModels();

    registerBlockTexture(ARKCraftBlocks.cropPlot, 1, "crop_plot");
    registerBlockTexture(ARKCraftBlocks.cropPlot, 2, "crop_plot");
    registerBlockTexture(ARKCraftBlocks.cable, 1, "cable_vert");

    meshedItems.forEach(i -> Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register((Item) i, i::getModel));

    Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(new IBlockColor()
    {
        @Override
        public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
        {
            return worldIn != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : (ColorizerGrass.getGrassColor(0.5D, 1.0D));
        }
    }, new Block[] {ARKCraftBlocks.berryBush});
    ARKCustomModelLoader.init();
    ARKCustomModelLoader.instance.modelMap.put(new ResourceLocation("arkcraft:cable"), new ModelCable());
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityElectricOutlet.class, new TileEntityElectricOutletSpecialRenderer());
}
项目:TechStack-s-HeavyMachineryMod    文件:BlockMachineMowedGrass.java   
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) {
    return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
}
项目:Minestrappolation-4    文件:MBlockLeavesBase.java   
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    return BiomeColorHelper.getFoliageColorAtPos(worldIn, pos);
}
项目:ARKCraft-Code    文件:BlockBerryBush.java   
@Override
@SideOnly(Side.CLIENT)
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)
{
    return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);
}
项目:reptiles    文件:RenderIguana.java   
public static int[] getBlockBiomeColors(EntityLivingBase iguana) {
    double entityX = iguana.posX;
    double entityY = iguana.posY;
    double entityZ = iguana.posZ;

    int red = 0;
    int green = 0;
    int blue = 0;

    int currColor;
    int blockCount = 27; // 3 * 3 * 3

    for (int x = -1; x <= 1; ++x) {
        for (int y = 0; y <= 2; ++y) {
            for (int z = -1; z <= 1; ++z) {
                IBlockState iBlockState = iguana.world.getBlockState(new BlockPos(entityX + x, entityY + y - 0.5, entityZ + z));
                Block block = iBlockState.getBlock();

                if (block instanceof BlockAir) {
                    blockCount--;
                    continue;
                }

                if (block instanceof BlockGrass || block instanceof BlockTallGrass) {
                    currColor = BiomeColorHelper.getGrassColorAtPos(iguana.world, new BlockPos(entityX + x, entityY + y, entityZ + z));
                } else if (block instanceof BlockLeaves) {
                    currColor = BiomeColorHelper.getFoliageColorAtPos(iguana.world, new BlockPos(entityX + x, entityY + y, entityZ + z));
                } else {
                    currColor = iBlockState.getMapColor(iguana.world, new BlockPos(entityX + x, entityY + y, entityZ + z)).colorValue;
                }
                red += (currColor & 0xFF0000) >> 16;
                green += (currColor & 0xFF00) >> 8;
                blue += currColor & 0xFF;
            }
        }
    }

    // default to grey color if the Chameleon is falling through the air (without any blocks near it)
    // also has the benefit of avoiding a divide by zero
    if (blockCount == 0) {
        return new int[] { 135, 135, 135 };
    }

    red /= blockCount;
    green /= blockCount;
    blue /= blockCount;

    return new int[] { red, green, blue };
}
项目:reptiles    文件:RenderChameleon.java   
public static int[] getBlockBiomeColors(EntityLivingBase chameleon) {
    double entityX = chameleon.posX;
    double entityY = chameleon.posY;
    double entityZ = chameleon.posZ;

    int red = 0;
    int green = 0;
    int blue = 0;

    int currColor;
    int blockCount = 27; // 3 * 3 * 3

    for (int x = -1; x <= 1; ++x) {
        for (int y = 0; y <= 2; ++y) {
            for (int z = -1; z <= 1; ++z) {
                IBlockState iBlockState = chameleon.world.getBlockState(new BlockPos(entityX + x, entityY + y - 0.5, entityZ + z));
                Block block = iBlockState.getBlock();

                if (block instanceof BlockAir) {
                    blockCount--;
                    continue;
                }

                if (block instanceof BlockGrass || block instanceof BlockTallGrass) {
                    currColor = BiomeColorHelper.getGrassColorAtPos(chameleon.world, new BlockPos(entityX + x, entityY + y, entityZ + z));
                } else if (block instanceof BlockLeaves) {
                    currColor = BiomeColorHelper.getFoliageColorAtPos(chameleon.world, new BlockPos(entityX + x, entityY + y, entityZ + z));
                } else {
                    currColor = iBlockState.getMapColor(chameleon.world, new BlockPos(entityX + x, entityY + y, entityZ + z)).colorValue;
                }
                red += (currColor & 0xFF0000) >> 16;
                green += (currColor & 0xFF00) >> 8;
                blue += currColor & 0xFF;
            }
        }
    }

    // default to grey color if the Chameleon is falling through the air (without any blocks near it)
    // also has the benefit of avoiding a divide by zero
    if (blockCount == 0) {
        return new int[] { 135, 135, 135 };
    }

    red /= blockCount;
    green /= blockCount;
    blue /= blockCount;

    return new int[] { red, green, blue };
}