net.fabricmc.loader.api.metadata.ModMetadata Java Examples
The following examples show how to use
net.fabricmc.loader.api.metadata.ModMetadata.
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: SandboxHooks.java From Sandbox with GNU Lesser General Public License v3.0 | 6 votes |
public static void setupGlobal() { Set<String> supportedMods = Sets.newHashSet("minecraft", "sandbox", "sandboxapi", "fabricloader"); Sandbox.unsupportedModsLoaded = FabricLoader.getInstance().getAllMods().stream() .map(ModContainer::getMetadata) .map(ModMetadata::getId) .anyMatch(((Predicate<String>) supportedMods::contains).negate()); Policy.setPolicy(new AddonSecurityPolicy()); Registry.REGISTRIES.add(new Identifier("sandbox", "container"), SandboxRegistries.CONTAINER_FACTORIES); ((SandboxInternal.Registry) Registry.BLOCK).set(new BasicRegistry<>(Registry.BLOCK, Block.class, WrappingUtil::convert, WrappingUtil::convert)); ((SandboxInternal.Registry) Registry.ITEM).set(new BasicRegistry<>(Registry.ITEM, Item.class, WrappingUtil::convert, WrappingUtil::convert)); ((SandboxInternal.Registry) Registry.ENCHANTMENT).set(new BasicRegistry<>((SimpleRegistry<net.minecraft.enchantment.Enchantment>) Registry.ENCHANTMENT, Enchantment.class, WrappingUtil::convert, b -> (Enchantment) b)); ((SandboxInternal.Registry) Registry.FLUID).set(new BasicRegistry<>(Registry.FLUID, Fluid.class, WrappingUtil::convert, WrappingUtil::convert)); ((SandboxInternal.Registry) Registry.ENTITY_TYPE).set(new BasicRegistry<>(Registry.ENTITY_TYPE, Entity.Type.class, WrappingUtil::convert, WrappingUtil::convert)); ((SandboxInternal.Registry) Registry.BLOCK_ENTITY).set(new BasicRegistry((SimpleRegistry) Registry.BLOCK_ENTITY, BlockEntity.Type.class, (Function<BlockEntity.Type, BlockEntityType>) WrappingUtil::convert, (Function<BlockEntityType, BlockEntity.Type>) WrappingUtil::convert, true)); // DONT TOUCH THIS FOR HEAVENS SAKE PLEASE GOD NO ((SandboxInternal.Registry) SandboxRegistries.CONTAINER_FACTORIES).set(new BasicRegistry<>(SandboxRegistries.CONTAINER_FACTORIES, ContainerFactory.class, a -> a, a -> a)); }
Example #2
Source File: OptifabricSetup.java From OptiFabric with Mozilla Public License 2.0 | 5 votes |
private boolean isVersionValid(String modID, String validVersion) throws VersionParsingException { ModMetadata modMetadata = getModMetaData(modID); if(modMetadata == null) { throw new RuntimeException(String.format("Failed to get mod container for %s, something has broke badly.", modID)); } Predicate<SemanticVersionImpl> predicate = SemanticVersionPredicateParser.create(validVersion); SemanticVersionImpl version = new SemanticVersionImpl(modMetadata.getVersion().getFriendlyString(), false); return predicate.test(version); }
Example #3
Source File: ModList.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
private ModFileInfo createModFileInfo(ModContainer modContainer) { ModMetadata metadata = modContainer.getMetadata(); // First try to find a patchwork:annotations entry for this file. If it exists, then this is the "primary" mod // for a given JAR file. CustomValue annotations = metadata.getCustomValue("patchwork:annotations"); if (annotations != null) { String annotationJsonLocation = annotations.getAsString(); return new ModFileInfo(modContainer, annotationJsonLocation); } // If there is no annotation data indicative of a primary mod file, try to then find the parent (primary) mod ID. // This indicates that this is a dummy JiJ mod created by Patchwork Patcher. CustomValue parent = metadata.getCustomValue("patchwork:parent"); if (parent != null) { return getModFileById(parent.getAsString()); } // This mod lacks annotation data or a parent mod ID. // Check to see if it was run through an old version of Patcher (if it lacks both the parent and annotations // attributes but has the source attribute) CustomValue source = modContainer.getMetadata().getCustomValue("patchwork:source"); if (source != null) { CustomValue.CvObject object = source.getAsObject(); String loader = object.get("loader").getAsString(); if (loader.equals("forge")) { LOGGER.warn("A mod was patched with an old version of Patchwork Patcher, please re-patch it! " + "No annotation data is available for " + metadata.getId() + " (loaded from " + modContainer.getRootPath() + ")"); } } // Either a patchwork mod missing annotation data, or a normal Fabric mod. return new ModFileInfo(); }
Example #4
Source File: OptifabricSetup.java From OptiFabric with Mozilla Public License 2.0 | 4 votes |
private ModMetadata getModMetaData(String modId) { Optional<ModContainer> modContainer = FabricLoader.getInstance().getModContainer(modId); return modContainer.map(ModContainer::getMetadata).orElse(null); }
Example #5
Source File: GameProvider.java From fabric-loader with Apache License 2.0 | 4 votes |
public BuiltinMod(URL url, ModMetadata metadata) { this.url = url; this.metadata = metadata; }
Example #6
Source File: BuiltinMetadataWrapper.java From fabric-loader with Apache License 2.0 | 4 votes |
public BuiltinMetadataWrapper(ModMetadata parent) { this.parent = parent; }
Example #7
Source File: BuiltinModMetadata.java From fabric-loader with Apache License 2.0 | 4 votes |
public ModMetadata build() { return new BuiltinModMetadata(id, version, name, description, authors, contributors, contact, license, icons); }
Example #8
Source File: ModContainer.java From fabric-loader with Apache License 2.0 | 4 votes |
@Override public ModMetadata getMetadata() { return info; }
Example #9
Source File: ModContainer.java From fabric-loader with Apache License 2.0 | 2 votes |
/** * Returns the metadata of this mod. */ ModMetadata getMetadata();