@Override public void registerBlockVariants(String modId) { ResourceLocation[] rl = new ResourceLocation[4]; int i = 0; for (BlockMetalFurnace.Types type : BlockMetalFurnace.Types.values()) { if (!isBurning) rl[i] = new ResourceLocation(modId + "upgradedFurnace_" + type.getName()); else rl[i] = new ResourceLocation(modId + "upgradedFurnace_" + type.getName() + "_lit"); i++; } if (!isBurning) ModelBakery.registerItemVariants(Item.getItemFromBlock(ModBlocks.MetalFurnace), rl); else ModelBakery.registerItemVariants(Item.getItemFromBlock(ModBlocks.MetalFurnace_Lit), rl); }
@SideOnly(Side.CLIENT) public static void registerFluidModels(Fluid fluid) { if(fluid == null) { return; } Block block = fluid.getBlock(); if(block != null) { Item item = Item.getItemFromBlock(block); FluidStateMapper mapper = new FluidStateMapper(fluid); // item-model if(item != null) { ModelBakery.registerItemVariants(item); ModelLoader.setCustomMeshDefinition(item, mapper); } // block-model ModelLoader.setCustomStateMapper(block, mapper); } }
@Override @SideOnly(Side.CLIENT) public void initModel() { final Map<WolfArmor, ModelResourceLocation> models = Maps.newHashMap(); for(WolfArmor armor : new WolfArmor[]{WolfArmor.LEATHER, WolfArmor.CHAIN, WolfArmor.IRON, WolfArmor.DIRON, WolfArmor.DIAMOND, WolfArmor.GOLD}){ ModelResourceLocation loc = new ModelResourceLocation("crystalmod:wolfarmor", "armor="+armor.name().toLowerCase()); models.put(armor, loc); ModelBakery.registerItemVariants(this, loc); } ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return models.get(getWolfArmor(stack)); } }); }
@Override public Runnable getRegClient() { return new Runnable() { @Override public void run() { Item item = getComponent(); if (getComponent().getCreativeTab() == null) item.setCreativeTab(CreativeTabs.CREATIVE_TAB_ARRAY[getCreativeTabId()]); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(RegistryHelper.INSTANCE.currentMod() + ":" + getRegisterName(), "inventory")); ModelBakery.registerItemVariants(item, new ResourceLocation(RegistryHelper.INSTANCE.currentMod(), getRegisterName())); } }; }
@Override public Runnable getRegClient() { return new Runnable() { @Override public void run() { if (getComponent().getCreativeTabToDisplayOn() == null) getComponent().setCreativeTab(CreativeTabs.CREATIVE_TAB_ARRAY[getCreativeTabId()]); Item item = Item.getItemFromBlock(getComponent()); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(getComponent().getRegistryName(), "inventory")); ModelBakery.registerItemVariants(item, getComponent().getRegistryName()); } }; }
public static final void registerFluidsClient() { final ModelResourceLocation fluidSteamLocation = new ModelResourceLocation(QBarConstants.MODID + ":" + "blockfluidsteam", "steam"); ModelLoader.setCustomStateMapper(QBarFluids.blockFluidSteam, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(final IBlockState state) { return fluidSteamLocation; } }); ModelBakery.registerItemVariants(Item.getItemFromBlock(QBarFluids.blockFluidSteam), fluidSteamLocation); ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(QBarFluids.blockFluidSteam), stack -> fluidSteamLocation); }
@SideOnly(Side.CLIENT) public void registerRenderer() { IFluidBlock block = BlocksRegistry.liquidXpBlock; Item item = Item.getItemFromBlock((Block)block); assert (item == Items.AIR); ModelBakery.registerItemVariants(item); ModelResourceLocation modelResourceLocation = new ModelResourceLocation(MekfarmMod.MODID + ":fluids", this.getName()); ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return modelResourceLocation; } }); ModelLoader.setCustomStateMapper((Block) block, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return modelResourceLocation; } }); }
@SideOnly(Side.CLIENT) public void registerRenderer() { IFluidBlock block = BlocksRegistry.sewageBlock; Item item = Item.getItemFromBlock((Block)block); assert (item == Items.AIR); ModelBakery.registerItemVariants(item); ModelResourceLocation modelResourceLocation = new ModelResourceLocation(MekfarmMod.MODID + ":fluids", this.getName()); ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return modelResourceLocation; } }); ModelLoader.setCustomStateMapper((Block) block, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return modelResourceLocation; } }); }
private void registerVariantBlocks(ProxyModBase proxy) { for (InfoBlock block : proxy.blocks) { if (!(block instanceof InfoBlockVariant)) continue; InfoBlockVariant blockVar = (InfoBlockVariant) block; List<String> variants = Lists.newArrayList(); for (Object metalObj : blockVar.getVariantProp().getAllowedValues()) { IStringSerializable value = (IStringSerializable) metalObj; String name = proxy.getModId() + ":" + value.getName() + blockVar.getVariantSuffix(); variants.add(name); } ModelBakery.registerItemVariants(Item.getItemFromBlock(block.getBlock()), variants.stream().map(ResourceLocation::new).toArray(ResourceLocation[]::new)); ModelLoader.setCustomStateMapper(block.getBlock(), (new StateMap.Builder()).withName(blockVar.getVariantProp()) .withSuffix(blockVar.getVariantSuffix()) .build()); } }
public void registerFluidModel(Block block) { Item item = Item.getItemFromBlock(block); ModelBakery.registerItemVariants(item); final ModelResourceLocation loc = new ModelResourceLocation(Reference.MODID + ":fluid", "liquidmalgra"); ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return loc; } }); ModelLoader.setCustomStateMapper(block, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return loc; } }); }
@Override public void preInit(FMLPreInitializationEvent event) { super.preInit(event); for (final String name : Fluids.getFluidBlockRegistry().keySet()) { final Block block = Fluids.getFluidBlockByName(name); final Item item = Item.getItemFromBlock(block); if (!item.getRegistryName().getResourceDomain().equals(BaseGems.MODID)) continue; final ModelResourceLocation fluidModelLocation = new ModelResourceLocation(item.getRegistryName().getResourceDomain() + ":" + name, "fluid"); ModelBakery.registerItemVariants(item); ModelLoader.setCustomMeshDefinition(item, stack -> fluidModelLocation); ModelLoader.setCustomStateMapper(block, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return fluidModelLocation; } }); } }
@SideOnly(Side.CLIENT) public void initModelsAndVariants() { if (getCustomMeshDefinition() != null) { ModelLoader.setCustomMeshDefinition(this, getCustomMeshDefinition()); for (int i = 0; i < VARIANTS.length; i++) { ModelBakery.registerItemVariants(this, getCustomModelResourceLocation(VARIANTS[i])); } } else { if (!getHasSubtypes()) { ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(getRegistryName().toString())); } else { for (int i = 0; i < VARIANTS.length; i++) { ModelLoader.setCustomModelResourceLocation(this, i, getCustomModelResourceLocation(VARIANTS[i])); } } } }
@SideOnly(Side.CLIENT) @Override public void registerRender() { ModelResourceLocation[] locations = new ModelResourceLocation[]{ new ModelResourceLocation(this.getRegistryName() + "_empty", "inventory"), new ModelResourceLocation(this.getRegistryName() + "_chest", "inventory"), new ModelResourceLocation(this.getRegistryName() + "_storage_core", "inventory") }; ModelBakery.registerItemVariants(this, locations); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { if(stack.hasTagCompound() && stack.getTagCompound().getBoolean("isFull")) { if(stack.getTagCompound().getBoolean("isChest")) { return locations[1]; } if(stack.getTagCompound().getBoolean("isStorageCore")) { return locations[2]; } } return locations[0]; } }); }
@SideOnly(Side.CLIENT) public static void bakeModels(String modID){ for(Fluid fluid : fluidBlocks.keySet()){ BlockFluidBase block = fluidBlocks.get(fluid); Item item = Item.getItemFromBlock(block); final ModelResourceLocation fluidModelLocation = new ModelResourceLocation( modID.toLowerCase() + ":" + fluidBlockNames.get(block), "fluid"); ModelBakery.registerItemVariants(item); ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { public ModelResourceLocation getModelLocation(ItemStack stack) { return fluidModelLocation; } }); ModelLoader.setCustomStateMapper(block, new StateMapperBase() { protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return fluidModelLocation; } }); } }
private void registerFluidModel(Block fluidBlock, String name) { Item item = Item.getItemFromBlock(fluidBlock); ModelBakery.registerItemVariants(item); final ModelResourceLocation modelResourceLocation = new ModelResourceLocation("abyssalcraft:fluid", name); ModelLoader.setCustomMeshDefinition(item, stack -> modelResourceLocation); ModelLoader.setCustomStateMapper(fluidBlock, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState p_178132_1_) { return modelResourceLocation; } }); }
@SubscribeEvent public static void registerModels(final ModelRegistryEvent event) { ModelLoader.setCustomModelResourceLocation(SWItems.DOG_TAG, 0, Resources.DOG_TAG_MODEL); ModelLoader.setCustomModelResourceLocation(SWItems.DOG_TREAT, 0, Resources.DOG_TREAT_MODEL); ModelLoader.setCustomModelResourceLocation(SWItems.WHISTLE, 0, Resources.WHISTLE_MODEL); ModelLoader.setCustomModelResourceLocation(SWItems.PET_CARRIER, 0, Resources.PET_CARRIER_MODEL); for (EnumWolfSpecies wolfSpecies : EnumWolfSpecies.values()) { ModelLoader.setCustomModelResourceLocation(SWItems.DOG_EGG, wolfSpecies.ordinal(), Resources.SPAWN_EGG_MODEL); } ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(SWBlocks.DOG_BOWL), 0, Resources.DOG_BOWL); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(SWBlocks.DOG_BOWL), 1, Resources.DOG_BOWL1); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(SWBlocks.DOG_BOWL), 2, Resources.DOG_BOWL2); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(SWBlocks.DOG_BOWL), 3, Resources.DOG_BOWL3); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(SWBlocks.DOG_BOWL), 4, Resources.DOG_BOWL4); ModelBakery.registerItemVariants(SWBlocks.DOG_BOWL_IB, Resources.DOG_BOWL, Resources.DOG_BOWL1, Resources.DOG_BOWL2, Resources.DOG_BOWL3, Resources.DOG_BOWL4); }
public void registerRender() { int i = 0; Item item = Item.getItemFromBlock(this); ResourceLocation[] list = new ResourceLocation[getVariantNames().size()]; for (String s : getVariantNames()) { String loc = this.getRegistryName().toString();// +"#variants="+s; ResourceLocation res = new ResourceLocation(loc); ModelResourceLocation mrl = new ModelResourceLocation(loc, "variants=" + s); ModelLoader.setCustomModelResourceLocation(item, i, mrl); list[i] = res; i++; } ModelBakery.registerItemVariants(Item.getItemFromBlock(this), list); }
public static void register(IFCustomFluidBlock base) { Item fluid = Item.getItemFromBlock(base); ModelBakery.registerItemVariants(fluid); FluidStateMapper mapper = new FluidStateMapper(base.getName()); ModelLoader.setCustomMeshDefinition(fluid, mapper); ModelLoader.setCustomStateMapper(base, mapper); }
@SubscribeEvent public void onModelRegistry(ModelRegistryEvent event) { ModelLoader.setCustomModelResourceLocation(Torched.itemTorchGun, 0, new ModelResourceLocation("torched:torchgun", "inventory")); ModelLoader.setCustomModelResourceLocation(Torched.itemTorchFirework, 0, new ModelResourceLocation("torched:torchfirework", "inventory")); ModelLoader.setCustomModelResourceLocation(Torched.itemTorchFirework, 1, new ModelResourceLocation("torched:torchrpt", "inventory")); ModelLoader.setCustomModelResourceLocation(Torched.itemTorchLauncher, 0, new ModelResourceLocation("torched:torchlauncher", "inventory")); ModelBakery.registerItemVariants(Torched.itemTorchFirework, new ResourceLocation("torched", "torchfirework"), new ResourceLocation("torched", "torchrpt")); }
@SideOnly(Side.CLIENT) public static void initModels() { Item item = Item.getItemFromBlock(ModBlocks.liquid_butter); ModelBakery.registerItemVariants(item); ModelResourceLocation location = new ModelResourceLocation("btweagles:fluid", "liquid_butter"); ModelLoader.setCustomMeshDefinition(item, stack -> location); ModelLoader.setCustomStateMapper(ModBlocks.liquid_butter, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return location; } }); }
@SideOnly(Side.CLIENT) @Override public void initModel(){ ModelBakery.registerItemVariants(this, new ModelResourceLocation(Melodium.MODID+":composition_paper"), new ModelResourceLocation(Melodium.MODID+":song_paper")); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition(){ @Override public ModelResourceLocation getModelLocation(ItemStack stack) { if (isLearned(stack)){ return new ModelResourceLocation(Melodium.MODID+":song_paper"); } return new ModelResourceLocation(Melodium.MODID+":composition_paper"); } }); }
@Override public void registerModelBakeryVariants() { ModelBakery.registerItemVariants(ModItems.itemChip, new ResourceLocation(Refs.MOD_ID, "chip_basic"), new ResourceLocation(Refs.MOD_ID, "chip_advanced")); ModelBakery.registerItemVariants(Item.getItemFromBlock(ModBlocks.blockBreaker), new ResourceLocation(Refs.MOD_ID, "blockBreaker_basic"), new ResourceLocation(Refs.MOD_ID, "blockBreaker_advanced")); }
/** * Helper method for registering all itemstacks for given item to map to universal bucket model. */ public static void setBucketModelDefinition(Item item) { ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return ModelDynBucket.LOCATION; } }); ModelBakery.registerItemVariants(item, ModelDynBucket.LOCATION); }
@Override public void registerBlockVariants(String modId) { ResourceLocation[] rl = new ResourceLocation[BlockMobChest.Mobs.values().length]; int i = 0; for (BlockMobChest.Mobs mob : BlockMobChest.Mobs.values()) { rl[i] = new ResourceLocation(modId + "mobChest_" + mob.getName()); i++; } ModelBakery.registerItemVariants(Item.getItemFromBlock(ModBlocks.MobChests), rl); }
@Override public void registerBlockVariants(String modId) { ModelBakery.registerItemVariants( Item.getItemFromBlock(ModBlocks.VanillaCraftingTables), new ResourceLocation(modId + "vanillaCraftingTable_acacia"), new ResourceLocation(modId + "vanillaCraftingTable_birch"), new ResourceLocation(modId + "vanillaCraftingTable_darkoak"), new ResourceLocation(modId + "vanillaCraftingTable_jungle"), new ResourceLocation(modId + "vanillaCraftingTable_spruce") ); }
@Override public void registerBlockVariants(String modId) { ResourceLocation[] rl = new ResourceLocation[16]; int i = 0; for (EnumDyeColor color : EnumDyeColor.values()) { rl[i] = new ResourceLocation(modId + "stainedClearGlass_" + color.getName()); i++; } ModelBakery.registerItemVariants(Item.getItemFromBlock(ModBlocks.StainedClearGlass), rl); }
@Override @SideOnly(Side.CLIENT) public void initModel(){ ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return ModelWrappedFood.LOCATION; } }); ModelBakery.registerItemVariants(this, ModelWrappedFood.LOCATION); }
@Override @SideOnly(Side.CLIENT) public void initModel(){ ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return ModelSeed.LOCATION; } }); ModelBakery.registerItemVariants(this, ModelSeed.LOCATION); }
@Override @SideOnly(Side.CLIENT) public void initModel() { final ModelResourceLocation locUnBound = new ModelResourceLocation("crystalmod:telepearl", "bound=false"); final ModelResourceLocation locBound = new ModelResourceLocation("crystalmod:telepearl", "bound=true"); ModelBakery.registerItemVariants(this, locUnBound, locBound); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { boolean bound = !ItemStackTools.isNullStack(stack) && stack.hasTagCompound() && ItemNBTHelper.verifyExistance(stack, "TeleportLocation"); return bound ? locBound : locUnBound; } }); }
@Override @SideOnly(Side.CLIENT) public void initModel() { final ModelResourceLocation off = new ModelResourceLocation(getRegistryName(), "on=false"); ModelBakery.registerItemVariants(this, off); final ModelResourceLocation on = new ModelResourceLocation(getRegistryName(), "on=true"); ModelBakery.registerItemVariants(this, on); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return ItemNBTHelper.getBoolean(stack, NBT_ON, false) ? on : off; } }); }
@Override @SideOnly(Side.CLIENT) public void initModel() { final ModelResourceLocation loc = new ModelResourceLocation("crystalmod:item_wirelesspanel", "active=false"); ModelBakery.registerItemVariants(this, loc); final ModelResourceLocation active = new ModelResourceLocation("crystalmod:item_wirelesspanel", "active=true"); ModelBakery.registerItemVariants(this, active); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return isValid(stack) ? active : loc; } }); }
@SideOnly(Side.CLIENT) public static void registerRendersForLinker2() { ModelBakery.registerItemVariants(INSTANCE); ModelLoader.setCustomMeshDefinition(INSTANCE, MeshDefinitionFix.create(stack -> { if (isActive(stack)) { return modelOn; } else { return model; } })); ModelLoader.registerItemVariants(INSTANCE, new ModelResourceLocation[] { model, modelOn }); }
public static void registerItemRenderer(Item item, int meta, ResourceLocation name) { ModelBakery.registerItemVariants(item, name); ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(name, "inventory")); }
@Override public void registerItemVariantModel(Item item, String name, int metadata) { if (item != null) { ModelBakery.registerItemVariants(item, new ResourceLocation("homesweethome:" + name)); ModelLoader.setCustomModelResourceLocation(item, metadata, new ModelResourceLocation(HomeSweetHome.MOD_ID + ":" + name, "inventory")); } }
@SideOnly(Side.CLIENT) public static void initModels() { final ItemMeshDefinition ORES = new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { switch (stack.getItemDamage()) { case 0: return new ModelResourceLocation("exnihiloadscensio:itemOre", "type=piece"); case 1: return new ModelResourceLocation("exnihiloadscensio:itemOre", "type=hunk"); case 2: return new ModelResourceLocation("exnihiloadscensio:itemOre", "type=dust"); case 3: return new ModelResourceLocation("exnihiloadscensio:itemOre", "type=ingot"); default: return new ModelResourceLocation(stack.getItem().getRegistryName(), "inventory"); } } }; for (ItemOre ore : itemOreRegistry) { ModelLoader.setCustomMeshDefinition(ore, ORES); ModelBakery.registerItemVariants(ore, new ModelResourceLocation("exnihiloadscensio:itemOre", "type=piece"), new ModelResourceLocation("exnihiloadscensio:itemOre", "type=hunk"), new ModelResourceLocation("exnihiloadscensio:itemOre", "type=dust"), new ModelResourceLocation("exnihiloadscensio:itemOre", "type=ingot")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(ore, ORES); } }
public static void registerVariants (Item item, String modid, String... locations) { final ResourceLocation[] variantArray = new ResourceLocation[locations.length]; for (int i = 0; i < locations.length; i++) variantArray[i] = new ResourceLocation(modid, item.getUnlocalizedName() + "_" + locations[i]); ModelBakery.registerItemVariants(item, variantArray); for (final String location : locations) registerModel(item, new ResourceLocation(modid, item.getUnlocalizedName() + "_" + location)); }
public static void registerVariants (Block block, String modid, String... locations) { final ResourceLocation[] variantArray = new ResourceLocation[locations.length]; for (int i = 0; i < locations.length; i++) variantArray[i] = new ResourceLocation(modid, block.getUnlocalizedName() + "_" + locations[i]); ModelBakery.registerItemVariants(Item.getItemFromBlock(block), variantArray); for (final String location : locations) registerModel(block, new ResourceLocation(modid, block.getUnlocalizedName() + "_" + location)); }
/** * Регистрация модели для предмета по ресурсу * @param item предмет * @param fullModelLocation ресурс */ @Override public void registerItemModel(Item item, final ModelResourceLocation fullModelLocation) { ModelBakery.registerItemVariants(item, fullModelLocation); // Ensure the custom model is loaded and prevent the default model from being loaded // registerItemModel(item, MeshDefinitionFix.create(stack -> fullModelLocation)); registerItemModel(item,new ItemMesh(fullModelLocation)); }
@Override public void registerItemRender(Item item, int sub, String name, String modid) { ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation(modid + ":" + name, "inventory"); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, sub, itemModelResourceLocation); ModelBakery.registerItemVariants(item, itemModelResourceLocation); }
@Override public void registerBlockRender(Block block, int sub, String model, String modid) { ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation(modid + ":" + model, "inventory"); ModelBakery.registerItemVariants(Item.getItemFromBlock(block), itemModelResourceLocation); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), sub, itemModelResourceLocation); }