
Growth Crystals - Error in DistanceCoefficient Calculation?
milcondoin opened this issue ยท 1 comments
This error regards all variants of the growth crystal block.
In this example I use the BlockGrowth.java.
Line 88-90:
88: double distance = Math.sqrt(Math.pow(x-xO,2) + Math.pow(y - yO,2) + Math.pow(z - zO,2));
89: distance = Math.min(1D, distance);
90: double distanceCoefficient = 1D - (distance);
Line 88 calculates the distance correctly, no complains here.
But in line 89 the distance is changed for every block, that is not the crystal itself, down to 1, resulting in line 90 having always a coefficient of 0.
If you want a constant effect (regardless of distance) on the blocks, you can remove all this calculation and just set the value 0 for the distanceCoefficient.
If you want a diminishing return because of distance, you could change those lines possibly to the following:
89: distance = Math.max(1D, distance); //avoiding a DivisionByZero
90: double distanceCoefficient = 1D - (1D/distance);