mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 00:37:52 +00:00
Fix RuntimeEnumExtender creating new enums with incorrect ordinal value (#5402)
This commit is contained in:
1 parent
6365674a2a
commit
d2a3b5bed8
3 files changed
+27
-39
No files matched your search
@@ -21,56 +21,41 @@ package net.minecraftforge.debug.misc;
|
||||
|
||||
import net.minecraftforge.common.BiomeManager.BiomeType;
|
||||
import net.minecraftforge.common.EnumPlantType;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.DeferredWorkQueue;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLModLoadingContext;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@Mod(modid = "enumplanttypetest", name = "EnumPlantTypeTest", version = "1.0", acceptableRemoteVersions = "*")
|
||||
@Mod("enumplanttypetest")
|
||||
public class EnumPlantTypeTest
|
||||
{
|
||||
private static Logger logger;
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onPreInit(FMLPreInitializationEvent event)
|
||||
public EnumPlantTypeTest()
|
||||
{
|
||||
logger = event.getModLog();
|
||||
FMLModLoadingContext.get().getModEventBus().addListener(this::setup);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void onInit(FMLInitializationEvent event)
|
||||
@SubscribeEvent
|
||||
public void setup(final FMLCommonSetupEvent event)
|
||||
{
|
||||
BiomeType biomeType = null;
|
||||
try
|
||||
DeferredWorkQueue.runLater(() ->
|
||||
{
|
||||
biomeType = BiomeType.getType("FAKE");
|
||||
}
|
||||
catch (NullPointerException npe)
|
||||
{
|
||||
logger.warn("EnumHelper in BiomeType is working incorrectly!", npe);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (biomeType == null || !biomeType.name().equals("FAKE"))
|
||||
int index = BiomeType.values().length;
|
||||
BiomeType biomeType = BiomeType.create("FAKE");
|
||||
if (biomeType == null || !biomeType.name().equals("FAKE") || biomeType.ordinal() != index)
|
||||
{
|
||||
logger.warn("EnumHelper in BiomeType is working incorrectly!");
|
||||
LOGGER.warn("RuntimeEnumExtender is working incorrectly for BiomeType!");
|
||||
}
|
||||
}
|
||||
EnumPlantType plantType = null;
|
||||
try
|
||||
{
|
||||
plantType = EnumPlantType.getPlantType("FAKE");
|
||||
}
|
||||
catch (NullPointerException npe)
|
||||
{
|
||||
logger.warn("EnumHelper in EnumPlantType is working incorrectly!", npe);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (plantType == null || !plantType.name().equals("FAKE"))
|
||||
|
||||
EnumPlantType plantType = EnumPlantType.create("FAKE");
|
||||
if (plantType == null || !plantType.name().equals("FAKE") || plantType != EnumPlantType.create("FAKE"))
|
||||
{
|
||||
logger.warn("EnumHelper in EnumPlantType is working incorrectly!");
|
||||
LOGGER.warn("RuntimeEnumExtender is working incorrectly for EnumPlantType!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user