diff --git a/src/api/java/baritone/api/behavior/IMemoryBehavior.java b/src/api/java/baritone/api/behavior/IMemoryBehavior.java new file mode 100644 index 00000000..ea5e9007 --- /dev/null +++ b/src/api/java/baritone/api/behavior/IMemoryBehavior.java @@ -0,0 +1,36 @@ +/* + * 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 . + */ + +package baritone.api.behavior; + +import baritone.api.behavior.memory.IRememberedInventory; +import net.minecraft.util.math.BlockPos; + +/** + * @author Brady + * @since 9/23/2018 + */ +public interface IMemoryBehavior extends IBehavior { + + /** + * Gets a remembered inventory by its block position. + * + * @param pos The position of the container block + * @return The remembered inventory + */ + IRememberedInventory getInventoryByPos(BlockPos pos); +} diff --git a/src/api/java/baritone/api/behavior/memory/IRememberedInventory.java b/src/api/java/baritone/api/behavior/memory/IRememberedInventory.java new file mode 100644 index 00000000..c57ded91 --- /dev/null +++ b/src/api/java/baritone/api/behavior/memory/IRememberedInventory.java @@ -0,0 +1,39 @@ +/* + * 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 . + */ + +package baritone.api.behavior.memory; + +import net.minecraft.item.ItemStack; + +import java.util.List; + +/** + * @author Brady + * @since 9/23/2018 + */ +public interface IRememberedInventory { + + /** + * @return The contents of this inventory + */ + List getContents(); + + /** + * @return The number of slots in this inventory + */ + int getSize(); +} diff --git a/src/main/java/baritone/behavior/MemoryBehavior.java b/src/main/java/baritone/behavior/MemoryBehavior.java index 20ffa163..b0980322 100644 --- a/src/main/java/baritone/behavior/MemoryBehavior.java +++ b/src/main/java/baritone/behavior/MemoryBehavior.java @@ -17,6 +17,8 @@ package baritone.behavior; +import baritone.api.behavior.IMemoryBehavior; +import baritone.api.behavior.memory.IRememberedInventory; import baritone.api.event.events.PacketEvent; import baritone.api.event.events.PlayerUpdateEvent; import baritone.api.event.events.type.EventState; @@ -37,7 +39,7 @@ import java.util.*; * @author Brady * @since 8/6/2018 9:47 PM */ -public final class MemoryBehavior extends Behavior implements Helper { +public final class MemoryBehavior extends Behavior implements IMemoryBehavior, Helper { public static MemoryBehavior INSTANCE = new MemoryBehavior(); @@ -127,6 +129,7 @@ public final class MemoryBehavior extends Behavior implements Helper { }); } + @Override public final RememberedInventory getInventoryByPos(BlockPos pos) { return this.rememberedInventories.get(pos); } @@ -169,7 +172,7 @@ public final class MemoryBehavior extends Behavior implements Helper { *

* Associated with a {@link BlockPos} in {@link MemoryBehavior#rememberedInventories}. */ - public static class RememberedInventory { + public static class RememberedInventory implements IRememberedInventory { /** * The list of items in the inventory @@ -190,11 +193,14 @@ public final class MemoryBehavior extends Behavior implements Helper { this.items = new ArrayList<>(); } - /** - * @return The list of items in the inventory - */ - public final List getItems() { + @Override + public final List getContents() { return this.items; } + + @Override + public final int getSize() { + return this.size; + } } }