@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)); } } }
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); } }
@Override public List<String> getTabCompletion(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos) { return CommandBase.getListOfStringsMatchingLastWord(args, Item.REGISTRY.getKeys()); } };
public static List<ResourceLocation> getSoundList() { // blacklisted: minecraft:record List<ResourceLocation> allSounds = new ArrayList<>(); for (ResourceLocation r : SoundEvent.REGISTRY.getKeys()) { if (!r.toString().contains("minecraft:record")) allSounds.add(r); } allSounds.sort(Comparator.comparing(ResourceLocation::toString)); return allSounds; }
/** * 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 boolean dumpModObjects(@Nonnull File file) { StringBuilder sb = new StringBuilder(); for (Object key : Block.REGISTRY.getKeys()) { if (key != null) { sb.append(key.toString()); sb.append("\n"); } } for (Object key : Item.REGISTRY.getKeys()) { if (key != null) { sb.append(key.toString()); sb.append("\n"); } } try { Files.write(sb, file, Charsets.UTF_8); return true; } catch (IOException e) { Log.warn("Error dumping ore dictionary entries: " + e.getMessage()); e.printStackTrace(); return false; } }
public static void debugStoneGeneration(Iterable<StoneInfoBasedGenerator> generators) { System.out.println("### OUTPUTTING BIOME CSV DATA ###"); System.out.print("sep=;\nBiome"); for(StoneInfoBasedGenerator gen : generators) System.out.print(";" + WordUtils.capitalize(gen.name)); System.out.print(";Biome Type"); System.out.println(); for(ResourceLocation r : Biome.REGISTRY.getKeys()) { Biome b = Biome.REGISTRY.getObject(r); System.out.print(b.getBiomeName()); for(StoneInfoBasedGenerator gen : generators) { if(gen.canGenerateInBiome(b)) System.out.print(";yes"); else System.out.print(";no"); } System.out.print(";" + (b.isMutation() ? "mutation" : "normal")); System.out.println(); } System.out.println("### DONE ###"); }
@Override public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) { if (args.length == 1) { return getListOfStringsMatchingLastWord(args, server.getOnlinePlayerNames()); } else if (args.length == 2) { return getListOfStringsMatchingLastWord(args, Item.REGISTRY.getKeys()); } else if (args.length == 4) { return getListOfStringsMatchingLastWord(args, API.instance().getStorageDiskManager(sender.getEntityWorld()).getAll().keySet().stream().map(UUID::toString).collect(Collectors.toList())); } return Collections.emptyList(); } }
public void saveToFile(final File file) throws Exception { file.getParentFile().mkdirs(); file.createNewFile(); FileOutputStream fileOutputStream = new FileOutputStream(file); NBTTagCompound tagCompound = new NBTTagCompound(); saveListToNBT("Items", tagCompound, itemEntires.values()); saveListToNBT("Ores", tagCompound, oreEntries.values()); tagCompound.setString("Version", Reference.VERSION); tagCompound.setInteger("RecipeCount", CraftingManager.REGISTRY.getKeys().size()); tagCompound.setInteger("BasicEntriesCount", basicEntries); tagCompound.setInteger("ModBlacklistCount", modBlacklist.size()); CompressedStreamTools.writeCompressed(tagCompound, fileOutputStream); fileOutputStream.close(); }
public boolean needsCalculation(final File file) throws IOException, ClassNotFoundException { String reason = ""; if (file.exists()) { FileInputStream fileInputStream = new FileInputStream(file); NBTTagCompound tagCompound = CompressedStreamTools.readCompressed(fileInputStream); String version = tagCompound.getString("Version"); int recipeCount = tagCompound.getInteger("RecipeCount"); int basicEntries = tagCompound.getInteger("BasicEntriesCount"); fileInputStream.close(); //checks if the saved versions differ from the current version of the mod //and alos checks if the recipe list count has changed if (version.equalsIgnoreCase(Reference.VERSION)) { if (recipeCount == CraftingManager.REGISTRY.getKeys().size()) { if (basicEntries != this.basicEntries) { reason = "Basic Entries size changed"; } else { return false; } } else { reason = "Recipe List Changed"; } } } else { reason = "Matter Registry File missing"; } //if the registry file is missing then calculate MOLog.warn(reason + "! Recalculation required!"); return true; }
for(String key : PsiAPI.spellPieceRegistry.getKeys()) { Class<? extends SpellPiece> clazz = PsiAPI.spellPieceRegistry.getObject(key); PieceGroup group = PsiAPI.groupsForPiece.get(clazz);
@Override public void update() { if (isPowered() == false && this.onlyRunIfPowered()) { //i need signal to run. i dont have signal. set timer zero so pulse triggers right away timer = 0; } if (this.isRunning() == false) { return; } if (this.updateTimerIsZero()) { if (soundIndex >= 0 && soundIndex < SoundEvent.REGISTRY.getKeys().size()) { List<ResourceLocation> allSounds = getSoundList(); ResourceLocation sound = allSounds.get(soundIndex); if (sound != null && SoundEvent.REGISTRY.getObject(sound) != null) { playSound(sound); } } } }
Optional<ResourceLocation> recipeOption = CraftingManager.REGISTRY.getKeys().stream() .filter(resource -> { if (CraftingManager.REGISTRY.getObject(resource).matches(temporaryCraftingGrid, world)) {
int biomeCount = Biome.REGISTRY.getKeys().size();
public <T> void addPages(String type, RegistryNamespaced<ResourceLocation, T> registry, StackProvider<T> provider) { Set<ResourceLocation> ids = registry.getKeys();
@Override public int getBiomeID(Chunk chunk) { int biomesCount = Biome.REGISTRY.getKeys().size(); int[] chunkBiomes; try {
@Override public int getBiomeID(Chunk chunk) { int biomesCount = Biome.REGISTRY.getKeys().size(); int[] chunkBiomes; try {
enchantment = Enchantment.getEnchantmentByID(CommandBase.parseInt(loc, 0, Enchantment.REGISTRY.getKeys().size() - 1)); } catch (NumberInvalidException e) { enchantment = Enchantment.getEnchantmentByLocation(loc);
@Override public void postInit(FMLPostInitializationEvent event) { List<ResourceLocation> recipeList = new ArrayList(CraftingManager.REGISTRY.getKeys()); for(ResourceLocation res : recipeList) { IRecipe recipe = CraftingManager.REGISTRY.getObject(res);
@Override public void postInit(FMLPostInitializationEvent event) { List<ResourceLocation> recipeList = new ArrayList(CraftingManager.REGISTRY.getKeys()); for(ResourceLocation res : recipeList) { IRecipe recipe = CraftingManager.REGISTRY.getObject(res);