@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(); } }
@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); }
public static IModel retexture(Map<String, String> textures, IModel blockModel) { if (blockModel instanceof IRetexturableModel) return ((IRetexturableModel) blockModel).retexture(ImmutableMap.copyOf(textures)); // else if (blockModel instanceof MultiModel) { // Map<String, Pair<IModel, IModelState>> parts = Maps.newHashMap(); // for (Entry<String, Pair<IModel, IModelState>> entry : ((MultiModel) blockModel).getParts() // .entrySet()) { // parts.put(entry.getKey(), Pair.of(retexture(textures, entry.getValue().getLeft()), // entry.getValue().getRight())); // } // return new MultiModel(retexture(textures, ((MultiModel) blockModel).getBaseModel()), // blockModel.getDefaultState(), parts); // } return blockModel; }
@SubscribeEvent public void onTextureStitch(TextureStitchEvent.Pre event) { RenderUtil.loadSprites("factorization", FzIcons.class, "", event); RenderUtil.loadSprites("factorization", BarrelModel.class, "blocks/storage/", event); try { BarrelModel.template = (IRetexturableModel) ModelLoaderRegistry.getModel(new ResourceLocation("factorization:block/barrel_template")); IModel socketBase = ModelLoaderRegistry.getModel(new ResourceLocation("factorization:block/socket")); } catch (IOException e) { throw new RuntimeException(e); } }
public GoodGraveModel(IBakedModel standard, IRetexturableModel retexturableModel) { this.standard = standard; this.retexturableModel = retexturableModel; }