net.minecraftforge.registries.IRegistryDelegate Java Examples

The following examples show how to use net.minecraftforge.registries.IRegistryDelegate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Foliage.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void registerExtendedBlockColor(BlockColors bc, IExtendedBlockColor extColor, Block... blocks) {
	Map<IRegistryDelegate<Block>, IBlockColor> internalMap = ObfuscationReflectionHelper.getPrivateValue(BlockColors.class, bc, "blockColorMap"); //forge-added field in 1.12, no srg name available
	//TODO someone test this in obf lol
	
	for(Block b : blocks) {
		IRegistryDelegate<Block> delegate = b.delegate;
		IBlockColor regularColor = internalMap.get(delegate);
		
		bc.registerBlockColorHandler(((state, world, pos, tintIndex) -> extColor.colorMultiplierExt(regularColor, state, world, pos, tintIndex)), b);
	}
}
 
Example #2
Source File: MixinItemModelMesherForge.java    From VanillaFix with MIT License 5 votes vote down vote up
/**
 * @reason Don't get all models during init (with dynamic loading, that would
 * generate them all). Just store location instead.
 **/
@Overwrite
@Override
public void register(Item item, int meta, ModelResourceLocation location) {
    IRegistryDelegate<Item> key = item.delegate;
    TIntObjectHashMap<ModelResourceLocation> locs = locations.get(key);
    if (locs == null) {
        locs = new TIntObjectHashMap<>();
        locations.put(key, locs);
    }
    locs.put(meta, location);
}