net.minecraft.util.registry.SimpleRegistry Java Examples
The following examples show how to use
net.minecraft.util.registry.SimpleRegistry.
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: SandboxHooks.java From Sandbox with GNU Lesser General Public License v3.0 | 6 votes |
public static void setupGlobal() { Set<String> supportedMods = Sets.newHashSet("minecraft", "sandbox", "sandboxapi", "fabricloader"); Sandbox.unsupportedModsLoaded = FabricLoader.getInstance().getAllMods().stream() .map(ModContainer::getMetadata) .map(ModMetadata::getId) .anyMatch(((Predicate<String>) supportedMods::contains).negate()); Policy.setPolicy(new AddonSecurityPolicy()); Registry.REGISTRIES.add(new Identifier("sandbox", "container"), SandboxRegistries.CONTAINER_FACTORIES); ((SandboxInternal.Registry) Registry.BLOCK).set(new BasicRegistry<>(Registry.BLOCK, Block.class, WrappingUtil::convert, WrappingUtil::convert)); ((SandboxInternal.Registry) Registry.ITEM).set(new BasicRegistry<>(Registry.ITEM, Item.class, WrappingUtil::convert, WrappingUtil::convert)); ((SandboxInternal.Registry) Registry.ENCHANTMENT).set(new BasicRegistry<>((SimpleRegistry<net.minecraft.enchantment.Enchantment>) Registry.ENCHANTMENT, Enchantment.class, WrappingUtil::convert, b -> (Enchantment) b)); ((SandboxInternal.Registry) Registry.FLUID).set(new BasicRegistry<>(Registry.FLUID, Fluid.class, WrappingUtil::convert, WrappingUtil::convert)); ((SandboxInternal.Registry) Registry.ENTITY_TYPE).set(new BasicRegistry<>(Registry.ENTITY_TYPE, Entity.Type.class, WrappingUtil::convert, WrappingUtil::convert)); ((SandboxInternal.Registry) Registry.BLOCK_ENTITY).set(new BasicRegistry((SimpleRegistry) Registry.BLOCK_ENTITY, BlockEntity.Type.class, (Function<BlockEntity.Type, BlockEntityType>) WrappingUtil::convert, (Function<BlockEntityType, BlockEntity.Type>) WrappingUtil::convert, true)); // DONT TOUCH THIS FOR HEAVENS SAKE PLEASE GOD NO ((SandboxInternal.Registry) SandboxRegistries.CONTAINER_FACTORIES).set(new BasicRegistry<>(SandboxRegistries.CONTAINER_FACTORIES, ContainerFactory.class, a -> a, a -> a)); }
Example #2
Source File: AbstractProtocol.java From multiconnect with MIT License | 5 votes |
@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 |
@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 |
@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 |
@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: AbstractProtocol.java From multiconnect with MIT License | 4 votes |
@SuppressWarnings("unchecked") public static <T> void restore(Registry<?> registry, DefaultRegistry<?> defaultRegistry) { ((DefaultRegistry<T>) defaultRegistry).restore((SimpleRegistry<T>) registry); }
Example #7
Source File: BasicRegistry.java From Sandbox with GNU Lesser General Public License v3.0 | 4 votes |
public BasicRegistry(SimpleRegistry<B> vanilla, Class<A> type, Function<A, B> convertAB, Function<B, A> convertBA) { this.convertAB = convertAB; this.convertBA = convertBA; this.vanilla = vanilla; this.type = type; }
Example #8
Source File: ISimpleRegistry.java From multiconnect with MIT License | votes |
SimpleRegistry<T> copy();