mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 05:02:18 +00:00
Global Loot Modifiers
This commit is contained in:
63 files changed
+1058
-1502
No files matched your search
@@ -25,11 +25,12 @@ public class ForgeDeferredRegistriesSetup
|
||||
}
|
||||
|
||||
ForgeRegistries.DEFERRED_ENTITY_DATA_SERIALIZERS.register(modEventBus);
|
||||
//ForgeRegistries.DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_BIOME_MODIFIER_SERIALIZERS.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_FLUID_TYPES.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_STRUCTURE_MODIFIER_SERIALIZERS.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_HOLDER_SET_TYPES.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_DISPLAY_CONTEXTS.register(modEventBus);
|
||||
ForgeRegistries.DEFERRED_CONDITION_CODECS.register(modEventBus);
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,8 @@ import net.minecraft.world.level.levelgen.feature.Feature;
|
||||
import net.minecraft.world.level.levelgen.feature.foliageplacers.FoliagePlacerType;
|
||||
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType;
|
||||
import net.minecraftforge.common.Tags;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
import net.minecraftforge.common.loot.IGlobalLootModifier;
|
||||
import net.minecraftforge.common.world.BiomeModifier;
|
||||
import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.registries.holdersets.HolderSetType;
|
||||
@@ -104,12 +106,12 @@ public class ForgeRegistries
|
||||
* Use {@link Keys#ENTITY_DATA_SERIALIZERS} to create a {@link DeferredRegister}.
|
||||
*/
|
||||
public static final Supplier<IForgeRegistry<EntityDataSerializer<?>>> ENTITY_DATA_SERIALIZERS = DEFERRED_ENTITY_DATA_SERIALIZERS.makeRegistry(GameData::getDataSerializersRegistryBuilder);
|
||||
//static final DeferredRegister<Codec<? extends IGlobalLootModifier>> DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS.location().getNamespace());
|
||||
static final DeferredRegister<Codec<? extends IGlobalLootModifier>> DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS.location().getNamespace());
|
||||
/**
|
||||
* Calling {@link Supplier#get()} before {@link NewRegistryEvent} is fired will result in a null registry returned.
|
||||
* Use {@link Keys#GLOBAL_LOOT_MODIFIER_SERIALIZERS} to create a {@link DeferredRegister}.
|
||||
*/
|
||||
//public static final Supplier<IForgeRegistry<Codec<? extends IGlobalLootModifier>>> GLOBAL_LOOT_MODIFIER_SERIALIZERS = DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS.makeRegistry(GameData::getGLMSerializersRegistryBuilder);
|
||||
public static final Supplier<IForgeRegistry<Codec<? extends IGlobalLootModifier>>> GLOBAL_LOOT_MODIFIER_SERIALIZERS = DEFERRED_GLOBAL_LOOT_MODIFIER_SERIALIZERS.makeRegistry(GameData::getGLMSerializersRegistryBuilder);
|
||||
static final DeferredRegister<Codec<? extends BiomeModifier>> DEFERRED_BIOME_MODIFIER_SERIALIZERS = DeferredRegister.create(Keys.BIOME_MODIFIER_SERIALIZERS, Keys.BIOME_MODIFIER_SERIALIZERS.location().getNamespace());
|
||||
/**
|
||||
* Calling {@link Supplier#get()} before {@link NewRegistryEvent} is fired will result in a null registry returned.
|
||||
@@ -142,6 +144,13 @@ public class ForgeRegistries
|
||||
*/
|
||||
public static final Supplier<IForgeRegistry<ItemDisplayContext>> DISPLAY_CONTEXTS = DEFERRED_DISPLAY_CONTEXTS.makeRegistry(GameData::getItemDisplayContextRegistryBuilder);
|
||||
|
||||
static final DeferredRegister<Codec<? extends ICondition>> DEFERRED_CONDITION_CODECS = DeferredRegister.create(Keys.CONDITION_SERIALIZERS, Keys.CONDITION_SERIALIZERS.location().getNamespace());
|
||||
/**
|
||||
* Calling {@link Supplier#get()} before {@link NewRegistryEvent} is fired will result in a null registry returned.
|
||||
* Use {@link Keys#CONDITION_SERIALIZERS} to create a {@link DeferredRegister}.
|
||||
*/
|
||||
public static final Supplier<IForgeRegistry<Codec<? extends ICondition>>> CONDITION_SERIALIZERS = DEFERRED_CONDITION_CODECS.makeRegistry(GameData::getConditionCodecRegistryBuilder);
|
||||
|
||||
public static final class Keys {
|
||||
//Vanilla
|
||||
public static final ResourceKey<Registry<Block>> BLOCKS = key("block");
|
||||
@@ -179,12 +188,13 @@ public class ForgeRegistries
|
||||
|
||||
// Forge
|
||||
public static final ResourceKey<Registry<EntityDataSerializer<?>>> ENTITY_DATA_SERIALIZERS = key("forge:entity_data_serializers");
|
||||
//public static final ResourceKey<Registry<Codec<? extends IGlobalLootModifier>>> GLOBAL_LOOT_MODIFIER_SERIALIZERS = key("forge:global_loot_modifier_serializers");
|
||||
public static final ResourceKey<Registry<Codec<? extends IGlobalLootModifier>>> GLOBAL_LOOT_MODIFIER_SERIALIZERS = key("forge:global_loot_modifier_serializers");
|
||||
public static final ResourceKey<Registry<Codec<? extends BiomeModifier>>> BIOME_MODIFIER_SERIALIZERS = key("forge:biome_modifier_serializers");
|
||||
public static final ResourceKey<Registry<Codec<? extends StructureModifier>>> STRUCTURE_MODIFIER_SERIALIZERS = key("forge:structure_modifier_serializers");
|
||||
public static final ResourceKey<Registry<FluidType>> FLUID_TYPES = key("forge:fluid_type");
|
||||
public static final ResourceKey<Registry<HolderSetType>> HOLDER_SET_TYPES = key("forge:holder_set_type");
|
||||
public static final ResourceKey<Registry<ItemDisplayContext>> DISPLAY_CONTEXTS = key("forge:display_contexts");
|
||||
public static final ResourceKey<Registry<Codec<? extends ICondition>>> CONDITION_SERIALIZERS = key("forge:condition_codecs");
|
||||
|
||||
// Forge Dynamic
|
||||
public static final ResourceKey<Registry<BiomeModifier>> BIOME_MODIFIERS = key("forge:biome_modifier");
|
||||
@@ -207,4 +217,4 @@ public class ForgeRegistries
|
||||
Bootstrap.bootStrap();
|
||||
Tags.init();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,8 @@ import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraftforge.common.CreativeModeTabRegistry;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.crafting.conditions.ICondition;
|
||||
import net.minecraftforge.common.loot.IGlobalLootModifier;
|
||||
import net.minecraftforge.common.util.LogMessageAdapter;
|
||||
import net.minecraftforge.common.world.BiomeModifier;
|
||||
import net.minecraftforge.common.world.StructureModifier;
|
||||
@@ -91,6 +93,7 @@ public class GameData
|
||||
init();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void init()
|
||||
{
|
||||
if (DISABLE_VANILLA_REGISTRIES)
|
||||
@@ -146,12 +149,10 @@ public class GameData
|
||||
return makeRegistry(Keys.ENTITY_DATA_SERIALIZERS, 256 /*vanilla space*/, MAX_VARINT).disableSaving().disableOverrides();
|
||||
}
|
||||
|
||||
/*
|
||||
static RegistryBuilder<Codec<? extends IGlobalLootModifier>> getGLMSerializersRegistryBuilder()
|
||||
{
|
||||
return makeRegistry(Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS).disableSaving().disableSync();
|
||||
}
|
||||
*/
|
||||
|
||||
static RegistryBuilder<Codec<? extends BiomeModifier>> getBiomeModifierSerializersRegistryBuilder()
|
||||
{
|
||||
@@ -173,6 +174,11 @@ public class GameData
|
||||
return new RegistryBuilder<HolderSetType>().disableSaving().disableSync();
|
||||
}
|
||||
|
||||
static RegistryBuilder<Codec<? extends ICondition>> getConditionCodecRegistryBuilder()
|
||||
{
|
||||
return new RegistryBuilder<Codec<? extends ICondition>>().disableSaving().disableSync();
|
||||
}
|
||||
|
||||
static RegistryBuilder<ItemDisplayContext> getItemDisplayContextRegistryBuilder()
|
||||
{
|
||||
return new RegistryBuilder<ItemDisplayContext>()
|
||||
@@ -232,7 +238,6 @@ public class GameData
|
||||
return RegistryManager.ACTIVE.getRegistry(Keys.POI_TYPES).getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static void vanillaSnapshot()
|
||||
{
|
||||
LOGGER.debug(REGISTRIES, "Creating vanilla freeze snapshot");
|
||||
@@ -250,13 +255,13 @@ public class GameData
|
||||
LOGGER.debug(REGISTRIES, "Vanilla freeze snapshot created");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void unfreezeData()
|
||||
{
|
||||
LOGGER.debug(REGISTRIES, "Unfreezing vanilla registries");
|
||||
BuiltInRegistries.REGISTRY.stream().filter(r -> r instanceof MappedRegistry).forEach(r -> ((MappedRegistry<?>)r).unfreeze());
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static void freezeData()
|
||||
{
|
||||
LOGGER.debug(REGISTRIES, "Freezing registries");
|
||||
@@ -286,7 +291,7 @@ public class GameData
|
||||
public static void revertToFrozen() {
|
||||
revertTo(RegistryManager.FROZEN, true);
|
||||
}
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
|
||||
public static void revertTo(final RegistryManager target, boolean fireEvents)
|
||||
{
|
||||
if (target.registries.isEmpty())
|
||||
@@ -312,7 +317,6 @@ public class GameData
|
||||
LOGGER.debug(REGISTRIES, "{} state restored.", target.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public static void revert(RegistryManager state, ResourceLocation registry, boolean lock)
|
||||
{
|
||||
LOGGER.debug(REGISTRIES, "Reverting {} to {}", registry, state.getName());
|
||||
@@ -381,8 +385,10 @@ public class GameData
|
||||
this.nextId = 0;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
void remove(I key)
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
Integer prev = this.tToId.remove(key);
|
||||
if (prev != null)
|
||||
{
|
||||
@@ -437,6 +443,7 @@ public class GameData
|
||||
{
|
||||
final ClearableObjectIntIdentityMap<BlockState> idMap = new ClearableObjectIntIdentityMap<BlockState>()
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public int getId(BlockState key)
|
||||
{
|
||||
@@ -527,6 +534,7 @@ public class GameData
|
||||
@Override
|
||||
public void onAdd(IForgeRegistryInternal<PoiType> owner, RegistryManager stage, int id, ResourceKey<PoiType> key, PoiType obj, @Nullable PoiType oldObj)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<BlockState, PoiType> map = owner.getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class);
|
||||
if (oldObj != null)
|
||||
{
|
||||
@@ -595,7 +603,6 @@ public class GameData
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static Multimap<ResourceLocation, ResourceLocation> injectSnapshot(Map<ResourceLocation, ForgeRegistry.Snapshot> snapshot, boolean injectFrozenData, boolean isLocalWorld)
|
||||
{
|
||||
LOGGER.info(REGISTRIES, "Injecting existing registry data into this {} instance", EffectiveSide.get());
|
||||
@@ -756,7 +763,6 @@ public class GameData
|
||||
}
|
||||
|
||||
//Another bouncer for generic reasons
|
||||
@SuppressWarnings("unchecked")
|
||||
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<MissingMappingsEvent.Mapping<T>> mappings = e.getAllMappings(ResourceKey.createRegistryKey(name));
|
||||
|
||||
Reference in new issue
Block a user