Add a BiomeCategories API (#2338) (#2777)

* Add a BiomeCategories API (#2338)

* Add a BiomeCategories API

* licenses

* Use a supplier to retain the lazy-load & dynamicness of the existing system, but still retaining the inversion of control that this PR was intended to provide

* Minor fawe adapter cleanup

* Actually add the new files?

* Fixes

---------

Co-authored-by: Maddy Miller <mnmiller1@me.com>
This commit is contained in:
Jordan
2024-06-27 15:15:14 +02:00
committed by GitHub
parent ad5739e014
commit fee9029bf0
25 changed files with 975 additions and 371 deletions

View File

@ -8,6 +8,7 @@ import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.registry.state.Property;
@ -114,6 +115,26 @@ public interface IDelegateBukkitImplAdapter<T> extends BukkitImplAdapter<T> {
return getParent().getInternalBlockStateId(state);
}
@Override
default boolean clearContainerBlockContents(World world, BlockVector3 pt) {
return getParent().clearContainerBlockContents(world, pt);
}
@Override
default void setBiome(Location location, BiomeType biome) {
getParent().setBiome(location, biome);
}
@Override
default BiomeType getBiome(Location location) {
return getParent().getBiome(location);
}
@Override
default void sendBiomeUpdates(World world, Iterable<BlockVector2> chunks) {
getParent().sendBiomeUpdates(world, chunks);
}
@Override
default BlockMaterial getMaterial(BlockType blockType) {
return getParent().getMaterial(blockType);

View File

@ -35,6 +35,7 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.wna.WorldNativeAccess;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.registry.state.Property;
@ -110,7 +111,7 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
BlockState getBlock(Location location);
/**
* Get the block at the given location.
* Get the block with NBT data at the given location.
*
* @param location the location
* @return the block
@ -280,6 +281,46 @@ public interface BukkitImplAdapter<T> extends IBukkitAdapter {
throw new UnsupportedOperationException("This adapter does not support clearing block contents.");
}
/**
* Set the biome at a location.
*
* @param location the location
* @param biome the new biome
*/
default void setBiome(Location location, BiomeType biome) {
throw new UnsupportedOperationException("This adapter does not support custom biomes.");
}
/**
* Gets the current biome at a location.
*
* @param location the location
* @return the biome
*/
default BiomeType getBiome(Location location) {
throw new UnsupportedOperationException("This adapter does not support custom biomes.");
}
/**
* Initialize registries that require NMS access.
*/
default void initializeRegistries() {
}
/**
* Sends biome updates for the given chunks.
*
* <p>This doesn't modify biomes at all, it just sends the current state of the biomes
* in the world to all of the nearby players, updating the visual representation of the
* biomes on their clients.</p>
*
* @param world the world
* @param chunks a list of chunk coordinates to send biome updates for
*/
default void sendBiomeUpdates(World world, Iterable<BlockVector2> chunks) {
}
//FAWE start
default BlockMaterial getMaterial(BlockType blockType) {
return getMaterial(blockType.getDefaultState());