Strange hammer mechanics

gt6

(Kernogo) #1

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.

(Donzil Zenovka) #2

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


(Gregorius Techneticies) #3

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


(Kernogo) #4

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


(Gregorius Techneticies) #5

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.


(Kernogo) #6

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


(Laurynas Liutkus) #7

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


(Gregorius Techneticies) #8

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