Java Code Examples for net.minecraft.util.registry.RegistryKey#of()

The following examples show how to use net.minecraft.util.registry.RegistryKey#of() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Protocol_1_13_2.java    From multiconnect with MIT License 6 votes vote down vote up
private void mutateEntityTypeRegistry(ISimpleRegistry<EntityType<?>> registry) {
    registry.unregister(EntityType.CAT);
    int ocelotId = Registry.ENTITY_TYPE.getRawId(EntityType.OCELOT);
    registry.unregister(EntityType.OCELOT);
    RegistryKey<EntityType<?>> ocelotKey = RegistryKey.of(registry.getRegistryKey(), new Identifier("ocelot"));
    registry.register(EntityType.CAT, ocelotId, ocelotKey);
    registry.unregister(EntityType.FOX);
    registry.unregister(EntityType.PANDA);
    registry.unregister(EntityType.PILLAGER);
    registry.unregister(EntityType.RAVAGER);
    registry.unregister(EntityType.TRADER_LLAMA);
    registry.unregister(EntityType.WANDERING_TRADER);
    registry.unregister(EntityType.TRIDENT);
    insertAfter(registry, EntityType.FISHING_BOBBER, EntityType.TRIDENT, "trident");
    ENTITY_REGISTRY_1_13 = registry.copy();
}
 
Example 2
Source File: AbstractProtocol.java    From multiconnect with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T> void insertAfter(ISimpleRegistry<T> registry, T element, T toInsert, String id, boolean inPlace) {
    RegistryKey<T> key = RegistryKey.of(registry.getRegistryKey(), new Identifier(id));
    int numericalId = ((SimpleRegistry<T>) registry).getRawId(element) + 1;
    if (inPlace) {
        registry.registerInPlace(toInsert, numericalId, key);
    } else {
        registry.register(toInsert, numericalId, key);
    }
}
 
Example 3
Source File: AbstractProtocol.java    From multiconnect with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
protected <T> void postMutateRegistry(Registry<T> registry) {
    if (!(registry instanceof SimpleRegistry)) return;
    if (registry instanceof DefaultedRegistry) return;
    ISimpleRegistry<T> iregistry = (ISimpleRegistry<T>) registry;
    DefaultRegistry<T> defaultRegistry = (DefaultRegistry<T>) DefaultRegistry.DEFAULT_REGISTRIES.get(registry);
    if (defaultRegistry == null) return;
    for (Map.Entry<Identifier, T> entry : defaultRegistry.defaultEntriesById.entrySet()) {
        if (registry.getId(entry.getValue()) == null) {
            RegistryKey<T> key = RegistryKey.of(iregistry.getRegistryKey(), entry.getKey());
            iregistry.register(entry.getValue(), iregistry.getNextId(), key, false);
        }
    }
}
 
Example 4
Source File: AbstractProtocol.java    From multiconnect with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T> void rename(ISimpleRegistry<T> registry, T value, String newName) {
    int id = ((SimpleRegistry<T>) registry).getRawId(value);
    registry.purge(value);
    RegistryKey<T> key = RegistryKey.of(registry.getRegistryKey(), new Identifier(newName));
    registry.registerInPlace(value, id, key);
}
 
Example 5
Source File: Protocol_1_13_2.java    From multiconnect with MIT License 5 votes vote down vote up
private void mutateRecipeSerializerRegistry(ISimpleRegistry<RecipeSerializer<?>> registry) {
    registry.unregister(RecipeSerializer.SUSPICIOUS_STEW);
    registry.unregister(RecipeSerializer.BLASTING);
    registry.unregister(RecipeSerializer.SMOKING);
    registry.unregister(RecipeSerializer.CAMPFIRE_COOKING);
    registry.unregister(RecipeSerializer.STONECUTTING);
    RegistryKey<RecipeSerializer<?>> bannerAddPatternKey = RegistryKey.of(registry.getRegistryKey(), new Identifier("crafting_special_banneraddpattern"));
    registry.register(AddBannerPatternRecipe.SERIALIZER, registry.getNextId(), bannerAddPatternKey);
}
 
Example 6
Source File: Entities_1_12_2.java    From multiconnect with MIT License 4 votes vote down vote up
private static void register(ISimpleRegistry<EntityType<?>> registry, EntityType<?> entity, int id, String name, String oldName) {
    RegistryKey<EntityType<?>> key = RegistryKey.of(registry.getRegistryKey(), new Identifier(name));
    registry.register(entity, id, key, false);
}
 
Example 7
Source File: Particles_1_12_2.java    From multiconnect with MIT License 4 votes vote down vote up
private static void register(ISimpleRegistry<ParticleType<?>> registry, ParticleType<?> particle, int id, String name) {
    RegistryKey<ParticleType<?>> key = RegistryKey.of(registry.getRegistryKey(), new Identifier(name));
    registry.register(particle, id, key, false);
}
 
Example 8
Source File: Blocks_1_12_2.java    From multiconnect with MIT License 4 votes vote down vote up
private static void register(ISimpleRegistry<Block> registry, Block block, int id, String name) {
    RegistryKey<Block> key = RegistryKey.of(registry.getRegistryKey(), new Identifier(name));
    registry.registerInPlace(block, id, key, false);
}
 
Example 9
Source File: Enchantments_1_12_2.java    From multiconnect with MIT License 4 votes vote down vote up
private static void register(ISimpleRegistry<Enchantment> registry, Enchantment enchantment, int id, String name) {
    RegistryKey<Enchantment> key = RegistryKey.of(registry.getRegistryKey(), new Identifier(name));
    registry.register(enchantment, id, key, false);
}
 
Example 10
Source File: Items_1_12_2.java    From multiconnect with MIT License 4 votes vote down vote up
private static void register(ISimpleRegistry<Item> registry, Item item, int id, String name) {
    RegistryKey<Item> key = RegistryKey.of(registry.getRegistryKey(), new Identifier(name));
    registry.registerInPlace(item, id, key, false);
}
 
Example 11
Source File: Items_1_12_2.java    From multiconnect with MIT License 4 votes vote down vote up
private static void registerBlockItem(ISimpleRegistry<Item> registry, Block block) {
    RegistryKey<Item> key = RegistryKey.of(registry.getRegistryKey(), Registry.BLOCK.getId(block));
    registry.registerInPlace(Item.BLOCK_ITEMS.getOrDefault(block, AIR), Registry.BLOCK.getRawId(block), key, false);
}
 
Example 12
Source File: GalacticraftDimensions.java    From Galacticraft-Rewoven with MIT License 3 votes vote down vote up
public static void register() {
    Registry.register(Registry.CHUNK_GENERATOR, new Identifier(Constants.MOD_ID, "moon"), MoonChunkGenerator.CODEC);

    MOON = RegistryKey.of(Registry.DIMENSION, new Identifier(Constants.MOD_ID, "moon"));

    FabricDimensions.registerDefaultPlacer(MOON, GalacticraftDimensions::placeEntity);
}