Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent non placable items causing issues in acceptable throwaway items. #3400

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

wagyourtail
Copy link
Collaborator

fixes #3399

@scorbett123
Copy link
Collaborator

Is it possible to expand this to all items which can't be walked on?

@XorOwl
Copy link

XorOwl commented Apr 17, 2022

Is it possible to expand this to all items which can't be walked on?

Looking around for some candidates,
Spider web and string are two obvious ones.
I dont know how it handles things, but paintings, signs and item frames are worth considering,
Maybe carpet.

@wagyourtail
Copy link
Collaborator Author

wagyourtail commented Apr 19, 2022

should I just check if the block it would place is canWalkOn or something? canWalkOn(bsi, x, y, z, item.getdefaultstate())?

@ZacSharp
Copy link
Collaborator

ZacSharp commented Apr 19, 2022

I'd say canWalkOn with a special case for isWater and isLava blocks (because those use the coordinates) is a good solution. If you find a way to do it without passing dummy arumgents that's better.

@wagyourtail
Copy link
Collaborator Author

I did a thing, does all now. does that look good?

@wagyourtail wagyourtail changed the title prevent air from causing issues in acceptable throwaway items. prevent non placable items causing issues in acceptable throwaway items. Apr 19, 2022
@XorOwl
Copy link

XorOwl commented Apr 19, 2022

I did a thing, does all now. does that look good?

Looks good, but question,
You removed
import baritone.api.BaritoneAPI;
from InventoryBehavior.java
was that intentional? looks like it might have been an oopsie, but i'm not familiar enough with baritone's api to know for sure.

@wagyourtail
Copy link
Collaborator Author

my ide isn't showing any errors and it still builds, so the import was unused

Copy link
Collaborator

@scorbett123 scorbett123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is much better, just a small performance thing.

@@ -97,7 +97,8 @@ private void swapWithHotBar(int inInventory, int inHotbar) {
private int firstValidThrowaway() { // TODO offhand idk
NonNullList<ItemStack> invy = ctx.player().inventory.mainInventory;
for (int i = 0; i < invy.size(); i++) {
if (Baritone.settings().acceptableThrowawayItems.value.contains(invy.get(i).getItem())) {
Item item = invy.get(i).getItem();
if (MovementHelper.filterThrowawayForPlacing(Baritone.settings().acceptableThrowawayItems.value).contains(item)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better for this to be run once at the beginning of the function instead of for every item in the inventory.

Comment on lines +363 to +365
return block == Blocks.FARMLAND || block == Blocks.GRASS_PATH ||
block == Blocks.ENDER_CHEST || block == Blocks.CHEST || block == Blocks.TRAPPED_CHEST ||
block == Blocks.GLASS || block == Blocks.STAINED_GLASS;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also return true for slabs if allowWalkOnBottomSlab is enabled.

@@ -344,6 +347,25 @@ static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, IBlockSta
return block instanceof BlockStairs;
}

static List<Item> filterThrowawayForPlacing(List<Item> items) {
Copy link
Collaborator

@ZacSharp ZacSharp Apr 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a comment here (and probably on canWalkOn as well) would be a good idea to make sure people know these two methods should be roughly in sync (precisely: this method may only return items where canWalkOn is guaranteed to return true for all blockstates the item can place).

@@ -344,6 +347,25 @@ static boolean canWalkOn(BlockStateInterface bsi, int x, int y, int z, IBlockSta
return block instanceof BlockStairs;
}

static List<Item> filterThrowawayForPlacing(List<Item> items) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be split into filterThrowawayForPlacing and an overload of canWalkOn (taking only a blockstate) so if we need to check single blocks we don't face the same problem once again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Baritone tries to place air, and gets stuck in a loop
4 participants