Initial 1.16.2 Update

This commit is contained in:
LexManos committed 2020-08-13 00:35:08 -07:00
1 parent a3c4ffd2c1
commit fe43088c96
233 files changed
+1644 -2297

No files matched your search

@@ -32,6 +32,7 @@ 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;
@@ -40,6 +41,8 @@ import net.minecraft.potion.Effect;
import net.minecraft.potion.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;
@@ -70,7 +73,6 @@ public class ForgeRegistries
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<Biome> BIOMES = RegistryManager.ACTIVE.getRegistry(Biome.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);
@@ -96,7 +98,6 @@ public class ForgeRegistries
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<ChunkGeneratorType<?, ?>> CHUNK_GENERATOR_TYPES = RegistryManager.ACTIVE.getRegistry(ChunkGeneratorType.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<BlockStateProviderType<?>> BLOCK_STATE_PROVIDER_TYPES = RegistryManager.ACTIVE.getRegistry(BlockStateProviderType.class);
@@ -108,11 +109,57 @@ public class ForgeRegistries
public static final IForgeRegistry<DataSerializerEntry> DATA_SERIALIZERS = RegistryManager.ACTIVE.getRegistry(DataSerializerEntry.class);
public static final IForgeRegistry<GlobalLootModifierSerializer<?>> LOOT_MODIFIER_SERIALIZERS = RegistryManager.ACTIVE.getRegistry(GlobalLootModifierSerializer.class);
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");
//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");
private static <T> RegistryKey<Registry<T>> key(String name)
{
return RegistryKey.func_240904_a_(new ResourceLocation(name));
}
private static void init() {}
}
/**
* This function is just to make sure static inializers in other classes have run and setup their registries before we query them.
*/
private static void init()
{
Keys.init();
GameData.init();
Bootstrap.register();
Tags.init();
@@ -20,6 +20,7 @@
package net.minecraftforge.registries;
import com.google.common.collect.*;
import com.mojang.serialization.Lifecycle;
import net.minecraft.block.AirBlock;
import net.minecraft.block.Block;
@@ -48,13 +49,13 @@ import net.minecraft.state.StateContainer;
import net.minecraft.stats.StatType;
import net.minecraft.tileentity.TileEntityType;
import net.minecraft.util.ObjectIntIdentityMap;
import net.minecraft.util.RegistryKey;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
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;
@@ -97,6 +98,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES;
import static net.minecraftforge.registries.ForgeRegistries.Keys.*;
/**
* INTERNAL ONLY
@@ -105,53 +107,6 @@ import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES;
public class GameData
{
private static final Logger LOGGER = LogManager.getLogger();
// Vanilla registries
// Names used here match those in net.minecraft.util.Registry
// Game objects
private static final ResourceLocation BLOCKS = new ResourceLocation("block");
private static final ResourceLocation FLUIDS = new ResourceLocation("fluid");
private static final ResourceLocation ITEMS = new ResourceLocation("item");
private static final ResourceLocation POTIONS = new ResourceLocation("mob_effect");
private static final ResourceLocation BIOMES = new ResourceLocation("biome");
private static final ResourceLocation SOUNDEVENTS = new ResourceLocation("sound_event");
private static final ResourceLocation POTIONTYPES = new ResourceLocation("potion");
private static final ResourceLocation ENCHANTMENTS = new ResourceLocation("enchantment");
private static final ResourceLocation ENTITIES = new ResourceLocation("entity_type");
private static final ResourceLocation TILEENTITIES = new ResourceLocation("block_entity_type");
private static final ResourceLocation PARTICLE_TYPES = new ResourceLocation("particle_type");
private static final ResourceLocation CONTAINERS = new ResourceLocation("menu");
private static final ResourceLocation PAINTING_TYPES = new ResourceLocation("motive"); // sic
private static final ResourceLocation RECIPE_SERIALIZERS = new ResourceLocation("recipe_serializer");
private static final ResourceLocation ATTRIBUTES = new ResourceLocation("attribute");
private static final ResourceLocation STAT_TYPES = new ResourceLocation("stat_type");
// Villages
private static final ResourceLocation PROFESSIONS = new ResourceLocation("villager_profession");
private static final ResourceLocation POI_TYPES = new ResourceLocation("point_of_interest_type");
private static final ResourceLocation MEMORY_MODULE_TYPES = new ResourceLocation("memory_module_type");
private static final ResourceLocation SENSOR_TYPES = new ResourceLocation("sensor_type");
private static final ResourceLocation SCHEDULES = new ResourceLocation("schedule");
private static final ResourceLocation ACTIVITIES = new ResourceLocation("activities");
// Worldgen
private static final ResourceLocation WORLD_CARVERS = new ResourceLocation("carver");
private static final ResourceLocation SURFACE_BUILDERS = new ResourceLocation("surface_builder");
private static final ResourceLocation FEATURES = new ResourceLocation("feature");
private static final ResourceLocation DECORATORS = new ResourceLocation("decorator");
private static final ResourceLocation BIOME_PROVIDER_TYPES = new ResourceLocation("biome_source_type");
private static final ResourceLocation CHUNK_STATUS = new ResourceLocation("chunk_status");
private static final ResourceLocation STRUCTURE_FEATURES = new ResourceLocation("structure_feature");
private static final ResourceLocation BLOCK_STATE_PROVIDER_TYPES = new ResourceLocation("block_state_provider_type");
private static final ResourceLocation BLOCK_PLACER_TYPES = new ResourceLocation("block_placer_type");
private static final ResourceLocation FOLIAGE_PLACER_TYPES = new ResourceLocation("foliage_placer_type");
private static final ResourceLocation TREE_DECORATOR_TYPES = new ResourceLocation("tree_decorator_type");
// Custom forge registries
private static final ResourceLocation SERIALIZERS = new ResourceLocation("minecraft:dataserializers");
private static final ResourceLocation LOOT_MODIFIER_SERIALIZERS = new ResourceLocation("forge:loot_modifier_serializers");
private static final int MAX_VARINT = Integer.MAX_VALUE - 1; //We were told it is their intention to have everything in a reg be unlimited, so assume that until we find cases where it isnt.
private static final ResourceLocation BLOCK_TO_ITEM = new ResourceLocation("minecraft:blocktoitemmap");
@@ -167,7 +122,6 @@ public class GameData
init();
}
@SuppressWarnings("unchecked")
public static void init()
{
if (DISABLE_VANILLA_REGISTRIES)
@@ -180,78 +134,80 @@ public class GameData
hasInit = true;
// Game objects
makeRegistry(BLOCKS, Block.class, new ResourceLocation("air")).addCallback(BlockCallbacks.INSTANCE).legacyName("blocks").create();
makeRegistry(FLUIDS, Fluid.class, new ResourceLocation("empty")).create();
makeRegistry(ITEMS, Item.class, new ResourceLocation("air")).addCallback(ItemCallbacks.INSTANCE).legacyName("items").create();
makeRegistry(POTIONS, Effect.class).legacyName("potions").create();
makeRegistry(BIOMES, Biome.class).legacyName("biomes").create();
makeRegistry(SOUNDEVENTS, SoundEvent.class).legacyName("soundevents").create();
makeRegistry(POTIONTYPES, Potion.class, new ResourceLocation("empty")).legacyName("potiontypes").create();
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(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(ENTITIES, EntityType.class, new ResourceLocation("pig")).legacyName("entities").create();
makeRegistry(TILEENTITIES, TileEntityType.class).disableSaving().legacyName("tileentities").create();
makeRegistry(PARTICLE_TYPES, ParticleType.class).disableSaving().create();
makeRegistry(CONTAINERS, ContainerType.class).disableSaving().create();
makeRegistry(PAINTING_TYPES, PaintingType.class, new ResourceLocation("kebab")).create();
makeRegistry(RECIPE_SERIALIZERS, IRecipeSerializer.class).disableSaving().create();
makeRegistry(ENTITY_TYPES, c(EntityType.class), "pig").legacyName("entities").create();
makeRegistry(TILE_ENTITY_TYPES, c(TileEntityType.class)).disableSaving().legacyName("tileentities").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(ATTRIBUTES, Attribute.class).onValidate(AttributeCallbacks.INSTANCE).disableSaving().disableSync().create();
makeRegistry(STAT_TYPES, StatType.class).create();
makeRegistry(STAT_TYPES, c(StatType.class)).create();
// Villagers
makeRegistry(PROFESSIONS, VillagerProfession.class, new ResourceLocation("none")).create();
makeRegistry(POI_TYPES, PointOfInterestType.class, new ResourceLocation("unemployed")).disableSync().create();
makeRegistry(MEMORY_MODULE_TYPES, MemoryModuleType.class, new ResourceLocation("dummy")).disableSync().create();
makeRegistry(SENSOR_TYPES, SensorType.class, new ResourceLocation("dummy")).disableSaving().disableSync().create();
makeRegistry(VILLAGER_PROFESSIONS, VillagerProfession.class, "none").create();
makeRegistry(POI_TYPES, PointOfInterestType.class, "unemployed").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();
// Worldgen
makeRegistry(WORLD_CARVERS, WorldCarver.class).disableSaving().disableSync().create();
makeRegistry(SURFACE_BUILDERS, SurfaceBuilder.class).disableSaving().disableSync().create();
makeRegistry(FEATURES, Feature.class).addCallback(FeatureCallbacks.INSTANCE).disableSaving().create();
makeRegistry(DECORATORS, Placement.class).disableSaving().disableSync().create();
makeRegistry(CHUNK_STATUS, ChunkStatus.class, new ResourceLocation("empty")).disableSaving().disableSync().create();
makeRegistry(STRUCTURE_FEATURES, Structure.class).disableSaving().disableSync().create();
makeRegistry(BLOCK_STATE_PROVIDER_TYPES, BlockStateProviderType.class).disableSaving().disableSync().create();
makeRegistry(BLOCK_PLACER_TYPES, BlockPlacerType.class).disableSaving().disableSync().create();
makeRegistry(FOLIAGE_PLACER_TYPES, FoliagePlacerType.class).disableSaving().disableSync().create();
makeRegistry(TREE_DECORATOR_TYPES, TreeDecoratorType.class).disableSaving().disableSync().create();
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().create();
makeRegistry(DECORATORS, c(Placement.class)).disableSaving().disableSync().create();
makeRegistry(CHUNK_STATUS, ChunkStatus.class, "empty").disableSaving().disableSync().create();
makeRegistry(STRUCTURE_FEATURES, c(Structure.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();
makeRegistry(TREE_DECORATOR_TYPES, c(TreeDecoratorType.class)).disableSaving().disableSync().create();
// Custom forge registries
makeRegistry(SERIALIZERS, DataSerializerEntry.class, 256 /*vanilla space*/, MAX_VARINT).disableSaving().disableOverrides().addCallback(SerializerCallbacks.INSTANCE).create();
makeRegistry(LOOT_MODIFIER_SERIALIZERS, GlobalLootModifierSerializer.class).disableSaving().disableSync().create();
makeRegistry(DATA_SERIALIZERS, DataSerializerEntry.class, 256 /*vanilla space*/, MAX_VARINT).disableSaving().disableOverrides().addCallback(SerializerCallbacks.INSTANCE).create();
makeRegistry(LOOT_MODIFIER_SERIALIZERS, c(GlobalLootModifierSerializer.class)).disableSaving().disableSync().create();
}
@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)
{
return new RegistryBuilder<T>().setName(key.func_240901_a_()).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)
{
return new RegistryBuilder<T>().setName(key.func_240901_a_()).setType(type).setIDRange(min, max).addCallback(new NamespacedWrapper.Factory<T>());
}
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(RegistryKey<? extends Registry<T>> key, Class<T> type, String _default)
{
return new RegistryBuilder<T>().setName(key.func_240901_a_()).setType(type).setMaxID(MAX_VARINT).addCallback(new NamespacedDefaultedWrapper.Factory<T>()).setDefaultKey(new ResourceLocation(_default));
}
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type)
public static <T extends IForgeRegistryEntry<T>> SimpleRegistry<T> getWrapper(RegistryKey<? extends Registry<T>> key, Lifecycle lifecycle)
{
return new RegistryBuilder<T>().setName(name).setType(type).setMaxID(MAX_VARINT).addCallback(new NamespacedWrapper.Factory<T>());
}
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type, int min, int max)
{
return new RegistryBuilder<T>().setName(name).setType(type).setIDRange(min, max).addCallback(new NamespacedWrapper.Factory<T>());
}
private static <T extends IForgeRegistryEntry<T>> RegistryBuilder<T> makeRegistry(ResourceLocation name, Class<T> type, ResourceLocation _default)
{
return new RegistryBuilder<T>().setName(name).setType(type).setMaxID(MAX_VARINT).addCallback(new NamespacedDefaultedWrapper.Factory<T>()).setDefaultKey(_default);
}
public static <V extends IForgeRegistryEntry<V>> DefaultedRegistry<V> getWrapperDefaulted(Class<? super V> cls)
{
IForgeRegistry<V> reg = RegistryManager.ACTIVE.<V>getRegistry(cls);
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + cls.toString());
IForgeRegistry<T> reg = RegistryManager.ACTIVE.getRegistry(key);
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + key.toString());
@SuppressWarnings("unchecked")
DefaultedRegistry<V> ret = reg.getSlaveMap(NamespacedDefaultedWrapper.Factory.ID, NamespacedDefaultedWrapper.class);
Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + cls.toString());
SimpleRegistry<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 <V extends IForgeRegistryEntry<V>> SimpleRegistry<V> getWrapper(Class<? super V> cls)
public static <T extends IForgeRegistryEntry<T>> DefaultedRegistry<T> getWrapper(RegistryKey<? extends Registry<T>> key, Lifecycle lifecycle, String defKey)
{
IForgeRegistry<V> reg = RegistryManager.ACTIVE.<V>getRegistry(cls);
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + cls.toString());
IForgeRegistry<T> reg = RegistryManager.ACTIVE.getRegistry(key);
Validate.notNull(reg, "Attempted to get vanilla wrapper for unknown registry: " + key.toString());
@SuppressWarnings("unchecked")
SimpleRegistry<V> ret = reg.getSlaveMap(NamespacedWrapper.Factory.ID, NamespacedWrapper.class);
Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + cls.toString());
DefaultedRegistry<T> ret = reg.getSlaveMap(NamespacedDefaultedWrapper.Factory.ID, NamespacedDefaultedWrapper.class);
Validate.notNull(ret, "Attempted to get vanilla wrapper for registry created incorrectly: " + key.toString());
return ret;
}
@@ -435,7 +391,7 @@ public class GameData
final ClearableObjectIntIdentityMap<BlockState> idMap = new ClearableObjectIntIdentityMap<BlockState>()
{
@Override
public int get(BlockState key)
public int getId(BlockState key)
{
Integer integer = (Integer)this.identityMap.get(key);
// There are some cases where this map is queried to serialize a state that is valid,
@@ -852,11 +808,11 @@ public class GameData
keys.sort((o1, o2) -> String.valueOf(o1).compareToIgnoreCase(String.valueOf(o2)));
//Move Blocks to first, and Items to second.
keys.remove(BLOCKS);
keys.remove(ITEMS);
keys.remove(BLOCKS.func_240901_a_());
keys.remove(ITEMS.func_240901_a_());
keys.add(0, BLOCKS);
keys.add(1, ITEMS);
keys.add(0, BLOCKS.func_240901_a_());
keys.add(1, ITEMS.func_240901_a_());
for (int i = 0, keysSize = keys.size(); i < keysSize; i++) {
final ResourceLocation rl = keys.get(i);
if (!filter.test(rl)) continue;
@@ -22,6 +22,7 @@ package net.minecraftforge.registries;
import java.util.Collection;
import java.util.Iterator;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Random;
import java.util.Set;
@@ -50,7 +51,7 @@ class NamespacedDefaultedWrapper<T extends IForgeRegistryEntry<T>> extends Defau
}
@Override
public <V extends T> V register(int id, RegistryKey<T> key, V value)
public <V extends T> V register(int id, RegistryKey<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,14 +68,22 @@ class NamespacedDefaultedWrapper<T extends IForgeRegistryEntry<T>> extends Defau
}
@Override
public <V extends T> V register(RegistryKey<T> key, V value)
public <V extends T> V register(RegistryKey<T> key, V value, Lifecycle lifecycle)
{
return register(-1, key, value);
return register(-1, key, value, lifecycle);
}
@Override
public <V extends T> V func_241874_a(OptionalInt id, RegistryKey<T> key, V value, Lifecycle lifecycle) {
int wanted = -1;
if (id.isPresent() && getByValue(id.getAsInt()) != null)
wanted = id.getAsInt();
return register(wanted, key, value, lifecycle);
}
// Reading Functions
@Override
public Optional<T> getValue(@Nullable ResourceLocation name)
public Optional<T> func_241873_b(@Nullable ResourceLocation name)
{
return Optional.ofNullable( this.delegate.getRaw(name)); //get without default
}
@@ -112,12 +121,6 @@ class NamespacedDefaultedWrapper<T extends IForgeRegistryEntry<T>> extends Defau
return this.delegate.getValue(id);
}
@Override
public boolean func_230518_b_(int id)
{
return this.getByValue(id) != null;
}
@Override
public Iterator<T> iterator()
{
@@ -22,6 +22,7 @@ package net.minecraftforge.registries;
import java.util.Collection;
import java.util.Iterator;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Random;
import java.util.Set;
import javax.annotation.Nullable;
@@ -43,12 +44,12 @@ class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry
public NamespacedWrapper(ForgeRegistry<T> owner)
{
super(RegistryKey.func_240904_a_(owner.getRegistryName()), Lifecycle.experimental());
super(RegistryKey.func_240904_a_(owner.getRegistryName()), Lifecycle.experimental());
this.delegate = owner;
}
@Override
public <V extends T> V register(int id, RegistryKey<T> key, V value)
public <V extends T> V register(int id, RegistryKey<T> key, V value, Lifecycle lifecycle)
{
if (locked)
throw new IllegalStateException("Can not register to a locked registry. Modder should use Forge Register methods.");
@@ -65,9 +66,17 @@ class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry
}
@Override
public <R extends T> R register(RegistryKey<T> key, R value)
public <R extends T> R register(RegistryKey<T> key, R value, Lifecycle lifecycle)
{
return register(-1, key, value);
return register(-1, key, value, lifecycle);
}
@Override
public <V extends T> V func_241874_a(OptionalInt id, RegistryKey<T> key, V value, Lifecycle lifecycle) {
int wanted = -1;
if (id.isPresent() && getByValue(id.getAsInt()) != null)
wanted = id.getAsInt();
return register(wanted, key, value, lifecycle);
}
// Reading Functions
@@ -79,7 +88,7 @@ class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry
}
@Override
public Optional<T> getValue(@Nullable ResourceLocation name)
public Optional<T> func_241873_b(@Nullable ResourceLocation name)
{
return Optional.ofNullable( this.delegate.getRaw(name)); //get without default
}
@@ -32,7 +32,9 @@ 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.minecraftforge.registries.ForgeRegistry.Snapshot;
import org.apache.commons.lang3.tuple.Pair;
@@ -75,6 +77,11 @@ public class RegistryManager
return (ForgeRegistry<V>)this.registries.get(key);
}
public <V extends IForgeRegistryEntry<V>> ForgeRegistry<V> getRegistry(RegistryKey<? extends Registry<V>> key)
{
return getRegistry(key.func_240901_a_());
}
public <V extends IForgeRegistryEntry<V>> IForgeRegistry<V> getRegistry(Class<? super V> cls)
{
return getRegistry(superTypes.get(cls));