@Override public ModelResourceLocation getSubTileBlockModelForName(String name) { return new ModelResourceLocation("builtin/missing", "missing"); }
if( !location.getResourceDomain().equals( AppEng.MOD_ID ) ) BiFunction<ModelResourceLocation, IBakedModel, IBakedModel> customizer = this.customizer.get( location.getResourcePath() ); if( customizer != null )
/** * Register your model for the given subtile class here. * Call this DURING PREINIT. * Your model json must specify key "tintindex" in all the faces it wants tint applied. * Tint is applied whenever a player recolors the flower using floral dye * * @param subTileName The String ID of the subtile * @param model A path to a blockstate json and variant to be used the block. The item model will be drawn from the same blockstate json, from variant "inventory" */ public static void registerSubtileModel(String subTileName, ModelResourceLocation model) { registerSubtileModel(subTileName, model, new ModelResourceLocation(model.getNamespace() + ":" + model.getPath(), "inventory")); }
ModelResourceLocation itemMrl = new ModelResourceLocation(defaultMrl.getResourceDomain() + ":" + defaultMrl.getResourcePath() + "#inventory"); event.getModelRegistry().putObject(itemMrl, model); ModelResourceLocation itemMrl = new ModelResourceLocation(defaultMrl.getResourceDomain() + ":" + defaultMrl.getResourcePath() + "#inventory"); final IBakedModel model = event.getModelRegistry().getObject(itemMrl); if (model == null || model == missingModel) {
@Nonnull @Override public ModelResourceLocation getModelLocation(@Nonnull ItemStack stack) { ModelResourceLocation emptyQuiver = empty.getModelLocation(stack); if(HAS_ARROW.apply(stack, null, null) > 0){ String variant = emptyQuiver.getVariant(); String path = emptyQuiver.toString().replace("#"+variant, suf); return new ModelResourceLocation(path, variant); } return emptyQuiver; } }
@Override public IModel loadModel(ResourceLocation modelLocation) { ModelResourceLocation location = (ModelResourceLocation) modelLocation; ResourceLocation registryName = new ResourceLocation(Constants.MOD_ID, location.getVariant()); Item item = ForgeRegistries.ITEMS.getValue(registryName); if (!(item instanceof ItemCrated)) { return ModelLoaderRegistry.getModelOrMissing(new ModelResourceLocation(modelLocation, "inventory")); } ItemCrated crated = (ItemCrated) item; return new ModelCrate(crated); }
@SubscribeEvent @SideOnly(Side.CLIENT) public void onBakedEvent(ModelBakeEvent e) { //Find all ExtraTrees saplings List<ModelResourceLocation> models = e.getModelRegistry().getKeys().stream() .filter(mrl -> mrl.getResourceDomain().startsWith(Constants.EXTRA_TREES_MOD_ID)) .filter(mrl -> mrl.getResourcePath().startsWith("germlings")).collect(Collectors.toList()); //Replace model Map<String, ETTreeDefinition> map = Arrays.stream(ETTreeDefinition.values()).collect(Collectors.toMap(o -> o.name().toLowerCase(), o -> o)); models.forEach(model -> { String species = model.getVariant().split("=")[1]; ETTreeDefinition treeSpecies = map.get(species); int primaryColor = treeSpecies.getLeafColor().getRGB(); int secondaryColor = treeSpecies.getWoodColor().getRGB(); IBakedModel bakedModel = e.getModelRegistry().getObject(model); if (bakedModel == null) { return; } e.getModelRegistry().putObject(model, new DoublePassBakedModel(bakedModel, primaryColor, secondaryColor)); }); } }
@Override public boolean accepts(ResourceLocation modelLocation) { if (!(modelLocation instanceof ModelResourceLocation)) { return false; } ModelResourceLocation location = (ModelResourceLocation) modelLocation; return location.getNamespace().equals(Constants.MOD_ID) && location.getPath().equals("crate-filled") && !location.getVariant().equals("inventory"); }
@Override public boolean accepts(ResourceLocation modelLocation) { if (!modelLocation.getResourceDomain().equals(XNet.MODID)) { return false; } if (modelLocation instanceof ModelResourceLocation && ((ModelResourceLocation)modelLocation).getVariant().equals("inventory")) { return false; } return NAMES.contains(modelLocation.getResourcePath()); }
@SubscribeEvent public static void onModelBake(ModelBakeEvent event) { if (BloodMagic.IS_DEV && SUPPRESS_ASSET_ERRORS) return; Stopwatch stopwatch = Stopwatch.createStarted(); Map<ResourceLocation, Exception> modelErrors = ReflectionHelper.getPrivateValue(ModelLoader.class, event.getModelLoader(), "loadingExceptions"); Set<ModelResourceLocation> missingVariants = ReflectionHelper.getPrivateValue(ModelLoader.class, event.getModelLoader(), "missingVariants"); // Collect all Blood Magic model errors List<ResourceLocation> errored = new ArrayList<>(); for (ResourceLocation modelError : modelErrors.keySet()) if (modelError.getResourceDomain().equalsIgnoreCase(BloodMagic.MODID)) errored.add(modelError); // Collect all Blood Magic variant errors List<ModelResourceLocation> missing = new ArrayList<>(); for (ModelResourceLocation missingVariant : missingVariants) if (missingVariant.getResourceDomain().equalsIgnoreCase(BloodMagic.MODID)) missing.add(missingVariant); // Remove discovered model errors for (ResourceLocation modelError : errored) modelErrors.remove(modelError); // Remove discovered variant errors missingVariants.removeAll(missing); if (errored.size() > 0) BMLog.DEBUG.info("Suppressed {} model errors from Blood Magic.", errored.size()); if (missing.size() > 0) BMLog.DEBUG.info("Suppressed {} variant errors from Blood Magic.", missing.size()); BMLog.DEBUG.info("Suppressed discovered model/variant errors in {}", stopwatch.stop()); }
@SubscribeEvent public static void onModelBaked(ModelBakeEvent event) { for(ModelResourceLocation mrl : event.getModelRegistry().getKeys()) { if(mrl.getVariant().equals("inventory")) { ResourceLocation location = new ResourceLocation(mrl.getResourceDomain(), mrl.getResourcePath()); if(location.equals(ItemHandler.DART_GUN.getRegistryName())) { event.getModelRegistry().putObject(mrl, new GuiItemModelWrapper(event.getModelRegistry().getObject(mrl), DART_GUN_GUI)); } } } } private static IBakedModel getModel(ResourceLocation resourceLocation, TextureMap map) {
@Override public IModel loadModel(ResourceLocation modelLocation) throws Exception { ModelResourceLocation variant = (ModelResourceLocation) modelLocation; ModelBlockDefinition definition = getModelBlockDefinition(variant); if (definition.hasVariant(variant.getVariant())) { return new WeightedRandomModel(definition.getVariant(variant.getVariant())); } else { if (definition.hasMultipartData()) { Block block = ModelLocationInformation.getBlockFromBlockstateLocation(new ResourceLocation(variant.getNamespace(), variant.getPath())); if (block != null) { definition.getMultipartData().setStateContainer(block.getBlockState()); } } return new MultipartModel(new ResourceLocation(variant.getNamespace(), variant.getPath()), definition.getMultipartData()); } }
@Override public boolean accepts(ResourceLocation modelLocation) { if (!modelLocation.getResourceDomain().equals(BuildingGadgets.MODID)) { return false; } if (modelLocation instanceof ModelResourceLocation && ((ModelResourceLocation) modelLocation).getVariant().equals("inventory")) { return false; } return NAMES.contains(modelLocation.getResourcePath()); }
@Override public ModelResourceLocation getSubTileItemModelForName(String name) { return new ModelResourceLocation("builtin/missing", "missing"); }
if (modelLoc.getResourceDomain().equals(REFERENCE.MODID) && modelLoc.getResourcePath().equals(BlockBloodContainer.regName) ) { modelLocations.add(modelLoc); if (modelLoc.getResourceDomain().equals(REFERENCE.MODID) && modelLoc.getResourcePath().equals(BlockAltarInspiration.regName) && !modelLoc.getVariant().equals("inventory")) { modelLocations.add(modelLoc); if (modelLoc.getResourceDomain().equals(REFERENCE.MODID) && modelLoc.getResourcePath().equals(BlockWeaponTable.regName) && !modelLoc.getVariant().equals("inventory")) { modelLocations.add(modelLoc);
@Override public IModel loadModel(ResourceLocation modelLocation) throws Exception { ModelResourceLocation variant = (ModelResourceLocation) modelLocation; ModelBlockDefinition definition = ModelUtil.getModelBlockDefinition(variant); try { VariantList variants = definition.getVariant(variant.getVariant()); return new SimpleModel(variant, variants); } catch (MissingVariantException e) { if (definition.hasMultipartData()) { return new MultipartModel(new ResourceLocation(variant.getNamespace(), variant.getPath()), definition.getMultipartData()); } throw e; } } }
@SubscribeEvent public void onModelBaked(ModelBakeEvent modelBakeEvent){ setLoader(modelBakeEvent.getModelLoader()); for(Item shield : BattlegearConfig.shield) { if(shield!=null) { ModelResourceLocation mainLoc = DefaultMesh.INVENTORY.getModelLocation(new ItemStack(shield)); ResourceLocation itemLoc = new ResourceLocation(mainLoc.getResourceDomain(), "item/" + mainLoc.getResourcePath()); IModel originalModel = getModel(itemLoc); if(originalModel instanceof IRetexturableModel){ ModelBlock internalFrontModel = getInternalModel(originalModel); if (internalFrontModel != null) { ModelBlock front = makeItem(internalFrontModel); IBakedModel baked = wrap(join((IRetexturableModel) originalModel, front), itemLoc); if(baked != null) modelBakeEvent.getModelRegistry().putObject(mainLoc, baked); } } } } setLoader(null); }
@Override public boolean accepts(ResourceLocation modelLocation) { if (modelLocation.getResourceDomain().equals("logisticspipes")) { if (modelLocation instanceof ModelResourceLocation) { ResourceLocation rl = new ResourceLocation(modelLocation.getResourceDomain(), modelLocation.getResourcePath()); if (((ModelResourceLocation)modelLocation).getVariant().equals("inventory")) { Item item = ForgeRegistries.ITEMS.getValue(rl); if (item instanceof ItemLogisticsPipe) { CoreUnroutedPipe pipe = ((ItemLogisticsPipe) item).getDummyPipe(); nameTextureIdMap.put((ModelResourceLocation) modelLocation, pipe); return true; } } if (rl.equals(LPBlocks.pipe.getRegistryName())) { return true; } } } return false; }
private static ModelResourceLocation getTableLoc(BlockToolTable.TableTypes type) { return new ModelResourceLocation(LOCATION_ToolTable, String.format("%s=%s", BlockToolTable.TABLES.getName(), BlockToolTable.TABLES.getName(type))); }
@Nullable private Type getType(ResourceLocation modelLocation) { if (!(modelLocation instanceof ModelResourceLocation)) return null; ResourceLocation clean = new ResourceLocation(modelLocation.getResourceDomain(), modelLocation.getResourcePath()); String variant = ((ModelResourceLocation) modelLocation).getVariant(); if (variant.equals("inventory")) { // TODO split placement item into seperate items Item item = ForgeRegistries.ITEMS.getValue(clean); if (item instanceof LogisticsSolidBlockItem) { return ((LogisticsSolidBlockItem) item).getType(); } else return null; } else { Block block = ForgeRegistries.BLOCKS.getValue(clean); if (block instanceof LogisticsSolidBlock) { return ((LogisticsSolidBlock) block).getType(); } else return null; } }