3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-03 01:50:07 +01:00

implement getBiome(BlockVector3)

fixes #622
Dieser Commit ist enthalten in:
dordsor21 2020-09-18 11:52:49 +01:00
Ursprung 2e73746abe
Commit 7375827844
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
10 geänderte Dateien mit 96 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -3,6 +3,7 @@ package com.boydti.fawe.beta;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.extent.InputExtent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
@ -21,6 +22,11 @@ public interface IChunkGet extends IBlocks, Trimable, InputExtent, ITileInput {
@Override
BiomeType getBiomeType(int x, int y, int z);
@Override
default BiomeType getBiome(BlockVector3 position) {
return getBiomeType(position.getX(), position.getY(), position.getZ());
}
@Override
BlockState getBlock(int x, int y, int z);

Datei anzeigen

@ -4,6 +4,7 @@ import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.extent.OutputExtent;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -21,6 +22,11 @@ public interface IChunkSet extends IBlocks, OutputExtent {
@Override
boolean setBiome(int x, int y, int z, BiomeType biome);
@Override
default boolean setBiome(BlockVector3 position, BiomeType biome) {
return setBiome(position.getX(), position.getY(), position.getZ(), biome);
}
@Override
<T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T holder);

Datei anzeigen

@ -12,6 +12,7 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
@ -52,6 +53,12 @@ public interface IChunkExtent<T extends IChunk> extends Extent {
return chunk.setBiome(x & 15, y, z & 15, biome);
}
@Override
default boolean setBiome(BlockVector3 position, BiomeType biome) {
final IChunk chunk = getOrCreateChunk(position.getX() >> 4, position.getZ() >> 4);
return chunk.setBiome(position.getX() & 15, position.getY(), position.getZ() & 15, biome);
}
@Override
default BlockState getBlock(int x, int y, int z) {
final IChunk chunk = getOrCreateChunk(x >> 4, z >> 4);
@ -70,6 +77,12 @@ public interface IChunkExtent<T extends IChunk> extends Extent {
return chunk.getBiomeType(x & 15, y, z & 15);
}
@Override
default BiomeType getBiome(BlockVector3 position) {
final IChunk chunk = getOrCreateChunk(position.getX() >> 4, position.getZ() >> 4);
return chunk.getBiomeType(position.getX() & 15, position.getY(), position.getZ() & 15);
}
@Override
default void setSkyLight(int x, int y, int z, int value) {
final IChunk chunk = getOrCreateChunk(x >> 4, z >> 4);

Datei anzeigen

@ -184,4 +184,14 @@ public abstract class FilterBlock extends BlockVector3 implements Extent, TileEn
public BlockState getStateRelativeY(Extent orDefault, int y) {
return getBlockRelativeY(y);
}
@Override @Nullable
public BiomeType getBiome(BlockVector3 position) {
return null;
}
@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
return setBiome(position.getX(), position.getY(), position.getZ(), biome);
}
}

Datei anzeigen

@ -8,6 +8,7 @@ import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
@ -15,13 +16,13 @@ import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
public class CPUOptimizedClipboard extends LinearClipboard {
@ -44,6 +45,11 @@ public class CPUOptimizedClipboard extends LinearClipboard {
return biomes != null;
}
@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
return setBiome(position.getX(), position.getY(), position.getZ(), biome);
}
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
setBiome(getIndex(x, 0, z), biome);
@ -87,6 +93,11 @@ public class CPUOptimizedClipboard extends LinearClipboard {
return getBiome(getIndex(x, 0, z));
}
@Override
public BiomeType getBiome(BlockVector3 position) {
return getBiome(getIndex(position.getX(), 0, position.getZ()));
}
public void convertTilesToIndex() {
if (nbtMapLoc.isEmpty()) {
return;

Datei anzeigen

@ -178,6 +178,11 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
return hasBiomes;
}
@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
return setBiome(position.getX(), position.getY(), position.getZ(), biome);
}
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
setBiome(getIndex(x, y, z), biome);
@ -223,6 +228,11 @@ public class DiskOptimizedClipboard extends LinearClipboard implements Closeable
return getBiome(getIndex(x, 0, z));
}
@Override
public BiomeType getBiome(BlockVector3 position) {
return getBiome(getIndex(position.getX(), 0, position.getZ()));
}
public BlockArrayClipboard toClipboard() {
try {
CuboidRegion region = new CuboidRegion(BlockVector3.at(0, 0, 0), BlockVector3.at(getWidth() - 1, getHeight() - 1, getLength() - 1));

Datei anzeigen

@ -11,6 +11,7 @@ import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard.ClipboardEntity;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType;
@ -69,6 +70,11 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
return biomes != null;
}
@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
return setBiome(position.getX(), position.getY(), position.getZ(), biome);
}
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
setBiome(getIndex(x, 0, z), biome);
@ -112,6 +118,11 @@ public class MemoryOptimizedClipboard extends LinearClipboard {
return getBiome(getIndex(x, 0, z));
}
@Override
public BiomeType getBiome(BlockVector3 position) {
return getBiome(getIndex(position.getX(), 0, position.getZ()));
}
public int getOrdinal(int index) {
int i = index >> BLOCK_SHIFT;
int li = (index & BLOCK_MASK) << 1;

Datei anzeigen

@ -6,6 +6,7 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Location;
@ -78,6 +79,11 @@ public abstract class ReadOnlyClipboard extends SimpleClipboard {
throw new UnsupportedOperationException("Clipboard is immutable");
}
@Override
public boolean setBiome(BlockVector3 position, BiomeType biome) {
throw new UnsupportedOperationException("Clipboard is immutable");
}
@Override
public abstract List<? extends Entity> getEntities();

Datei anzeigen

@ -2,6 +2,7 @@ package com.boydti.fawe.object.clipboard;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
@ -53,6 +54,11 @@ public class WorldCopyClipboard extends ReadOnlyClipboard {
return getExtent().getBiomeType(x, y, z);
}
@Override
public BiomeType getBiome(BlockVector3 position) {
return getExtent().getBiomeType(position.getX(), position.getY(), position.getZ());
}
@Override
public List<? extends Entity> getEntities() {
if (!hasEntities) return new ArrayList<>();

Datei anzeigen

@ -40,6 +40,7 @@ import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.SideEffect;
import com.sk89q.worldedit.util.SideEffectSet;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
@ -346,4 +347,19 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
* @param packet the chunk packet
*/
void sendFakeChunk(@Nullable Player player, ChunkPacket packet);
@Override @Nullable
default BiomeType getBiome(BlockVector3 position) {
return null;
}
@Override
default boolean setBiome(int x, int y, int z, BiomeType biome) {
return false;
}
@Override
default boolean setBiome(BlockVector3 position, BiomeType biome) {
return false;
}
}