public SoundEvent getSound() { if (sounds != null && sounds.length > 0) { if (SoundEvent.REGISTRY.containsKey(sounds[rand.nextInt(sounds.length)])) { return SoundEvent.REGISTRY.getObject(sounds[rand.nextInt(sounds.length)]); } } return null; }
@Override public void writePacketNBT(NBTTagCompound cmp) { cmp.setInteger(TAG_MANA, mana); cmp.setInteger(TAG_MANA_REQUIRED, manaRequired); cmp.setInteger(TAG_STAGE, stage.ordinal()); cmp.setInteger(TAG_STAGE_TICKS, stageTicks); cmp.setInteger(TAG_STAGE_3_END_TICKS, stage3EndTicks); NBTTagCompound itemCmp = new NBTTagCompound(); if(!itemToEnchant.isEmpty()) itemCmp = itemToEnchant.writeToNBT(itemCmp); cmp.setTag(TAG_ITEM, itemCmp); String enchStr = enchants.stream() .map(e -> Enchantment.REGISTRY.getNameForObject(e.enchantment) + "=" + e.enchantmentLevel) .collect(Collectors.joining(",")); cmp.setString(TAG_ENCHANTS, enchStr); }
public static void runConsumers() { List<ResourceLocation> recipeList = new ArrayList(CraftingManager.REGISTRY.getKeys()); for(ResourceLocation res : recipeList) { IRecipe recipe = CraftingManager.REGISTRY.getObject(res); for(Consumer<IRecipe> consumer : recipeConsumers) consumer.accept(recipe); } }
Item item = Item.REGISTRY.getObjectById( data[0] ); if( item == null ) Item baseItem = Item.REGISTRY.getObject( itemId );
private static void loadFromConfig(Configuration config, String key, ShedPattern defaultPattern) { String itemName = ""; int metadata = 0; int rate = -1; int lexiconSize = 40; if(defaultPattern != null) { itemName = Item.REGISTRY.getNameForObject(defaultPattern.getItemStack().getItem()).toString(); metadata = defaultPattern.getItemStack().getItemDamage(); rate = defaultPattern.rate; lexiconSize = defaultPattern.lexiconSize; } Property prop = config.get("Shedding", key + ".item", itemName); prop.setComment("Configuration of Shedding for "+key); itemName = prop.getString(); rate = config.get("Shedding", key + ".rate", rate).getInt(); metadata = config.get("Shedding", key + ".metadata", metadata).getInt(); lexiconSize = config.get("Shedding", key + ".lexiconDisplaySize", lexiconSize).getInt(); if(itemName != null && Item.REGISTRY.getObject(new ResourceLocation(itemName)) != null && rate != -1) patterns.add(new ShedPattern(EntityList.getClass(new ResourceLocation(key)), new ItemStack(Item.REGISTRY.getObject(new ResourceLocation(itemName)), 1, metadata), rate, lexiconSize)); }
@Nullable private static SoundEvent getSound(ItemStack stack) { if(isDOIT(stack)) return ModSounds.doit; else return SoundEvent.REGISTRY.getObject(new ResourceLocation(ItemNBTHelper.getString(stack, TAG_SOUND, ""))); }
private void discoverArrows() { Iterator<Item> iter = Item.REGISTRY.iterator(); ImmutableList.Builder<Item> builder = ImmutableList.builder(); if(arrow != null) { builder.add(arrow); } while(iter.hasNext()) { Item item = iter.next(); // vanilla style arrow if(item instanceof ItemArrow) { builder.add(item); } } DISCOVERED_ARROWS = builder.build(); } }
@EventHandler public void serverAboutToStart(FMLServerAboutToStartEvent event) { if (this.platform != null) { logger.warn("FMLServerStartingEvent occurred when FMLServerStoppingEvent hasn't"); WorldEdit.getInstance().getPlatformManager().unregister(platform); } this.platform = new ForgePlatform(this); WorldEdit.getInstance().getPlatformManager().register(platform); if (Loader.isModLoaded("sponge")) { this.provider = new ForgePermissionsProvider.SpongePermissionsProvider(); } else { this.provider = new ForgePermissionsProvider.VanillaPermissionsProvider(platform); } for (ResourceLocation name : Block.REGISTRY.getKeys()) { String nameStr = name.toString(); if (!BlockType.REGISTRY.keySet().contains(nameStr)) { BlockTypes.register(new BlockType(nameStr)); } } for (ResourceLocation name : Item.REGISTRY.getKeys()) { String nameStr = name.toString(); if (!ItemType.REGISTRY.keySet().contains(nameStr)) { ItemTypes.register(new ItemType(nameStr)); } } }
@Override public BooleanSupplier parse(JsonContext context, JsonObject json) { final String enchId = JsonUtils.getString(json, "id"); return () -> Enchantment.REGISTRY.containsKey(new ResourceLocation(enchId)); } }
public static boolean isItem(NBTTagCompound json) { if(json != null && json.hasKey("id") && json.hasKey("Count", 99) && json.hasKey("Damage", 99)) { if(json.hasKey("id", 8)) { return Item.REGISTRY.containsKey(new ResourceLocation(json.getString("id"))); } else { return Item.REGISTRY.getObjectById(json.getInteger("id")) != null; } } return false; }
public static int findEmpty( final RegistryNamespaced registry, final int minId, final int maxId ) { for( int x = minId; x < maxId; x++ ) { if( registry.getObjectById( x ) == null ) { return x; } } return -1; }
public static void initTC() { Item salisMundus = Item.REGISTRY.getObject(new ResourceLocation("thaumcraft", "salis_mundus")); Item bathSalts = Item.REGISTRY.getObject(new ResourceLocation("thaumcraft", "bath_salts")); Item amber = Item.REGISTRY.getObject(new ResourceLocation("thaumcraft", "amber")); warpWardBrew = BotaniaAPI.registerBrewRecipe(ModBrews.warpWard, new ItemStack(Items.NETHER_WART), new ItemStack(salisMundus), new ItemStack(bathSalts), new ItemStack(amber)); }
item = Item.REGISTRY.getObjectById(id); // Old format (numbers) jID = "" + id; } else item = Item.REGISTRY.getObject(new ResourceLocation(jID)); // New format (names)
public static void updateItemList() { itemNames.clear(); Iterator<Item> iterator = Item.REGISTRY.iterator(); NonNullList<ItemStack> curList = NonNullList.create(); while(iterator.hasNext()) { Item item = iterator.next(); if(item != null && item.getCreativeTab() != null) { curList.clear(); try { item.getSubItems(null, curList); for(ItemStack stack : curList) itemNames.add(CorporeaHelper.stripControlCodes(stack.getDisplayName().trim())); } catch (Exception e) {} } } }
@Override public List<String> getTabCompletion(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos) { return CommandBase.getListOfStringsMatchingLastWord(args, Item.REGISTRY.getKeys()); } };
/** * Register the usage multipliers config from the given string array. * @param config The config where each element is in the form 'biomename'. * @param blacklistNames The set of biome names to set. */ public void setBlacklist(String[] config, Set<ResourceLocation> blacklistNames) { blacklistNames.clear(); for (String line : config) { try { ResourceLocation biomeKey = new ResourceLocation(line); if (!Biome.REGISTRY.containsKey(biomeKey)) { EvilCraft.clog("Invalid line '" + line + "' found for " + "a Biome Extract blacklist config: " + line + " does not refer to an existing biome; skipping."); } else { blacklistNames.add(biomeKey); } } catch (NumberFormatException e) { EvilCraft.clog("Invalid line '" + line + "' found for " + "a Biome Extract blacklist config: " + line + " is not a number; skipping."); } } }
public static boolean isEmpty( final Item item ) { return item == Item.REGISTRY.getObjectById( 0 ); }
public static Item findItem(@Nonnull String mod, @Nonnull String itemName) { final ResourceLocation name = new ResourceLocation(mod, itemName); if (Item.REGISTRY.containsKey(name)) { return Item.REGISTRY.getObject(name); } return null; }
/** * Removes recipes that match the provided predicate. Outputs to the mod log for each recipe removed. * @param predicate The predicate to check */ public static void removeRecipe(Predicate<IRecipe> predicate) { // The collect call prevents a ConcurrentModification by moving all of the IRecipes into a separate collection. CraftingManager.REGISTRY.getKeys().stream() .filter(key -> { IRecipe recipe = CraftingManager.REGISTRY.getObject(key); return recipe != null && predicate.test(recipe); }) .collect(Collectors.toSet()) .forEach(RecipeUtility::removeRecipe); }
public static void initTC() { Potion warpWardPotion = Potion.REGISTRY.getObject(new ResourceLocation("thaumcraft:warpward")); if(warpWardPotion != null) warpWard = new BrewMod(LibBrewNames.WARP_WARD, 0xFBBDFF, 25000, new PotionEffect(warpWardPotion, 12000, 0)).setNotBloodPendantInfusable(); } }