Cleanup usages of static imports and build script so that our build doesn't spam useless error like messages.

So that it is easier to see real errors.
Add compatibility checking to standard testing tasks.
This commit is contained in:
LexManos committed 2023-07-17 17:26:28 -07:00
1 parent e6bb7eecbd
commit ebb316a15c
28 files changed
+202 -258

No files matched your search

@@ -5,9 +5,8 @@
package net.minecraftforge.common;
import static net.minecraftforge.fml.Logging.FORGEMOD;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.Logging;
import net.minecraftforge.fml.event.config.ModConfigEvent;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
@@ -16,7 +15,6 @@ import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
public class ForgeConfig {
public static class Server {
public final BooleanValue removeErroringBlockEntities;
@@ -135,7 +133,7 @@ public class ForgeConfig {
.define("useCombinedDepthStencilAttachment", false);
compressLanIPv6Addresses = builder
.comment("[DEPRECATED] [NOW IN COMMON CONFIG] When enabled, Forge will convert discovered 'Open to LAN' IPv6 addresses to their more compact, compressed representation")
.comment("[DEPRECATED] Does nothing anymore, IPv6 addresses will be compressed always")
.translation("forge.configgui.compressLanIPv6Addresses")
.define("compressLanIPv6Addresses", true);
@@ -171,12 +169,12 @@ public class ForgeConfig {
@SubscribeEvent
public static void onLoad(final ModConfigEvent.Loading configEvent) {
LogManager.getLogger().debug(FORGEMOD, "Loaded forge config file {}", configEvent.getConfig().getFileName());
LogManager.getLogger().debug(Logging.FORGEMOD, "Loaded forge config file {}", configEvent.getConfig().getFileName());
}
@SubscribeEvent
public static void onFileChange(final ModConfigEvent.Reloading configEvent) {
LogManager.getLogger().debug(FORGEMOD, "Forge config just got changed on the file system!");
LogManager.getLogger().debug(Logging.FORGEMOD, "Forge config just got changed on the file system!");
}
//General
@@ -5,11 +5,6 @@
package net.minecraftforge.common;
import static com.electronwill.nightconfig.core.ConfigSpec.CorrectionAction.ADD;
import static com.electronwill.nightconfig.core.ConfigSpec.CorrectionAction.REMOVE;
import static com.electronwill.nightconfig.core.ConfigSpec.CorrectionAction.REPLACE;
import static net.minecraftforge.fml.Logging.CORE;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -26,6 +21,7 @@ import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import net.minecraftforge.fml.Logging;
import net.minecraftforge.fml.config.IConfigSpec;
import net.minecraftforge.fml.loading.FMLEnvironment;
import org.apache.commons.lang3.tuple.Pair;
@@ -82,12 +78,12 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
this.childConfig = config;
if (config != null && !isCorrect(config)) {
String configName = config instanceof FileConfig ? ((FileConfig) config).getNioPath().toString() : config.toString();
LOGGER.warn(CORE, "Configuration file {} is not correct. Correcting", configName);
LOGGER.warn(Logging.CORE, "Configuration file {} is not correct. Correcting", configName);
correct(config,
(action, path, incorrectValue, correctedValue) ->
LOGGER.warn(CORE, "Incorrect key {} was corrected from {} to its default, {}. {}", DOT_JOINER.join( path ), incorrectValue, correctedValue, incorrectValue == correctedValue ? "This seems to be an error." : ""),
LOGGER.warn(Logging.CORE, "Incorrect key {} was corrected from {} to its default, {}. {}", DOT_JOINER.join( path ), incorrectValue, correctedValue, incorrectValue == correctedValue ? "This seems to be an error." : ""),
(action, path, incorrectValue, correctedValue) ->
LOGGER.debug(CORE, "The comment on key {} does not match the spec. This may create a backup.", DOT_JOINER.join( path )));
LOGGER.debug(Logging.CORE, "The comment on key {} does not match the spec. This may create a backup.", DOT_JOINER.join( path )));
if (config instanceof FileConfig) {
((FileConfig) config).save();
@@ -178,7 +174,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
final String key = specEntry.getKey();
final Object specValue = specEntry.getValue();
final Object configValue = configMap.get(key);
final CorrectionAction action = configValue == null ? ADD : REPLACE;
final CorrectionAction action = configValue == null ? CorrectionAction.ADD : CorrectionAction.REPLACE;
parentPath.addLast(key);
@@ -256,7 +252,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
ittr.remove();
parentPath.addLast(entry.getKey());
listener.onCorrect(REMOVE, parentPathUnmodifiable, entry.getValue(), null);
listener.onCorrect(CorrectionAction.REMOVE, parentPathUnmodifiable, entry.getValue(), null);
parentPath.removeLast();
count++;
}
@@ -367,13 +363,13 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
@Override
public Object correct(Object value) {
if (value == null || !(value instanceof List) || ((List<?>)value).isEmpty()) {
LOGGER.debug(CORE, "List on key {} is deemed to need correction. It is null, not a list, or an empty list. Modders, consider defineListAllowEmpty?", path.get(path.size() - 1));
LOGGER.debug(Logging.CORE, "List on key {} is deemed to need correction. It is null, not a list, or an empty list. Modders, consider defineListAllowEmpty?", path.get(path.size() - 1));
return getDefault();
}
List<?> list = Lists.newArrayList((List<?>) value);
list.removeIf(elementValidator.negate());
if (list.isEmpty()) {
LOGGER.debug(CORE, "List on key {} is deemed to need correction. It failed validation.", path.get(path.size() - 1));
LOGGER.debug(Logging.CORE, "List on key {} is deemed to need correction. It failed validation.", path.get(path.size() - 1));
return getDefault();
}
return list;
@@ -395,13 +391,13 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
@Override
public Object correct(Object value) {
if (value == null || !(value instanceof List)) {
LOGGER.debug(CORE, "List on key {} is deemed to need correction, as it is null or not a list.", path.get(path.size() - 1));
LOGGER.debug(Logging.CORE, "List on key {} is deemed to need correction, as it is null or not a list.", path.get(path.size() - 1));
return getDefault();
}
List<?> list = Lists.newArrayList((List<?>) value);
list.removeIf(elementValidator.negate());
if (list.isEmpty()) {
LOGGER.debug(CORE, "List on key {} is deemed to need correction. It failed validation.", path.get(path.size() - 1));
LOGGER.debug(Logging.CORE, "List on key {} is deemed to need correction. It failed validation.", path.get(path.size() - 1));
return getDefault();
}
return list;
@@ -654,7 +650,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
if (comment.stream().allMatch(String::isBlank))
{
if (FMLEnvironment.production)
LOGGER.warn(CORE, "Detected a comment that is all whitespace for config option {}, which causes obscure bugs in Forge's config system and will cause a crash in the future. Please report this to the mod author.",
LOGGER.warn(Logging.CORE, "Detected a comment that is all whitespace for config option {}, which causes obscure bugs in Forge's config system and will cause a crash in the future. Please report this to the mod author.",
DOT_JOINER.join(path));
else
throw new IllegalStateException("Can not build comment for config option " + DOT_JOINER.join(path) + " as it comprises entirely of blank lines/whitespace. This is not allowed as it causes a \"constantly correcting config\" bug with NightConfig in Forge's config system.");
@@ -730,7 +726,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
boolean result = ((Number)min).doubleValue() <= n.doubleValue() && n.doubleValue() <= ((Number)max).doubleValue();
if(!result)
{
LOGGER.debug(CORE, "Range value {} is not within its bounds {}-{}", n.doubleValue(), ((Number)min).doubleValue(), ((Number)max).doubleValue());
LOGGER.debug(Logging.CORE, "Range value {} is not within its bounds {}-{}", n.doubleValue(), ((Number)min).doubleValue(), ((Number)max).doubleValue());
}
return result;
}
@@ -740,7 +736,7 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper<UnmodifiableConfi
boolean result = c.compareTo(min) >= 0 && c.compareTo(max) <= 0;
if(!result)
{
LOGGER.debug(CORE, "Range value {} is not within its bounds {}-{}", c, min, max);
LOGGER.debug(Logging.CORE, "Range value {} is not within its bounds {}-{}", c, min, max);
}
return result;
}
@@ -7,6 +7,7 @@ package net.minecraftforge.common;
import com.google.common.base.CharMatcher;
import net.minecraftforge.common.util.MavenVersionStringHelper;
import net.minecraftforge.fml.Logging;
import net.minecraftforge.fml.loading.StringUtils;
import net.minecraftforge.forgespi.language.IModInfo;
import org.apache.commons.lang3.text.ExtendedMessageFormat;
@@ -23,8 +24,6 @@ import java.util.Objects;
import java.util.function.BiConsumer;
import java.util.regex.Pattern;
import static net.minecraftforge.fml.Logging.CORE;
//TODO, this should be re-evaluated now that ITextComponents are passed everywhere instaed of strings.
public class ForgeI18n {
private static final Logger LOGGER = LogManager.getLogger();
@@ -81,7 +80,7 @@ public class ForgeI18n {
}
public static void loadLanguageData(final Map<String, String> properties) {
LOGGER.debug(CORE,"Loading I18N data entries: {}", properties.size());
LOGGER.debug(Logging.CORE,"Loading I18N data entries: {}", properties.size());
i18n = properties;
}
@@ -90,7 +89,7 @@ public class ForgeI18n {
try {
return parseFormat(pattern, args);
} catch (IllegalArgumentException e) {
LOGGER.error(CORE,"Illegal format found `{}`", pattern);
LOGGER.error(Logging.CORE,"Illegal format found `{}`", pattern);
return pattern;
}
}
@@ -5,10 +5,8 @@
package net.minecraftforge.common;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BiomeTags;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.ItemTags;
@@ -19,7 +17,6 @@ import net.minecraft.world.item.Item;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.registries.ForgeRegistries;
public class Tags
{
@@ -5,6 +5,7 @@
package net.minecraftforge.common.capabilities;
import net.minecraftforge.fml.Logging;
import net.minecraftforge.fml.ModLoader;
import net.minecraftforge.forgespi.language.ModFileScanData;
import org.apache.logging.log4j.LogManager;
@@ -15,8 +16,6 @@ import java.util.Comparator;
import java.util.IdentityHashMap;
import java.util.List;
import static net.minecraftforge.fml.Logging.CAPABILITIES;
public enum CapabilityManager
{
INSTANCE;
@@ -46,7 +45,7 @@ public enum CapabilityManager
{
if (cap.isRegistered())
{
LOGGER.error(CAPABILITIES, "Cannot register capability implementation multiple times : {}", realName);
LOGGER.error(Logging.CAPABILITIES, "Cannot register capability implementation multiple times : {}", realName);
throw new IllegalArgumentException("Cannot register a capability implementation multiple times : "+ realName);
}
else
@@ -74,7 +73,7 @@ public enum CapabilityManager
for (var auto : autos)
{
LOGGER.debug(CAPABILITIES, "Attempting to automatically register: " + auto);
LOGGER.debug(Logging.CAPABILITIES, "Attempting to automatically register: " + auto);
get(auto.getInternalName(), true);
}
@@ -10,8 +10,6 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandlerItem;
import net.minecraftforge.items.IItemHandler;
import static net.minecraftforge.common.capabilities.CapabilityManager.get;
/*
* References to Forge's built in capabilities.
* Modders are recommended to use their own CapabilityTokens for 3rd party caps to maintain soft dependencies.
@@ -19,8 +17,8 @@ import static net.minecraftforge.common.capabilities.CapabilityManager.get;
*/
public class ForgeCapabilities
{
public static final Capability<IEnergyStorage> ENERGY = get(new CapabilityToken<>(){});
public static final Capability<IFluidHandler> FLUID_HANDLER = get(new CapabilityToken<>(){});
public static final Capability<IFluidHandlerItem> FLUID_HANDLER_ITEM = get(new CapabilityToken<>(){});
public static final Capability<IItemHandler> ITEM_HANDLER = get(new CapabilityToken<>(){});
public static final Capability<IEnergyStorage> ENERGY = CapabilityManager.get(new CapabilityToken<>(){});
public static final Capability<IFluidHandler> FLUID_HANDLER = CapabilityManager.get(new CapabilityToken<>(){});
public static final Capability<IFluidHandlerItem> FLUID_HANDLER_ITEM = CapabilityManager.get(new CapabilityToken<>(){});
public static final Capability<IItemHandler> ITEM_HANDLER = CapabilityManager.get(new CapabilityToken<>(){});
}
@@ -6,9 +6,7 @@
package net.minecraftforge.common.data;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.Registries;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.IntrinsicHolderTagsProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.TagKey;
@@ -23,6 +21,7 @@ import java.util.Locale;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
// We typically don't do static imports as S2S can't remap them {as they are not qualified}, however this conflicts with vanilla and our tag class names, and our tags don't get obfed so its one line of warning.
import static net.minecraftforge.common.Tags.Blocks.*;
public final class ForgeBlockTagsProvider extends BlockTagsProvider
@@ -9,11 +9,10 @@ import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.FluidTagsProvider;
import net.minecraftforge.common.ForgeMod;
import net.minecraftforge.common.Tags.Fluids;
import java.util.concurrent.CompletableFuture;
import static net.minecraftforge.common.Tags.Fluids.MILK;
public final class ForgeFluidTagsProvider extends FluidTagsProvider
{
public ForgeFluidTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, ExistingFileHelper existingFileHelper)
@@ -24,7 +23,7 @@ public final class ForgeFluidTagsProvider extends FluidTagsProvider
@Override
public void addTags(HolderLookup.Provider lookupProvider)
{
tag(MILK).addOptional(ForgeMod.MILK.getId()).addOptional(ForgeMod.FLOWING_MILK.getId());
tag(Fluids.MILK).addOptional(ForgeMod.MILK.getId()).addOptional(ForgeMod.FLOWING_MILK.getId());
}
@Override