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

add mineOnlyExposedOres setting #1995

Merged
merged 7 commits into from
Oct 14, 2020
Merged

Conversation

scorbett123
Copy link
Collaborator

adds an exposed Ores only setting.
if there is air no air on any side then it removes it from the goal.
fixes #1168

Copy link

@fee1-dead fee1-dead left a comment

Choose a reason for hiding this comment

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

LGTM, but why not have an integer setting since there are servers that hide ores except touches transparent block in a radius of two.

And, blocks like water, lava are see-through too and don't forget to include them.

@pozhiloy-enotik
Copy link

Love you!

@scorbett123 scorbett123 marked this pull request as draft September 4, 2020 17:43
@scorbett123
Copy link
Collaborator Author

converted to draft due to a bug in the latest commit.

/**
* When allowOnlyExposedOres is enabled this is the distance around to search.
* <p>
* I recommend keeping this value low as the amount of blocks that need to be scanned increases exponentially.
Copy link
Contributor

Choose a reason for hiding this comment

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

Rephrase this to be like

-      * I recommend keeping this value low as the amount of blocks that need to be scanned increases exponentially.
+      * It is recommended to keep this value low, as it exponentially increases calculation times.

@@ -409,6 +410,8 @@ private void addNearby() {
// remove any that are implausible to mine (encased in bedrock, or touching lava)
.filter(pos -> MineProcess.plausibleToBreak(ctx, pos))

.filter(pos -> isNextToAir(ctx, pos))
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this only calculate when the setting is enabled?

Copy link
Member

Choose a reason for hiding this comment

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

ya

}

public static boolean isTransparent(BlockPos pos, CalculationContext ctx) {
IBlockState blockState = ctx.bsi.get0(pos);
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure get0 is the correct method here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what do you suggest to use instead. If you use just get() then you get illegal state exceptions due to running it on the wrong thread. This is also the same as in the method above where it sees if it is plausible to break.

Copy link
Member

Choose a reason for hiding this comment

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

I believe get0 is correct in this case.

@scorbett123 scorbett123 marked this pull request as ready for review September 5, 2020 16:07
return blockState.getBlock() == Blocks.AIR ||
blockState.getBlock() == Blocks.FLOWING_LAVA ||
blockState.getBlock() == Blocks.FLOWING_WATER ||
blockState.getBlock() == Blocks.WATER;
Copy link
Member

Choose a reason for hiding this comment

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

This helper isTransparent belongs in MovementHelper. I believe there may already be something equivalent there, but I'm not certain.

@@ -452,4 +466,86 @@ public void mine(int quantity, BlockOptionalMetaLookup filter) {
rescan(new ArrayList<>(), new CalculationContext(baritone));
}
}

public static boolean makeSphere(BlockPos pos, double radius, CalculationContext ctx) {
Copy link
Member

Choose a reason for hiding this comment

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

This is extreme cringe.

Literally everything about this function is cringe.

What is the use case for this? Ignore enteerman idk who that is.

Can't this be as simple as like:

for (int dx = -1; dx <= 1; dx++) {
    for (int dy = -1; dy <= 1; dy++) {
        for (int dz = -1; dz <= 1; dz++) {
            if (MovementHelper.isTransparent(pos.add(dx,dy,dz))) {
                return false;
            }
        }
    }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

leij's example is how I was doing spheres and enteerman or someone made fun of it :clown:

Copy link
Member

Choose a reason for hiding this comment

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

enteerman is the real clown then?

this isn't intended to be a sphere, why would it be?

Copy link
Contributor

Choose a reason for hiding this comment

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

😹

Copy link
Member

Choose a reason for hiding this comment

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

yeah it shouldn't be a sphere

Choose a reason for hiding this comment

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

i am bad at english and sorry if i didnt explain it well. It wasn't intended to be a sphere. just on some servers that blocks that are two blocks from a transparent block are all legit. I think hypixel does that in UHC so you can check that out. You can ignore me, I don't care. I sketched this out and this is how is should work: https://imgur.com/0O7BkWt

Choose a reason for hiding this comment

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

I dont know why this method is large but just take the 6 blocks that are adjacent to the block, and take adjacents of the adjacents, to check if it is air.

Choose a reason for hiding this comment

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

Or use ur method idk i dont play the game anymore, ask someone else's opinion on this

Copy link
Collaborator

@ZacSharp ZacSharp Sep 8, 2020

Choose a reason for hiding this comment

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

for me @leijurv's method looks way better but it only checks the direct and diagonal neighbours. I'd rather use

for (int dx = -radius; dx <= radius; dx++) {
    for (int dy = -radius; dy <= radius; dy++) {
        for (int dz = -radius; dz <= radius; dz++) {
            if (Math.abs(dx) + Math.abs(dy) + Math.abs(dz) <= radius 
                    && MovementHelper.isTransparent(pos.add(dx,dy,dz))) {
                return true;
            }
        }
    }
}

to check all blocks that have a manhattan distance of at most radius (I think that is was @Enteerman wants to show with his image)

@scorbett123 scorbett123 closed this Sep 8, 2020
@scorbett123 scorbett123 reopened this Sep 8, 2020
@scorbett123
Copy link
Collaborator Author

scorbett123 commented Sep 8, 2020

force pushing due to pushing the wrong commits earlier.

/**
* When allowOnlyExposedOres is enabled this is the distance around to search.
* <p>
* It is recommended to keep this value low, as it exponentially increases calculation times and also to keep the
Copy link
Collaborator

@ZacSharp ZacSharp Sep 8, 2020

Choose a reason for hiding this comment

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

this sentence is incomplete and the amount of checked blocks does not increase exponentially but by (approximately) 1.3*r**3 + 2*r**2 + 2.6*r + 1. That is cubically

Signed-off-by: Sam Corbett <[email protected]>
Copy link
Member

@leijurv leijurv left a comment

Choose a reason for hiding this comment

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

LGTM, fix formatting to match baritone style and i'll merge

@@ -562,4 +562,11 @@ static PlaceResult attemptToPlaceABlock(MovementState state, IBaritone baritone,
enum PlaceResult {
READY_TO_PLACE, ATTEMPTING, NO_OPTION;
}
public static boolean isTransparent(Block b) {

return b== Blocks.AIR ||
Copy link
Member

Choose a reason for hiding this comment

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

space

@@ -409,6 +410,13 @@ private void addNearby() {
// remove any that are implausible to mine (encased in bedrock, or touching lava)
.filter(pos -> MineProcess.plausibleToBreak(ctx, pos))

.filter(pos -> {
if (Baritone.settings().allowOnlyExposedOres.value)
Copy link
Member

Choose a reason for hiding this comment

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

plz use { in the if

for (int dy = -radius; dy <= radius; dy++) {
for (int dz = -radius; dz <= radius; dz++) {
if (Math.abs(dx) + Math.abs(dy) + Math.abs(dz) <= radius
&& MovementHelper.isTransparent(ctx.getBlock(pos.getX()+dx, pos.getY()+dy, pos.getZ()+dz))) {
Copy link
Member

Choose a reason for hiding this comment

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

run through autoformatter? put spaces before and after each +

@leijurv
Copy link
Member

leijurv commented Oct 14, 2020

@scorbett123 wait what, why did you rearrange those functions and classes? it makes the diff much bigger for no reason. can we leave the order the same and just add the new function? like how it was an hour ago?

@scorbett123
Copy link
Collaborator Author

Sorry, didn't mean to, something went wrong when committing, I think it might have been my auto formatter.

@leijurv
Copy link
Member

leijurv commented Oct 14, 2020

ohh yea, that's true intellij has this rearrange entries option that i think you gotta untick

@scorbett123
Copy link
Collaborator Author

is this better?

@leijurv
Copy link
Member

leijurv commented Oct 14, 2020

almost haha just one thing can you add curly braces to the if? 😹

Signed-off-by: scorbett123 <[email protected]>
@scorbett123
Copy link
Collaborator Author

Sorry, in my fourth attempt to fix the formatting and failing with using git I obviously forgot about those.

@leijurv leijurv merged commit 5a5d119 into cabaletta:master Oct 14, 2020
@scorbett123 scorbett123 deleted the exposedOres branch October 15, 2020 07:08
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.

Add "Ignore Not Exposed Ores" Option in AutoMine
6 participants