@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); }
@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); }
@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])); }
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); } }; }
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); } }; }
@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; } }; }
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); } } }
@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); }
@Override public void registerBlockColorHandler(Block block){ if (block instanceof IBlockColor){ IBlockColor iBlockColor = (IBlockColor) block; blockColor.registerBlockColorHandler(iBlockColor,block); } }
@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); }
@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; }
@Override public IBlockColor getBlockColor() { return null; }
@Override public IBlockColor getBlockColor() { return ColorHandlers.GRASS_COLORING; }
@SideOnly(Side.CLIENT) IBlockColor getBlockColor();
@Override public IBlockColor getBlockColor() { return ColorHandlers.REDSTONE_COLORING; }
@SideOnly(Side.CLIENT) public void addBlockColors(IBlockColor blockColor, Collection<Block> blocks) { addBlockColors(blockColor, blocks.toArray(new Block[0])); }
@SideOnly(Side.CLIENT) public void addBlockColors(IBlockColor blockColor, Block... blocks) { Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(blockColor, blocks); }
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()); }
@SideOnly(Side.CLIENT) public static void registerBlockColour(Block block) { if (!(block instanceof IBlockColor)) return; Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((IBlockColor) block, block); }
@SideOnly(Side.CLIENT) public IBlockColor getColorHandler ();
/** * 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); }