net.minecraftforge.fml.common.registry.ForgeRegistries Java Examples

The following examples show how to use net.minecraftforge.fml.common.registry.ForgeRegistries. 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: CraftShapedRecipe.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public void addToCraftingManager() {
    String[] shape = this.getShape();
    Map<Character, ItemStack> ingred = this.getIngredientMap();
    int width = shape[0].length();
    NonNullList<Ingredient> data = NonNullList.withSize(shape.length * width, Ingredient.EMPTY);

    for (int i = 0; i < shape.length; i++) {
        String row = shape[i];
        for (int j = 0; j < row.length(); j++) {
            data.set(i * width + j, Ingredient.fromStacks(new net.minecraft.item.ItemStack[]{CraftItemStack.asNMSCopy(ingred.get(row.charAt(j)))}));
        }
    }
    // TODO: Check if it's correct way to register recipes
    ForgeRegistries.RECIPES.register(new ShapedRecipes("", width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult())));
    // CraftingManager.register(CraftNamespacedKey.toMinecraft(this.getKey()), new ShapedRecipes("", width, shape.length, data, CraftItemStack.asNMSCopy(this.getResult())));
}
 
Example #2
Source File: ModHandler.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void addShapedEnergyTransferRecipe(String regName, ItemStack result, Predicate<ItemStack> chargePredicate, boolean transferMaxCharge, Object... recipe) {
    boolean skip = false;
    if (result.isEmpty()) {
        GTLog.logger.error("Result cannot be an empty ItemStack. Recipe: {}", regName);
        GTLog.logger.error("Stacktrace:", new IllegalArgumentException());
        skip = true;
    }
    skip |= validateRecipe(regName, recipe);
    if (skip) {
        RecipeMap.setFoundInvalidRecipe(true);
        return;
    }

    IRecipe shapedOreRecipe = new ShapedOreEnergyTransferRecipe(null, result.copy(), chargePredicate, transferMaxCharge, finalizeShapedRecipeInput(recipe))
        .setMirrored(false) //make all recipes not mirrored by default
        .setRegistryName(regName);
    ForgeRegistries.RECIPES.register(shapedOreRecipe);
}
 
Example #3
Source File: TFC.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
private void applyFoodValues(FoodReader reader)
{
	for(FoodJSON f : reader.foodList)
	{
		ResourceLocation rl = new ResourceLocation(f.itemName);
		Item i = ForgeRegistries.ITEMS.getValue(rl);
		if(i == null)
		{
			log.warn("FoodRegistry -> Item not found when searching ItemRegistry for object ->" + f.itemName);
			continue;
		}
		if(!(i instanceof IFood))
		{
			log.warn("Item ->" + f.itemName + " is not of type IFood");
			continue;
		}
		//IFood food = (IFood)i;
		//food.setExpirationTimer(f.decayTime);
		//food.setFoodGroup(f.foodGroup);

		FoodRegistry.getInstance().registerFood(f);
	}
}
 
Example #4
Source File: ModHandler.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static int removeRecipes(Predicate<IRecipe> predicate) {
    int recipesRemoved = 0;

    IForgeRegistry<IRecipe> registry = ForgeRegistries.RECIPES;
    List<IRecipe> toRemove = new ArrayList<>();

    for (IRecipe recipe : registry) {
        if (predicate.test(recipe)) {
            toRemove.add(recipe);
            recipesRemoved++;
        }
    }

    toRemove.forEach(recipe -> registry.register(new DummyRecipe().setRegistryName(recipe.getRegistryName())));

    return recipesRemoved;
}
 
Example #5
Source File: OreDictUtil.java    From AgriCraft with MIT License 6 votes vote down vote up
@Nonnull
private static Optional<ItemStack> makeItemStackNormal(@Nonnull String prefix, @Nonnull String suffix, int meta, int amount, String tags) {
    // Step 0. Fetch the item.
    final Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(prefix, suffix));

    // Step 1. Check that item is not null.
    if (item == null) {
        AgriCore.getLogger("agricraft").error("Unable to resolve item: {0}:{1}.", prefix, suffix);
        return Optional.empty();
    }

    // Step 2. Create the itemstack.
    final ItemStack stack = new ItemStack(item, amount, meta);

    // Step 3. Add NBT data.
    return addNbtData(stack, tags);
}
 
Example #6
Source File: MissingMappingEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public static void onMissingMappingEventBlocks(RegistryEvent.MissingMappings<Block> event)
{
    List<Mapping<Block>> list = event.getMappings();
    Map<String, String> renameMap = TileEntityID.getMap();

    for (Mapping<Block> mapping : list)
    {
        ResourceLocation oldLoc = mapping.key;
        String newName = renameMap.get(oldLoc.toString());

        if (newName != null)
        {
            Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(newName));

            if (block != null && block != Blocks.AIR)
            {
                mapping.remap(block);
                EnderUtilities.logger.info("Re-mapped block '{}' => '{}'", oldLoc, newName);
            }
        }
    }
}
 
Example #7
Source File: MissingMappingEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public static void onMissingMappingEventItems(RegistryEvent.MissingMappings<Item> event)
{
    List<Mapping<Item>> list = event.getMappings();
    Map<String, String> renameMap = TileEntityID.getMap();

    for (Mapping<Item> mapping : list)
    {
        ResourceLocation oldLoc = mapping.key;
        String newName = renameMap.get(oldLoc.toString());

        if (newName != null)
        {
            Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(newName));

            if (item != null && item != Items.AIR)
            {
                mapping.remap(item);
                EnderUtilities.logger.info("Re-mapped item '{}' => '{}'", oldLoc, newName);
            }
        }
    }
}
 
Example #8
Source File: TargetData.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean isTargetBlockUnchanged()
{
    MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
    if (server == null)
    {
        return false;
    }

    World world = server.getWorld(this.dimension);
    if (world == null)
    {
        return false;
    }

    IBlockState iBlockState = world.getBlockState(this.pos);
    Block block = iBlockState.getBlock();
    ResourceLocation rl = ForgeRegistries.BLOCKS.getKey(block);
    int meta = block.getMetaFromState(iBlockState);

    // The target block unique name and metadata matches what we have stored
    return this.blockMeta == meta && rl != null && this.blockName.equals(rl.toString());
}
 
Example #9
Source File: BlackLists.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void registerTeleportBlacklist(String[] blacklist)
{
    TELEPORT_BLACKLIST_CLASSES.clear();

    for (String name : blacklist)
    {
        EntityEntry entry = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(name));

        if (entry != null && entry.getEntityClass() != null)
        {
            TELEPORT_BLACKLIST_CLASSES.add(entry.getEntityClass());
        }
        else
        {
            EnderUtilities.logger.warn("Unknown Entity type '{}' on the teleport blacklist", name);
        }
    }
}
 
Example #10
Source File: GTTileDisassembler.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void init() {
	if (GTConfig.general.enableDisassembler) {
		for (IRecipe recipe : ForgeRegistries.RECIPES) {
			ItemStack input = recipe.getRecipeOutput().copy();
			List<ItemStack> outputList = new ArrayList<>();
			for (int i = 0; i < recipe.getIngredients().size(); ++i) {
				List<ItemStack> tempList = new ArrayList<>();
				Collections.addAll(tempList, recipe.getIngredients().get(i).getMatchingStacks());
				if (!tempList.isEmpty()) {
					ItemStack tempStack = isHighValueMaterial(tempList.get(0).copy()) ? Ic2Items.scrapMetal.copy()
							: tempList.get(0).copy();
					if (canItemBeReturned(tempStack)) {
						outputList.add(tempStack);
					}
				}
			}
			if (canInputBeUsed(input) && !outputList.isEmpty()) {
				ItemStack[] arr = outputList.toArray(new ItemStack[0]);
				addRecipe(new IRecipeInput[] { new RecipeInputItemStack(input) }, totalEu(5000), arr);
			}
		}
	}
}
 
Example #11
Source File: GTContainerAutocrafter.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void checkForMatchingRecipes() {
	for (IRecipe recipe : ForgeRegistries.RECIPES) {
		ItemStack craftingOutput = recipe.getRecipeOutput().copy();
		// iterates the tiles ghost slots to the fake crafting inventory for matching
		for (int i = 18; i < 27; ++i) {
			this.fakeMatrix.setInventorySlotContents(i - 18, this.block.inventory.get(i).copy());
		}
		// if recipe matches set the output ghost slot to the recipe output
		if (recipe.matches(fakeMatrix, this.block.getWorld())) {
			this.block.currentRecipe.clear();
			List<ItemStack> tempList = new ArrayList<>();
			// condense stacks and remove empty stacks in raw resource demands
			for (int j = 0; j < fakeMatrix.getSizeInventory(); ++j) {
				tempList.add((fakeMatrix.getStackInSlot(j).copy()));
			}
			this.block.setStackInSlot(27, craftingOutput);
			GTHelperStack.mergeItems(this.block.currentRecipe, tempList);
			return;
			// else then set the output slot to air
		} else {
			this.block.setStackInSlot(27, ItemStack.EMPTY);
			this.block.currentRecipe.clear();
		}
	}
}
 
Example #12
Source File: SizeWeightRegistry.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public SizeWeightProp getProperty(ItemStack is)
{
	int meta = is.getItem().getHasSubtypes() ? is.getItemDamage() : -1;
	String key = ForgeRegistries.ITEMS.getKey(is.getItem()).toString();
	SizeWeightProp prop = propertyMap.get(key + " " + meta);
	if(prop == null && meta >= 0 && is.getItem().getHasSubtypes())
	{
		prop = propertyMap.get(key + " -1");
	}

	if(prop != null)
		return prop;

	return new SizeWeightProp(EnumSize.SMALL, EnumWeight.VERYLIGHT);
}
 
Example #13
Source File: ItemBuildersWand.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void setSelectedFixedBlockType(NBTTagCompound tag, EntityPlayer player, World world, BlockPos pos)
{
    IBlockState state = world.getBlockState(pos);
    tag.setString("BlockName", ForgeRegistries.BLOCKS.getKey(state.getBlock()).toString());
    tag.setByte("BlockMeta", (byte)state.getBlock().getMetaFromState(state));

    ItemStack stackTmp = state.getBlock().getPickBlock(state, EntityUtils.getRayTraceFromPlayer(world, player, false), world, pos, player);
    int itemMeta = stackTmp.isEmpty() == false ? stackTmp.getMetadata() : 0;

    tag.setShort("ItemMeta", (short)itemMeta);
}
 
Example #14
Source File: CommonProxy.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public void init(FMLInitializationEvent event)
{
	registerGuiHandler();

	MinecraftForge.EVENT_BUS.register(new PlayerTracker());
	Global.EVENT_BUS.register(new CreateDungeonHandler());

	registerEntities();

	ForgeRegistries.POTIONS.register(PotionTFC.THIRST_POTION);
	ForgeRegistries.POTIONS.register(PotionTFC.ENCUMB_MEDIUM_POTION);
	ForgeRegistries.POTIONS.register(PotionTFC.ENCUMB_HEAVY_POTION);
	ForgeRegistries.POTIONS.register(PotionTFC.ENCUMB_MAX_POTION);
}
 
Example #15
Source File: TofuVillages.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static void register() {
       // Register the profession of Tofu Cook
       TofuVillages.ProfessionTofuCook = new VillagerRegistry.VillagerProfession("tofucraft:tofuCook",
               new ResourceLocation("tofucraft", "textures/mob/tofucook.png").toString(),//new ResourceLocation("tofucraft", "textures/mob/tofucook.png").toString(),
               "minecraft:textures/entity/zombie_villager/zombie_villager.png");
       TofuVillages.CareerTofuCook = new VillagerRegistry.VillagerCareer(TofuVillages.ProfessionTofuCook, "tofuCook")
               .addTrade(1, new TradeListTCookLv1())
               .addTrade(2, new TradeListTCookLv2())
               .addTrade(3, new TradeListTCookLv4());
       ForgeRegistries.VILLAGER_PROFESSIONS.register((TofuVillages.ProfessionTofuCook));
       VillagerRegistry.getById(0).getCareer(0).addTrade(2, new TradeListFarmerLv2());
   }
 
Example #16
Source File: CommonProxy.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
private void applySizeWeightValues(SizeWeightReader reader)
{
	for(SizeWeightJSON json : reader.list)
	{
		ResourceLocation rl = new ResourceLocation(json.itemName);
		Item i = ForgeRegistries.ITEMS.getValue(rl);
		if(i == null)
		{
			TFC.log.warn("SizeWeightRegistry -> Item not found when searching ItemRegistry for object ->" + json.itemName);
			continue;
		}

		SizeWeightRegistry.GetInstance().addProperty(json);
	}
}
 
Example #17
Source File: ItemDolly.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean tryPickUpBlock(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side)
{
    if (this.isCarryingBlock(stack) || this.shouldTryToPickUpBlock(world, pos, side, player) == false)
    {
        return false;
    }

    IBlockState state = world.getBlockState(pos);
    TileEntity te = world.getTileEntity(pos);
    String name = ForgeRegistries.BLOCKS.getKey(state.getBlock()).toString();
    int meta = state.getBlock().getMetaFromState(state);
    NBTTagCompound tagCarrying = NBTUtils.getCompoundTag(stack, "Carrying", true);
    tagCarrying.setString("Block", name);
    tagCarrying.setByte("Meta", (byte) meta);
    tagCarrying.setByte("PickupFacing", (byte) EntityUtils.getHorizontalLookingDirection(player).getIndex());

    ItemStack stackBlock = state.getBlock().getPickBlock(state, EntityUtils.getRayTraceFromPlayer(world, player, false), world, pos, player);

    if (stackBlock.isEmpty() == false)
    {
        tagCarrying.setString("DisplayName", stackBlock.getDisplayName());
    }

    if (te != null)
    {
        NBTTagCompound tag = new NBTTagCompound();
        te.writeToNBT(tag);
        tagCarrying.setTag("te", tag);
    }

    BlockUtils.setBlockToAirWithoutSpillingContents(world, pos);

    return true;
}
 
Example #18
Source File: NBTUtils.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Nullable
public static IBlockState readBlockStateFromTag(NBTTagCompound tag)
{
    Block block = ForgeRegistries.BLOCKS.getValue(new ResourceLocation(tag.getString("name")));

    if (block != null && block != Blocks.AIR)
    {
        return block.getStateFromMeta(tag.getByte("meta"));
    }

    return null;
}
 
Example #19
Source File: BlockUtils.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static Set<IBlockState> getMatchingBlockStatesForString(String blockStateString)
{
    Set<IBlockState> validStates = new HashSet<>();
    ResourceLocation air = new ResourceLocation("minecraft:air");
    int index = blockStateString.indexOf('[');
    String name = index > 0 ? blockStateString.substring(0, index) : blockStateString;
    ResourceLocation key = new ResourceLocation(name);
    Block block = ForgeRegistries.BLOCKS.getValue(key);

    if (block != null && (block != Blocks.AIR || key.equals(air)))
    {
        // First get all valid states for this block
        Collection<IBlockState> statesTmp = block.getBlockState().getValidStates();
        // Then get the list of properties and their values in the given name (if any)
        List<Pair<String, String>> props = getBlockStatePropertiesFromString(blockStateString);

        // ... and then filter the list of all valid states by the provided properties and their values
        if (props.isEmpty() == false)
        {
            for (Pair<String, String> pair : props)
            {
                statesTmp = getFilteredStates(statesTmp, pair.getLeft(), pair.getRight());
            }
        }

        validStates.addAll(statesTmp);
    }
    else
    {
        EnderUtilities.logger.warn("BlockUtils.getMatchingBlockStatesForString(): Invalid block state string '{}'", blockStateString);
    }

    return validStates;
}
 
Example #20
Source File: GuiSoundBlock.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void initSoundList()
{
    this.allSounds.clear();

    for (Map.Entry<ResourceLocation, SoundEvent> entry : ForgeRegistries.SOUND_EVENTS.getEntries())
    {
        int id = SoundEvent.REGISTRY.getIDForObject(entry.getValue());
        this.allSounds.add(Pair.of(id, entry.getKey().toString()));
    }
}
 
Example #21
Source File: BackpackRegistry.java    From WearableBackpacks with MIT License 5 votes vote down vote up
public static BackpackEntityEntry getEntityEntry(Class<? extends EntityLivingBase> entityClass) {
	if (EntityPlayer.class.isAssignableFrom(entityClass))
		return BackpackEntityEntry.PLAYER;
	if (_entityEntryLookupCache == null)
		_entityEntryLookupCache = ForgeRegistries.ENTITIES.getEntries().stream()
			.map(e -> new AbstractMap.SimpleEntry<>(e.getValue().getEntityClass(), getEntityEntry(e.getKey().toString())))
			.filter(e -> EntityLivingBase.class.isAssignableFrom(e.getKey()) && (e.getValue() != null))
			.collect(Collectors.toMap(e -> e.getKey().asSubclass(EntityLivingBase.class), Map.Entry::getValue));
	return _entityEntryLookupCache.get(entityClass);
}
 
Example #22
Source File: BackpackRegistry.java    From WearableBackpacks with MIT License 5 votes vote down vote up
public Class<? extends EntityLivingBase> getEntityClass() {
	return _entityClassLookupCache.computeIfAbsent(entityID, id ->
		Optional.ofNullable(ForgeRegistries.ENTITIES.getValue(new ResourceLocation(id)))
			.map(EntityEntry::getEntityClass)
			.filter(EntityLivingBase.class::isAssignableFrom)
			.map(c -> c.asSubclass(EntityLivingBase.class))
		).orElse(null);
}
 
Example #23
Source File: BlockInfo.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public BlockInfo(Block block, int blockMeta, int itemMeta)
{
    this.block = block;
    this.blockMeta = blockMeta;
    this.itemMeta = itemMeta;
    this.blockState = this.block.getStateFromMeta(this.blockMeta);
    this.blockStateActual = this.blockState;
    this.resource = ForgeRegistries.BLOCKS.getKey(block);
}
 
Example #24
Source File: CommandFindBiome.java    From Traverse-Legacy-1-12-2 with MIT License 5 votes vote down vote up
@Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos targetPos) {
	if(args.length==1) {
		List<String> strings = new ArrayList<>();
		for (Biome b : ForgeRegistries.BIOMES.getValues()) {
			String s = b.getRegistryName().toString();
			if (s.toLowerCase().contains(args[0].toLowerCase()))
				strings.add(s);
		}

		return strings;
	}
	return Collections.emptyList();
}
 
Example #25
Source File: PLBlocks.java    From Production-Line with MIT License 5 votes vote down vote up
public static void init() {
    oreIridium = new BlockPL(Material.ROCK, "ore_iridium", 10, 20, "pickaxe", 3);
    airBrakeCasing = new BlockOrientable(Material.IRON, "air_brake_casing");
    new BlockMisc();
    machine = new BlockMachine();

    // special registry TODO: Better registry system
    waterHyacinth = new BlockWaterHyacinth();
    waterHyacinth.setRegistryName(ProductionLine.loc("waterHyacinth"));
    ForgeRegistries.BLOCKS.register(waterHyacinth);
}
 
Example #26
Source File: NEIInitialization.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private static void loadModSubsets() {
    ProgressBar bar = ProgressManager.push("Mod Subsets", ForgeRegistries.ITEMS.getKeys().size());
    HashMap<String, ItemStackSet> modSubsets = new HashMap<>();

    for (Item item : ForgeRegistries.ITEMS) {
        try {
            ResourceLocation ident = item.getRegistryName();
            bar.step(ident.toString());
            if (ident == null) {
                LogHelper.error("Failed to find identifier for: " + item);
                continue;
            }
            String modId = ident.getResourceDomain();
            ItemInfo.itemOwners.put(item, modId);
            ItemStackSet itemset = modSubsets.computeIfAbsent(modId, k -> new ItemStackSet());
            itemset.with(item);
        } catch (Throwable t) {
            LogHelper.errorError("Failed to process mod subset item %s %s", t, String.valueOf(item), String.valueOf(item.getRegistryName()));
        }
    }
    ProgressManager.pop(bar);

    API.addSubset("Mod.Minecraft", modSubsets.remove("minecraft"));
    for (Entry<String, ItemStackSet> entry : modSubsets.entrySet()) {
        ModContainer mc = FMLCommonHandler.instance().findContainerFor(entry.getKey());
        if (mc == null) {
            LogHelper.error("Missing container for " + entry.getKey());
        } else {
            API.addSubset("Mod." + mc.getName(), entry.getValue());
        }
    }
}
 
Example #27
Source File: SignalsConfig.java    From Signals with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isBlacklisted(EntityMinecart cart, String[] config){
    if(config.length == 0) return false;
    EntityEntry entry = EntityRegistry.getEntry(cart.getClass());
    ResourceLocation cartID = ForgeRegistries.ENTITIES.getKey(entry);
    for(String blacklist : config) {
        if(cartID.equals(new ResourceLocation(blacklist))) {
            return true;
        }
    }
    return false;
}
 
Example #28
Source File: CraftShapelessRecipe.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public void addToCraftingManager() {
    List<ItemStack> ingred = this.getIngredientList();
    NonNullList<Ingredient> data = NonNullList.withSize(ingred.size(), Ingredient.EMPTY);
    for (int i = 0; i < ingred.size(); i++) {
        data.set(i, Ingredient.fromStacks(new net.minecraft.item.ItemStack[]{CraftItemStack.asNMSCopy(ingred.get(i))}));
    }
    // TODO: Check if it's correct way to register recipes
    ForgeRegistries.RECIPES.register(new ShapelessRecipes("", CraftItemStack.asNMSCopy(this.getResult()), data));
    // CraftingManager.a(CraftNamespacedKey.toMinecraft(this.getKey()), new ShapelessRecipes("", CraftItemStack.asNMSCopy(this.getResult()), data));
}
 
Example #29
Source File: IStructure.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Deprecated
static HashSet<IRecipe> getRecipesForItem(ItemStack stack) {
	HashSet<IRecipe> recipes = new HashSet<>();
	for (IRecipe recipe : ForgeRegistries.RECIPES.getValues()) {
		if (recipe == null) continue;
		if (ItemStack.areItemsEqualIgnoreDurability(recipe.getRecipeOutput(), stack)) {
			recipes.add(recipe);
		}
	}
	return recipes;
}
 
Example #30
Source File: CommandFindBiome.java    From Traverse-Legacy-1-12-2 with MIT License 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	Biome biome = null;
	if (args.length == 0) {
		sender.sendMessage(new TextComponentString("No biome specified"));
		return;
	}
	for (Biome b : ForgeRegistries.BIOMES.getValues()) {
		String name = b.getRegistryName().toString().replaceAll(" ", "_").toLowerCase();
		if (args[0].equalsIgnoreCase(name)) {
			biome = b;
		}
	}
	if (biome == null) {
		sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error! Biome '" + args[0] + "' cannot be found!"));
		return;
	}
	long start = System.currentTimeMillis();
	final Biome finalBiome = biome;
	new Thread(() -> {
		BlockPos pos = spiralOutwardsLookingForBiome(sender, sender.getEntityWorld(), finalBiome, sender.getPosition().getX(), sender.getPosition().getZ(), TraverseConfig.findBiomeCommandTimeout);
		if (pos == null) {
			server.addScheduledTask(() -> sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error! Biome '" + args[0] + "' could not be found after " + TextFormatting.GRAY + TraverseConfig.findBiomeCommandTimeout + "ms" + TextFormatting.RED + ".")));
			return;
		}
		if (sender instanceof EntityPlayerMP) {
			server.addScheduledTask(() -> {
				EntityPlayerMP playerMP = (EntityPlayerMP) sender;
				playerMP.connection.setPlayerLocation(pos.getX(), 150, pos.getZ(), 0, 0);
				sender.sendMessage(new TextComponentString(TextFormatting.WHITE + "Found '" + finalBiome.getRegistryName().toString() + "' Biome! " + TextFormatting.GRAY + "(" + (System.currentTimeMillis() - start) + "ms)"));
			});
			return;
		}
		server.addScheduledTask(() -> sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error! An unknown error occurred.")));
	}, "Biome Finder - Traverse").start();
}