Propagate 3D biome support up extent stack

Fixes #1399

Also improved Fabric gradle b/c why not
This commit is contained in:
Octavia Togami 2020-06-28 15:51:50 -07:00
parent 7ee60060c3
commit a6236b6796
No known key found for this signature in database
GPG Key ID: CC364524D1983C99
11 changed files with 47 additions and 33 deletions

View File

@ -148,11 +148,6 @@ public BaseBlock getFullBlock(BlockVector3 position) {
return clipboard.getFullBlock(position);
}
@Override
public boolean fullySupports3DBiomes() {
return true;
}
@Override
public BiomeType getBiome(BlockVector3 position) {
return clipboard.getBiome(position);

View File

@ -605,6 +605,11 @@ public int getBlockChangeCount() {
return changeSet.size();
}
@Override
public boolean fullySupports3DBiomes() {
return bypassNone.fullySupports3DBiomes();
}
@Override
public BiomeType getBiome(BlockVector3 position) {
return bypassNone.getBiome(position);

View File

@ -95,6 +95,11 @@ public List<? extends Entity> getEntities(Region region) {
return extent.getEntities(region);
}
@Override
public boolean fullySupports3DBiomes() {
return extent.fullySupports3DBiomes();
}
@Override
public BiomeType getBiome(BlockVector3 position) {
return extent.getBiome(position);

View File

@ -91,6 +91,11 @@ public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B
return false;
}
@Override
public boolean fullySupports3DBiomes() {
return false;
}
@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
return false;

View File

@ -54,6 +54,22 @@ public interface OutputExtent {
*/
<T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException;
/**
* Does this extent fully support 3D biomes?
*
* <p>
* If {@code false}, the extent only visually reads biomes from {@code y = 0}.
* The biomes will still be set in 3D, but the client will only see the one at
* {@code y = 0}. It is up to the caller to determine if they want to set that
* biome instead, or simply warn the actor.
* </p>
*
* @return if the extent fully supports 3D biomes
*/
default boolean fullySupports3DBiomes() {
return true;
}
/**
* Set the biome.
*

View File

@ -19,8 +19,6 @@
package com.sk89q.worldedit.function.biome;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.FlatRegionFunction;
@ -28,16 +26,17 @@
import com.sk89q.worldedit.function.pattern.BiomePattern;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Replaces the biome at the locations that this function is applied to.
*/
public class BiomeReplace implements FlatRegionFunction, RegionFunction {
private final Extent extent;
private BiomePattern biome;
private final BiomePattern biome;
/**
* Create a new instance.
@ -64,7 +63,7 @@ public BiomeReplace(Extent extent, BiomePattern pattern) {
@Override
public boolean apply(BlockVector3 position) throws WorldEditException {
if (extent instanceof World && !((World) extent).fullySupports3DBiomes()) {
if (!extent.fullySupports3DBiomes()) {
position = position.withY(0);
}
return extent.setBiome(position, biome.applyBiome(position));
@ -73,7 +72,7 @@ public boolean apply(BlockVector3 position) throws WorldEditException {
@Override
@Deprecated
public boolean apply(BlockVector2 position) throws WorldEditException {
if (extent instanceof World && !((World) extent).fullySupports3DBiomes()) {
if (!extent.fullySupports3DBiomes()) {
return apply(position.toBlockVector3());
}
boolean success = false;

View File

@ -96,7 +96,7 @@ public boolean apply(BlockVector3 position) throws WorldEditException {
.toBlockPoint()
.add(to);
if (destination instanceof World && !((World) destination).fullySupports3DBiomes()) {
if (!destination.fullySupports3DBiomes()) {
transformed = transformed.withY(0);
}

View File

@ -103,7 +103,7 @@ private boolean isOutside(int x, int y, int z, BiomeType baseBiome) {
public int generate(EditSession editSession, BiomeType baseBiome, boolean hollow) {
int affected = 0;
boolean fullySupports3DBiomes = editSession.getWorld().fullySupports3DBiomes();
boolean fullySupports3DBiomes = editSession.fullySupports3DBiomes();
for (BlockVector3 position : getExtent()) {
int x = position.getBlockX();

View File

@ -95,6 +95,11 @@ public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T
return getExtent().setBlock(position, block);
}
@Override
public boolean fullySupports3DBiomes() {
return getExtent().fullySupports3DBiomes();
}
@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
return getExtent().setBiome(position, biome);

View File

@ -100,20 +100,6 @@ public interface World extends Extent, Keyed {
*/
boolean useItem(BlockVector3 position, BaseItem item, Direction face);
/**
* Does this world fully support 3D biomes?
*
* <p>
* If {@code false}, the world only visually reads biomes from {@code y = 0}.
* The biomes will still be set in 3D, but the client will only see the one at
* {@code y = 0}. It is up to the caller to determine if they want to set that
* biome instead, or simply warn the actor.
* </p>
*
* @return if the world fully supports 3D biomes
*/
boolean fullySupports3DBiomes();
/**
* Similar to {@link Extent#setBlock(BlockVector3, BlockStateHolder)} but a
* {@code notifyAndLight} parameter indicates whether adjacent blocks

View File

@ -44,12 +44,12 @@
}
dependencies {
"compile"(project(":worldedit-core"))
"compile"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
"implementation"(project(":worldedit-core"))
"implementation"("org.apache.logging.log4j:log4j-slf4j-impl:2.8.1")
"minecraft"("com.mojang:minecraft:$minecraftVersion")
"mappings"("net.fabricmc:yarn:$yarnMappings")
"modCompile"("net.fabricmc:fabric-loader:$loaderVersion")
"modImplementation"("net.fabricmc:fabric-loader:$loaderVersion")
// [1] declare fabric-api dependency...
"fabricApi"("net.fabricmc.fabric-api:fabric-api:0.14.0+build.371-1.16")
@ -99,11 +99,9 @@
}
// Hook these up manually, because Fabric doesn't seem to quite do it properly.
"compileClasspath"("net.fabricmc:sponge-mixin:${project.versions.mixin}")
"compileOnly"("net.fabricmc:sponge-mixin:${project.versions.mixin}")
"annotationProcessor"("net.fabricmc:sponge-mixin:${project.versions.mixin}")
"annotationProcessor"("net.fabricmc:fabric-loom:${project.versions.loom}")
"testCompile"("org.mockito:mockito-core:1.9.0-rc1")
}
configure<BasePluginConvention> {