mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
Forge 1.19
* Bump pack.mcmeta formats * 1.19 biome modifiers * Mark ClientPlayerNetworkEvent.LoggedOutEvent's getters as nullable * Add docs and package-info to client extension interfaces package * Move RenderBlockOverlayEvent hooks to ForgeHooksClient * Add package-infos to client events package * Rename SoundLoadEvent to SoundEngineLoadEvent This reduces confusion from consumers which may think the name SoundLoadEvent refers to an individual sound being loaded rather than the sound engine. * Document and change SoundLoadEvent to fire on mod bus Previously, it fired on both the mod bus and the Forge bus, which is confusing for consumers. * Delete SoundSetupEvent Looking at its original implementation shows that there isn't an appropriate place in the new sound code to reinsert the event, and the place of 'sound engine/manager initialization event' is taken already by SoundLoadEvent. * Perform some cleanup on client events - Removed nullable annotations from ClientPlayerNetworkEvent - Renamed #getPartialTicks methods to #getPartialTick, to be consistent with vanilla's naming of the partial tick - Cleanup documentation to remove line breaks, use the spelling 'cancelled' over 'canceled', and improve docs on existing and new methods. * Remove EntityEvent.CanUpdate Closes MinecraftForge/MinecraftForge#6394 * Switch to Jetbrains nullability annotations * New PlayLevelSoundEvent; replaces old PlaySoundAtEntityEvent * Remove ForgeWorldPresetScreens * Remove IForgeRegistryEntry * Remove use of List<Throwable> in FML's CompletableFutures * Add docs to mod loading stages, stages, and phases * Gradle 7.4.2 * Use SLF4J in FMLLoader and other subprojects * Switch dynamic versions in subprojects to pinned ones * Switch ForgeRoot and MDK to FG plugin markers * Configure Forge javadoc task The task now uses a custom stylesheet with MCForge elements, and configured to combine the generation from the four FML subprojects (fmlloader, fmlcore, javafmllanguage, mclanguage) and the Forge project into the javadoc output. * Update docs/md files, for 1.19 update and the move away from IRC to Discord. * Make "Potentially dangerous alternative prefix" a debug warning, not info. Co-authored-by: Curle <[email protected]> Co-authored-by: sciwhiz12 <[email protected]> Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
1 parent
270e778ac5
commit
4ed9117799
1485 files changed
+14960
-15446
No files matched your search
@@ -5,86 +5,65 @@
|
||||
|
||||
package net.minecraftforge.registries;
|
||||
|
||||
import com.google.common.collect.*;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.mojang.serialization.Lifecycle;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.minecraft.core.DefaultedRegistry;
|
||||
import net.minecraft.core.IdMapper;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.BuiltinRegistries;
|
||||
import net.minecraft.world.level.block.AirBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.network.syncher.EntityDataSerializer;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||
import net.minecraft.world.entity.ai.attributes.DefaultAttributes;
|
||||
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
|
||||
import net.minecraft.world.entity.schedule.Activity;
|
||||
import net.minecraft.world.entity.schedule.Schedule;
|
||||
import net.minecraft.world.entity.ai.sensing.SensorType;
|
||||
import net.minecraft.world.entity.decoration.Motive;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.inventory.MenuType;
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiType;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.crafting.RecipeSerializer;
|
||||
import net.minecraft.network.syncher.EntityDataSerializer;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.item.alchemy.Potion;
|
||||
import net.minecraft.world.level.block.AirBlock;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.state.StateDefinition;
|
||||
import net.minecraft.stats.StatType;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.core.DefaultedRegistry;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.MappedRegistry;
|
||||
import net.minecraft.world.entity.ai.village.poi.PoiType;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
import net.minecraft.world.level.levelgen.DebugLevelSource;
|
||||
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProviderType;
|
||||
import net.minecraft.world.level.levelgen.carver.WorldCarver;
|
||||
import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.StructureFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType;
|
||||
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
|
||||
import net.minecraftforge.common.util.LogMessageAdapter;
|
||||
import net.minecraftforge.common.world.ForgeWorldPreset;
|
||||
import net.minecraftforge.event.RegistryEvent;
|
||||
import net.minecraftforge.event.RegistryEvent.MissingMappings;
|
||||
import net.minecraftforge.fml.ModLoader;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.IModStateTransition;
|
||||
import net.minecraftforge.fml.StartupMessageManager;
|
||||
import net.minecraftforge.fml.util.EnhancedRuntimeException;
|
||||
import net.minecraftforge.fml.util.thread.EffectiveSide;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES;
|
||||
import static net.minecraftforge.registries.ForgeRegistries.Keys.*;
|
||||
|
||||
import net.minecraft.core.IdMapper;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
|
||||
/**
|
||||
* INTERNAL ONLY
|
||||
* MODDERS SHOULD HAVE NO REASON TO USE THIS CLASS
|
||||
@@ -97,7 +76,6 @@ public class GameData
|
||||
private static final ResourceLocation BLOCK_TO_ITEM = new ResourceLocation("minecraft:blocktoitemmap");
|
||||
private static final ResourceLocation BLOCKSTATE_TO_ID = new ResourceLocation("minecraft:blockstatetoid");
|
||||
private static final ResourceLocation BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE = new ResourceLocation("minecraft:blockstatetopointofinteresttype");
|
||||
private static final ResourceLocation SERIALIZER_TO_ENTRY = new ResourceLocation("forge:serializer_to_entry");
|
||||
private static final ResourceLocation STRUCTURES = new ResourceLocation("minecraft:structures");
|
||||
|
||||
private static boolean hasInit = false;
|
||||
@@ -120,77 +98,73 @@ public class GameData
|
||||
hasInit = true;
|
||||
|
||||
// Game objects
|
||||
makeRegistry(BLOCKS, Block.class, "air").addCallback(BlockCallbacks.INSTANCE).legacyName("blocks").vanillaHolder(Block::builtInRegistryHolder).create();
|
||||
makeRegistry(FLUIDS, Fluid.class, "empty").vanillaHolder(Fluid::builtInRegistryHolder).create();
|
||||
makeRegistry(ITEMS, Item.class, "air").addCallback(ItemCallbacks.INSTANCE).legacyName("items").vanillaHolder(Item::builtInRegistryHolder).create();
|
||||
makeRegistry(MOB_EFFECTS, MobEffect.class).legacyName("potions").create();
|
||||
makeRegistry(BLOCKS, "air").addCallback(BlockCallbacks.INSTANCE).legacyName("blocks").vanillaHolder(Block::builtInRegistryHolder).create();
|
||||
makeRegistry(FLUIDS, "empty").vanillaHolder(Fluid::builtInRegistryHolder).create();
|
||||
makeRegistry(ITEMS, "air").addCallback(ItemCallbacks.INSTANCE).legacyName("items").vanillaHolder(Item::builtInRegistryHolder).create();
|
||||
makeRegistry(MOB_EFFECTS).legacyName("potions").create();
|
||||
//makeRegistry(BIOMES, Biome.class).legacyName("biomes").create();
|
||||
makeRegistry(SOUND_EVENTS, SoundEvent.class).legacyName("soundevents").create();
|
||||
makeRegistry(POTIONS, Potion.class, "empty").legacyName("potiontypes").create();
|
||||
makeRegistry(ENCHANTMENTS, Enchantment.class).legacyName("enchantments").create();
|
||||
makeRegistry(ENTITY_TYPES, c(EntityType.class), "pig").legacyName("entities").vanillaHolder(EntityType::builtInRegistryHolder).create();
|
||||
makeRegistry(BLOCK_ENTITY_TYPES, c(BlockEntityType.class)).disableSaving().legacyName("blockentities").create();
|
||||
makeRegistry(PARTICLE_TYPES, c(ParticleType.class)).disableSaving().create();
|
||||
makeRegistry(CONTAINER_TYPES, c(MenuType.class)).disableSaving().create();
|
||||
makeRegistry(PAINTING_TYPES, Motive.class, "kebab").create();
|
||||
makeRegistry(RECIPE_SERIALIZERS, c(RecipeSerializer.class)).disableSaving().create();
|
||||
makeRegistry(ATTRIBUTES, Attribute.class).onValidate(AttributeCallbacks.INSTANCE).disableSaving().disableSync().create();
|
||||
makeRegistry(STAT_TYPES, c(StatType.class)).create();
|
||||
makeRegistry(SOUND_EVENTS).legacyName("soundevents").create();
|
||||
makeRegistry(POTIONS, "empty").legacyName("potiontypes").create();
|
||||
makeRegistry(ENCHANTMENTS).legacyName("enchantments").create();
|
||||
makeRegistry(ENTITY_TYPES, "pig").legacyName("entities").vanillaHolder(EntityType::builtInRegistryHolder).create();
|
||||
makeRegistry(BLOCK_ENTITY_TYPES).disableSaving().legacyName("blockentities").create();
|
||||
makeRegistry(PARTICLE_TYPES).disableSaving().create();
|
||||
makeRegistry(CONTAINER_TYPES).disableSaving().create();
|
||||
makeRegistry(PAINTING_VARIANTS, "kebab").create();
|
||||
makeRegistry(RECIPE_TYPES).disableSaving().disableSync().create();
|
||||
makeRegistry(RECIPE_SERIALIZERS).disableSaving().create();
|
||||
makeRegistry(ATTRIBUTES).onValidate(AttributeCallbacks.INSTANCE).disableSaving().disableSync().create();
|
||||
makeRegistry(STAT_TYPES).create();
|
||||
|
||||
// Villagers
|
||||
makeRegistry(VILLAGER_PROFESSIONS, VillagerProfession.class, "none").create();
|
||||
makeRegistry(POI_TYPES, PoiType.class, "unemployed").addCallback(PointOfInterestTypeCallbacks.INSTANCE).disableSync().create();
|
||||
makeRegistry(MEMORY_MODULE_TYPES, c(MemoryModuleType.class), "dummy").disableSync().create();
|
||||
makeRegistry(SENSOR_TYPES, c(SensorType.class), "dummy").disableSaving().disableSync().create();
|
||||
makeRegistry(SCHEDULES, Schedule.class).disableSaving().disableSync().create();
|
||||
makeRegistry(ACTIVITIES, Activity.class).disableSaving().disableSync().create();
|
||||
makeRegistry(VILLAGER_PROFESSIONS, "none").create();
|
||||
makeRegistry(POI_TYPES).addCallback(PointOfInterestTypeCallbacks.INSTANCE).disableSync().create();
|
||||
makeRegistry(MEMORY_MODULE_TYPES, "dummy").disableSync().create();
|
||||
makeRegistry(SENSOR_TYPES, "dummy").disableSaving().disableSync().create();
|
||||
makeRegistry(SCHEDULES).disableSaving().disableSync().create();
|
||||
makeRegistry(ACTIVITIES).disableSaving().disableSync().create();
|
||||
|
||||
// Worldgen
|
||||
makeRegistry(WORLD_CARVERS, c(WorldCarver.class)).disableSaving().disableSync().create();
|
||||
makeRegistry(FEATURES, c(Feature.class)).addCallback(FeatureCallbacks.INSTANCE).disableSaving().disableSync().create();
|
||||
makeRegistry(CHUNK_STATUS, ChunkStatus.class, "empty").disableSaving().disableSync().create();
|
||||
makeRegistry(STRUCTURE_FEATURES, c(StructureFeature.class)).disableSaving().disableSync().create();
|
||||
makeRegistry(BLOCK_STATE_PROVIDER_TYPES, c(BlockStateProviderType.class)).disableSaving().disableSync().create();
|
||||
makeRegistry(FOLIAGE_PLACER_TYPES, c(FoliagePlacerType.class)).disableSaving().disableSync().create();
|
||||
makeRegistry(TREE_DECORATOR_TYPES, c(TreeDecoratorType.class)).disableSaving().disableSync().create();
|
||||
makeRegistry(WORLD_CARVERS).disableSaving().disableSync().create();
|
||||
makeRegistry(FEATURES).addCallback(FeatureCallbacks.INSTANCE).disableSaving().disableSync().create();
|
||||
makeRegistry(CHUNK_STATUS, "empty").disableSaving().disableSync().create();
|
||||
makeRegistry(BLOCK_STATE_PROVIDER_TYPES).disableSaving().disableSync().create();
|
||||
makeRegistry(FOLIAGE_PLACER_TYPES).disableSaving().disableSync().create();
|
||||
makeRegistry(TREE_DECORATOR_TYPES).disableSaving().disableSync().create();
|
||||
|
||||
// Dynamic Worldgen
|
||||
makeRegistry(BIOMES, Biome.class).disableSync().create();
|
||||
makeRegistry(BIOMES).disableSync().create();
|
||||
}
|
||||
|
||||
static RegistryBuilder<DataSerializerEntry> getDataSerializersRegistryBuilder()
|
||||
static RegistryBuilder<EntityDataSerializer<?>> getDataSerializersRegistryBuilder()
|
||||
{
|
||||
return makeRegistry(DATA_SERIALIZERS, DataSerializerEntry.class, 256 /*vanilla space*/, MAX_VARINT).disableSaving().disableOverrides()
|
||||
.addCallback(SerializerCallbacks.INSTANCE);
|
||||
return makeRegistry(DATA_SERIALIZERS, 256 /*vanilla space*/, MAX_VARINT).disableSaving().disableOverrides();
|
||||
}
|
||||
|
||||
static RegistryBuilder<GlobalLootModifierSerializer<?>> getGLMSerializersRegistryBuilder()
|
||||
{
|
||||
return makeRegistry(LOOT_MODIFIER_SERIALIZERS, c(GlobalLootModifierSerializer.class)).disableSaving().disableSync();
|
||||
return makeRegistry(LOOT_MODIFIER_SERIALIZERS).disableSaving().disableSync();
|
||||
}
|
||||
|
||||
static RegistryBuilder<ForgeWorldPreset> getWorldTypesRegistryBuilder()
|
||||
{
|
||||
return makeRegistry(WORLD_TYPES, ForgeWorldPreset.class).disableSaving().disableSync();
|
||||
return makeRegistry(WORLD_TYPES).disableSaving().disableSync();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked") //Ugly hack to let us pass in a typed Class object. Remove when we remove type specific references.
|
||||
static <T> Class<T> c(Class<?> cls) { return (Class<T>)cls; }
|
||||
|
||||
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceKey<? extends Registry<T>> key, Class<T> type)
|
||||
private static <T> RegistryBuilder<T> makeRegistry(ResourceKey<? extends Registry<T>> key)
|
||||
{
|
||||
return new RegistryBuilder<T>().setName(key.location()).setType(type).setMaxID(MAX_VARINT).hasWrapper();
|
||||
return new RegistryBuilder<T>().setName(key.location()).setMaxID(MAX_VARINT).hasWrapper();
|
||||
}
|
||||
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceKey<? extends Registry<T>> key, Class<T> type, int min, int max)
|
||||
private static <T> RegistryBuilder<T> makeRegistry(ResourceKey<? extends Registry<T>> key, int min, int max)
|
||||
{
|
||||
return new RegistryBuilder<T>().setName(key.location()).setType(type).setIDRange(min, max).hasWrapper();
|
||||
return new RegistryBuilder<T>().setName(key.location()).setIDRange(min, max).hasWrapper();
|
||||
}
|
||||
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceKey<? extends Registry<T>> key, Class<T> type, String _default)
|
||||
private static <T> RegistryBuilder<T> makeRegistry(ResourceKey<? extends Registry<T>> key, String _default)
|
||||
{
|
||||
return new RegistryBuilder<T>().setName(key.location()).setType(type).setMaxID(MAX_VARINT).hasWrapper().setDefaultKey(new ResourceLocation(_default));
|
||||
return new RegistryBuilder<T>().setName(key.location()).setMaxID(MAX_VARINT).hasWrapper().setDefaultKey(new ResourceLocation(_default));
|
||||
}
|
||||
|
||||
public static <T extends IForgeRegistryEntry<T>> MappedRegistry<T> getWrapper(ResourceKey<? extends Registry<T>> key, Lifecycle lifecycle)
|
||||
public static <T> MappedRegistry<T> getWrapper(ResourceKey<? extends Registry<T>> key, Lifecycle lifecycle)
|
||||
{
|
||||
IForgeRegistry<T> reg = RegistryManager.ACTIVE.getRegistry(key);
|
||||
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + key.toString());
|
||||
@@ -200,7 +174,7 @@ public class GameData
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static <T extends IForgeRegistryEntry<T>> DefaultedRegistry<T> getWrapper(ResourceKey<? extends Registry<T>> key, Lifecycle lifecycle, String defKey)
|
||||
public static <T> DefaultedRegistry<T> getWrapper(ResourceKey<? extends Registry<T>> key, Lifecycle lifecycle, String defKey)
|
||||
{
|
||||
IForgeRegistry<T> reg = RegistryManager.ACTIVE.getRegistry(key);
|
||||
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + key.toString());
|
||||
@@ -228,37 +202,13 @@ public class GameData
|
||||
return RegistryManager.ACTIVE.getRegistry(POI_TYPES).getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<EntityDataSerializer<?>, DataSerializerEntry> getSerializerMap()
|
||||
{
|
||||
ForgeRegistry<DataSerializerEntry> registry = RegistryManager.ACTIVE.getRegistry(DATA_SERIALIZERS);
|
||||
return registry == null ? null : registry.getSlaveMap(SERIALIZER_TO_ENTRY, Map.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static BiMap<String, StructureFeature<?>> getStructureMap()
|
||||
{
|
||||
return (BiMap<String, StructureFeature<?>>) RegistryManager.ACTIVE.getRegistry(FEATURES).getSlaveMap(STRUCTURES, BiMap.class);
|
||||
}
|
||||
|
||||
public static <K extends IForgeRegistryEntry<K>> K register_impl(K value)
|
||||
{
|
||||
Validate.notNull(value, "Attempted to register a null object");
|
||||
Validate.notNull(value.getRegistryName(), String.format(Locale.ENGLISH, "Attempt to register object without having set a registry name %s (type %s)", value, value.getClass().getName()));
|
||||
final IForgeRegistry<K> registry = RegistryManager.ACTIVE.getRegistry(value.getRegistryType());
|
||||
Validate.notNull(registry, "Attempted to registry object without creating registry first: " + value.getRegistryType().getName());
|
||||
registry.register(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static void vanillaSnapshot()
|
||||
{
|
||||
LOGGER.debug(REGISTRIES, "Creating vanilla freeze snapshot");
|
||||
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
|
||||
for (Map.Entry<ResourceLocation, ForgeRegistry<?>> r : RegistryManager.ACTIVE.registries.entrySet())
|
||||
{
|
||||
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(r.getKey());
|
||||
loadRegistry(r.getKey(), RegistryManager.ACTIVE, RegistryManager.VANILLA, clazz, true);
|
||||
loadRegistry(r.getKey(), RegistryManager.ACTIVE, RegistryManager.VANILLA, true);
|
||||
}
|
||||
RegistryManager.VANILLA.registries.forEach((name, reg) ->
|
||||
{
|
||||
@@ -282,10 +232,9 @@ public class GameData
|
||||
LOGGER.debug(REGISTRIES, "Freezing registries");
|
||||
Registry.REGISTRY.stream().filter(r -> r instanceof MappedRegistry).forEach(r -> ((MappedRegistry<?>)r).freeze());
|
||||
|
||||
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
|
||||
for (Map.Entry<ResourceLocation, ForgeRegistry<?>> r : RegistryManager.ACTIVE.registries.entrySet())
|
||||
{
|
||||
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(r.getKey());
|
||||
loadRegistry(r.getKey(), RegistryManager.ACTIVE, RegistryManager.FROZEN, clazz, true);
|
||||
loadRegistry(r.getKey(), RegistryManager.ACTIVE, RegistryManager.FROZEN, true);
|
||||
}
|
||||
RegistryManager.FROZEN.registries.forEach((name, reg) ->
|
||||
{
|
||||
@@ -318,15 +267,14 @@ public class GameData
|
||||
RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.resetDelegates());
|
||||
|
||||
LOGGER.debug(REGISTRIES, "Reverting to {} data state.", target.getName());
|
||||
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
|
||||
for (Map.Entry<ResourceLocation, ForgeRegistry<?>> r : RegistryManager.ACTIVE.registries.entrySet())
|
||||
{
|
||||
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(r.getKey());
|
||||
loadRegistry(r.getKey(), target, RegistryManager.ACTIVE, clazz, true);
|
||||
loadRegistry(r.getKey(), target, RegistryManager.ACTIVE, true);
|
||||
}
|
||||
RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.bake());
|
||||
// the id mapping has reverted, fire remap events for those that care about id changes
|
||||
if (fireEvents) {
|
||||
fireRemapEvent(ImmutableMap.of(), true);
|
||||
fireRemapEvent(ImmutableMap.of(), true);
|
||||
ObjectHolderRegistry.applyObjectHolders();
|
||||
}
|
||||
|
||||
@@ -338,14 +286,19 @@ public class GameData
|
||||
public static void revert(RegistryManager state, ResourceLocation registry, boolean lock)
|
||||
{
|
||||
LOGGER.debug(REGISTRIES, "Reverting {} to {}", registry, state.getName());
|
||||
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(registry);
|
||||
loadRegistry(registry, state, RegistryManager.ACTIVE, clazz, lock);
|
||||
loadRegistry(registry, state, RegistryManager.ACTIVE, lock);
|
||||
LOGGER.debug(REGISTRIES, "Reverting complete");
|
||||
}
|
||||
|
||||
public static Stream<IModStateTransition.EventGenerator<?>> generateRegistryEvents() {
|
||||
List<ResourceLocation> keys = Lists.newArrayList(RegistryManager.ACTIVE.registries.keySet());
|
||||
keys.sort((o1, o2) -> String.valueOf(o1).compareToIgnoreCase(String.valueOf(o2)));
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void postRegisterEvents()
|
||||
{
|
||||
Set<ResourceLocation> keySet = new HashSet<>(RegistryManager.ACTIVE.registries.keySet());
|
||||
keySet.addAll(RegistryManager.getVanillaRegistryKeys());
|
||||
keySet.addAll(BuiltinRegistries.REGISTRY.keySet());
|
||||
List<ResourceLocation> keys = keySet.stream()
|
||||
.sorted((o1, o2) -> String.valueOf(o1).compareToIgnoreCase(String.valueOf(o2)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//Move Blocks to first, and Items to second.
|
||||
keys.remove(BLOCKS.location());
|
||||
@@ -354,65 +307,44 @@ public class GameData
|
||||
keys.add(0, BLOCKS.location());
|
||||
keys.add(1, ITEMS.location());
|
||||
|
||||
final Function<ResourceLocation, ? extends RegistryEvent.Register<?>> registerEventGenerator = rl -> RegistryManager.ACTIVE.getRegistry(rl).getRegisterEvent(rl);
|
||||
return keys.stream().map(rl -> IModStateTransition.EventGenerator.fromFunction(mc -> registerEventGenerator.apply(rl)));
|
||||
}
|
||||
RuntimeException aggregate = new RuntimeException();
|
||||
|
||||
public static CompletableFuture<List<Throwable>> preRegistryEventDispatch(final Executor executor, final IModStateTransition.EventGenerator<? extends RegistryEvent.Register<?>> eventGenerator) {
|
||||
return CompletableFuture.runAsync(()-> {
|
||||
final RegistryEvent.Register<?> event = eventGenerator.apply(null);
|
||||
final ResourceLocation rl = event.getName();
|
||||
ForgeRegistry<?> fr = (ForgeRegistry<?>) event.getRegistry();
|
||||
StartupMessageManager.modLoaderConsumer().ifPresent(s -> s.accept("REGISTERING " + rl));
|
||||
fr.unfreeze();
|
||||
}, executor).thenApply(v->Collections.emptyList());
|
||||
}
|
||||
for (ResourceLocation rootRegistryName : keys)
|
||||
{
|
||||
try
|
||||
{
|
||||
ResourceKey<? extends Registry<?>> registryKey = ResourceKey.createRegistryKey(rootRegistryName);
|
||||
ForgeRegistry<?> forgeRegistry = RegistryManager.ACTIVE.getRegistry(rootRegistryName);
|
||||
Registry<?> vanillaRegistry = Registry.REGISTRY.containsKey(rootRegistryName) ? Registry.REGISTRY.get(rootRegistryName) : BuiltinRegistries.REGISTRY.get(rootRegistryName);
|
||||
RegisterEvent registerEvent = new RegisterEvent(registryKey, forgeRegistry, vanillaRegistry);
|
||||
|
||||
public static CompletableFuture<List<Throwable>> postRegistryEventDispatch(final Executor executor, final IModStateTransition.EventGenerator<? extends RegistryEvent.Register<?>> eventGenerator) {
|
||||
return CompletableFuture.runAsync(()-> {
|
||||
final RegistryEvent.Register<?> event = eventGenerator.apply(null);
|
||||
final ResourceLocation rl = event.getName();
|
||||
ForgeRegistry<?> fr = (ForgeRegistry<?>) event.getRegistry();
|
||||
fr.freeze();
|
||||
applyHolderLookups(rl);
|
||||
}, executor).handle((v, t)->t != null ? Collections.singletonList(t): Collections.emptyList());
|
||||
}
|
||||
StartupMessageManager.modLoaderConsumer().ifPresent(s -> s.accept("REGISTERING " + registryKey.location()));
|
||||
if (forgeRegistry != null)
|
||||
forgeRegistry.unfreeze();
|
||||
|
||||
private static void applyHolderLookups(ResourceLocation registryName)
|
||||
{
|
||||
LOGGER.debug(REGISTRIES, "Applying holder lookups: {}", registryName);
|
||||
ObjectHolderRegistry.applyObjectHolders(registryName::equals);
|
||||
LOGGER.debug(REGISTRIES, "Holder lookups applied: {}", registryName);
|
||||
}
|
||||
ModLoader.get().postEvent(registerEvent);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static CompletableFuture<List<Throwable>> checkForRevertToVanilla(final Executor executor, final CompletableFuture<List<Throwable>> listCompletableFuture) {
|
||||
return listCompletableFuture.whenCompleteAsync((errors, except) -> {
|
||||
if (except != null) {
|
||||
LOGGER.fatal("Detected errors during registry event dispatch, rolling back to VANILLA state");
|
||||
revertTo(RegistryManager.VANILLA, false);
|
||||
LOGGER.fatal("Detected errors during registry event dispatch, roll back to VANILLA complete");
|
||||
} else {
|
||||
RegistryManager.getVanillaRegistryKeys().forEach(registryName -> {
|
||||
Registry<?> registry = Registry.REGISTRY.get(registryName);
|
||||
if (registry == null)
|
||||
return;
|
||||
postVanillaRegisterEvent(registry);
|
||||
});
|
||||
BuiltinRegistries.REGISTRY.forEach(GameData::postVanillaRegisterEvent);
|
||||
net.minecraftforge.common.ForgeHooks.modifyAttributes();
|
||||
if (forgeRegistry != null)
|
||||
forgeRegistry.freeze();
|
||||
LOGGER.debug(REGISTRIES, "Applying holder lookups: {}", registryKey.location());
|
||||
ObjectHolderRegistry.applyObjectHolders(registryKey.location()::equals);
|
||||
LOGGER.debug(REGISTRIES, "Holder lookups applied: {}", registryKey.location());
|
||||
} catch (Throwable t)
|
||||
{
|
||||
aggregate.addSuppressed(t);
|
||||
}
|
||||
}, executor);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static void postVanillaRegisterEvent(Registry<?> registry)
|
||||
{
|
||||
if (RegistryManager.ACTIVE.getRegistry(registry.key().location()) != null)
|
||||
return;
|
||||
|
||||
ModLoader.get().postEvent(new VanillaRegisterEvent(registry));
|
||||
applyHolderLookups(registry.key().location());
|
||||
if (aggregate.getSuppressed().length > 0)
|
||||
{
|
||||
LOGGER.fatal("Failed to register some entries, see suppressed exceptions for details", aggregate);
|
||||
LOGGER.fatal("Detected errors during registry event dispatch, rolling back to VANILLA state");
|
||||
revertTo(RegistryManager.VANILLA, false);
|
||||
LOGGER.fatal("Detected errors during registry event dispatch, roll back to VANILLA complete");
|
||||
} else
|
||||
{
|
||||
ForgeHooks.modifyAttributes();
|
||||
}
|
||||
}
|
||||
|
||||
//Lets us clear the map so we can rebuild it.
|
||||
@@ -440,7 +372,7 @@ public class GameData
|
||||
static final BlockCallbacks INSTANCE = new BlockCallbacks();
|
||||
|
||||
@Override
|
||||
public void onAdd(IForgeRegistryInternal<Block> owner, RegistryManager stage, int id, Block block, @Nullable Block oldBlock)
|
||||
public void onAdd(IForgeRegistryInternal<Block> owner, RegistryManager stage, int id, ResourceKey<Block> key, Block block, @Nullable Block oldBlock)
|
||||
{
|
||||
if (oldBlock != null)
|
||||
{
|
||||
@@ -448,7 +380,7 @@ public class GameData
|
||||
StateDefinition<Block, BlockState> newContainer = block.getStateDefinition();
|
||||
|
||||
// Test vanilla blockstates, if the number matches, make sure they also match in their string representations
|
||||
if (block.getRegistryName().getNamespace().equals("minecraft") && !oldContainer.getProperties().equals(newContainer.getProperties()))
|
||||
if (key.location().getNamespace().equals("minecraft") && !oldContainer.getProperties().equals(newContainer.getProperties()))
|
||||
{
|
||||
String oldSequence = oldContainer.getProperties().stream()
|
||||
.map(s -> String.format(Locale.ENGLISH, "%s={%s}", s.getName(),
|
||||
@@ -460,8 +392,8 @@ public class GameData
|
||||
.collect(Collectors.joining(";"));
|
||||
|
||||
LOGGER.error(REGISTRIES,()-> LogMessageAdapter.adapt(sb-> {
|
||||
sb.append("Registry replacements for vanilla block '").append(block.getRegistryName()).
|
||||
append("' must not change the number or order of blockstates.\n");
|
||||
sb.append("Registry replacements for vanilla block '").append(key.location())
|
||||
.append("' must not change the number or order of blockstates.\n");
|
||||
sb.append("\tOld: ").append(oldSequence).append('\n');
|
||||
sb.append("\tNew: ").append(newSequence);
|
||||
}));
|
||||
@@ -500,7 +432,6 @@ public class GameData
|
||||
public Block createDummy(ResourceLocation key)
|
||||
{
|
||||
Block ret = new BlockDummyAir(Block.Properties.of(Material.AIR));
|
||||
GameData.forceRegistryName(ret, key);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -543,7 +474,7 @@ public class GameData
|
||||
static final ItemCallbacks INSTANCE = new ItemCallbacks();
|
||||
|
||||
@Override
|
||||
public void onAdd(IForgeRegistryInternal<Item> owner, RegistryManager stage, int id, Item item, @Nullable Item oldItem)
|
||||
public void onAdd(IForgeRegistryInternal<Item> owner, RegistryManager stage, int id, ResourceKey<Item> key, Item item, @Nullable Item oldItem)
|
||||
{
|
||||
if (oldItem instanceof BlockItem)
|
||||
{
|
||||
@@ -586,32 +517,6 @@ public class GameData
|
||||
}
|
||||
}
|
||||
|
||||
private static class SerializerCallbacks implements IForgeRegistry.AddCallback<DataSerializerEntry>, IForgeRegistry.ClearCallback<DataSerializerEntry>, IForgeRegistry.CreateCallback<DataSerializerEntry>
|
||||
{
|
||||
static final SerializerCallbacks INSTANCE = new SerializerCallbacks();
|
||||
|
||||
@Override
|
||||
public void onAdd(IForgeRegistryInternal<DataSerializerEntry> owner, RegistryManager stage, int id, DataSerializerEntry entry, @Nullable DataSerializerEntry oldEntry)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<EntityDataSerializer<?>, DataSerializerEntry> map = owner.getSlaveMap(SERIALIZER_TO_ENTRY, Map.class);
|
||||
if (oldEntry != null) map.remove(oldEntry.getSerializer());
|
||||
map.put(entry.getSerializer(), entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClear(IForgeRegistryInternal<DataSerializerEntry> owner, RegistryManager stage)
|
||||
{
|
||||
owner.getSlaveMap(SERIALIZER_TO_ENTRY, Map.class).clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(IForgeRegistryInternal<DataSerializerEntry> owner, RegistryManager stage)
|
||||
{
|
||||
owner.setSlaveMap(SERIALIZER_TO_ENTRY, new IdentityHashMap<>());
|
||||
}
|
||||
}
|
||||
|
||||
private static class FeatureCallbacks implements IForgeRegistry.ClearCallback<Feature<?>>, IForgeRegistry.CreateCallback<Feature<?>>
|
||||
{
|
||||
static final FeatureCallbacks INSTANCE = new FeatureCallbacks();
|
||||
@@ -629,19 +534,19 @@ public class GameData
|
||||
}
|
||||
}
|
||||
|
||||
private static class PointOfInterestTypeCallbacks implements IForgeRegistry.AddCallback<PoiType> , IForgeRegistry.ClearCallback<PoiType>, IForgeRegistry.CreateCallback<PoiType>
|
||||
private static class PointOfInterestTypeCallbacks implements IForgeRegistry.AddCallback<PoiType>, IForgeRegistry.ClearCallback<PoiType>, IForgeRegistry.CreateCallback<PoiType>
|
||||
{
|
||||
static final PointOfInterestTypeCallbacks INSTANCE = new PointOfInterestTypeCallbacks();
|
||||
|
||||
@Override
|
||||
public void onAdd(IForgeRegistryInternal<PoiType> owner, RegistryManager stage, int id, PoiType obj, @Nullable PoiType oldObj)
|
||||
public void onAdd(IForgeRegistryInternal<PoiType> owner, RegistryManager stage, int id, ResourceKey<PoiType> key, PoiType obj, @Nullable PoiType oldObj)
|
||||
{
|
||||
Map<BlockState, PoiType> map = owner.getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class);
|
||||
if (oldObj != null)
|
||||
{
|
||||
oldObj.getBlockStates().forEach(map::remove);
|
||||
oldObj.matchingStates().forEach(map::remove);
|
||||
}
|
||||
obj.getBlockStates().forEach((state) ->
|
||||
obj.matchingStates().forEach((state) ->
|
||||
{
|
||||
PoiType oldType = map.put(state, obj);
|
||||
if (oldType != null)
|
||||
@@ -664,7 +569,7 @@ public class GameData
|
||||
}
|
||||
}
|
||||
|
||||
private static <T extends IForgeRegistryEntry<T>> void loadRegistry(final ResourceLocation registryName, final RegistryManager from, final RegistryManager to, final Class<T> regType, boolean freeze)
|
||||
private static <T> void loadRegistry(final ResourceLocation registryName, final RegistryManager from, final RegistryManager to, boolean freeze)
|
||||
{
|
||||
ForgeRegistry<T> fromRegistry = from.getRegistry(registryName);
|
||||
if (fromRegistry == null)
|
||||
@@ -739,15 +644,14 @@ public class GameData
|
||||
|
||||
RegistryManager STAGING = new RegistryManager();
|
||||
|
||||
final Map<ResourceLocation, Map<ResourceLocation, Integer[]>> remaps = Maps.newHashMap();
|
||||
final Map<ResourceLocation, Map<ResourceLocation, IdMappingEvent.IdRemapping>> remaps = Maps.newHashMap();
|
||||
final LinkedHashMap<ResourceLocation, Map<ResourceLocation, Integer>> missing = Maps.newLinkedHashMap();
|
||||
// Load the snapshot into the "STAGING" registry
|
||||
snapshot.forEach((key, value) ->
|
||||
{
|
||||
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(key);
|
||||
remaps.put(key, Maps.newLinkedHashMap());
|
||||
missing.put(key, Maps.newLinkedHashMap());
|
||||
loadPersistentDataToStagingRegistry(RegistryManager.ACTIVE, STAGING, remaps.get(key), missing.get(key), key, value, clazz);
|
||||
loadPersistentDataToStagingRegistry(RegistryManager.ACTIVE, STAGING, remaps.get(key), missing.get(key), key, value);
|
||||
});
|
||||
|
||||
snapshot.forEach((key, value) ->
|
||||
@@ -789,21 +693,25 @@ public class GameData
|
||||
{
|
||||
ResourceLocation name = m.getKey();
|
||||
ForgeRegistry<?> reg = STAGING.getRegistry(name);
|
||||
RegistryEvent.MissingMappings<?> event = reg.getMissingEvent(name, m.getValue());
|
||||
MissingMappingsEvent event = reg.getMissingEvent(name, m.getValue());
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
List<MissingMappings.Mapping<?>> lst = event.getAllMappings().stream().filter(e -> e.getAction() == MissingMappings.Action.DEFAULT).sorted((a, b) -> a.toString().compareTo(b.toString())).collect(Collectors.toList());
|
||||
List<MissingMappingsEvent.Mapping<?>> lst = event.getAllMappings(reg.getRegistryKey()).stream()
|
||||
.filter(e -> e.action == MissingMappingsEvent.Action.DEFAULT)
|
||||
.sorted(Comparator.comparing(Object::toString))
|
||||
.collect(Collectors.toList());
|
||||
if (!lst.isEmpty())
|
||||
{
|
||||
LOGGER.error(REGISTRIES,()->LogMessageAdapter.adapt(sb->{
|
||||
LOGGER.error(REGISTRIES, () -> LogMessageAdapter.adapt(sb -> {
|
||||
sb.append("Unidentified mapping from registry ").append(name).append('\n');
|
||||
lst.stream().sorted().forEach(map->sb.append('\t').append(map.key).append(": ").append(map.id).append('\n'));
|
||||
lst.stream().sorted().forEach(map -> sb.append('\t').append(map.key).append(": ").append(map.id).append('\n'));
|
||||
}));
|
||||
}
|
||||
event.getAllMappings().stream().filter(e -> e.getAction() == MissingMappings.Action.FAIL).forEach(fail -> failed.put(name, fail.key));
|
||||
event.getAllMappings(reg.getRegistryKey()).stream()
|
||||
.filter(e -> e.action == MissingMappingsEvent.Action.FAIL)
|
||||
.forEach(fail -> failed.put(name, fail.key));
|
||||
|
||||
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(name);
|
||||
processMissing(clazz, name, STAGING, event, m.getValue(), remaps.get(name), defaulted.get(name), failed.get(name), !isLocalWorld);
|
||||
processMissing(name, STAGING, event, m.getValue(), remaps.get(name), defaulted.get(name), failed.get(name), !isLocalWorld);
|
||||
});
|
||||
|
||||
if (!defaulted.isEmpty() && !isLocalWorld)
|
||||
@@ -853,8 +761,7 @@ public class GameData
|
||||
// So we load it from the frozen persistent registry
|
||||
RegistryManager.ACTIVE.registries.forEach((name, reg) ->
|
||||
{
|
||||
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(name);
|
||||
loadFrozenDataToStagingRegistry(STAGING, name, remaps.get(name), clazz);
|
||||
loadFrozenDataToStagingRegistry(STAGING, name, remaps.get(name));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -862,11 +769,10 @@ public class GameData
|
||||
STAGING.registries.forEach((name, reg) -> reg.validateContent(name));
|
||||
|
||||
// Load the STAGING registry into the ACTIVE registry
|
||||
//for (Map.Entry<ResourceLocation, IForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
|
||||
//for (Map.Entry<ResourceLocation, IForgeRegistry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
|
||||
RegistryManager.ACTIVE.registries.forEach((key, value) ->
|
||||
{
|
||||
final Class<? extends IForgeRegistryEntry> registrySuperType = RegistryManager.ACTIVE.getSuperType(key);
|
||||
loadRegistry(key, STAGING, RegistryManager.ACTIVE, registrySuperType, true);
|
||||
loadRegistry(key, STAGING, RegistryManager.ACTIVE, true);
|
||||
});
|
||||
|
||||
RegistryManager.ACTIVE.registries.forEach((name, reg) -> {
|
||||
@@ -886,14 +792,14 @@ public class GameData
|
||||
return ArrayListMultimap.create();
|
||||
}
|
||||
|
||||
private static void fireRemapEvent(final Map<ResourceLocation, Map<ResourceLocation, Integer[]>> remaps, final boolean isFreezing) {
|
||||
private static void fireRemapEvent(final Map<ResourceLocation, Map<ResourceLocation, IdMappingEvent.IdRemapping>> remaps, final boolean isFreezing) {
|
||||
StartupMessageManager.modLoaderConsumer().ifPresent(s->s.accept("Remapping mod data"));
|
||||
MinecraftForge.EVENT_BUS.post(new RegistryEvent.IdMappingEvent(remaps, isFreezing));
|
||||
MinecraftForge.EVENT_BUS.post(new IdMappingEvent(remaps, isFreezing));
|
||||
StartupMessageManager.modLoaderConsumer().ifPresent(s->s.accept("Remap complete"));
|
||||
}
|
||||
|
||||
//Has to be split because of generics, Yay!
|
||||
private static <T extends IForgeRegistryEntry<T>> void loadPersistentDataToStagingRegistry(RegistryManager pool, RegistryManager to, Map<ResourceLocation, Integer[]> remaps, Map<ResourceLocation, Integer> missing, ResourceLocation name, ForgeRegistry.Snapshot snap, Class<T> regType)
|
||||
private static <T> void loadPersistentDataToStagingRegistry(RegistryManager pool, RegistryManager to, Map<ResourceLocation, IdMappingEvent.IdRemapping> remaps, Map<ResourceLocation, Integer> missing, ResourceLocation name, ForgeRegistry.Snapshot snap)
|
||||
{
|
||||
ForgeRegistry<T> active = pool.getRegistry(name);
|
||||
if (active == null)
|
||||
@@ -908,15 +814,15 @@ public class GameData
|
||||
|
||||
//Another bouncer for generic reasons
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T extends IForgeRegistryEntry<T>> void processMissing(Class<T> clazz, ResourceLocation name, RegistryManager STAGING, MissingMappings<?> e, Map<ResourceLocation, Integer> missing, Map<ResourceLocation, Integer[]> remaps, Collection<ResourceLocation> defaulted, Collection<ResourceLocation> failed, boolean injectNetworkDummies)
|
||||
private static <T> void processMissing(ResourceLocation name, RegistryManager STAGING, MissingMappingsEvent e, Map<ResourceLocation, Integer> missing, Map<ResourceLocation, IdMappingEvent.IdRemapping> remaps, Collection<ResourceLocation> defaulted, Collection<ResourceLocation> failed, boolean injectNetworkDummies)
|
||||
{
|
||||
List<MissingMappings.Mapping<T>> mappings = ((MissingMappings<T>)e).getAllMappings();
|
||||
List<MissingMappingsEvent.Mapping<T>> mappings = e.getAllMappings(ResourceKey.createRegistryKey(name));
|
||||
ForgeRegistry<T> active = RegistryManager.ACTIVE.getRegistry(name);
|
||||
ForgeRegistry<T> staging = STAGING.getRegistry(name);
|
||||
staging.processMissingEvent(name, active, mappings, missing, remaps, defaulted, failed, injectNetworkDummies);
|
||||
}
|
||||
|
||||
private static <T extends IForgeRegistryEntry<T>> void loadFrozenDataToStagingRegistry(RegistryManager STAGING, ResourceLocation name, Map<ResourceLocation, Integer[]> remaps, Class<T> clazz)
|
||||
private static <T> void loadFrozenDataToStagingRegistry(RegistryManager STAGING, ResourceLocation name, Map<ResourceLocation, IdMappingEvent.IdRemapping> remaps)
|
||||
{
|
||||
ForgeRegistry<T> frozen = RegistryManager.FROZEN.getRegistry(name);
|
||||
ForgeRegistry<T> newRegistry = STAGING.getRegistry(name, RegistryManager.FROZEN);
|
||||
@@ -943,37 +849,9 @@ public class GameData
|
||||
String prefix = ModLoadingContext.get().getActiveNamespace();
|
||||
if (warnOverrides && !oldPrefix.equals(prefix) && oldPrefix.length() > 0)
|
||||
{
|
||||
LogManager.getLogger().info("Potentially Dangerous alternative prefix `{}` for name `{}`, expected `{}`. This could be a intended override, but in most cases indicates a broken mod.", oldPrefix, name, prefix);
|
||||
LogManager.getLogger().debug("Mod `{}` attempting to register `{}` to the namespace `{}`. This could be intended, but likely means an EventBusSubscriber without a modid.", prefix, name, oldPrefix);
|
||||
prefix = oldPrefix;
|
||||
}
|
||||
return new ResourceLocation(prefix, name);
|
||||
}
|
||||
|
||||
private static Field regName;
|
||||
private static void forceRegistryName(IForgeRegistryEntry<?> entry, ResourceLocation name)
|
||||
{
|
||||
if (regName == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
regName = ForgeRegistryEntry.class.getDeclaredField("registryName");
|
||||
regName.setAccessible(true);
|
||||
}
|
||||
catch (NoSuchFieldException | SecurityException e)
|
||||
{
|
||||
LOGGER.error(REGISTRIES, "Could not get `registryName` field from IForgeRegistryEntry.Impl", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
regName.set(entry, name);
|
||||
}
|
||||
catch (IllegalArgumentException | IllegalAccessException e)
|
||||
{
|
||||
LOGGER.error(REGISTRIES,"Could not set `registryName` field in IForgeRegistryEntry.Impl to `{}`", name.toString(), e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user