Remove hardcoding of world limits (#1199)

* Remove hardcoding of world limits
 - seems to be working fine without the datapack for world height changing
 - particular attention should be given to LocalBlockVectorSet and MathMan changes

* update adapters

* Override getMinY in various classes and ensure selections have a world attached to them

* no message

* Address comments
 - Fix for lighting mode 1

* A few more changes

* Fix LocalBlockVectorSet

* Fix range statement

* Various fixes/comment-addressing
- There's not much point in having a different file name now for history. We've broken it before...
- Fix history read/write
- Fix range on for loops in CharBlocks

* undo bad CharBlocks change

* Fix history y level

* Fix biome history

* Fix lighting

* Fix /up

* Make regen fail not because of these changes

* Fixes for y < 0

* Fix isEmpty where only the uppermost chunksection is edited

* Fix javadocs/FAWE annotations

* Better explain why BiomeMath is removed

* If history task throws an error, it should only be caught and printed if not completing now.

* Min|max world heights for new patterns

* Load biomes from NMS instead of bukkit (#1200)

* Update adapters

* Update adapters

* Don't initialise BlockTypes when biomes aren't set up yet so all BiomeTypes.BIOME are no longer null thanks.

* Address some comments.

* rename layer -> sectionIndex to imply inclusivity

* Javadoctored.

Co-authored-by: NotMyFault <mc.cache@web.de>
Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
This commit is contained in:
dordsor21
2021-08-17 22:13:51 +01:00
committed by GitHub
parent 5b2bd45d86
commit 1d9b1a3d5e
110 changed files with 1489 additions and 677 deletions

View File

@ -19,53 +19,54 @@
package com.sk89q.worldedit.internal.util;
import net.royawesome.jlibnoise.MathHelper;
public class BiomeMath {
// From BiomeArray / BiomeContainer
public static final int HORIZONTAL_SECTION_COUNT = (int) Math.round(Math.log(16.0D) / Math.log(2.0D)) - 2;
public static final int VERTICAL_SECTION_COUNT = (int) Math.round(Math.log(256.0D) / Math.log(2.0D)) - 2;
public static final int HORIZONTAL_BIT_MASK = (1 << HORIZONTAL_SECTION_COUNT) - 1;
public static final int VERTICAL_BIT_MASK = (1 << VERTICAL_SECTION_COUNT) - 1;
//FAWE - Removed because it's unneeded, and it would require effort to have it work with worlds of differing heights across
// different game versions
private BiomeMath() {
}
/**
* Compute the index into the MC biome array, for non-extended-height worlds.
*
* @param x the block x coordinate
* @param y the block y coordinate
* @param z the block z coordinate
* @return the index into the standard MC biome array
*/
public static int computeBiomeIndex(int x, int y, int z) {
int l = (x >> 2) & HORIZONTAL_BIT_MASK;
int m = MathHelper.clamp(y >> 2, 0, VERTICAL_BIT_MASK);
int n = (z >> 2) & HORIZONTAL_BIT_MASK;
return m << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT
| n << HORIZONTAL_SECTION_COUNT
| l;
}
/**
* Compute the index into the MC biome array, for extended-height worlds.
*
* @param x the block x coordinate
* @param y the block y coordinate
* @param z the block z coordinate
* @param minY minimum y of the world
* @param maxY maximum y of the world
* @return the index into the standard MC biome array
*/
public static int computeBiomeIndex(int x, int y, int z, int minY, int maxY) {
int l = (x >> 2) & HORIZONTAL_BIT_MASK;
int m = MathHelper.clamp((y >> 2) - minY, 0, maxY);
int n = (z >> 2) & HORIZONTAL_BIT_MASK;
return m << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT
| n << HORIZONTAL_SECTION_COUNT
| l;
}
// // From BiomeArray / BiomeContainer
// public static final int HORIZONTAL_SECTION_COUNT = (int) Math.round(Math.log(16.0D) / Math.log(2.0D)) - 2;
// public static final int VERTICAL_SECTION_COUNT = (int) Math.round(Math.log(256.0D) / Math.log(2.0D)) - 2;
// public static final int HORIZONTAL_BIT_MASK = (1 << HORIZONTAL_SECTION_COUNT) - 1;
// public static final int VERTICAL_BIT_MASK = (1 << VERTICAL_SECTION_COUNT) - 1;
//
// private BiomeMath() {
// }
//
// /**
// * Compute the index into the MC biome array, for non-extended-height worlds.
// *
// * @param x the block x coordinate
// * @param y the block y coordinate
// * @param z the block z coordinate
// * @return the index into the standard MC biome array
// */
// public static int computeBiomeIndex(int x, int y, int z) {
// int l = (x >> 2) & HORIZONTAL_BIT_MASK;
// int m = MathHelper.clamp(y >> 2, 0, VERTICAL_BIT_MASK);
// int n = (z >> 2) & HORIZONTAL_BIT_MASK;
// return m << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT
// | n << HORIZONTAL_SECTION_COUNT
// | l;
// }
//
// /**
// * Compute the index into the MC biome array, for extended-height worlds.
// *
// * @param x the block x coordinate
// * @param y the block y coordinate
// * @param z the block z coordinate
// * @param minY minimum y of the world
// * @param maxY maximum y of the world
// * @return the index into the standard MC biome array
// */
// public static int computeBiomeIndex(int x, int y, int z, int minY, int maxY) {
// int l = (x >> 2) & HORIZONTAL_BIT_MASK;
// int m = MathHelper.clamp((y >> 2) - minY, 0, maxY);
// int n = (z >> 2) & HORIZONTAL_BIT_MASK;
// return m << HORIZONTAL_SECTION_COUNT + HORIZONTAL_SECTION_COUNT
// | n << HORIZONTAL_SECTION_COUNT
// | l;
// }
}