# Strange hammer mechanics

Hello!

It was not clear for me how hammer prospecting worked so I searched the source code of GregTech to find it (would be great if it said that in the game). Here’s the code I found here:

``````Random tRandom = new Random(aX^aY^aZ^aSide);
for (int i = 0, j = (int)(9+2*aQuality); i < j * 2; i++) {
tX = (int) (aX-4-aQuality+tRandom.nextInt(j));
tY = (int) (aY-4-aQuality+tRandom.nextInt(j));
tZ = (int) (aZ-4-aQuality+tRandom.nextInt(j));
tBlock = aWorld.getBlock(tX, tY, tZ);
``````

It searches randomly in a very large cube with the edge of (9 + 2 * aQuality).

I believe that the cube is too large. That’s ~34 stacks of blocks to search in with a level 2 hammer! Upgrading the hammer doesn’t help, it only makes the cube larger.

Also, the cube is offset strangely, so it searches not only only ahead, but also behind, regardless of what side of block has been hit.

I suggest the hammer mechanics to be changed:

• Make the search range a static 5x5x7 cuboid (or whatever you want, but less than currently).
• Make hammer search only ahead, not behind.
• Make leveling up hammer increase number of blocks searched randomly.
5 Likes

Didn’t realize the hammer searched behind you as well.
That would explain some of the unusual readings I get.

2 Likes

There is a good reason why the Cube is so large, otherwise it wont find Ores, since Ores are generated in huge Veins as opposed to small blobs like in vanilla MC.

And dont forget the for Loop that it runs through, the Quality also increases Sample Count.

https://git.gregtech.overminddl1.com/GregTech-6/GT6/src/branch/master/src/main/java/gregapi/block/ToolCompat.java#L363-L376

2 Likes

Ok, but I still think the hammer should only find ores ahead of the block it hit, so it becomes clearer where to dig.

2 Likes

The reason it scans all around is because just because you dug a tunnel doesn’t change where the sample comes from. I will increase the sample count based on quality a bit further, so you see easier that you are close to an Ore. For the direction you need to dig tunnels and hammer until you dont find a sample of said Ore anymore.

And prospecting isn’t really supposed to be for small Ores, so I might change that too to only detect big Ores.

5 Likes

Thanks for reply, I used hammer to find diamonds that’s why I asked

2 Likes

This should go to changelog. No longer detecting small ores is significant.

3 Likes

Oh right, adding that to it but I wont commit yet until I do something else.

1 Like