Create IMemoryBehavior interface

This commit is contained in:
Brady 2018-09-23 17:07:53 -05:00
parent 7edf581c6a
commit 62b8bc0f47
No known key found for this signature in database
GPG Key ID: 73A788379A197567
3 changed files with 87 additions and 6 deletions

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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);
}

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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<ItemStack> getContents();
/**
* @return The number of slots in this inventory
*/
int getSize();
}

View File

@ -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 {
* <p>
* 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<ItemStack> getItems() {
@Override
public final List<ItemStack> getContents() {
return this.items;
}
@Override
public final int getSize() {
return this.size;
}
}
}