@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(BuildingGadgets.MODID)) { return false; } if (modelLocation instanceof ModelResourceLocation && ((ModelResourceLocation) modelLocation).getVariant().equals("inventory")) { return false; } return NAMES.contains(modelLocation.getResourcePath()); }
@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()); }
@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; } }
@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)); }); } }
@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; } }
@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); }
@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; }
@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()); } }
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; } } }