java类net.minecraft.client.renderer.color.IBlockColor的实例源码

LightBlock.java 文件源码 项目:rflux 阅读 21 收藏 0 点赞 0 评论 0
@SideOnly(Side.CLIENT)
    public void initBlockColors() {
        Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(new IBlockColor() {
            @Override
            public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) {
                if (pos != null && worldIn != null) {
                    TileEntity te = worldIn.getTileEntity(pos);
                    if (te instanceof LightTE) {
                        LightTE tileEntity = (LightTE) te;
                        return 0xff0000;
//                        return tileEntity.getShieldColor();
                    }
                }
                return 0xffffff;
            }
        }, this);
    }
ClientProxy.java 文件源码 项目:NaturalTrees 阅读 32 收藏 0 点赞 0 评论 0
@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);
}
SmartModelAttacher.java 文件源码 项目:EnderIO 阅读 25 收藏 0 点赞 0 评论 0
@SideOnly(Side.CLIENT)
public static void registerColoredBlocksAndItems() {
  NNList<Block> blocklist = new NNList<Block>();
  NNList<Item> itemlist = new NNList<Item>();
  for (RegistrationHolder<?, ?> holder : blocks) {
    Block block = holder.block;
    Item item = Item.getItemFromBlock(block);
    if (block instanceof IPaintable || block instanceof ITintedBlock || block instanceof ITintedItem || item instanceof ITintedItem) {
      blocklist.add(block);
      if (item != Items.AIR) {
        itemlist.add(item);
      }
    } else {
      if (block instanceof IBlockColor) {
        Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((IBlockColor) block, block);
      }
      if (item instanceof IItemColor) {
        Minecraft.getMinecraft().getItemColors().registerItemColorHandler((IItemColor) item, item);
      }
    }
  }

  PaintTintHandler handler = new PaintTintHandler();
  Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(handler, blocklist.toArray(new Block[0]));
  Minecraft.getMinecraft().getItemColors().registerItemColorHandler(handler, itemlist.toArray(new Item[0]));
}
LeavesGrassUtils.java 文件源码 项目:SeasonsAPI 阅读 100 收藏 0 点赞 0 评论 0
private static IBlockColor getFoliageColor (final IBlockColor original) {
    return new IBlockColor() {

        @Override
        public int colorMultiplier(IBlockState state, IBlockAccess p_186720_2_, BlockPos pos, int tintIndex) {
            return Seasons.enabled ? LeavesGrassUtils.getLeavesColor(state, p_186720_2_, pos, original.colorMultiplier(state, p_186720_2_, pos, tintIndex)) : original.colorMultiplier(state, p_186720_2_, pos, tintIndex);
        }
    };
}
LeavesGrassUtils.java 文件源码 项目:SeasonsAPI 阅读 19 收藏 0 点赞 0 评论 0
private static IBlockColor getGrassColor (final IBlockColor original) {
    return new IBlockColor() {

        @Override
        public int colorMultiplier(IBlockState state, IBlockAccess p_186720_2_, BlockPos pos, int tintIndex) {
            return Seasons.enabled ? LeavesGrassUtils.getGrassColor(state, p_186720_2_, pos, original.colorMultiplier(state, p_186720_2_, pos, tintIndex)) : original.colorMultiplier(state, p_186720_2_, pos, tintIndex);
        }
    };
}
AlchemyBlockColor.java 文件源码 项目:Alchemy 阅读 22 收藏 0 点赞 0 评论 0
@Override
@SideOnly(Side.CLIENT)
public IBlockColor getBlockColor() {
    return new IBlockColor() {

        @Override
        public int colorMultiplier(IBlockState state, IBlockAccess access, BlockPos pos, int index) {
            return index == 1 ? color : -1;
        }

    };
}
AlchemyColorLoader.java 文件源码 项目:Alchemy 阅读 25 收藏 0 点赞 0 评论 0
private static <T extends Block & IColorBlock> void registerBlockColor() {
    BlockColors colors = Minecraft.getMinecraft().getBlockColors();
    for (T t : (List<T>) block_color) {
        IBlockColor color = t.getBlockColor();
        if (color != null) {
            colors.registerBlockColorHandler(color, t);
            AlchemyInitHook.push_event(t);
        }
    }
}
ClientProxy.java 文件源码 项目:TechStack-s-HeavyMachineryMod 阅读 21 收藏 0 点赞 0 评论 0
@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);
}
RegisterColorHelper.java 文件源码 项目:NordMod 阅读 21 收藏 0 点赞 0 评论 0
@Override
public void registerBlockColorHandler(Block block){
    if (block instanceof IBlockColor){
        IBlockColor iBlockColor = (IBlockColor) block;
        blockColor.registerBlockColorHandler(iBlockColor,block);
    }
}
ClientProxy.java 文件源码 项目:FloodLights 阅读 22 收藏 0 点赞 0 评论 0
@Override
public void initRenderers() {
    ClientRegistry.bindTileEntitySpecialRenderer(TileEntityPhantomLight.class, new TileEntityPhantomLightRenderer());
    RenderUtil.setupColors();
    minecraft.getBlockColors().registerBlockColorHandler(new IBlockColor() {
        @Override
        public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int renderPass) {
            return getColorAsInt(state.getValue(BlockFLColorableMachine.COLOR));
        }
    },ModBlocks.blockCarbonLight,ModBlocks.blockElectricLight,ModBlocks.blockSmallElectricLight);
}
PaintTintHandler.java 文件源码 项目:EnderIO 阅读 20 收藏 0 点赞 0 评论 0
@Override
public int colorMultiplier(@Nonnull IBlockState state, @Nullable IBlockAccess world, @Nullable BlockPos pos, int tintIndex) {
  if (world == null || pos == null) {
    return -1;
  }
  Block block = state.getBlock();

  IBlockState paintSource = null;
  if (block instanceof IPaintable) {
    paintSource = ((IPaintable) block).getPaintSource(state, world, pos);
    if (paintSource != null && paintSource.getBlock() != block) {
      block = paintSource.getBlock();
      state = paintSource;
    } else {
      paintSource = null;
    }
  }
  if (block instanceof ITintedBlock) {
    return ((ITintedBlock) block).getBlockTint(state, world, pos, tintIndex);
  }
  if (block instanceof IBlockColor) {
    return ((IBlockColor) block).colorMultiplier(state, world, pos, tintIndex);
  }
  if (paintSource != null) {
    return Minecraft.getMinecraft().getBlockColors().colorMultiplier(paintSource, world, pos, tintIndex);
  }
  return -1;
}
ItemToolShard.java 文件源码 项目:BetterWithAddons 阅读 19 收藏 0 点赞 0 评论 0
@Override
public IBlockColor getBlockColor() {
    return null;
}
ItemSamuraiArmor.java 文件源码 项目:BetterWithAddons 阅读 21 收藏 0 点赞 0 评论 0
@Override
public IBlockColor getBlockColor() {
    return null;
}
BlockExtraGrass.java 文件源码 项目:BetterWithAddons 阅读 23 收藏 0 点赞 0 评论 0
@Override
public IBlockColor getBlockColor() {
    return ColorHandlers.GRASS_COLORING;
}
BlockEcksieSapling.java 文件源码 项目:BetterWithAddons 阅读 21 收藏 0 点赞 0 评论 0
@Override
public IBlockColor getBlockColor() {
    return null;
}
IColorable.java 文件源码 项目:BetterWithAddons 阅读 21 收藏 0 点赞 0 评论 0
@SideOnly(Side.CLIENT)
IBlockColor getBlockColor();
BlockWirePCB.java 文件源码 项目:BetterWithAddons 阅读 25 收藏 0 点赞 0 评论 0
@Override
public IBlockColor getBlockColor() {
    return ColorHandlers.REDSTONE_COLORING;
}
ProxyModBase.java 文件源码 项目:CommonUtils 阅读 20 收藏 0 点赞 0 评论 0
@SideOnly(Side.CLIENT)
public void addBlockColors(IBlockColor blockColor, Collection<Block> blocks) {
    addBlockColors(blockColor, blocks.toArray(new Block[0]));
}
ProxyModBase.java 文件源码 项目:CommonUtils 阅读 27 收藏 0 点赞 0 评论 0
@SideOnly(Side.CLIENT)
public void addBlockColors(IBlockColor blockColor, Block... blocks) {
    Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(blockColor, blocks);
}
IColorBlock.java 文件源码 项目:Alchemy 阅读 21 收藏 0 点赞 0 评论 0
@SideOnly(Side.CLIENT)
IBlockColor getBlockColor();
ClientProxy.java 文件源码 项目:ARKCraft 阅读 23 收藏 0 点赞 0 评论 0
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());
}
MMDLibRegistry.java 文件源码 项目:MMDLib-old 阅读 23 收藏 0 点赞 0 评论 0
@SideOnly(Side.CLIENT)
public static void registerBlockColour(Block block) {
    if (!(block instanceof IBlockColor)) return;
    Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((IBlockColor) block, block);
}
IColorfulBlock.java 文件源码 项目:Bookshelf 阅读 22 收藏 0 点赞 0 评论 0
@SideOnly(Side.CLIENT)
public IBlockColor getColorHandler ();
RegistryHelper.java 文件源码 项目:Bookshelf 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Registers a color handler for a block. This method is client side only, and should be
 * called during the init stage.
 *
 * @param block The block to register the handler for.
 * @param color The color handler to register.
 */
@SideOnly(Side.CLIENT)
public void registerColorHandler (@Nonnull Block block, @Nonnull IBlockColor color) {

    Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(color, block);
}


问题


面经


文章

微信
公众号

扫码关注公众号