Java Code Examples for net.minecraft.util.ResourceLocation#getPath()
The following examples show how to use
net.minecraft.util.ResourceLocation#getPath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VariantLoader.java From VanillaFix with MIT License | 6 votes |
private ModelBlockDefinition loadModelBlockDefinition(ResourceLocation location) { ResourceLocation blockstateLocation = new ResourceLocation(location.getNamespace(), "blockstates/" + location.getPath() + ".json"); List<ModelBlockDefinition> list = Lists.newArrayList(); try { for (IResource resource : Minecraft.getMinecraft().getResourceManager().getAllResources(blockstateLocation)) { list.add(loadModelBlockDefinition(location, resource)); } } catch (IOException e) { throw new RuntimeException("Encountered an exception when loading model definition of model " + blockstateLocation, e); } return new ModelBlockDefinition(list); }
Example 2
Source File: BuiltinLoader.java From VanillaFix with MIT License | 6 votes |
@Override public IModel loadModel(ResourceLocation modelLocation) throws Exception { String path = modelLocation.getPath(); if ("builtin/generated".equals(path) || "block/builtin/generated".equals(path) || "item/builtin/generated".equals(path)) { // TODO: why is this necessary? return ItemLayerModel.INSTANCE; //new VanillaModelWrapper(modelLocation, MODEL_GENERATED); } if ("builtin/entity".equals(path)) { return new VanillaModelWrapper(modelLocation, MODEL_ENTITY); } if ("builtin/missing".equals(path)) { return WRAPPED_MODEL_MISSING; } throw new FileNotFoundException(modelLocation.toString()); }
Example 3
Source File: VanillaLoader.java From VanillaFix with MIT License | 6 votes |
@Override public IModel loadModel(ResourceLocation modelLocation) throws Exception { // Load vanilla model ModelBlock vanillaModel; ResourceLocation vanillaModelLocation = new ResourceLocation(modelLocation.getNamespace(), modelLocation.getPath() + ".json"); try (IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(vanillaModelLocation); Reader reader = new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8)) { vanillaModel = ModelBlock.deserialize(reader); vanillaModel.name = modelLocation.toString(); } // Load armature animation (currently disabled for efficiency, see MixinModelBlockAnimation) String modelPath = modelLocation.getPath(); if (modelPath.startsWith("models/")) { modelPath = modelPath.substring("models/".length()); } ResourceLocation armatureLocation = new ResourceLocation(modelLocation.getNamespace(), "armatures/" + modelPath + ".json"); ModelBlockAnimation animation = ModelBlockAnimation.loadVanillaAnimation(Minecraft.getMinecraft().getResourceManager(), armatureLocation); // Return the vanilla model weapped in a VanillaModelWrapper return new VanillaModelWrapper(modelLocation, vanillaModel , false, animation); }
Example 4
Source File: TemplateManagerEU.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
public TemplateEnderUtilities getTemplate(ResourceLocation id) { String s = id.getPath(); if (this.templates.containsKey(s)) { return this.templates.get(s); } this.readTemplate(id); if (this.templates.containsKey(s)) { return this.templates.get(s); } TemplateEnderUtilities template = new TemplateEnderUtilities(); this.templates.put(s, template); return template; }
Example 5
Source File: TemplateManagerEU.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
public TemplateMetadata getTemplateMetadata(ResourceLocation rl) { String s = rl.getPath(); if (this.templateMetas.containsKey(s)) { return this.templateMetas.get(s); } this.readTemplateMetadata(rl); if (this.templateMetas.containsKey(s)) { return this.templateMetas.get(s); } TemplateMetadata templateMeta = new TemplateMetadata(); this.templateMetas.put(s, templateMeta); return templateMeta; }
Example 6
Source File: VariantLoader.java From VanillaFix with MIT License | 5 votes |
private ModelBlockDefinition getModelBlockDefinition(ResourceLocation location) { ResourceLocation simpleLocation = new ResourceLocation(location.getNamespace(), location.getPath()); try { return modelBlockDefinitionCache.get(simpleLocation, () -> loadModelBlockDefinition(simpleLocation)); } catch (ExecutionException e) { throw new RuntimeException(e.getCause()); } }
Example 7
Source File: DynamicModelProvider.java From VanillaFix with MIT License | 5 votes |
private ResourceLocation getActualLocation(ResourceLocation location) { if (location instanceof ModelResourceLocation) { return location; } if (location.getPath().startsWith("builtin/") || location.getPath().startsWith("block/builtin/") || location.getPath().startsWith("item/builtin/")) { // TODO: why is this necessary return location; } return new ResourceLocation(location.getNamespace(), "models/" + location.getPath()); }
Example 8
Source File: ModelLocationInformation.java From VanillaFix with MIT License | 4 votes |
public static ResourceLocation getItemLocation(String location) { ResourceLocation resourcelocation = new ResourceLocation(location.replaceAll("#.*", "")); return new ResourceLocation(resourcelocation.getNamespace(), "item/" + resourcelocation.getPath()); }
Example 9
Source File: TemplateManagerEU.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public boolean writeTemplate(ResourceLocation id) { String fileName = id.getPath(); if (this.templates.containsKey(fileName) == false) { return false; } else { if (this.directory.exists() == false) { if (this.directory.mkdirs() == false) { return false; } } else if (this.directory.isDirectory() == false) { return false; } final File templateFile = new File(this.directory, fileName + ".nbt"); final NBTTagCompound nbt = new NBTTagCompound(); final TemplateEnderUtilities template = this.templates.get(fileName); template.write(nbt); ThreadedFileIOBase.getThreadedIOInstance().queueIO(() -> { try { OutputStream outputStream = new FileOutputStream(templateFile); CompressedStreamTools.writeCompressed(nbt, outputStream); outputStream.close(); } catch (IOException e) { EnderUtilities.logger.warn("Failed to write template to file '{}'", templateFile, e); } return false; }); return true; } }
Example 10
Source File: TemplateManagerEU.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
protected File getTemplateMetadataFile(ResourceLocation rl) { return new File(this.directory, rl.getPath() + "_meta.nbt"); }
Example 11
Source File: TemplateManagerEU.java From enderutilities with GNU Lesser General Public License v3.0 | 4 votes |
public boolean writeTemplateMetadata(ResourceLocation rl) { String fileName = rl.getPath(); if (this.templateMetas.containsKey(fileName) == false) { return false; } else { if (this.directory.exists() == false) { if (this.directory.mkdirs() == false) { return false; } } else if (this.directory.isDirectory() == false) { return false; } final File templateFile = new File(this.directory, fileName + "_meta.nbt"); final NBTTagCompound nbt = new NBTTagCompound(); final TemplateMetadata templateMeta = this.templateMetas.get(fileName); templateMeta.write(nbt); ThreadedFileIOBase.getThreadedIOInstance().queueIO(() -> { try { OutputStream outputStream = new FileOutputStream(templateFile); CompressedStreamTools.writeCompressed(nbt, outputStream); outputStream.close(); } catch (IOException e) { EnderUtilities.logger.warn("Failed to write template metadata to file '{}'", templateFile); } return false; }); return true; } }