Skip to content

Commit

Permalink
I tried
Browse files Browse the repository at this point in the history
  • Loading branch information
rycbar0 committed Nov 10, 2023
1 parent 2cd5c6b commit 7f15324
Show file tree
Hide file tree
Showing 5 changed files with 547 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/api/java/baritone/api/IBaritone.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ public interface IBaritone {
*/
IElytraProcess getElytraProcess();

/**
* @return The {@Link ICraftingProcess} instance
* @see ICraftingProcess
*/
ICraftingProcess getCraftingProcess();

/**
* @return The {@link IWorldProvider} instance
* @see IWorldProvider
Expand Down
53 changes: 53 additions & 0 deletions src/api/java/baritone/api/command/datatypes/ItemById.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/

package baritone.api.command.datatypes;

import baritone.api.command.exception.CommandException;
import baritone.api.command.helpers.TabCompleteHelper;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.ItemLike;

import java.util.stream.Stream;

public enum ItemById implements IDatatypeFor<Item> {
INSTANCE;

@Override
public Item get(IDatatypeContext ctx) throws CommandException {
Item item;
if ((item = BuiltInRegistries.ITEM.get(new ResourceLocation(ctx.getConsumer().getString()))) == Items.AIR) {
throw new IllegalArgumentException("No item found by that id");
}
return item;
}

@Override
public Stream<String> tabComplete(IDatatypeContext ctx) throws CommandException {
return new TabCompleteHelper()
.append(BuiltInRegistries.ITEM.keySet().stream().map(ResourceLocation::toString))
.filterPrefixNamespaced(ctx.getConsumer().getString())
.sortAlphabetically()
.stream();
}
}
83 changes: 83 additions & 0 deletions src/api/java/baritone/api/process/ICraftingProcess.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/

package baritone.api.process;

import baritone.api.BaritoneAPI;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.Slot;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.alchemy.Potion;
import net.minecraft.world.item.crafting.*;
import org.checkerframework.checker.units.qual.C;

import java.util.List;

/**
* This Process controls the Production of Items.
*/
public interface ICraftingProcess extends IBaritoneProcess {

/**
* Executes the crafting of the requested recipes such that we obtain the requested amount of output.
* It is possible to mix recipes with different out puts, but it may lead to strange results.
* @param recipes List of recipes that should be used.
* @param amount how many result items are wanted.
*/
void craft(List<CraftingRecipe> recipes, int amount);

/**
* @param item that should be crafted.
* @param allCraftingRecipes if all crafting recipes should be returned or only the one that can be crafted
* @return List of recipes that result in the provided Item.
*/
List<CraftingRecipe> getCraftingRecipes(Item item, boolean allCraftingRecipes);

/**
* @param recipes that should be crafted.
* @param amount how much output is wanted.
* @return Can we craft this the requested amount of output from the provided recipes?
*/
boolean canCraft(List<CraftingRecipe> recipes, int amount);

/**
* @param recipe the recipe we want to craft.
* @return Do we need a crafting table or can we craft it in our inventory?
*/
boolean canCraftInInventory(CraftingRecipe recipe);
/*
void smithing(SmithingRecipe recipe);
void stoneCutting(StonecutterRecipe recipe, int amount);
boolean forge(Slot primaryItem, Slot secondaryItem);
void grind(Slot item);
void smelt(SmeltingRecipe recipe, int amount);
List<SmeltingRecipe> getSmeltingRecipe(Item item, boolean allSmeltingRecipes);
void brew(Potion potion, int amount);
void trade();/**/

/* todo
* crafting
* smithing
* forge (anvil)
* grind
* smelting
* brewing
* weaving
* trading
* enchanting
* */
}
8 changes: 8 additions & 0 deletions src/main/java/baritone/Baritone.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import baritone.api.behavior.IBehavior;
import baritone.api.event.listener.IEventBus;
import baritone.api.process.IBaritoneProcess;
import baritone.api.process.ICraftingProcess;
import baritone.api.process.IElytraProcess;
import baritone.api.utils.IPlayerContext;
import baritone.behavior.*;
Expand Down Expand Up @@ -80,6 +81,7 @@ public class Baritone implements IBaritone {
private final FarmProcess farmProcess;
private final InventoryPauserProcess inventoryPauserProcess;
private final ElytraProcess elytraProcess;
private final CraftingProcess craftingProcess;

private final PathingControlManager pathingControlManager;
private final SelectionManager selectionManager;
Expand Down Expand Up @@ -123,6 +125,7 @@ public class Baritone implements IBaritone {
this.farmProcess = this.registerProcess(FarmProcess::new);
this.inventoryPauserProcess = this.registerProcess(InventoryPauserProcess::new);
this.elytraProcess = this.registerProcess(ElytraProcess::create);
this.craftingProcess = this.registerProcess(CraftingProcess::new);
this.registerProcess(BackfillProcess::new);
}

Expand Down Expand Up @@ -240,6 +243,11 @@ public IElytraProcess getElytraProcess() {
return this.elytraProcess;
}

@Override
public ICraftingProcess getCraftingProcess() {
return this.craftingProcess;
}

@Override
public void openClick() {
new Thread(() -> {
Expand Down
Loading

0 comments on commit 7f15324

Please sign in to comment.