Page 1 of 1

Mining Power.

Posted: Mon Oct 06, 2014 4:06 pm
by bobingabout
As you might know, I've been working on mods for a while, one of them being an ores mod.
So, I looked up the formula for mining times etc, which is as follows.
(Mining power - Mining hardness) * Speed / Mining Time = production rate (in resource/s)

The Harness and Time are set in the resource entity, Power and Speed set by the entity mining it.

In the case of mining drills, the default ones have a speed and power set.
But the Player entity has a speed (of 0.01), and the tools also have a speed (of 2.5 for iron, and 4 for steel), but none seem to have a Mnining Power set.

Q: What is the Mining Power of the Player, and Mining tools, and is it possible to change/set them?

Re: Mining Power.

Posted: Mon Oct 06, 2014 5:24 pm
by Rseding91
If I'm understanding the code correctly this is how the player mines resources:

Code: Select all

(Player Speed - Mining Hardness) * Player Speed * (if Tool Tool Speed else 1) / Mining Time

Re: Mining Power.

Posted: Mon Oct 06, 2014 6:23 pm
by bobingabout
I think you made a bit of a mistake there.
Player mining speed is 0.01, so using that for power would mean it can't mine anything, so the mining power would be the conditional part, not mining speed.
Basically, the result needs to be positive, otherwise you get a mining time of Zero, or negative, which results in being unable to mine.

Otherwise, thankyou for the statement basically saying speed = power for tools, this does help things out.

Also means that you can mine harder ores by hand using a steel pick than the best mining drill can automate, which is silly!

Does this look right?

if player:

Code: Select all

( 1 - Mining Hardness ) * Player Mining Speed / Mining Time
if tool:

Code: Select all

( Tool Speed - Mining Hardness ) * Player Mining Speed * Tool Speed / Mining Time
Even with quick maths though, these numbers don't come out right.
Mining Iron ore by hand. 0.1 * 0.01 /2 = 0.0005 resources per second = 2000 seconds to mine a single peice of iron ore = more than half an hour
Mining iron ore with an iron pick = (2.5 - 0.9) * 0.01 * 2.5 / 2 = 0.02 resources per second = 50 seconds to mind a single peice of iron ore.

is it possible that this mining time is in Ticks instead of Seconds? it comes closer to 30 seconds, and 0.8 seconds, but then Steel pick is pretty much instant...

Re: Mining Power.

Posted: Mon Oct 06, 2014 6:53 pm
by Rseding91
Umm.. I did go wrong somewhere. I think I started with the mining drill formula then switched to the player mining formula half way through :P

Code: Select all

(1 + Player Speed Modifier) * Player Speed * ((if Tool, Tool Speed * 1 else 1) - Hardness) / Mining Time
Keep in mind "Mining Time" is the number of seconds it takes to mine the resource (time * 60 ticks).

So:

Iron pick: 2.5 speed
Iron ore: 0.9 hardness, 2 mining speed

(1 + 0) * 0.01 * (2.5 - 0.9) / (2 * 60) = 1.3~ seconds per iron ore with a iron pick.

Re: Mining Power.

Posted: Mon Oct 06, 2014 7:13 pm
by bobingabout
That still gives you: 1 * 0.01 * 0.1 / 2 for raw player mining speed, which is half an hour.
but now gives 125 seconds for iron axe, and 64 seconds for steel axe.

I think this is in Ticks, not Seconds, if you add in there a *60 for ticks, you get 33 seconds for by hand, 2 ish seconds for iron, and 1 ish seconds for steel, which is about right.

The key part I wanted to know though is answered, Mining power by hand is.... 1, or tool's speed. Mining speed is... just the players speed *60, because it's in ticks, not seconds.

Re: Mining Power.

Posted: Mon Oct 06, 2014 7:18 pm
by Rseding91
bobingabout wrote:That still gives you: 1 * 0.01 * 0.1 / 2 for raw player mining speed, which is half an hour.
but now gives 125 seconds for iron axe, and 64 seconds for steel axe.

I think this is in Ticks, not Seconds, if you add in there a *60 for ticks, you get 33 seconds for by hand, 2 ish seconds for iron, and 1 ish seconds for steel, which is about right.

The key part I wanted to know though is answered, Mining power by hand is.... 1, or tool's speed. Mining speed is... just the players speed *60, because it's in ticks, not seconds.

Right, I edited the post just before I saw you replied here. Keep in mind you can adjust the "manual mining speed modifier" of a given player (positive or negative) via: game.player.force.manualminingspeedmodifier = number

So you can adjust the mining speed to a negative number (-1) and make it literally impossible for the player to mine anything (the mining progress would run backwards).