fix an array oob with dynamic worldheight

This commit is contained in:
Wagyourtail 2022-02-08 01:36:32 -07:00
parent af240d38e0
commit 407f4dbbae
No known key found for this signature in database
GPG Key ID: B3A2A4A58244B050
2 changed files with 3 additions and 3 deletions

View File

@ -65,8 +65,8 @@ public interface ActionCosts {
static double[] generateFallNBlocksCost() {
double[] costs = new double[257];
for (int i = 0; i < 257; i++) {
double[] costs = new double[4097];
for (int i = 0; i < 4096; i++) {
costs[i] = distanceToTicks(i);
}
return costs;

View File

@ -26,7 +26,7 @@ public class ActionCostsTest {
@Test
public void testFallNBlocksCost() {
assertEquals(FALL_N_BLOCKS_COST.length, 257); // Fall 0 blocks through fall 256 blocks
assertEquals(FALL_N_BLOCKS_COST.length, 4097); // Fall 0 blocks through fall 4096 blocks
for (int i = 0; i < 257; i++) {
double blocks = ticksToBlocks(FALL_N_BLOCKS_COST[i]);
assertEquals(blocks, i, 0.000000000001); // If you add another 0 the test fails at i=217 LOL