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
base: master
Are you sure you want to change the base?
Conversation
Is it possible to expand this to all items which can't be walked on? |
Looking around for some candidates, |
should I just check if the block it would place is canWalkOn or something? |
I'd say |
I did a thing, does all now. does that look good? |
Looks good, but question, |
my ide isn't showing any errors and it still builds, so the import was unused |
There was a problem hiding this 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)) { |
There was a problem hiding this comment.
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.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
fixes #3399