public static void init() { log.info("Loading Research Handler..."); RegistryBuilder<Research> builder = new RegistryBuilder<>(); builder.setName(loc); builder.setType(Research.class); builder.setIDRange(MIN_ID, MAX_ID); iResearchRegistry = (FMLControlledNamespacedRegistry<Research>) builder.create(); // iResearchRegistry = PersistentRegistryManager.createRegistry(loc, // Research.class, new ResourceLocation("invalid"), MIN_ID, MAX_ID, // true, ResearchCallbacks.INSTANCE, ResearchCallbacks.INSTANCE, // ResearchCallbacks.INSTANCE); }
private void setupItemList() { String domain = domainListModel.get(domainListSelection) + ":"; FMLControlledNamespacedRegistry<Item> r1 = GameData.getItemRegistry(); cachedItems.clear(); for(Object keyobj : r1.getKeys()) { String name = keyobj.toString(); int index = name.indexOf(':'); if((index < 0 && domain.equals("minecraft:")) || name.startsWith(domain)) { String fillName = index < 0 ? name : name.substring(index + 1); Item item = r1.getObject(name); if(item.getHasSubtypes()) { List<ItemStack> itemStacks = new ArrayList<ItemStack>(); item.getSubItems(item, item.getCreativeTab(), itemStacks); int id = 0; for(ItemStack stack : itemStacks) { String indexName = String.format("%s:%03d", fillName, id++); if(checkMatches(indexName, currentFilterPattern)) { itemListModel.add(indexName); cachedItems.put(indexName, stack); } } } else { if(checkMatches(fillName, currentFilterPattern)) { itemListModel.add(fillName); cachedItems.put(fillName, new ItemStack(r1.getObject(name))); } } } } }
private static SoundEvent registerSound(ResourceLocation rl){ SoundEvent ret = new SoundEvent(rl).setRegistryName(rl); ((FMLControlledNamespacedRegistry) SoundEvent.REGISTRY).register(ret); return ret; }
/** * @param registry - The registry to get data from. * @param item - The Item to create a stack for */ public ItemFMLRegistryWrapper(FMLControlledNamespacedRegistry<T> registry, Item item) { this.registry = registry; this.item = item; }
/** * @return the used registry. */ public FMLControlledNamespacedRegistry<T> getRegistry() { return registry; }
private static SoundEvent registerSound(ResourceLocation rl){ SoundEvent ret = new SoundEvent(rl).setRegistryName(rl); ((FMLControlledNamespacedRegistry)SoundEvent.REGISTRY).register(ret); return ret; }