mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Cleanup FMLLoader and Launch Handlers.
Cleanup some of the build.gradle Start work on restructuring test mods. They are now treated as their own jars, as well as having their mods.toml auto-generated. No more mods.toml conflicts! Add pattern matching support to Data run modlist.
This commit is contained in:
64 files changed
+883
-1108
No files matched your search
@@ -20,7 +20,6 @@ import net.minecraft.FileUtil;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MouseHandler;
|
||||
import net.minecraft.client.Options;
|
||||
import net.minecraft.client.color.block.BlockColors;
|
||||
import net.minecraft.client.color.item.ItemColors;
|
||||
@@ -60,7 +59,6 @@ import net.minecraft.client.renderer.texture.SpriteContents;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlas;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.resources.language.I18n;
|
||||
import net.minecraft.client.resources.metadata.animation.AnimationMetadataSection;
|
||||
import net.minecraft.client.resources.metadata.animation.FrameSize;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.client.resources.model.Material;
|
||||
@@ -76,12 +74,10 @@ import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.ChatTypeDecoration;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.ComponentContents;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.protocol.status.ServerStatus;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ReloadableResourceManager;
|
||||
import net.minecraft.server.packs.resources.Resource;
|
||||
@@ -97,10 +93,8 @@ import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.ItemStackLinkedSet;
|
||||
import net.minecraft.world.item.crafting.RecipeManager;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.GameType;
|
||||
@@ -151,12 +145,9 @@ import net.minecraftforge.client.model.data.ModelData;
|
||||
import net.minecraftforge.client.textures.ForgeTextureMetadata;
|
||||
import net.minecraftforge.client.textures.TextureAtlasSpriteLoaderManager;
|
||||
import net.minecraftforge.common.ForgeConfig;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.ForgeI18n;
|
||||
import net.minecraftforge.common.ForgeMod;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.MutableHashedLinkedMap;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.IExtensionPoint;
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.lwjgl.opengl.GL11;
|
||||
/**
|
||||
* All the vanilla {@linkplain IGuiOverlay HUD overlays} in the order that they render.
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public enum VanillaGuiOverlay {
|
||||
VIGNETTE("vignette", (gui, guiGraphics, partialTick, screenWidth, screenHeight) -> {
|
||||
if (Minecraft.useFancyGraphics()) {
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
package net.minecraftforge.data.loading;
|
||||
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.data.registries.VanillaRegistries;
|
||||
import net.minecraft.server.Bootstrap;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.ModWorkManager;
|
||||
import net.minecraftforge.data.event.GatherDataEvent;
|
||||
@@ -19,12 +19,13 @@ import org.apache.logging.log4j.Logger;
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DatagenModLoader {
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static GatherDataEvent.DataGeneratorConfig dataGeneratorConfig;
|
||||
private static ExistingFileHelper existingFileHelper;
|
||||
private static boolean runningDataGen;
|
||||
|
||||
@@ -32,25 +33,49 @@ public class DatagenModLoader {
|
||||
return runningDataGen;
|
||||
}
|
||||
|
||||
public static void begin(final Set<String> mods, final Path path, final Collection<Path> inputs, Collection<Path> existingPacks,
|
||||
Set<String> existingMods, final boolean serverGenerators, final boolean clientGenerators, final boolean devToolGenerators, final boolean reportsGenerator,
|
||||
final boolean structureValidator, final boolean flat, final String assetIndex, final File assetsDir) {
|
||||
if (mods.contains("minecraft") && mods.size() == 1)
|
||||
public static void begin(
|
||||
Set<String> patterns, Path output, Collection<Path> inputs, Collection<Path> existingPacks, Set<String> existingMods,
|
||||
boolean genServer, boolean genClient, boolean genDev, boolean genReports,
|
||||
boolean validate, boolean flat, String assetIndex, File assetsDir
|
||||
) {
|
||||
if (patterns.contains("minecraft") && patterns.size() == 1)
|
||||
return;
|
||||
LOGGER.info("Initializing Data Gatherer for mods {}", mods);
|
||||
|
||||
runningDataGen = true;
|
||||
Bootstrap.bootStrap();
|
||||
ModLoader.get().gatherAndInitializeMods(ModWorkManager.syncExecutor(), ModWorkManager.parallelExecutor(), ()->{});
|
||||
CompletableFuture<HolderLookup.Provider> lookupProvider = CompletableFuture.supplyAsync(VanillaRegistries::createLookup, Util.backgroundExecutor());
|
||||
dataGeneratorConfig = new GatherDataEvent.DataGeneratorConfig(mods, path, inputs, lookupProvider, serverGenerators,
|
||||
clientGenerators, devToolGenerators, reportsGenerator, structureValidator, flat);
|
||||
var lookupProvider = CompletableFuture.supplyAsync(VanillaRegistries::createLookup, Util.backgroundExecutor());
|
||||
|
||||
var mods = new HashSet<String>();
|
||||
for (var pattern : patterns) {
|
||||
if (pattern.indexOf('.') == -1) // No wildcard!
|
||||
mods.add(pattern);
|
||||
|
||||
var m = Pattern.compile('^' + pattern + '$');
|
||||
ModList.get().forEachModInOrder(mc -> {
|
||||
var id = mc.getModId();
|
||||
if (!"forge".equals(id) && !"minecraft".equals(id) && m.matcher(id).matches())
|
||||
mods.add(id);
|
||||
});
|
||||
}
|
||||
LOGGER.info("Initializing Data Gatherer for mods {}", mods);
|
||||
|
||||
var config = new GatherDataEvent.DataGeneratorConfig(mods, output, inputs, lookupProvider, genServer,
|
||||
genClient, genDev, genReports, validate, flat);
|
||||
|
||||
if (!mods.contains("forge")) {
|
||||
// If we aren't generating data for forge, automatically add forge as an existing so mods can access forge's data
|
||||
existingMods.add("forge");
|
||||
}
|
||||
existingFileHelper = new ExistingFileHelper(existingPacks, existingMods, structureValidator, assetIndex, assetsDir);
|
||||
ModLoader.get().runEventGenerator(mc -> new GatherDataEvent(mc, dataGeneratorConfig.makeGenerator(p -> dataGeneratorConfig.isFlat() ? p : p.resolve(mc.getModId()),
|
||||
dataGeneratorConfig.getMods().contains(mc.getModId())), dataGeneratorConfig, existingFileHelper));
|
||||
dataGeneratorConfig.runAll();
|
||||
|
||||
existingFileHelper = new ExistingFileHelper(existingPacks, existingMods, validate, assetIndex, assetsDir);
|
||||
ModLoader.get().runEventGenerator(mc -> new GatherDataEvent(
|
||||
mc,
|
||||
config.makeGenerator(
|
||||
p -> config.isFlat() ? p : p.resolve(mc.getModId()),
|
||||
config.getMods().contains(mc.getModId())
|
||||
), config, existingFileHelper)
|
||||
);
|
||||
config.runAll();
|
||||
}
|
||||
}
|
||||
@@ -27,14 +27,12 @@ import java.util.concurrent.Executor;
|
||||
* The event is fired on each reload and lets modders add their own ReloadListeners, for server-side resources.
|
||||
* The event is fired on the {@link MinecraftForge#EVENT_BUS}
|
||||
*/
|
||||
public class AddReloadListenerEvent extends Event
|
||||
{
|
||||
public class AddReloadListenerEvent extends Event {
|
||||
private final List<PreparableReloadListener> listeners = new ArrayList<>();
|
||||
private final ReloadableServerResources serverResources;
|
||||
private final RegistryAccess registryAccess;
|
||||
|
||||
public AddReloadListenerEvent(ReloadableServerResources serverResources, RegistryAccess registryAccess)
|
||||
{
|
||||
public AddReloadListenerEvent(ReloadableServerResources serverResources, RegistryAccess registryAccess) {
|
||||
this.serverResources = serverResources;
|
||||
this.registryAccess = registryAccess;
|
||||
}
|
||||
@@ -42,21 +40,18 @@ public class AddReloadListenerEvent extends Event
|
||||
/**
|
||||
* @param listener the listener to add to the ResourceManager on reload
|
||||
*/
|
||||
public void addListener(PreparableReloadListener listener)
|
||||
{
|
||||
public void addListener(PreparableReloadListener listener) {
|
||||
listeners.add(new WrappedStateAwareListener(listener));
|
||||
}
|
||||
|
||||
public List<PreparableReloadListener> getListeners()
|
||||
{
|
||||
public List<PreparableReloadListener> getListeners() {
|
||||
return ImmutableList.copyOf(listeners);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The ReloableServerResources being reloaded.
|
||||
*/
|
||||
public ReloadableServerResources getServerResources()
|
||||
{
|
||||
public ReloadableServerResources getServerResources() {
|
||||
return serverResources;
|
||||
}
|
||||
|
||||
@@ -64,8 +59,7 @@ public class AddReloadListenerEvent extends Event
|
||||
* This context object holds data relevant to the current reload, such as staged tags.
|
||||
* @return The condition context for the currently active reload.
|
||||
*/
|
||||
public ICondition.IContext getConditionContext()
|
||||
{
|
||||
public ICondition.IContext getConditionContext() {
|
||||
return serverResources.getConditionContext();
|
||||
}
|
||||
|
||||
@@ -74,8 +68,7 @@ public class AddReloadListenerEvent extends Event
|
||||
* All built-in and dynamic registries are loaded and frozen by this point.
|
||||
* @return The RegistryAccess context for the currently active reload.
|
||||
*/
|
||||
public RegistryAccess getRegistryAccess()
|
||||
{
|
||||
public RegistryAccess getRegistryAccess() {
|
||||
return registryAccess;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user