@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)); } }); }
public static void registerBlockWithStateMapper(Block block) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getModelManager().getBlockModelShapes().registerBlockWithStateMapper(block, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return new ModelResourceLocation(state.getBlock().getRegistryName(), "normal"); } }); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return new ModelResourceLocation(stack.getItem().getRegistryName(), "inventory"); } }); }
@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; } }); }
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 registerISensitiveMeshes(Collection<Item> items) { for (Item it : items) { if (!(it instanceof ISensitiveMesh)) { continue; } final ISensitiveMesh ism = (ISensitiveMesh) it; ModelLoader.setCustomMeshDefinition(it, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { String meshName = ism.getMeshName(stack); return new ModelResourceLocation("factorization:" + meshName + "#inventory"); } }); for (ItemStack is : ism.getMeshSamples()) { ModelLoader.addVariantName(it, "factorization:" + ism.getMeshName(is)); } } }
@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]; } }); }
@Override public void postRegisterBlock(FWBlock block) { super.postRegisterBlock(block); //Hack to inject custom itemblock definition Item itemFromBlock = Item.getItemFromBlock(block); ModelLoader.setCustomMeshDefinition(itemFromBlock, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { ResourceLocation itemRL = (ResourceLocation) Item.itemRegistry.getNameForObject(itemFromBlock); return new ModelResourceLocation(itemRL, "inventory"); } } ); }
@Override public Optional<ItemMeshDefinition> __getCustomMeshDefinition() { // DO NOT use a lambda here, converting this code to a lambda results // in the model being unresolvable //noinspection Convert2Lambda return Optional.of(new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { Optional<org.spongepowered.api.item.inventory.ItemStack> optContained = getPrizeStack(stack); return optContained.isPresent() ? new ModelResourceLocation( optContained.get().getItem().getId(), "inventory" ) : null; } }); }
@SideOnly(Side.CLIENT) public static void buildRenderFor(Block block, String name) { final ModelResourceLocation fluidLocation = new ModelResourceLocation(MReference.MODID + ":" + name, "fluid"); Item fluid = Item.getItemFromBlock(block); ModelBakery.addVariantName(fluid); ModelLoader.setCustomMeshDefinition(fluid, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return fluidLocation; } }); ModelLoader.setCustomStateMapper(block, new StateMapperBase() { @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return fluidLocation; } }); }
public static void preInit() { for (final ItemLootBag item : ItemLootBag.getLootBags()) { // IDK which one is effective, or which one is recommended. So I'm using them all. // The modeling system is confusing... ModelLoader.registerItemVariants(item, new ModelResourceLocation(item.texture), new ModelResourceLocation(item.texture, "inventory")); ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return new ModelResourceLocation(item.texture); } }); ModelLoader.registerItemVariants(item, new ModelResourceLocation(item.texture)); ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.texture)); } }
@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 registerModelLocation(final Item item, final String name, final String type) { RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); //System.out.println("registerModelLocation for " + name); if (renderItem != null) { renderItem.getItemModelMesher().register(item, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { //System.out.println(name + "/" + stack.getUnlocalizedName()); if (item instanceof ISubtypeFromStackPovider && ((ISubtypeFromStackPovider)item).getSubType(stack) != null) { //System.out.println(ModInfo.ModID + ":" + name + "/" + ((ISubtypeFromStackPovider)item).getSubType(stack)); return new ModelResourceLocation(ModInfo.ModID + ":" + name + "/" + ((ISubtypeFromStackPovider)item).getSubType(stack), type); } else { return new ModelResourceLocation(ModInfo.ModID + ":" + name, type); } } }); } }
@SuppressWarnings("unchecked") private void reflectMaps() { if (LOCATIONS == null || SHAPERS == null) { try { ItemModelMesher mesher = Minecraft.getMinecraft().getRenderItem().getItemModelMesher(); Field locs = ReflectionHelper.findField(ItemModelMesherForge.class, "locations"); LOCATIONS = (Map<IRegistryDelegate<Item>, TIntObjectHashMap<ModelResourceLocation>>) locs.get(mesher); Field shapers = ReflectionHelper.findField(ItemModelMesher.class, "field_178092_c", "shapers"); SHAPERS = (Map<Item, ItemMeshDefinition>) shapers.get(mesher); Field models = ReflectionHelper.findField(ModelLoader.class, "stateModels"); STATE_MODELS = (Map<ModelResourceLocation, IModel>) models.get(MODEL_LOADER); } catch (Exception e) { EnderUtilities.logger.warn("ModelNullifierBaked: Failed to reflect model maps", e); } } }
@Override @SideOnly(Side.CLIENT) public void registerResources() { String[] variants = getVariants(); models = new ArrayList<ModelResourceLocation>(variants.length); for (int i = 0; i < variants.length; ++i) { models.add(new ModelResourceLocation(variants[i], "inventory")); } ModelLoader.registerItemVariants(this, models.toArray(new ModelResourceLocation[0])); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return models.get(0); } }); }
@Override @SideOnly(Side.CLIENT) public void registerResources() { String[] variants = getVariants(); this.models = new ArrayList<ModelResourceLocation>(variants.length); for (int i = 0; i < variants.length; ++i) { this.models.add(new ModelResourceLocation(variants[i], "inventory")); } ModelLoader.registerItemVariants(this, this.models.toArray(new ModelResourceLocation[0])); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return models.get(0); } }); }
/** * Pedestal has two variants, one each using meta 0 and 8 */ @Override @SideOnly(Side.CLIENT) public void registerResources() { String[] variants = getVariants(); this.models = new ArrayList<ModelResourceLocation>(variants.length); for (int i = 0; i < variants.length; ++i) { this.models.add(new ModelResourceLocation(variants[i], "inventory")); } ModelLoader.registerItemVariants(this, this.models.toArray(new ModelResourceLocation[0])); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return models.get(stack.getItemDamage() == 8 ? 1 : 0); } }); }
@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"); } }); }
/** * 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); }
@Load(side = Side.CLIENT) @SideOnly(Side.CLIENT) public void loadRenders() { try { Field field = ModelLoader.class.getDeclaredField("customMeshDefinitions"); field.setAccessible(true); Map<IRegistryDelegate<Item>, ItemMeshDefinition> customMeshDefinitions = (Map<IRegistryDelegate<Item>, ItemMeshDefinition>) field.get(null); cachedLiqueurs.forEach(liqueur -> { if (customMeshDefinitions.containsKey(liqueur)) ModelLoader.setCustomModelResourceLocation(liqueur, 0, customMeshDefinitions.get(liqueur).getModelLocation(new ItemStack(liqueur))); }); } catch (Exception e) { FoodCraftReloaded.getLogger().error("Cannot get custom mesh definitions", e); } }
@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 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 registerModel(IVariantHolder holder) { ItemMeshDefinition def = holder.getCustomMeshDefinition(); if(holder.getCustomMeshDefinition() != null) ModelLoader.setCustomMeshDefinition((Item)holder, def); else registerModel((Item)holder,holder.getVariants()); }
@SideOnly(Side.CLIENT) public void initModel() { List<ModelResourceLocation> resources = new ArrayList<>(); for (DishInfo info : dishInfos) { resources.add(new ModelResourceLocation(getRegistryName(), "food=" + info.getTag())); } ModelLoader.registerItemVariants(this, resources.toArray(new ModelResourceLocation[resources.size()])); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return new ModelResourceLocation(getRegistryName(), "food=" + dishInfos[stack.getItemDamage()].getTag()); } }); }
@Override public void registerItem(FWItem item) { super.registerItem(item); //Hacks to inject custom item definition ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { ResourceLocation itemRL = (ResourceLocation) Item.itemRegistry.getNameForObject(item); return new ModelResourceLocation(itemRL, "inventory"); } } ); }
@SuppressWarnings("unused") private void render(Object item) { if (item instanceof Item && item instanceof ICustomItem) { if (Sponge.getPlatform().getExecutionType().isClient()) { RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); ItemModelMesher mesher = renderItem.getItemModelMesher(); Optional<ItemMeshDefinition> optMeshDefinition = ((ICustomItem) item).__getCustomMeshDefinition(); if (optMeshDefinition.isPresent()) { mesher.register((Item) item, optMeshDefinition.get()); } List<String> variants = ((ICustomItem) item).__getMeshDefinitions(); List<ResourceLocation> modelResources = new ArrayList<>(); for (int i = 0; i < variants.size(); ++i) { ModelResourceLocation resourceLocation = new ModelResourceLocation( "skree:" + variants.get(i), "inventory" ); if (!optMeshDefinition.isPresent()) { mesher.register((Item) item, i, resourceLocation); } modelResources.add(resourceLocation); } ModelBakery.registerItemVariants( (Item) item, modelResources.toArray(new ResourceLocation[modelResources.size()]) ); } } else { throw new IllegalArgumentException("Invalid custom item!"); } }
private void setgrapplebowtextures(Item item, final ModelResourceLocation notinusetexture, final ModelResourceLocation inusetexture) { ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { if (ClientProxyClass.isactive(stack)) { return inusetexture; } return notinusetexture; } }); ModelBakery.registerItemVariants(item, notinusetexture); ModelBakery.registerItemVariants(item, inusetexture); }
@Override @SideOnly(Side.CLIENT) public void initModel() { final ModelResourceLocation hammerModel = new ModelResourceLocation(Reference.MOD_ID + ":" + BASENAME + ".HAMMER", "inventory"); final ModelResourceLocation wrenchModel = new ModelResourceLocation(Reference.MOD_ID + ":" + BASENAME + ".BCWRENCH", "inventory"); final ModelResourceLocation paintModel = new ModelResourceLocation(Reference.MOD_ID + ":" + BASENAME + ".DECORATE", "inventory"); final ModelResourceLocation configModel = new ModelResourceLocation(Reference.MOD_ID + ":" + BASENAME + ".CONFIG", "inventory"); ModelBakery.registerItemVariants(this, hammerModel, wrenchModel, paintModel, configModel); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { MalletMode m = getMode(stack); if (m == MalletMode.HAMMER) return hammerModel; else if (m == MalletMode.BCWRENCH) return wrenchModel; else if (m == MalletMode.CONFIG) return configModel; else return paintModel; } }); }
@Nullable private IModel getItemModel(ItemStack stack) { // Unfortunately this can't be done before the init phase... this.reflectMaps(); Item item = stack.getItem(); ModelResourceLocation mrl = null; TIntObjectHashMap<ModelResourceLocation> map = LOCATIONS.get(item.delegate); if (map != null) { mrl = map.get(stack.getMetadata()); } if (mrl == null) { ItemMeshDefinition mesh = SHAPERS.get(item); if (mesh != null) { mrl = mesh.getModelLocation(stack); } } if (mrl != null) { try { return ModelLoaderRegistry.getModel(mrl); } catch (Exception e) { return STATE_MODELS.get(mrl); } } return null; }
/** * Adds fluid block models to the game and applies them to the fluid blocks */ @SideOnly(Side.CLIENT) public static void bakeModels(){ String modID = PowerAdvantage.MODID; for(Map.Entry<String,Block> e : allBlocks.entrySet()){ Block b = e.getValue(); String name = e.getKey(); if(b instanceof BlockFluidBase){ BlockFluidBase block = (BlockFluidBase)b; Fluid fluid = block.getFluid(); Item item = Item.getItemFromBlock(block); final ModelResourceLocation fluidModelLocation = new ModelResourceLocation( modID.toLowerCase() + ":" + name, "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; } }); } } }
/** * Register same base texture for each egg subtype */ @Override @SideOnly(Side.CLIENT) public void registerResources() { this.model = new ModelResourceLocation("minecraft:spawn_egg", "inventory"); ModelLoader.registerItemVariants(this, this.model); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return ItemCustomEgg.this.model; } }); }
@Override @SideOnly(Side.CLIENT) public void registerResources() { this.model = new ModelResourceLocation(ModInfo.ID + ":warp_stone", "inventory"); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return ItemWarpStone.this.model; // All use same texture for now } }); }
/** * Required or smart model will not work */ @Override @SideOnly(Side.CLIENT) public void registerResources() { ModelLoader.registerItemVariants(this, ModelDynamicItemBlock.resource); ModelLoader.setCustomMeshDefinition(this, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return ModelDynamicItemBlock.resource; } }); }
@Override public void registerRender() { models = new HashMap<String, ModelResourceLocation>(); String[] modelPaths = new String[] { "rafradek_blocklauncher:block_cannon", "rafradek_blocklauncher:block_rifle", "rafradek_blocklauncher:block_shotgun", "rafradek_blocklauncher:block_thrower", "rafradek_blocklauncher:tnt_launcher", "rafradek_blocklauncher:tnt_launcher_2", "rafradek_blocklauncher:block_chaingun", "rafradek_blocklauncher:block_sniper", "rafradek_blocklauncher:tnt_mines" }; for (String string : modelPaths) { ModelResourceLocation model = new ModelResourceLocation(string, "inventory"); models.put(string, model); ModelBakery.registerItemVariants(BlockLauncher.cannon, model); } ModelLoader.setCustomMeshDefinition(BlockLauncher.cannon, new ItemMeshDefinition() { @Override public ModelResourceLocation getModelLocation(ItemStack p_178113_1_) { int type = BlockLauncher.cannon.getType(p_178113_1_); if (type == 0) return models.get("rafradek_blocklauncher:block_rifle"); else if (type == 1) return models.get("rafradek_blocklauncher:block_cannon"); else if (type == 2) return models.get("rafradek_blocklauncher:block_shotgun"); else if (type == 3) return models.get("rafradek_blocklauncher:block_thrower"); else if (type == 4) return models.get("rafradek_blocklauncher:block_chaingun"); else if (type == 5) return models.get("rafradek_blocklauncher:block_sniper"); else if (type == 16) return models.get("rafradek_blocklauncher:tnt_launcher"); else if (type == 17) // if(stack.getTagCompound().getInteger("wait")<=0) return models.get("rafradek_blocklauncher:tnt_launcher_2"); // else // return this.tntlauncherEmptyIcon; else if (type == 18) // if(stack.getTagCompound().getInteger("wait")<=0) return models.get("rafradek_blocklauncher:tnt_mines"); // else // return this.tntlauncherEmptyIcon; return models.get("rafradek_blocklauncher:block_cannon"); } }); // ModelBakery.addVariantName(BlockLauncher.launchpart, // "rafradek_blocklauncher:launchpart","rafradek_blocklauncher:launchpart_better"); ModelLoader.setCustomModelResourceLocation(BlockLauncher.launchpart, 0, new ModelResourceLocation("rafradek_blocklauncher:launchpart", "inventory")); ModelLoader.setCustomModelResourceLocation(BlockLauncher.launchpartBetter, 0, new ModelResourceLocation("rafradek_blocklauncher:launchpart_better", "inventory")); RenderingRegistry.registerEntityRenderingHandler(EntityFallingEnchantedBlock.class, new IRenderFactory<EntityFallingEnchantedBlock>() { @Override public RenderFallingBlock createRenderFor(RenderManager manager) { // TODO Auto-generated method stub return new RenderFallingBlock(manager); } }); }
/** * Adds generic ItemStack -> model variant logic. * You still need to manually call ModelBakery.registerItemVariants with all values that meshDefinition can return. */ public static void setCustomMeshDefinition(Item item, ItemMeshDefinition meshDefinition) { customMeshDefinitions.put(item.delegate, meshDefinition); }