net.minecraft.util.registry.RegistryKey Java Examples

The following examples show how to use net.minecraft.util.registry.RegistryKey. 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: MixinSimpleRegistry.java    From multiconnect with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public SimpleRegistry<T> copy() {
    SimpleRegistry<T> newRegistry = new SimpleRegistry<>(getRegistryKey(), ((RegistryAccessor<T>) this).getLifecycle());
    for (Map.Entry<RegistryKey<T>, T> entry : entriesByKey.entrySet()) {
        newRegistry.set(indexedEntries.getId(entry.getValue()), entry.getKey(), entry.getValue());
    }
    return newRegistry;
}
 
Example #6
Source File: MixinSimpleRegistry.java    From multiconnect with MIT License 5 votes vote down vote up
@Override
public void registerInPlace(T t, int id, RegistryKey<T> key, boolean sideEffects) {
    if (id == getNextId())
        setNextId(id + 1);
    set(id, key, t);

    if (sideEffects)
        registerListeners.forEach(listener -> listener.onUpdate(t, true));
}
 
Example #7
Source File: MixinSimpleRegistry.java    From multiconnect with MIT License 5 votes vote down vote up
@Override
public void register(T t, int id, RegistryKey<T> key, boolean sideEffects) {
    for (int remapId = getNextId(); remapId > id; remapId--) {
        T toRemap = indexedEntries.get(remapId - 1);
        //noinspection unchecked
        ((IInt2ObjectBiMap<T>) indexedEntries).multiconnect_remove(toRemap);
        indexedEntries.put(toRemap, remapId);
    }
    setNextId(getNextId() + 1);
    set(id, key, t);

    if (sideEffects)
        registerListeners.forEach(listener -> listener.onUpdate(t, false));
}
 
Example #8
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 #9
Source File: WorldMixin_RealTime.java    From Galaxy with GNU Affero General Public License v3.0 4 votes vote down vote up
protected WorldMixin_RealTime(MutableWorldProperties mutableWorldProperties, RegistryKey<World> registryKey, RegistryKey<DimensionType> registryKey2, DimensionType dimensionType, Supplier<Profiler> profiler, boolean bl, boolean bl2, long l) {
    super(mutableWorldProperties, registryKey, registryKey2, dimensionType, profiler, bl, bl2, l);
}
 
Example #10
Source File: MixinSimpleRegistry.java    From multiconnect with MIT License 4 votes vote down vote up
@Accessor
@Override
public abstract BiMap<RegistryKey, T> getEntriesByKey();
 
Example #11
Source File: MixinSimpleRegistry.java    From multiconnect with MIT License 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public RegistryKey<Registry<T>> getRegistryKey() {
    return ((RegistryAccessor<T>) this).multiconnect_getRegistryKey();
}
 
Example #12
Source File: RegistryAccessor.java    From multiconnect with MIT License 4 votes vote down vote up
@Accessor("registryKey")
RegistryKey<Registry<T>> multiconnect_getRegistryKey();
 
Example #13
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 #14
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 #15
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 #16
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 #17
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 #18
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 #19
Source File: Protocol_1_11.java    From multiconnect with MIT License 4 votes vote down vote up
private void mutateCustomStatRegistry(ISimpleRegistry<Identifier> registry) {
    registry.register(JUNK_FISHED, registry.getNextId(), RegistryKey.of(registry.getRegistryKey(), JUNK_FISHED));
    registry.register(TREASURE_FISHED, registry.getNextId(), RegistryKey.of(registry.getRegistryKey(), TREASURE_FISHED));
    Stats.CUSTOM.getOrCreateStat(JUNK_FISHED, StatFormatter.DEFAULT);
    Stats.CUSTOM.getOrCreateStat(TREASURE_FISHED, StatFormatter.DEFAULT);
}
 
Example #20
Source File: ISimpleRegistry.java    From multiconnect with MIT License 4 votes vote down vote up
default void registerInPlace(T t, int id, RegistryKey<T> key) {
    registerInPlace(t, id, key, true);
}
 
Example #21
Source File: ISimpleRegistry.java    From multiconnect with MIT License 4 votes vote down vote up
default void register(T t, int id, RegistryKey<T> key) {
    register(t, id, key, true);
}
 
Example #22
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);
}
 
Example #23
Source File: ISimpleRegistry.java    From multiconnect with MIT License votes vote down vote up
void registerInPlace(T t, int id, RegistryKey<T> key, boolean sideEffects); 
Example #24
Source File: MixinSimpleRegistry.java    From multiconnect with MIT License votes vote down vote up
@Shadow public abstract <V extends T> V set(int rawId, RegistryKey<T> id, V value); 
Example #25
Source File: ISimpleRegistry.java    From multiconnect with MIT License votes vote down vote up
void register(T t, int id, RegistryKey<T> key, boolean sideEffects); 
Example #26
Source File: ISimpleRegistry.java    From multiconnect with MIT License votes vote down vote up
BiMap<RegistryKey, T> getEntriesByKey(); 
Example #27
Source File: ISimpleRegistry.java    From multiconnect with MIT License votes vote down vote up
RegistryKey<Registry<T>> getRegistryKey();