@SubscribeEvent public void onModelBake(ModelBakeEvent event) { try { IModel model = ModelLoaderRegistry.getModel(MODEL_grave); if (model instanceof IRetexturableModel) { IRetexturableModel graveModel = (IRetexturableModel) model; IBakedModel standard = event.getModelRegistry().getObject(locGrave); IBakedModel finalModel = new GoodGraveModel(standard, graveModel); event.getModelRegistry().putObject(locGrave, finalModel); } } catch (Exception e) { e.printStackTrace(); } }
@SuppressWarnings("unused") @SubscribeEvent public void modelBake(ModelBakeEvent event) { List<IBakedModel> capacitors = new ArrayList<IBakedModel>(); IBakedModel teBasic = event.modelRegistry.getObject(new ModelResourceLocation(Reference.MOD_ID + ":blockCapacitor", "facing=north,type=1")); IBakedModel teHardened = event.modelRegistry.getObject(new ModelResourceLocation(Reference.MOD_ID + ":blockCapacitor", "facing=north,type=2")); IBakedModel teReinforced = event.modelRegistry.getObject(new ModelResourceLocation(Reference.MOD_ID + ":blockCapacitor", "facing=north,type=3")); IBakedModel teResonant = event.modelRegistry.getObject(new ModelResourceLocation(Reference.MOD_ID + ":blockCapacitor", "facing=north,type=4")); IBakedModel eioBasic = event.modelRegistry.getObject(new ModelResourceLocation(Reference.MOD_ID + ":blockCapacitor", "facing=north,type=5")); IBakedModel eioDouble = event.modelRegistry.getObject(new ModelResourceLocation(Reference.MOD_ID + ":blockCapacitor", "facing=north,type=6")); IBakedModel eioVibrant = event.modelRegistry.getObject(new ModelResourceLocation(Reference.MOD_ID + ":blockCapacitor", "facing=north,type=7")); capacitors.add(teBasic); capacitors.add(teHardened); capacitors.add(teReinforced); capacitors.add(teResonant); capacitors.add(eioBasic); capacitors.add(eioDouble); capacitors.add(eioVibrant); SmartModelCapacitor capacitorModel = new SmartModelCapacitor(capacitors); event.modelRegistry.putObject(new ModelResourceLocation(Reference.MOD_ID + ":blockCapacitor", "inventory"), capacitorModel); }
@SubscribeEvent (priority = EventPriority.HIGHEST) public void onModelBake(ModelBakeEvent event) { IModel missingIModel = ModelLoaderRegistry.getMissingModel(); IBakedModel missingModel = missingIModel.bake(missingIModel.getDefaultState(), DefaultVertexFormats.ITEM, TextureUtils.bakedTextureGetter); Map<IModel, IBakedModel> bakedModels = new HashMap<>(); HashMultimap<IModel, ModelResourceLocation> models = HashMultimap.create(); Multimaps.invertFrom(Multimaps.forMap(toBake), models); ProgressBar bar = ProgressManager.push("CCL ModelLoading: Baking", models.keySet().size()); for (IModel model : models.keySet()) { bar.step(String.format("[%s]", Joiner.on(", ").join(models.get(model)))); if (model == missingIModel) { bakedModels.put(model, missingModel); continue; } bakedModels.put(model, model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, TextureUtils.bakedTextureGetter)); } ProgressManager.pop(bar); for (Entry<ModelResourceLocation, IModel> entry : toBake.entrySet()) { event.getModelRegistry().putObject(entry.getKey(), bakedModels.get(entry.getValue())); } }
@SubscribeEvent public void onModelBakeEvent(ModelBakeEvent event) { models.clear(); /*{ Object object = event.getModelRegistry().getObject(EnderPlayerSensor.SmartBlockModel.modelResourceLocation); Object object2 = event.getModelRegistry().getObject(EnderPlayerSensor.SmartBlockModel.modelTResourceLocation); if (object instanceof IBakedModel && object2 instanceof IBakedModel) { IBakedModel existingModel = (IBakedModel)object; IBakedModel existingModel2 = (IBakedModel)object2; EnderPlayerSensor.SmartBlockModel customModel = new EnderPlayerSensor.SmartBlockModel(existingModel,existingModel2); event.getModelRegistry().putObject(EnderPlayerSensor.SmartBlockModel.modelResourceLocation, customModel); //event.modelRegistry.putObject(EnderPlayerSensor.SmartBlockModel.modelTResourceLocation, customModel); } } { Object object = event.getModelRegistry().getObject(BlockRsDoor.SmartBlockModel.modelResourceLocation); if (object instanceof IBakedModel) { IBakedModel existingModel = (IBakedModel)object; BlockRsDoor.SmartBlockModel customModel = new BlockRsDoor.SmartBlockModel(existingModel); event.getModelRegistry().putObject(BlockRsDoor.SmartBlockModel.modelResourceLocation, customModel); //event.modelRegistry.putObject(EnderPlayerSensor.SmartBlockModel.modelTResourceLocation, customModel); } }*/ }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onModelBake (ModelBakeEvent event) { event.getModelRegistry().putObject(new ModelResourceLocation("darkutils:sneaky", "normal"), new ModelSneakyBlock()); event.getModelRegistry().putObject(new ModelResourceLocation("darkutils:sneaky_lever", "powered=true"), new ModelSneakyBlock()); event.getModelRegistry().putObject(new ModelResourceLocation("darkutils:sneaky_lever", "powered=false"), new ModelSneakyBlock()); event.getModelRegistry().putObject(new ModelResourceLocation("darkutils:sneaky_button", "powered=true"), new ModelSneakyBlock()); event.getModelRegistry().putObject(new ModelResourceLocation("darkutils:sneaky_button", "powered=false"), new ModelSneakyBlock()); event.getModelRegistry().putObject(new ModelResourceLocation("darkutils:sneaky_ghost", "normal"), new ModelSneakyBlock()); event.getModelRegistry().putObject(new ModelResourceLocation("darkutils:sneaky_torch", "normal"), new ModelSneakyBlock()); event.getModelRegistry().putObject(new ModelResourceLocation("darkutils:sneaky_obsidian", "normal"), new ModelSneakyBlock()); event.getModelRegistry().putObject(new ModelResourceLocation("darkutils:sneaky_plate", "powered=true"), new ModelSneakyBlock()); event.getModelRegistry().putObject(new ModelResourceLocation("darkutils:sneaky_plate", "powered=false"), new ModelSneakyBlock()); event.getModelRegistry().putObject(new ModelResourceLocation("darkutils:sneaky_bedrock", "normal"), new ModelSneakyBlock()); }
@SubscribeEvent public void onModelBake(ModelBakeEvent event) { // bake and register our models here Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter = ModelLoader.defaultTextureGetter(); // get all of the sprites that we will use TextureAtlasSprite stone = bakedTextureGetter.apply(new ResourceLocation("Minecraft:blocks/stone")); TextureAtlasSprite nether = bakedTextureGetter.apply(new ResourceLocation("Minecraft:blocks/netherrack")); TextureAtlasSprite end = bakedTextureGetter.apply(new ResourceLocation("Minecraft:blocks/end_stone")); TextureAtlasSprite uranium = bakedTextureGetter.apply(new ResourceLocation(Constants.MODID, "blocks/uranium_bits")); TextureAtlasSprite thorium = bakedTextureGetter.apply(new ResourceLocation(Constants.MODID, "blocks/thorium_bits")); TextureAtlasSprite blazonium = bakedTextureGetter.apply(new ResourceLocation(Constants.MODID, "blocks/blazonium_bits")); TextureAtlasSprite terminium = bakedTextureGetter.apply(new ResourceLocation(Constants.MODID, "blocks/terminium_bits")); // Add all of the models event.getModelRegistry().putObject( new ModelResourceLocation(Constants.MODID+":GlowOre_" + BlockRegistry.UraniumOre.Type), new GlowOreBakedModel(stone, uranium)); event.getModelRegistry().putObject(new ModelResourceLocation(Constants.MODID+":GlowOre_" + BlockRegistry.ThoriumOre.Type), new GlowOreBakedModel(stone, thorium)); event.getModelRegistry().putObject(new ModelResourceLocation(Constants.MODID+":GlowOre_" + BlockRegistry.BlazoniumOre.Type), new GlowOreBakedModel(nether, blazonium)); event.getModelRegistry().putObject(new ModelResourceLocation(Constants.MODID+":GlowOre_" + BlockRegistry.TerminiumOre.Type), new GlowOreBakedModel(end, terminium)); }
@SubscribeEvent public void onModelBake(ModelBakeEvent event) { // tool tables replaceAnvilModel(locAnvilN, Core.CreateRes(Reference.ModID + ":block/anvil"), event); replaceAnvilModel(locAnvilS, Core.CreateRes(Reference.ModID + ":block/anvil"), event); replaceAnvilModel(locAnvilE, Core.CreateRes(Reference.ModID + ":block/anvil"), event); replaceAnvilModel(locAnvilW, Core.CreateRes(Reference.ModID + ":block/anvil"), event); replacePitKilnModel(locPitKilnCharcoal, Core.CreateRes(Reference.ModID + ":block/pitkiln/pitkiln_0"), event); replacePitKilnModel(locPitKilnStraw, Core.CreateRes(Reference.ModID + ":block/pitkiln/pitkiln_0"), event); replaceSmallVesselModel(locSmallVessel, Core.CreateRes(Reference.ModID + ":block/smallvessel"), event); // silence the missing-model message for the default itemblock //event.getModelRegistry().putObject(locAnvil, event.getModelRegistry().getObject(locAnvil)); }
@SubscribeEvent public void onModelBakePost(ModelBakeEvent event) { if (supressErrors) { Map<ResourceLocation, Exception> modelErrors = (Map<ResourceLocation, Exception>) ReflectionHelper.getPrivateValue(ModelLoader.class, event.getModelLoader(), "loadingExceptions"); Set<ModelResourceLocation> missingVariants = (Set<ModelResourceLocation>) ReflectionHelper.getPrivateValue(ModelLoader.class, event.getModelLoader(), "missingVariants"); List<ResourceLocation> errored = modelErrors.keySet().stream().filter((r) -> IGNORES.contains(r.getResourceDomain())).collect(Collectors.toList()); List<ResourceLocation> missing = missingVariants.stream().filter((r) -> IGNORES.contains(r.getResourceDomain())).collect(Collectors.toList()); errored.forEach(modelErrors::remove); missing.forEach(missingVariants::remove); AgriCore.getLogger("agricraft").info("Suppressed {0} Model Loading Errors!", errored.size()); AgriCore.getLogger("agricraft").info("Suppressed {0} Missing Model Variants!", missing.size()); } }
@SubscribeEvent public void onModelBakeEvent(ModelBakeEvent event){ TextureMap blockMap = FMLClientHandler.instance().getClient().getTextureMapBlocks(); TextureAtlasSprite textures[] = new TextureAtlasSprite[15]; textures[0] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/machine_Top"); textures[1] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/machine_Bottom"); textures[2] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/machine_Side_0"); textures[3] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/oreTumbler_Front"); textures[4] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/oreTumbler_Front_Active"); textures[5] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/flowstoneBottler_Front"); textures[6] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/flowstoneBottler_Front_Activate"); textures[7] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/furnace_Front"); textures[8] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/furnace_Front_Active"); textures[9] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/lumberMill_Front"); textures[10] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/lumberMill_Front_Active"); textures[11] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/metalMixer_Front"); textures[12] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/metalMixer_Front_Active"); textures[13] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/cooler_Front"); textures[14] = blockMap.getAtlasSprite("flowstoneenergy:blocks/machines/cooler_Front_Active"); IBakedModel machineModel = new SmartModelMachines(textures); event.modelRegistry.putObject(ClientProxy.machinesBlockLocation, machineModel); event.modelRegistry.putObject(ClientProxy.machinesItemLocation, machineModel); }
@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); }
@SubscribeEvent public void onModelBake(ModelBakeEvent evt) { final IModel model = ModelLoaderRegistry.getModelOrMissing(MARKER_MODEL_LOCATION); final TextureMap textureMapBlocks = Minecraft.getMinecraft().getTextureMapBlocks(); final IBakedModel bakedModel = model.bake(model.getDefaultState(), DefaultVertexFormats.ITEM, input -> textureMapBlocks.getAtlasSprite(input.toString())); renderer.onModelBake(() -> { final Tessellator tessellator = Tessellator.getInstance(); BufferBuilder vertexBuffer = tessellator.getBuffer(); vertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM); for (EnumFacing enumfacing : EnumFacing.values()) renderQuads(vertexBuffer, bakedModel.getQuads(null, enumfacing, 0L)); renderQuads(vertexBuffer, bakedModel.getQuads(null, null, 0L)); vertexBuffer.finishDrawing(); return vertexBuffer; }); }
@SubscribeEvent public void onModelBake(ModelBakeEvent event) { for (Entry<Block, BlockInfo> e : ConfigHandler.ores.entrySet()) { for (ModelResourceLocation res : e.getValue().getModels()) { IBakedModel model = event.getModelRegistry().getObject(res); if (!(model instanceof BlendedModel)) { Map<ModelResourceLocation, IModel> stateModels = ReflectionHelper.getPrivateValue(ModelLoader.class, event.getModelLoader(), "stateModels"); IModel imodel = stateModels.get(res); BlendedModel wrapped = new BlendedModel(imodel, model); wrapped.setOreTexture(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/" + e.getValue().getTexture().getResourcePath() + "_differential")); wrapped.setBaseState(e.getValue().getState()); event.getModelRegistry().putObject(res, wrapped); } } } }
@SubscribeEvent() @SideOnly(Side.CLIENT) public void bakeModels(ModelBakeEvent event) { cache.clear(); for (Entry<String, Pair<ResourceLocation, PaintMode>> entry : modelLocations.entrySet()) { try { ResourceLocation resourceLocation = entry.getValue().getLeft(); if (resourceLocation != null) { IModel model = ModelLoaderRegistry.getModel(resourceLocation); models.put(entry.getKey(), model); } else { models.put(entry.getKey(), ModelLoaderRegistry.getMissingModel()); } } catch (Exception e) { Log.warn("Model '" + entry.getValue() + "' failed to load: " + e); } } }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onModelSpellPageBakeEvent(ModelBakeEvent event) { Object object = event.getModelRegistry().getObject(ModelSpellPage.modelResourceLocation); if (object instanceof IBakedModel) { IBakedModel existingModel = (IBakedModel) object; ModelSpellPage spellPageModel = new ModelSpellPage(existingModel); event.getModelRegistry().putObject(ModelSpellPage.modelResourceLocation, spellPageModel); ModelSpellPage.SpellPageOverrideList.INSTANCE.clearCache(); } }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onModelKnowledgeBookBakeEvent(ModelBakeEvent event) { Object object = event.getModelRegistry().getObject(ModelKnowledgeBook.modelResourceLocation); if (object instanceof IBakedModel) { IBakedModel existingModel = (IBakedModel) object; ModelKnowledgeBook knowledgeBookModel = new ModelKnowledgeBook(existingModel); event.getModelRegistry().putObject(ModelKnowledgeBook.modelResourceLocation, knowledgeBookModel); ModelKnowledgeBook.KnowledgeBookOverrideList.INSTANCE.clearCache(); } }
@SubscribeEvent public static void setupModels(ModelBakeEvent event) { try { lodestone_sliver = ModelLoaderRegistry.getModel(new ResourceLocation(Etheric.MODID, "item/lodestone_sliver")).bake(TRSRTransformation.identity(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter()); } catch (Exception e) { Etheric.logger.error("Error loading seeing stone submodel", e); lodestone_sliver = ModelLoaderRegistry.getMissingModel().bake(TRSRTransformation.identity(), DefaultVertexFormats.ITEM, ModelLoader.defaultTextureGetter()); } }
@SubscribeEvent public static void onBake(ModelBakeEvent e) { putModel(e, new StandardModels.Crystal(), Utils.gRL("crystal")); putModel(e, new StandardModels.CrystalGlass(), Utils.gRL("crystal_glass")); putModel(e, new StandardModels.Glove(), Utils.gRL("glove")); putModel(e, new StandardModels.TranslationDesk(), Utils.gRL("translation_desk")); putModel(e, new StandardModels.CrystalSmall(), Utils.gRL("crystal_small")); StandardModels.WallIfTablet wit = new StandardModels.WallIfTablet(); putModel(e, wit, Utils.gRL("wall_if_tablet")); putModel(e, wit, Utils.gRL("broken_wall_if_tablet")); putModel(e, new StandardModels.Microscope(), Utils.gRL("microscope")); putModel(e, new StandardModels.LuminousCrystalGlass(), Utils.gRL("luminous_crystal_glass")); putModel(e, new StandardModels.Test(), Utils.gRL("test")); putModel(e, new StandardModels.CodeStorage(), Utils.gRL("code_storage")); putModel(e, new StandardModels.CodeStorage.Top(), Utils.gRL("code_storage/top")); putModel(e, new StandardModels.CodeStorage.Body(), Utils.gRL("code_storage/body")); for(MagibenchRegistry.Tier t : PurMag.INSTANCE.getMagibenchRegistry().getTiers()) { putModel(e, new StandardModels.Magibench(t), t.getSmartModel()); } putModel(e, new StandardModels.StoneCrusher.Item(), Utils.gRL("stone_crusher")); putModel(e, new StandardModels.StoneCrusher.Main(), Utils.gRL("stone_crusher/main")); putModel(e, new StandardModels.StoneCrusher.Lever(), Utils.gRL("stone_crusher/lever")); putModel(e, new StandardModels.StoneCrusher.Coil(), Utils.gRL("stone_crusher/coil")); putModel(e, new StandardModels.StoneCrusher.Handle(), Utils.gRL("stone_crusher/handle")); }
@SubscribeEvent public void registerModels(ModelBakeEvent e) { ModelLoader.setCustomModelResourceLocation(RSAddonsItems.WIRELESS_CRAFTING_GRID, 0, new ModelResourceLocation("refinedstorageaddons:wireless_crafting_grid", "inventory")); ModelLoader.setCustomModelResourceLocation(RSAddonsItems.NETWORK_PICKER, 0, new ModelResourceLocation("refinedstorageaddons:network_picker", "inventory")); ModelLoader.setCustomModelResourceLocation(RSAddonsItems.NETWORK_BAG, 0, new ModelResourceLocation("refinedstorageaddons:network_bag", "inventory")); ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(RSAddonsBlocks.INFINITE_WIRELESS_TRANSMITTER), 0, new ModelResourceLocation("refinedstorageaddons:infinite_wireless_transmitter", "inventory")); ModelLoader.setCustomStateMapper(RSAddonsBlocks.INFINITE_WIRELESS_TRANSMITTER, new StateMapperCTM("refinedstorageaddons:infinite_wireless_transmitter")); }
@SubscribeEvent public void onModelBake(ModelBakeEvent event) { ImmutableList.Builder<BakedQuad> builder = ImmutableList.builder(); builder.addAll(ItemLayerModel.getQuadsForSprite(0, txInstrument, DefaultVertexFormats.ITEM, Optional.empty())); event.getModelRegistry().putObject(new ModelResourceLocation("clef:instrument", "inventory"), new BakedModelInstrument(builder.build(), txInstrument, ImmutableMap.copyOf(new HashMap<>()), null, null)); }
@SubscribeEvent(priority = EventPriority.LOWEST) @SideOnly(Side.CLIENT) public void onModelBake(ModelBakeEvent event) { if(!InteractionBWA.ARMOR_SHARD_RENDER) return; for (Item item : Item.REGISTRY) { if (!ItemUtil.isTool(item)) continue; for (String s : getVariantNames(event.getModelLoader(), item)) { ResourceLocation file = getItemLocation(s); ModelResourceLocation memory = ModelLoader.getInventoryVariant(s); IModel model = null; try { model = ModelLoaderRegistry.getModel(file); } catch (Exception e) { try { model = ModelLoaderRegistry.getModel(memory); } catch (Exception e1) { //e1.printStackTrace(); } } if(model == null) continue; IModel brokenmodel = new ModelToolShardInner(ImmutableList.copyOf(model.getTextures())); IBakedModel bakedbrokenmodel = brokenmodel.bake(brokenmodel.getDefaultState(), DefaultVertexFormats.ITEM, location -> Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString())); ToolShardOverrideHandler.INSTANCE.addModel(item,bakedbrokenmodel); } } }
@SubscribeEvent public void onModelBake(ModelBakeEvent event) { state = ContextState.LoadingModels; for (AutoModel model : autoModels) { model.loadModelAndBake(); } for (TheltaModule module : modules) { module.loadModels(this); } state = ContextState.Intermediary; }
@SubscribeEvent public void onModelPost(ModelBakeEvent event) { if (!Environment.debug()) return; Map<ResourceLocation, ModelStates> map = Maps.newHashMap(); List<ModelStates> list = Lists.newArrayList(); Set<ModelResourceLocation> set = ReflectionHelper.getPrivateValue(ModelLoader.class, event.getModelLoader(), "missingVariants"); // IRegistry modelReg = event.modelRegistry; // Object missingModel = modelReg.getArgs(MISS); for (ModelResourceLocation missing : set) { ResourceLocation location = new ResourceLocation(missing.getResourceDomain(), missing.getResourcePath()); if (map.containsKey(location)) map.get(location).addVariant(missing.getVariant()); else { ModelStates temp = new ModelStates(missing); map.put(location, temp); } } Gson gson = this.buildGson(); try { for (final ModelStates state : list) if (state.vars.size() == 1 && state.vars.get(0).equals("inventory")) this.writeItem(state, gson); else this.writeBlock(state, gson); } catch (IOException e) { e.printStackTrace(); } standard = null; }
@SubscribeEvent public void onModelBake(final ModelBakeEvent evt) { final ModelResourceLocation key = new ModelResourceLocation(QBarConstants.MODID + ":" + QBarItems.BLUEPRINT .name, "inventory"); final IBakedModel originalModel = evt.getModelRegistry().getObject(key); evt.getModelRegistry().putObject(key, new BlueprintRender(originalModel)); for (Item item : QBarItems.ITEMS) { if (item instanceof IItemModelProvider && ((IItemModelProvider) item).hasSpecialModel()) ((IItemModelProvider) item).registerModels(); else QBar.proxy.registerItemRenderer(item, 0, item.getUnlocalizedName().substring(5)); } ModelLoader.setCustomModelResourceLocation(Item.getByNameOrId("qbar:fluidpipe"), 1, new ModelResourceLocation(QBarConstants.MODID + ":fluidpipe", "inventoryvalve")); ModelLoader.setCustomModelResourceLocation(Item.getByNameOrId("qbar:steampipe"), 1, new ModelResourceLocation(QBarConstants.MODID + ":steampipe", "inventoryvalve")); ModelLoader.setCustomModelResourceLocation(Item.getByNameOrId("qbar:itemextractor"), 1, new ModelResourceLocation(QBarConstants.MODID + ":itemextractor", "facing=down,filter=true")); ModelLoader.setCustomModelResourceLocation(Item.getByNameOrId("qbar:itemsplitter"), 1, new ModelResourceLocation(QBarConstants.MODID + ":itemsplitter", "facing=up,filter=true")); QBarBlocks.BLOCKS.keySet().stream().filter(IModelProvider.class::isInstance).forEach(block -> { IModelProvider modelProvider = (IModelProvider) block; BiConsumer<Integer, Block> modelRegister = modelProvider.registerItemModels(); for (int i = 0; i < modelProvider.getItemModelCount(); i++) modelRegister.accept(i, block); }); }
public static void replaceAnvilModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) { try { IModel model = ModelLoaderRegistry.getModel(modelLocation); IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation); if(standard instanceof IPerspectiveAwareModel) { IBakedModel finalModel = new BakedAnvilModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK); event.getModelRegistry().putObject(modelVariantLocation, finalModel); } } catch(Exception e) { e.printStackTrace(); } }
public static void replacePitKilnModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) { try { IModel model = ModelLoaderRegistry.getModel(modelLocation); IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation); if(standard instanceof IPerspectiveAwareModel) { IBakedModel finalModel = new BakedPitKilnModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK); event.getModelRegistry().putObject(modelVariantLocation, finalModel); } } catch(Exception e) { e.printStackTrace(); } }
public static void replaceSmallVesselModel(ModelResourceLocation modelVariantLocation, ResourceLocation modelLocation, ModelBakeEvent event) { try { IModel model = ModelLoaderRegistry.getModel(modelLocation); IBakedModel standard = event.getModelRegistry().getObject(modelVariantLocation); if(standard instanceof IPerspectiveAwareModel) { IBakedModel finalModel = new BakedSmallVesselModel((IPerspectiveAwareModel) standard, DefaultVertexFormats.BLOCK); event.getModelRegistry().putObject(modelVariantLocation, finalModel); } } catch(Exception e) { e.printStackTrace(); } }
@SubscribeEvent public void onModelBake(ModelBakeEvent event) { for (MarkerColor color : MarkerColor.values()) { ModelResourceLocation resource = color.getModelLocation(); event.getModelRegistry().putObject(resource, this.bakeMarkerModel(resource)); } }
@SubscribeEvent public static void atModelsBaked(ModelBakeEvent bakeEvent) { IRegistry<ModelResourceLocation, IBakedModel> modelRegistry = bakeEvent.getModelRegistry(); Map<ModelResourceLocation, IBakedModel> dependencies = new HashMap<>(); for (IBakedModel model : modelRegistry) { if (!(model instanceof BakedModelWrapper)) { continue; } BakedModelWrapper bakedModel = (BakedModelWrapper) model; Set<ResourceLocation> overrideLocations = getDependencies(bakedModel); for (ResourceLocation dep : overrideLocations) { ModelResourceLocation actualDep = net.minecraftforge.client.model.ModelLoader .getInventoryVariant(dep.toString()); if (modelRegistry.getKeys().contains(actualDep)) { continue; } IModel depModel = ModelLoaderRegistry.getModelOrLogError(dep, "Missing dependency model"); IBakedModel depBakedModel = depModel.bake( depModel.getDefaultState(), DefaultVertexFormats.ITEM, EventListener::getTextureAtlas); dependencies.put(actualDep, depBakedModel); } } for (Entry<ModelResourceLocation, IBakedModel> entry : dependencies.entrySet()) { modelRegistry.putObject(entry.getKey(), entry.getValue()); } }
@SubscribeEvent public void onModelBake(ModelBakeEvent event) { MODEL_BACKPACK = bakeBlockModel("wearablebackpacks:block/backpack"); MODEL_BACKPACK_TOP = bakeBlockModel("wearablebackpacks:block/backpack_top"); MODEL_BACKPACK_STRAPS = bakeBlockModel("wearablebackpacks:block/backpack_straps"); MODEL_BACKPACK_ENCH = new BakedModelDefaultTexture(MODEL_BACKPACK); MODEL_BACKPACK_ENCH_TOP = new BakedModelDefaultTexture(MODEL_BACKPACK_TOP); MODEL_BACKPACK_BOX = ModelAABBCalculator.calcFrom(MODEL_BACKPACK, MODEL_BACKPACK_TOP); }
@SubscribeEvent public void onModelBake(ModelBakeEvent event) { for (final TwinTailType type : ItemHairBand.twinTailTypes) { IModel model = getModel(new ResourceLocation("twintails:twintails_" + type.getName() + ".obj")); if (model instanceof OBJModel) model = ((OBJModel) model).process(ImmutableMap.of("flip-v", "true")); IBakedModel bakedModel = BakerUtil.bake(model, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL, textures); type.getModel().setModel(bakedModel); } }
public static void collectOverlayQuads(@Nonnull ModelBakeEvent event) { final Block block = ModObject.block_machine_io.getBlockNN(); Map<IBlockState, ModelResourceLocation> locations = event.getModelManager().getBlockModelShapes().getBlockStateMapper().getVariants(block); NNIterator<IOMode> modes = crazypants.enderio.base.render.property.IOMode.MODES.iterator(); while (modes.hasNext()) { IOMode mode = modes.next(); IBlockState state = block.getDefaultState().withProperty(IOMode.IO, mode); ModelResourceLocation mrl = locations.get(state); if (mrl == null) { throw new RuntimeException("Model for state " + state + " failed to load from " + mrl + ". "); } IBakedModel model = event.getModelRegistry().getObject(mrl); if (model == null) { Log.warn("Model for state " + state + " failed to load from " + mrl + "."); continue; } QuadCollector quads = new QuadCollector(); BlockRenderLayer oldRenderLayer = MinecraftForgeClient.getRenderLayer(); BlockRenderLayer layer = block.getBlockLayer(); ForgeHooksClient.setRenderLayer(layer); List<BakedQuad> generalQuads = model.getQuads(state, null, 0); if (!generalQuads.isEmpty()) { quads.addQuads(null, layer, generalQuads); } for (EnumFacing face1 : EnumFacing.values()) { List<BakedQuad> faceQuads = model.getQuads(state, mode.getDirection(), 0); if (!faceQuads.isEmpty()) { quads.addQuads(face1, layer, faceQuads); } } ForgeHooksClient.setRenderLayer(oldRenderLayer); data[mode.getDirection().ordinal()][mode.getIomode().ordinal()] = quads; } }
@SubscribeEvent() public void bakeModels(@Nonnull ModelBakeEvent event) { for (Entry<ModelResourceLocation, Registry> entry : registries.entrySet()) { final ModelResourceLocation resource = entry.getKey(); if (resource != null) { IBakedModel model = event.getModelRegistry().getObject(resource); final Registry registry = entry.getValue(); if (registry != null && model != null) { event.getModelRegistry().putObject(resource, registry.wrap(model)); } } } }
@SubscribeEvent public void onModelBake(ModelBakeEvent event) { event.getModelRegistry().putObject(new ModelResourceLocation("generallaymansaestheticspyingscreen:block_glass_terminal", "normal"), new ModelEmpty(Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/obsidian"))); }
@SubscribeEvent public void onModelBake(ModelBakeEvent event) { event.getModelRegistry().putObject(new ModelResourceLocation("torched:torchlauncher", "inventory"), new ModelBaseWrapper(new ItemRenderTorchLauncher()).setItemDualHanded()); event.getModelRegistry().putObject(new ModelResourceLocation("torched:torchgun", "inventory"), new ModelBaseWrapper(new ItemRenderTorchGun()).setItemDualHanded()); }
private static void putModel(ModelBakeEvent e, IPXModel model, ResourceLocation loc) { model.bake(); e.getModelRegistry().putObject(new ModelResourceLocation(loc, "normal"), model); }
public static void onModelBake(ModelManager modelManager, IRegistry<ModelResourceLocation, IBakedModel> modelRegistry, ModelLoader modelLoader) { MinecraftForge.EVENT_BUS.post(new ModelBakeEvent(modelManager, modelRegistry, modelLoader)); modelLoader.onPostBakeEvent(modelRegistry); }