Update to 1.17

Update to Official classnames
Patchwork
Make the game compile and run
Merge in the new HUD overlay API
Merge in the new render properties API
PEEL
Use Gradle 7.2 snapshot to fix eclipse integration bug in 7.1, Would use 7.0 but FG needs 7.1 for some reason.
New FML installer
Update to 1.17.1

Co-authored-by: LexManos <[email protected]>
Co-authored-by: SizableShrimp <[email protected]>
Co-authored-by: cpw <[email protected]>
Co-authored-by: Curle <[email protected]>
Co-authored-by: Unnoen <[email protected]>
Co-authored-by: covers1624 <[email protected]>
Co-authored-by: DaemonUmbra <[email protected]>
Co-authored-by: gigaherz <[email protected]>
Signed-off-by: SizableShrimp <[email protected]>
This commit is contained in:
authored and Curle committed 2021-07-22 19:57:02 +01:00
1 parent 064ae6961b
commit be5446b91c
1990 files changed
+35661 -37544

No files matched your search

@@ -19,18 +19,18 @@
package net.minecraftforge.registries;
import net.minecraft.network.datasync.IDataSerializer;
import net.minecraft.network.syncher.EntityDataSerializer;
public final class DataSerializerEntry extends ForgeRegistryEntry<DataSerializerEntry>
{
private final IDataSerializer<?> serializer;
private final EntityDataSerializer<?> serializer;
public DataSerializerEntry(IDataSerializer<?> serializer)
public DataSerializerEntry(EntityDataSerializer<?> serializer)
{
this.serializer = serializer;
}
public IDataSerializer<?> getSerializer()
public EntityDataSerializer<?> getSerializer()
{
return serializer;
}
@@ -19,12 +19,11 @@
package net.minecraftforge.registries;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fmllegacy.RegistryObject;
import java.util.Collection;
import java.util.Collections;
@@ -35,8 +34,6 @@ import java.util.Objects;
import java.util.Set;
import java.util.function.Supplier;
import com.google.common.reflect.TypeToken;
/**
* Utility class to help with managing registry entries.
* Maintains a list of all suppliers for entries and registers them during the proper Register event.
@@ -19,46 +19,45 @@
package net.minecraftforge.registries;
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.attributes.Attribute;
import net.minecraft.entity.ai.brain.memory.MemoryModuleType;
import net.minecraft.entity.ai.brain.schedule.Activity;
import net.minecraft.entity.ai.brain.schedule.Schedule;
import net.minecraft.entity.ai.brain.sensor.SensorType;
import net.minecraft.entity.item.PaintingType;
import net.minecraft.entity.merchant.villager.VillagerProfession;
import net.minecraft.fluid.Fluid;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.util.registry.Bootstrap;
import net.minecraft.util.registry.Registry;
import net.minecraft.village.PointOfInterestType;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.particles.ParticleType;
import net.minecraft.potion.Effect;
import net.minecraft.potion.Potion;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.attributes.Attribute;
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.server.Bootstrap;
import net.minecraft.core.Registry;
import net.minecraft.world.entity.ai.village.poi.PoiType;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.stats.StatType;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.gen.blockplacer.BlockPlacerType;
import net.minecraft.world.gen.blockstateprovider.BlockStateProviderType;
import net.minecraft.world.gen.carver.WorldCarver;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.structure.Structure;
import net.minecraft.world.gen.foliageplacer.FoliagePlacerType;
import net.minecraft.world.gen.placement.Placement;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.gen.treedecorator.TreeDecoratorType;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.levelgen.feature.blockplacers.BlockPlacerType;
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.placement.FeatureDecorator;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
import net.minecraftforge.common.world.ForgeWorldType;
import net.minecraftforge.fml.common.registry.GameRegistry;
/**
* A class that exposes static references to all vanilla and Forge registries.
@@ -73,22 +72,22 @@ public class ForgeRegistries
public static final IForgeRegistry<Block> BLOCKS = RegistryManager.ACTIVE.getRegistry(Block.class);
public static final IForgeRegistry<Fluid> FLUIDS = RegistryManager.ACTIVE.getRegistry(Fluid.class);
public static final IForgeRegistry<Item> ITEMS = RegistryManager.ACTIVE.getRegistry(Item.class);
public static final IForgeRegistry<Effect> POTIONS = RegistryManager.ACTIVE.getRegistry(Effect.class);
public static final IForgeRegistry<MobEffect> POTIONS = RegistryManager.ACTIVE.getRegistry(MobEffect.class);
public static final IForgeRegistry<SoundEvent> SOUND_EVENTS = RegistryManager.ACTIVE.getRegistry(SoundEvent.class);
public static final IForgeRegistry<Potion> POTION_TYPES = RegistryManager.ACTIVE.getRegistry(Potion.class);
public static final IForgeRegistry<Enchantment> ENCHANTMENTS = RegistryManager.ACTIVE.getRegistry(Enchantment.class);
public static final IForgeRegistry<EntityType<?>> ENTITIES = RegistryManager.ACTIVE.getRegistry(EntityType.class);
public static final IForgeRegistry<TileEntityType<?>> TILE_ENTITIES = RegistryManager.ACTIVE.getRegistry(TileEntityType.class);
public static final IForgeRegistry<BlockEntityType<?>> BLOCK_ENTITIES = RegistryManager.ACTIVE.getRegistry(BlockEntityType.class);
public static final IForgeRegistry<ParticleType<?>> PARTICLE_TYPES = RegistryManager.ACTIVE.getRegistry(ParticleType.class);
public static final IForgeRegistry<ContainerType<?>> CONTAINERS = RegistryManager.ACTIVE.getRegistry(ContainerType.class);
public static final IForgeRegistry<PaintingType> PAINTING_TYPES = RegistryManager.ACTIVE.getRegistry(PaintingType.class);
public static final IForgeRegistry<IRecipeSerializer<?>> RECIPE_SERIALIZERS = RegistryManager.ACTIVE.getRegistry(IRecipeSerializer.class);
public static final IForgeRegistry<MenuType<?>> CONTAINERS = RegistryManager.ACTIVE.getRegistry(MenuType.class);
public static final IForgeRegistry<Motive> PAINTING_TYPES = RegistryManager.ACTIVE.getRegistry(Motive.class);
public static final IForgeRegistry<RecipeSerializer<?>> RECIPE_SERIALIZERS = RegistryManager.ACTIVE.getRegistry(RecipeSerializer.class);
public static final IForgeRegistry<Attribute> ATTRIBUTES = RegistryManager.ACTIVE.getRegistry(Attribute.class);
public static final IForgeRegistry<StatType<?>> STAT_TYPES = RegistryManager.ACTIVE.getRegistry(StatType.class);
// Villages
public static final IForgeRegistry<VillagerProfession> PROFESSIONS = RegistryManager.ACTIVE.getRegistry(VillagerProfession.class);
public static final IForgeRegistry<PointOfInterestType> POI_TYPES = RegistryManager.ACTIVE.getRegistry(PointOfInterestType.class);
public static final IForgeRegistry<PoiType> POI_TYPES = RegistryManager.ACTIVE.getRegistry(PoiType.class);
public static final IForgeRegistry<MemoryModuleType<?>> MEMORY_MODULE_TYPES = RegistryManager.ACTIVE.getRegistry(MemoryModuleType.class);
public static final IForgeRegistry<SensorType<?>> SENSOR_TYPES = RegistryManager.ACTIVE.getRegistry(SensorType.class);
public static final IForgeRegistry<Schedule> SCHEDULES = RegistryManager.ACTIVE.getRegistry(Schedule.class);
@@ -98,9 +97,9 @@ public class ForgeRegistries
public static final IForgeRegistry<WorldCarver<?>> WORLD_CARVERS = RegistryManager.ACTIVE.getRegistry(WorldCarver.class);
public static final IForgeRegistry<SurfaceBuilder<?>> SURFACE_BUILDERS = RegistryManager.ACTIVE.getRegistry(SurfaceBuilder.class);
public static final IForgeRegistry<Feature<?>> FEATURES = RegistryManager.ACTIVE.getRegistry(Feature.class);
public static final IForgeRegistry<Placement<?>> DECORATORS = RegistryManager.ACTIVE.getRegistry(Placement.class);
public static final IForgeRegistry<FeatureDecorator<?>> DECORATORS = RegistryManager.ACTIVE.getRegistry(FeatureDecorator.class);
public static final IForgeRegistry<ChunkStatus> CHUNK_STATUS = RegistryManager.ACTIVE.getRegistry(ChunkStatus.class);
public static final IForgeRegistry<Structure<?>> STRUCTURE_FEATURES = RegistryManager.ACTIVE.getRegistry(Structure.class);
public static final IForgeRegistry<StructureFeature<?>> STRUCTURE_FEATURES = RegistryManager.ACTIVE.getRegistry(StructureFeature.class);
public static final IForgeRegistry<BlockStateProviderType<?>> BLOCK_STATE_PROVIDER_TYPES = RegistryManager.ACTIVE.getRegistry(BlockStateProviderType.class);
public static final IForgeRegistry<BlockPlacerType<?>> BLOCK_PLACER_TYPES = RegistryManager.ACTIVE.getRegistry(BlockPlacerType.class);
public static final IForgeRegistry<FoliagePlacerType<?>> FOLIAGE_PLACER_TYPES = RegistryManager.ACTIVE.getRegistry(FoliagePlacerType.class);
@@ -116,49 +115,49 @@ public class ForgeRegistries
public static final class Keys {
//Vanilla
public static final RegistryKey<Registry<Block>> BLOCKS = key("block");
public static final RegistryKey<Registry<Fluid>> FLUIDS = key("fluid");
public static final RegistryKey<Registry<Item>> ITEMS = key("item");
public static final RegistryKey<Registry<Effect>> EFFECTS = key("mob_effect");
public static final RegistryKey<Registry<Potion>> POTIONS = key("potion");
public static final RegistryKey<Registry<Attribute>> ATTRIBUTES = key("attribute");
public static final RegistryKey<Registry<StatType<?>>> STAT_TYPES = key("stat_type");
public static final RegistryKey<Registry<SoundEvent>> SOUND_EVENTS = key("sound_event");
public static final RegistryKey<Registry<Enchantment>> ENCHANTMENTS = key("enchantment");
public static final RegistryKey<Registry<EntityType<?>>> ENTITY_TYPES = key("entity_type");
public static final RegistryKey<Registry<PaintingType>> PAINTING_TYPES = key("motive");
public static final RegistryKey<Registry<ParticleType<?>>> PARTICLE_TYPES = key("particle_type");
public static final RegistryKey<Registry<ContainerType<?>>> CONTAINER_TYPES = key("menu");
public static final RegistryKey<Registry<TileEntityType<?>>> TILE_ENTITY_TYPES = key("block_entity_type");
public static final RegistryKey<Registry<IRecipeSerializer<?>>> RECIPE_SERIALIZERS = key("recipe_serializer");
public static final RegistryKey<Registry<VillagerProfession>> VILLAGER_PROFESSIONS = key("villager_profession");
public static final RegistryKey<Registry<PointOfInterestType>> POI_TYPES = key("point_of_interest_type");
public static final RegistryKey<Registry<MemoryModuleType<?>>> MEMORY_MODULE_TYPES = key("memory_module_type");
public static final RegistryKey<Registry<SensorType<?>>> SENSOR_TYPES = key("sensor_type");
public static final RegistryKey<Registry<Schedule>> SCHEDULES = key("schedule");
public static final RegistryKey<Registry<Activity>> ACTIVITIES = key("activity");
public static final RegistryKey<Registry<WorldCarver<?>>> WORLD_CARVERS = key("worldgen/carver");
public static final RegistryKey<Registry<SurfaceBuilder<?>>> SURFACE_BUILDERS = key("worldgen/surface_builder");
public static final RegistryKey<Registry<Feature<?>>> FEATURES = key("worldgen/feature");
public static final RegistryKey<Registry<Placement<?>>> DECORATORS = key("worldgen/decorator");
public static final RegistryKey<Registry<ChunkStatus>> CHUNK_STATUS = key("chunk_status");
public static final RegistryKey<Registry<Structure<?>>> STRUCTURE_FEATURES = key("worldgen/structure_feature");
public static final RegistryKey<Registry<BlockStateProviderType<?>>> BLOCK_STATE_PROVIDER_TYPES = key("worldgen/block_state_provider_type");
public static final RegistryKey<Registry<BlockPlacerType<?>>> BLOCK_PLACER_TYPES = key("worldgen/block_placer_type");
public static final RegistryKey<Registry<FoliagePlacerType<?>>> FOLIAGE_PLACER_TYPES = key("worldgen/foliage_placer_type");
public static final RegistryKey<Registry<TreeDecoratorType<?>>> TREE_DECORATOR_TYPES = key("worldgen/tree_decorator_type");
public static final ResourceKey<Registry<Block>> BLOCKS = key("block");
public static final ResourceKey<Registry<Fluid>> FLUIDS = key("fluid");
public static final ResourceKey<Registry<Item>> ITEMS = key("item");
public static final ResourceKey<Registry<MobEffect>> EFFECTS = key("mob_effect");
public static final ResourceKey<Registry<Potion>> POTIONS = key("potion");
public static final ResourceKey<Registry<Attribute>> ATTRIBUTES = key("attribute");
public static final ResourceKey<Registry<StatType<?>>> STAT_TYPES = key("stat_type");
public static final ResourceKey<Registry<SoundEvent>> SOUND_EVENTS = key("sound_event");
public static final ResourceKey<Registry<Enchantment>> ENCHANTMENTS = key("enchantment");
public static final ResourceKey<Registry<EntityType<?>>> ENTITY_TYPES = key("entity_type");
public static final ResourceKey<Registry<Motive>> PAINTING_TYPES = key("motive");
public static final ResourceKey<Registry<ParticleType<?>>> PARTICLE_TYPES = key("particle_type");
public static final ResourceKey<Registry<MenuType<?>>> CONTAINER_TYPES = key("menu");
public static final ResourceKey<Registry<BlockEntityType<?>>> BLOCK_ENTITY_TYPES = key("block_entity_type");
public static final ResourceKey<Registry<RecipeSerializer<?>>> RECIPE_SERIALIZERS = key("recipe_serializer");
public static final ResourceKey<Registry<VillagerProfession>> VILLAGER_PROFESSIONS = key("villager_profession");
public static final ResourceKey<Registry<PoiType>> POI_TYPES = key("point_of_interest_type");
public static final ResourceKey<Registry<MemoryModuleType<?>>> MEMORY_MODULE_TYPES = key("memory_module_type");
public static final ResourceKey<Registry<SensorType<?>>> SENSOR_TYPES = key("sensor_type");
public static final ResourceKey<Registry<Schedule>> SCHEDULES = key("schedule");
public static final ResourceKey<Registry<Activity>> ACTIVITIES = key("activity");
public static final ResourceKey<Registry<WorldCarver<?>>> WORLD_CARVERS = key("worldgen/carver");
public static final ResourceKey<Registry<SurfaceBuilder<?>>> SURFACE_BUILDERS = key("worldgen/surface_builder");
public static final ResourceKey<Registry<Feature<?>>> FEATURES = key("worldgen/feature");
public static final ResourceKey<Registry<FeatureDecorator<?>>> DECORATORS = key("worldgen/decorator");
public static final ResourceKey<Registry<ChunkStatus>> CHUNK_STATUS = key("chunk_status");
public static final ResourceKey<Registry<StructureFeature<?>>> STRUCTURE_FEATURES = key("worldgen/structure_feature");
public static final ResourceKey<Registry<BlockStateProviderType<?>>> BLOCK_STATE_PROVIDER_TYPES = key("worldgen/block_state_provider_type");
public static final ResourceKey<Registry<BlockPlacerType<?>>> BLOCK_PLACER_TYPES = key("worldgen/block_placer_type");
public static final ResourceKey<Registry<FoliagePlacerType<?>>> FOLIAGE_PLACER_TYPES = key("worldgen/foliage_placer_type");
public static final ResourceKey<Registry<TreeDecoratorType<?>>> TREE_DECORATOR_TYPES = key("worldgen/tree_decorator_type");
// Vanilla Dynamic
public static final RegistryKey<Registry<Biome>> BIOMES = key("worldgen/biome");
public static final ResourceKey<Registry<Biome>> BIOMES = key("worldgen/biome");
//Forge
public static final RegistryKey<Registry<DataSerializerEntry>> DATA_SERIALIZERS = key("data_serializers");
public static final RegistryKey<Registry<GlobalLootModifierSerializer<?>>> LOOT_MODIFIER_SERIALIZERS = key("forge:loot_modifier_serializers");
public static final RegistryKey<Registry<ForgeWorldType>> WORLD_TYPES = key("forge:world_types");
public static final ResourceKey<Registry<DataSerializerEntry>> DATA_SERIALIZERS = key("data_serializers");
public static final ResourceKey<Registry<GlobalLootModifierSerializer<?>>> LOOT_MODIFIER_SERIALIZERS = key("forge:loot_modifier_serializers");
public static final ResourceKey<Registry<ForgeWorldType>> WORLD_TYPES = key("forge:world_types");
private static <T> RegistryKey<Registry<T>> key(String name)
private static <T> ResourceKey<Registry<T>> key(String name)
{
return RegistryKey.createRegistryKey(new ResourceLocation(name));
return ResourceKey.createRegistryKey(new ResourceLocation(name));
}
private static void init() {}
}
@@ -31,9 +31,9 @@ import java.util.Map.Entry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraftforge.common.util.LogMessageAdapter;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.loading.AdvancedLogMessageAdapter;
import net.minecraftforge.fml.util.ObfuscationReflectionHelper;
import org.apache.commons.lang3.Validate;
import java.util.Set;
@@ -48,13 +48,13 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import io.netty.buffer.Unpooled;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.StringNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringTag;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import net.minecraftforge.common.util.TablePrinter;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.RegistryEvent.MissingMappings;
@@ -71,7 +71,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
private final RegistryManager stage;
private final BiMap<Integer, V> ids = HashBiMap.create();
private final BiMap<ResourceLocation, V> names = HashBiMap.create();
private final BiMap<RegistryKey<V>, V> keys = HashBiMap.create();
private final BiMap<ResourceKey<V>, V> keys = HashBiMap.create();
private final Class<V> superType;
private final Map<ResourceLocation, ResourceLocation> aliases = Maps.newHashMap();
final Map<ResourceLocation, ?> slaves = Maps.newHashMap();
@@ -100,13 +100,13 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
boolean isFrozen = false;
private final ResourceLocation name;
private final RegistryKey<Registry<V>> key;
private final ResourceKey<Registry<V>> key;
private final RegistryBuilder<V> builder;
ForgeRegistry(RegistryManager stage, ResourceLocation name, RegistryBuilder<V> builder)
{
this.name = name;
this.key = RegistryKey.createRegistryKey(name);
this.key = ResourceKey.createRegistryKey(name);
this.builder = builder;
this.stage = stage;
this.superType = builder.getType();
@@ -169,7 +169,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
return this.name;
}
public RegistryKey<Registry<V>> getRegistryKey()
public ResourceKey<Registry<V>> getRegistryKey()
{
return this.key;
}
@@ -251,7 +251,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
}
@Override
public Set<Entry<RegistryKey<V>, V>> getEntries()
public Set<Entry<ResourceKey<V>, V>> getEntries()
{
return Collections.unmodifiableSet(this.keys.entrySet());
}
@@ -299,7 +299,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
}
@Nullable
public RegistryKey<V> getKey(int id)
public ResourceKey<V> getKey(int id)
{
V value = getValue(id);
return this.keys.inverse().get(value);
@@ -375,7 +375,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
}
this.names.put(key, value);
this.keys.put(RegistryKey.create(this.key, key), value);
this.keys.put(ResourceKey.create(this.key, key), value);
this.ids.put(idToUse, value);
this.availabilityMap.set(idToUse);
this.owners.put(new OverrideOwner(owner == null ? key.getPath() : owner, key), value);
@@ -635,7 +635,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
V value = this.names.remove(key);
if (value != null)
{
RegistryKey<V> rkey = this.keys.inverse().remove(value);
ResourceKey<V> rkey = this.keys.inverse().remove(value);
if (rkey == null)
throw new IllegalStateException("Removed a entry that did not have an associated RegistryKey: " + key + " " + value.toString() + " This should never happen unless hackery!");
@@ -691,7 +691,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
.header("Key", r -> r.key)
.header("Value", r -> r.value);
LOGGER.debug(REGISTRYDUMP, ()-> new AdvancedLogMessageAdapter(sb ->
LOGGER.debug(REGISTRYDUMP, ()-> LogMessageAdapter.adapt(sb ->
{
sb.append("Registry Name: ").append(name).append('\n');
tab.clearRows();
@@ -705,22 +705,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
}
}
//TODO: Convert to record in 1.17+
private static class DumpRow
{
final String id;
final String key;
final String value;
final String dummied;
private DumpRow(String id, String key, String value, String dummied)
{
this.id = id;
this.key = key;
this.value = value;
this.dummied = dummied;
}
}
private record DumpRow(String id, String key, String value, String dummied) {}
public void loadIds(Map<ResourceLocation, Integer> ids, Map<ResourceLocation, String> overrides, Map<ResourceLocation, Integer> missing, Map<ResourceLocation, Integer[]> remapped, ForgeRegistry<V> old, ResourceLocation name)
{
@@ -839,7 +824,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
if (value == null)
throw new IllegalStateException("ContainsKey for " + key + " was true, but removing by name returned no value.. This should never happen unless hackery!");
RegistryKey<V> rkey = this.keys.inverse().remove(value); // Remove from the RegistryKey -> Value map
ResourceKey<V> rkey = this.keys.inverse().remove(value); // Remove from the RegistryKey -> Value map
if (rkey == null)
throw new IllegalStateException("Removed a entry that did not have an associated RegistryKey: " + key + " " + value.toString() + " This should never happen unless hackery!");
@@ -895,36 +880,36 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
public final Set<Integer> blocked = Sets.newTreeSet();
public final Set<ResourceLocation> dummied = Sets.newTreeSet(sorter);
public final Map<ResourceLocation, String> overrides = Maps.newTreeMap(sorter);
private PacketBuffer binary = null;
private FriendlyByteBuf binary = null;
public CompoundNBT write()
public CompoundTag write()
{
CompoundNBT data = new CompoundNBT();
CompoundTag data = new CompoundTag();
ListNBT ids = new ListNBT();
ListTag ids = new ListTag();
this.ids.entrySet().stream().forEach(e ->
{
CompoundNBT tag = new CompoundNBT();
CompoundTag tag = new CompoundTag();
tag.putString("K", e.getKey().toString());
tag.putInt("V", e.getValue());
ids.add(tag);
});
data.put("ids", ids);
ListNBT aliases = new ListNBT();
ListTag aliases = new ListTag();
this.aliases.entrySet().stream().forEach(e ->
{
CompoundNBT tag = new CompoundNBT();
CompoundTag tag = new CompoundTag();
tag.putString("K", e.getKey().toString());
tag.putString("V", e.getValue().toString());
aliases.add(tag);
});
data.put("aliases", aliases);
ListNBT overrides = new ListNBT();
ListTag overrides = new ListTag();
this.overrides.entrySet().stream().forEach(e ->
{
CompoundNBT tag = new CompoundNBT();
CompoundTag tag = new CompoundTag();
tag.putString("K", e.getKey().toString());
tag.putString("V", e.getValue());
overrides.add(tag);
@@ -934,14 +919,14 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
int[] blocked = this.blocked.stream().mapToInt(x->x).sorted().toArray();
data.putIntArray("blocked", blocked);
ListNBT dummied = new ListNBT();
this.dummied.stream().sorted().forEach(e -> dummied.add(StringNBT.valueOf(e.toString())));
ListTag dummied = new ListTag();
this.dummied.stream().sorted().forEach(e -> dummied.add(StringTag.valueOf(e.toString())));
data.put("dummied", dummied);
return data;
}
public static Snapshot read(CompoundNBT nbt)
public static Snapshot read(CompoundTag nbt)
{
Snapshot ret = new Snapshot();
if (nbt == null)
@@ -949,24 +934,24 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
return ret;
}
ListNBT list = nbt.getList("ids", 10);
ListTag list = nbt.getList("ids", 10);
list.forEach(e ->
{
CompoundNBT comp = (CompoundNBT)e;
CompoundTag comp = (CompoundTag)e;
ret.ids.put(new ResourceLocation(comp.getString("K")), comp.getInt("V"));
});
list = nbt.getList("aliases", 10);
list.forEach(e ->
{
CompoundNBT comp = (CompoundNBT)e;
CompoundTag comp = (CompoundTag)e;
ret.aliases.put(new ResourceLocation(comp.getString("K")), new ResourceLocation(comp.getString("V")));
});
list = nbt.getList("overrides", 10);
list.forEach(e ->
{
CompoundNBT comp = (CompoundNBT)e;
CompoundTag comp = (CompoundTag)e;
ret.overrides.put(new ResourceLocation(comp.getString("K")), comp.getString("V"));
});
@@ -977,15 +962,15 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
}
list = nbt.getList("dummied", 8);
list.forEach(e -> ret.dummied.add(new ResourceLocation(((StringNBT)e).getAsString())));
list.forEach(e -> ret.dummied.add(new ResourceLocation(((StringTag)e).getAsString())));
return ret;
}
public synchronized PacketBuffer getPacketData()
public synchronized FriendlyByteBuf getPacketData()
{
if (binary == null) {
PacketBuffer pkt = new PacketBuffer(Unpooled.buffer());
FriendlyByteBuf pkt = new FriendlyByteBuf(Unpooled.buffer());
pkt.writeVarInt(this.ids.size());
this.ids.forEach((k,v) -> {
@@ -1014,10 +999,10 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
this.binary = pkt;
}
return new PacketBuffer(binary.slice());
return new FriendlyByteBuf(binary.slice());
}
public static Snapshot read(PacketBuffer buff)
public static Snapshot read(FriendlyByteBuf buff)
{
if (buff == null)
return new Snapshot();
@@ -21,7 +21,7 @@ package net.minecraftforge.registries;
import com.google.common.reflect.TypeToken;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable;
/**
@@ -24,71 +24,63 @@ import com.mojang.serialization.Lifecycle;
import java.util.*;
import net.minecraft.block.AirBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.attributes.Attribute;
import net.minecraft.entity.ai.attributes.AttributeModifierMap;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.entity.ai.brain.memory.MemoryModuleType;
import net.minecraft.entity.ai.brain.schedule.Activity;
import net.minecraft.entity.ai.brain.schedule.Schedule;
import net.minecraft.entity.ai.brain.sensor.SensorType;
import net.minecraft.entity.item.PaintingType;
import net.minecraft.entity.merchant.villager.VillagerProfession;
import net.minecraft.fluid.Fluid;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.crafting.IRecipeSerializer;
import net.minecraft.network.datasync.IDataSerializer;
import net.minecraft.particles.ParticleType;
import net.minecraft.potion.Effect;
import net.minecraft.potion.Potion;
import net.minecraft.state.StateContainer;
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.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.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.state.StateDefinition;
import net.minecraft.stats.StatType;
import net.minecraft.tags.TagRegistryManager;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.*;
import net.minecraft.util.registry.DefaultedRegistry;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.SimpleRegistry;
import net.minecraft.village.PointOfInterestType;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.ChunkStatus;
import net.minecraft.world.gen.DebugChunkGenerator;
import net.minecraft.world.gen.blockplacer.BlockPlacerType;
import net.minecraft.world.gen.blockstateprovider.BlockStateProviderType;
import net.minecraft.world.gen.carver.WorldCarver;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.structure.Structure;
import net.minecraft.world.gen.foliageplacer.FoliagePlacerType;
import net.minecraft.world.gen.placement.Placement;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.gen.treedecorator.TreeDecoratorType;
import net.minecraftforge.common.ForgeHooks;
import net.minecraft.tags.StaticTags;
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.blockplacers.BlockPlacerType;
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.placement.FeatureDecorator;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecoratorType;
import net.minecraftforge.common.ForgeTagHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
import net.minecraftforge.common.util.LogMessageAdapter;
import net.minecraftforge.common.world.ForgeWorldType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.RegistryEvent.MissingMappings;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.event.entity.EntityAttributeModificationEvent;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModLoader;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.ModLoadingStage;
import net.minecraftforge.fml.common.EnhancedRuntimeException;
import net.minecraftforge.fml.common.thread.EffectiveSide;
import net.minecraftforge.fml.event.lifecycle.FMLModIdMappingEvent;
import net.minecraftforge.fml.loading.AdvancedLogMessageAdapter;
import net.minecraftforge.fml.IModStateTransition;
import net.minecraftforge.fml.StartupMessageManager;
import net.minecraftforge.fml.util.EnhancedRuntimeException;
import net.minecraftforge.fml.util.thread.EffectiveSide;
import net.minecraftforge.fmllegacy.event.lifecycle.FMLModIdMappingEvent;
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -99,7 +91,6 @@ import java.lang.reflect.Field;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -107,7 +98,10 @@ import java.util.stream.Stream;
import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES;
import static net.minecraftforge.registries.ForgeRegistries.Keys.*;
import net.minecraftforge.fml.common.EnhancedRuntimeException.WrappedPrintStream;
import net.minecraft.core.IdMapper;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
/**
* INTERNAL ONLY
@@ -147,23 +141,23 @@ public class GameData
makeRegistry(BLOCKS, Block.class, "air").addCallback(BlockCallbacks.INSTANCE).legacyName("blocks").create();
makeRegistry(FLUIDS, Fluid.class, "empty").create();
makeRegistry(ITEMS, Item.class, "air").addCallback(ItemCallbacks.INSTANCE).legacyName("items").create();
makeRegistry(EFFECTS, Effect.class ).legacyName("potions").create();
makeRegistry(EFFECTS, MobEffect.class ).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").tagFolder("potions").create();
makeRegistry(ENCHANTMENTS, Enchantment.class).legacyName("enchantments").tagFolder("enchantments").create();
makeRegistry(ENTITY_TYPES, c(EntityType.class), "pig").legacyName("entities").create();
makeRegistry(TILE_ENTITY_TYPES, c(TileEntityType.class)).disableSaving().legacyName("tileentities").tagFolder("tile_entity_types").create();
makeRegistry(BLOCK_ENTITY_TYPES, c(BlockEntityType.class)).disableSaving().legacyName("blockentities").tagFolder("block_entity_types").create();
makeRegistry(PARTICLE_TYPES, c(ParticleType.class)).disableSaving().create();
makeRegistry(CONTAINER_TYPES, c(ContainerType.class)).disableSaving().create();
makeRegistry(PAINTING_TYPES, PaintingType.class, "kebab").create();
makeRegistry(RECIPE_SERIALIZERS, c(IRecipeSerializer.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();
// Villagers
makeRegistry(VILLAGER_PROFESSIONS, VillagerProfession.class, "none").create();
makeRegistry(POI_TYPES, PointOfInterestType.class, "unemployed").addCallback(PointOfInterestTypeCallbacks.INSTANCE).disableSync().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();
@@ -173,9 +167,9 @@ public class GameData
makeRegistry(WORLD_CARVERS, c(WorldCarver.class)).disableSaving().disableSync().create();
makeRegistry(SURFACE_BUILDERS, c(SurfaceBuilder.class)).disableSaving().disableSync().create();
makeRegistry(FEATURES, c(Feature.class)).addCallback(FeatureCallbacks.INSTANCE).disableSaving().disableSync().create();
makeRegistry(DECORATORS, c(Placement.class)).disableSaving().disableSync().create();
makeRegistry(DECORATORS, c(FeatureDecorator.class)).disableSaving().disableSync().create();
makeRegistry(CHUNK_STATUS, ChunkStatus.class, "empty").disableSaving().disableSync().create();
makeRegistry(STRUCTURE_FEATURES, c(Structure.class)).disableSaving().disableSync().create();
makeRegistry(STRUCTURE_FEATURES, c(StructureFeature.class)).disableSaving().disableSync().create();
makeRegistry(BLOCK_STATE_PROVIDER_TYPES, c(BlockStateProviderType.class)).disableSaving().disableSync().create();
makeRegistry(BLOCK_PLACER_TYPES, c(BlockPlacerType.class)).disableSaving().disableSync().create();
makeRegistry(FOLIAGE_PLACER_TYPES, c(FoliagePlacerType.class)).disableSaving().disableSync().create();
@@ -192,30 +186,30 @@ public class GameData
@SuppressWarnings("unchecked") //Ugly hack to let us pass in a typed Class object. Remove when we remove type specific references.
private static <T> Class<T> c(Class<?> cls) { return (Class<T>)cls; }
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(RegistryKey<? extends Registry<T>> key, Class<T> type)
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceKey<? extends Registry<T>> key, Class<T> type)
{
return new RegistryBuilder<T>().setName(key.location()).setType(type).setMaxID(MAX_VARINT).addCallback(new NamespacedWrapper.Factory<T>());
}
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(RegistryKey<? extends Registry<T>> key, Class<T> type, int min, int max)
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceKey<? extends Registry<T>> key, Class<T> type, int min, int max)
{
return new RegistryBuilder<T>().setName(key.location()).setType(type).setIDRange(min, max).hasWrapper();
}
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(RegistryKey<? extends Registry<T>> key, Class<T> type, String _default)
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceKey<? extends Registry<T>> key, Class<T> type, String _default)
{
return new RegistryBuilder<T>().setName(key.location()).setType(type).setMaxID(MAX_VARINT).hasWrapper().setDefaultKey(new ResourceLocation(_default));
}
public static <T extends IForgeRegistryEntry<T>> SimpleRegistry<T> getWrapper(RegistryKey<? extends Registry<T>> key, Lifecycle lifecycle)
public static <T extends IForgeRegistryEntry<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());
@SuppressWarnings("unchecked")
SimpleRegistry<T> ret = reg.getSlaveMap(NamespacedWrapper.Factory.ID, NamespacedWrapper.class);
MappedRegistry<T> ret = reg.getSlaveMap(NamespacedWrapper.Factory.ID, NamespacedWrapper.class);
Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + key.toString());
return ret;
}
public static <T extends IForgeRegistryEntry<T>> DefaultedRegistry<T> getWrapper(RegistryKey<? extends Registry<T>> key, Lifecycle lifecycle, String defKey)
public static <T extends IForgeRegistryEntry<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());
@@ -232,27 +226,27 @@ public class GameData
}
@SuppressWarnings("unchecked")
public static ObjectIntIdentityMap<BlockState> getBlockStateIDMap()
public static IdMapper<BlockState> getBlockStateIDMap()
{
return RegistryManager.ACTIVE.getRegistry(Block.class).getSlaveMap(BLOCKSTATE_TO_ID, ObjectIntIdentityMap.class);
return RegistryManager.ACTIVE.getRegistry(Block.class).getSlaveMap(BLOCKSTATE_TO_ID, IdMapper.class);
}
@SuppressWarnings("unchecked")
public static Map<BlockState, PointOfInterestType> getBlockStatePointOfInterestTypeMap()
public static Map<BlockState, PoiType> getBlockStatePointOfInterestTypeMap()
{
return RegistryManager.ACTIVE.getRegistry(PointOfInterestType.class).getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class);
return RegistryManager.ACTIVE.getRegistry(PoiType.class).getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class);
}
@SuppressWarnings("unchecked")
public static Map<IDataSerializer<?>, DataSerializerEntry> getSerializerMap()
public static Map<EntityDataSerializer<?>, DataSerializerEntry> getSerializerMap()
{
return RegistryManager.ACTIVE.getRegistry(DataSerializerEntry.class).getSlaveMap(SERIALIZER_TO_ENTRY, Map.class);
}
@SuppressWarnings("unchecked")
public static BiMap<String, Structure<?>> getStructureMap()
public static BiMap<String, StructureFeature<?>> getStructureMap()
{
return (BiMap<String, Structure<?>>) RegistryManager.ACTIVE.getRegistry(Feature.class).getSlaveMap(STRUCTURES, BiMap.class);
return (BiMap<String, StructureFeature<?>>) RegistryManager.ACTIVE.getRegistry(Feature.class).getSlaveMap(STRUCTURES, BiMap.class);
}
public static <K extends IForgeRegistryEntry<K>> K register_impl(K value)
@@ -350,7 +344,7 @@ public class GameData
}
@SuppressWarnings("rawtypes") //Eclipse compiler generics issue.
public static Stream<ModLoadingStage.EventGenerator<?>> generateRegistryEvents() {
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)));
@@ -362,10 +356,10 @@ public class GameData
keys.add(1, ITEMS.location());
final Function<ResourceLocation, ? extends RegistryEvent.Register<?>> registerEventGenerator = rl -> RegistryManager.ACTIVE.getRegistry(rl).getRegisterEvent(rl);
return keys.stream().map(rl -> ModLoadingStage.EventGenerator.fromFunction(mc -> registerEventGenerator.apply(rl)));
return keys.stream().map(rl -> IModStateTransition.EventGenerator.fromFunction(mc -> registerEventGenerator.apply(rl)));
}
public static CompletableFuture<List<Throwable>> preRegistryEventDispatch(final Executor executor, final ModLoadingStage.EventGenerator<? extends RegistryEvent.Register<?>> eventGenerator) {
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();
@@ -375,7 +369,7 @@ public class GameData
}, executor).thenApply(v->Collections.emptyList());
}
public static CompletableFuture<List<Throwable>> postRegistryEventDispatch(final Executor executor, final ModLoadingStage.EventGenerator<? extends RegistryEvent.Register<?>> eventGenerator) {
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();
@@ -406,18 +400,18 @@ public class GameData
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> entry : RegistryManager.ACTIVE.registries.entrySet())
{
ResourceLocation registryName = entry.getKey();
if (entry.getValue().getTagFolder() != null && TagRegistryManager.get(registryName) == null)
if (entry.getValue().getTagFolder() != null && StaticTags.get(registryName) == null)
{
LOGGER.debug(REGISTRIES, "Registering custom tag type for: {}", registryName);
customTagTypes.add(registryName);
TagRegistryManager.create(registryName, tagCollectionSupplier -> tagCollectionSupplier.getCustomTypeCollection(registryName));
StaticTags.create(ResourceKey.createRegistryKey(registryName), entry.getValue().getTagFolder());
}
}
ForgeTagHandler.setCustomTagTypes(customTagTypes);
}
//Lets us clear the map so we can rebuild it.
private static class ClearableObjectIntIdentityMap<I> extends ObjectIntIdentityMap<I>
private static class ClearableObjectIntIdentityMap<I> extends IdMapper<I>
{
void clear()
{
@@ -445,8 +439,8 @@ public class GameData
{
if (oldBlock != null)
{
StateContainer<Block, BlockState> oldContainer = oldBlock.getStateDefinition();
StateContainer<Block, BlockState> newContainer = block.getStateDefinition();
StateDefinition<Block, BlockState> oldContainer = oldBlock.getStateDefinition();
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()))
@@ -460,7 +454,7 @@ public class GameData
s.getPossibleValues().stream().map(Object::toString).collect(Collectors.joining( "," ))))
.collect(Collectors.joining(";"));
LOGGER.error(REGISTRIES,()-> new AdvancedLogMessageAdapter(sb-> {
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("\tOld: ").append(oldSequence).append('\n');
@@ -521,7 +515,7 @@ public class GameData
block.getLootTable();
}
DebugChunkGenerator.initValidStates();
DebugLevelSource.initValidStates();
}
private static class BlockDummyAir extends AirBlock //A named class so DummyBlockReplacementTest can detect if its a dummy
@@ -583,7 +577,7 @@ public class GameData
public void onValidate(IForgeRegistryInternal<Attribute> owner, RegistryManager stage, int id, ResourceLocation key, Attribute obj)
{
// some stuff hard patched in can cause this to derp if it's JUST vanilla, so skip
if (stage!=RegistryManager.VANILLA) GlobalEntityTypeAttributes.validate();
if (stage!=RegistryManager.VANILLA) DefaultAttributes.validate();
}
}
@@ -595,7 +589,7 @@ public class GameData
public void onAdd(IForgeRegistryInternal<DataSerializerEntry> owner, RegistryManager stage, int id, DataSerializerEntry entry, @Nullable DataSerializerEntry oldEntry)
{
@SuppressWarnings("unchecked")
Map<IDataSerializer<?>, DataSerializerEntry> map = owner.getSlaveMap(SERIALIZER_TO_ENTRY, Map.class);
Map<EntityDataSerializer<?>, DataSerializerEntry> map = owner.getSlaveMap(SERIALIZER_TO_ENTRY, Map.class);
if (oldEntry != null) map.remove(oldEntry.getSerializer());
map.put(entry.getSerializer(), entry);
}
@@ -630,21 +624,21 @@ public class GameData
}
}
private static class PointOfInterestTypeCallbacks implements IForgeRegistry.AddCallback<PointOfInterestType> , IForgeRegistry.ClearCallback<PointOfInterestType>, IForgeRegistry.CreateCallback<PointOfInterestType>
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<PointOfInterestType> owner, RegistryManager stage, int id, PointOfInterestType obj, @Nullable PointOfInterestType oldObj)
public void onAdd(IForgeRegistryInternal<PoiType> owner, RegistryManager stage, int id, PoiType obj, @Nullable PoiType oldObj)
{
Map<BlockState, PointOfInterestType> map = owner.getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class);
Map<BlockState, PoiType> map = owner.getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class);
if (oldObj != null)
{
oldObj.getBlockStates().forEach(map::remove);
}
obj.getBlockStates().forEach((state) ->
{
PointOfInterestType oldType = map.put(state, obj);
PoiType oldType = map.put(state, obj);
if (oldType != null)
{
throw new IllegalStateException(String.format("Point of interest types %s and %s both list %s in their blockstates, this is not allowed. Blockstates can only have one point of interest type each.", oldType, obj, state));
@@ -653,13 +647,13 @@ public class GameData
}
@Override
public void onClear(IForgeRegistryInternal<PointOfInterestType> owner, RegistryManager stage)
public void onClear(IForgeRegistryInternal<PoiType> owner, RegistryManager stage)
{
owner.getSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, Map.class).clear();
}
@Override
public void onCreate(IForgeRegistryInternal<PointOfInterestType> owner, RegistryManager stage)
public void onCreate(IForgeRegistryInternal<PoiType> owner, RegistryManager stage)
{
owner.setSlaveMap(BLOCKSTATE_TO_POINT_OF_INTEREST_TYPE, new HashMap<>());
}
@@ -796,7 +790,7 @@ public class GameData
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());
if (!lst.isEmpty())
{
LOGGER.error(REGISTRIES,()->new AdvancedLogMessageAdapter(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'));
}));
@@ -25,8 +25,8 @@ import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
/**
* Main interface for the registry system. Use this to query the registry system.
@@ -52,7 +52,7 @@ public interface IForgeRegistry<V extends IForgeRegistryEntry<V>> extends Iterab
@Nonnull Set<ResourceLocation> getKeys();
@Nonnull Collection<V> getValues();
@Nonnull Set<Entry<RegistryKey<V>, V>> getEntries();
@Nonnull Set<Entry<ResourceKey<V>, V>> getEntries();
/**
* Retrieve the slave map of type T from the registry.
@@ -18,7 +18,7 @@
*/
package net.minecraftforge.registries;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
import javax.annotation.Nullable;
@@ -19,7 +19,7 @@
package net.minecraftforge.registries;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
public interface IForgeRegistryInternal<V extends IForgeRegistryEntry<V>> extends IForgeRegistry<V>
{
@@ -19,7 +19,7 @@
package net.minecraftforge.registries;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
public interface IForgeRegistryModifiable<V extends IForgeRegistryEntry<V>> extends IForgeRegistry<V>
{
@@ -19,7 +19,7 @@
package net.minecraftforge.registries;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
import java.util.function.Supplier;
@@ -31,9 +31,9 @@ import javax.annotation.Nullable;
import org.apache.commons.lang3.Validate;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.DefaultedRegistry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.DefaultedRegistry;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -52,7 +52,7 @@ class NamespacedDefaultedWrapper<T extends IForgeRegistryEntry<T>> extends Defau
}
@Override
public <V extends T> V registerMapping(int id, RegistryKey<T> key, V value, Lifecycle lifecycle)
public <V extends T> V registerMapping(int id, ResourceKey<T> key, V value, Lifecycle lifecycle)
{
if (locked)
throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods.");
@@ -69,13 +69,13 @@ class NamespacedDefaultedWrapper<T extends IForgeRegistryEntry<T>> extends Defau
}
@Override
public <V extends T> V register(RegistryKey<T> key, V value, Lifecycle lifecycle)
public <V extends T> V register(ResourceKey<T> key, V value, Lifecycle lifecycle)
{
return registerMapping(-1, key, value, lifecycle);
}
@Override
public <V extends T> V registerOrOverride(OptionalInt id, RegistryKey<T> key, V value, Lifecycle lifecycle) {
public <V extends T> V registerOrOverride(OptionalInt id, ResourceKey<T> key, V value, Lifecycle lifecycle) {
int wanted = -1;
if (id.isPresent() && byId(id.getAsInt()) != null)
wanted = id.getAsInt();
@@ -98,7 +98,7 @@ class NamespacedDefaultedWrapper<T extends IForgeRegistryEntry<T>> extends Defau
@Override
@Nullable
public T get(@Nullable RegistryKey<T> name)
public T get(@Nullable ResourceKey<T> name)
{
return name == null ? null : this.delegate.getRaw(name.location()); //get without default
}
@@ -142,7 +142,7 @@ class NamespacedDefaultedWrapper<T extends IForgeRegistryEntry<T>> extends Defau
}
@Override
public Set<Map.Entry<RegistryKey<T>, T>> entrySet()
public Set<Map.Entry<ResourceKey<T>, T>> entrySet()
{
return this.delegate.getEntries();
}
@@ -28,16 +28,16 @@ import java.util.Random;
import java.util.Set;
import javax.annotation.Nullable;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.SimpleRegistry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.MappedRegistry;
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.mojang.serialization.Lifecycle;
class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry<T> implements ILockableRegistry
class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends MappedRegistry<T> implements ILockableRegistry
{
private static final Logger LOGGER = LogManager.getLogger();
private boolean locked = false;
@@ -50,7 +50,7 @@ class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry
}
@Override
public <V extends T> V registerMapping(int id, RegistryKey<T> key, V value, Lifecycle lifecycle)
public <V extends T> V registerMapping(int id, ResourceKey<T> key, V value, Lifecycle lifecycle)
{
if (locked)
throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods.");
@@ -67,13 +67,13 @@ class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry
}
@Override
public <R extends T> R register(RegistryKey<T> key, R value, Lifecycle lifecycle)
public <R extends T> R register(ResourceKey<T> key, R value, Lifecycle lifecycle)
{
return registerMapping(-1, key, value, lifecycle);
}
@Override
public <V extends T> V registerOrOverride(OptionalInt id, RegistryKey<T> key, V value, Lifecycle lifecycle) {
public <V extends T> V registerOrOverride(OptionalInt id, ResourceKey<T> key, V value, Lifecycle lifecycle) {
int wanted = -1;
if (id.isPresent() && byId(id.getAsInt()) != null)
wanted = id.getAsInt();
@@ -96,7 +96,7 @@ class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry
@Override
@Nullable
public T get(@Nullable RegistryKey<T> name)
public T get(@Nullable ResourceKey<T> name)
{
return name == null ? null : this.delegate.getRaw(name.location()); //get without default
}
@@ -140,7 +140,7 @@ class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry
}
@Override
public Set<Map.Entry<RegistryKey<T>, T>> entrySet()
public Set<Map.Entry<ResourceKey<T>, T>> entrySet()
{
return this.delegate.getEntries();
}
@@ -27,8 +27,8 @@ import java.util.Queue;
import java.util.function.Consumer;
import java.util.function.Predicate;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.ResourceLocationException;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.ResourceLocationException;
import javax.annotation.Nullable;
@@ -31,7 +31,7 @@ import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.forgespi.language.ModFileScanData;
@@ -93,21 +93,21 @@ public class ObjectHolderRegistry
final List<ModFileScanData.AnnotationData> annotations = ModList.get().getAllScanData().stream()
.map(ModFileScanData::getAnnotations)
.flatMap(Collection::stream)
.filter(a -> OBJECT_HOLDER.equals(a.getAnnotationType()) || MOD.equals(a.getAnnotationType()))
.filter(a -> OBJECT_HOLDER.equals(a.annotationType()) || MOD.equals(a.annotationType()))
.collect(Collectors.toList());
Map<Type, String> classModIds = Maps.newHashMap();
Map<Type, Class<?>> classCache = Maps.newHashMap();
// Gather all @Mod classes, so that @ObjectHolder's in those classes don't need to specify the mod id, Modder convince
annotations.stream().filter(a -> MOD.equals(a.getAnnotationType())).forEach(data -> classModIds.put(data.getClassType(), (String)data.getAnnotationData().get("value")));
annotations.stream().filter(a -> MOD.equals(a.annotationType())).forEach(data -> classModIds.put(data.clazz(), (String)data.annotationData().get("value")));
// double pass - get all the class level annotations first, then the field level annotations
annotations.stream().filter(a -> OBJECT_HOLDER.equals(a.getAnnotationType())).filter(a -> a.getTargetType() == ElementType.TYPE)
.forEach(data -> scanTarget(classModIds, classCache, data.getClassType(), null, (String)data.getAnnotationData().get("value"), true, data.getClassType().getClassName().startsWith("net.minecraft.")));
annotations.stream().filter(a -> OBJECT_HOLDER.equals(a.annotationType())).filter(a -> a.targetType() == ElementType.TYPE)
.forEach(data -> scanTarget(classModIds, classCache, data.clazz(), null, (String)data.annotationData().get("value"), true, data.clazz().getClassName().startsWith("net.minecraft.")));
annotations.stream().filter(a -> OBJECT_HOLDER.equals(a.getAnnotationType())).filter(a -> a.getTargetType() == ElementType.FIELD)
.forEach(data -> scanTarget(classModIds, classCache, data.getClassType(), data.getMemberName(), (String)data.getAnnotationData().get("value"), false, false));
annotations.stream().filter(a -> OBJECT_HOLDER.equals(a.annotationType())).filter(a -> a.targetType() == ElementType.FIELD)
.forEach(data -> scanTarget(classModIds, classCache, data.clazz(), data.memberName(), (String)data.annotationData().get("value"), false, false));
LOGGER.debug(REGISTRIES,"Found {} ObjectHolder annotations", objectHolders.size());
}
@@ -25,7 +25,7 @@ import java.util.Set;
import com.google.common.collect.Lists;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistry.*;
import javax.annotation.Nullable;
@@ -21,7 +21,7 @@ package net.minecraftforge.registries;
import com.google.common.base.Objects;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
/*
* This is the internal implementation class of the delegate.
@@ -32,10 +32,10 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.collect.Sets.SetView;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraftforge.fml.network.FMLHandshakeMessages;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.core.Registry;
import net.minecraftforge.fmllegacy.network.FMLHandshakeMessages;
import net.minecraftforge.registries.ForgeRegistry.Snapshot;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
@@ -77,7 +77,7 @@ public class RegistryManager
return (ForgeRegistry<V>)this.registries.get(key);
}
public <V extends IForgeRegistryEntry<V>> ForgeRegistry<V> getRegistry(RegistryKey<? extends Registry<V>> key)
public <V extends IForgeRegistryEntry<V>> ForgeRegistry<V> getRegistry(ResourceKey<? extends Registry<V>> key)
{
return getRegistry(key.location());
}