Merge branch '1.16' into vault-fix

Dieser Commit ist enthalten in:
IronApollo 2020-09-14 21:19:52 -04:00
Commit 4af36217b1
33 geänderte Dateien mit 351 neuen und 67 gelöschten Zeilen

Datei anzeigen

@ -3,6 +3,8 @@ package com.boydti.fawe.bukkit.adapter.mc1_14;
import com.sk89q.util.ReflectionUtil;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import net.minecraft.server.v1_14_R1.Block;
import net.minecraft.server.v1_14_R1.BlockAccessAir;
import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.EnumPistonReaction;
import net.minecraft.server.v1_14_R1.IBlockData;
import net.minecraft.server.v1_14_R1.ITileEntity;
@ -16,6 +18,7 @@ public class BlockMaterial_1_14 implements BlockMaterial {
private final boolean isTranslucent;
private final CraftBlockData craftBlockData;
private final org.bukkit.Material craftMaterial;
private final int opacity;
public BlockMaterial_1_14(Block block) {
this(block, block.getBlockData());
@ -28,6 +31,7 @@ public class BlockMaterial_1_14 implements BlockMaterial {
this.craftBlockData = CraftBlockData.fromData(defaultState);
this.craftMaterial = craftBlockData.getMaterial();
this.isTranslucent = !(boolean) ReflectionUtil.getField(Block.class, block, "v");
opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
}
public Block getBlock() {
@ -98,7 +102,7 @@ public class BlockMaterial_1_14 implements BlockMaterial {
@Override
public int getLightOpacity() {
return !isTranslucent() ? 15 : 0;
return opacity;
}
@Override

Datei anzeigen

@ -5,6 +5,7 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.blocks.CharBlocks;
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.bukkit.adapter.mc1_14.nbt.LazyCompoundTag_1_14;
@ -38,6 +39,7 @@ import net.minecraft.server.v1_14_R1.DataPaletteLinear;
import net.minecraft.server.v1_14_R1.Entity;
import net.minecraft.server.v1_14_R1.EntityTypes;
import net.minecraft.server.v1_14_R1.EnumSkyBlock;
import net.minecraft.server.v1_14_R1.HeightMap;
import net.minecraft.server.v1_14_R1.IBlockData;
import net.minecraft.server.v1_14_R1.LightEngine;
import net.minecraft.server.v1_14_R1.NBTTagCompound;
@ -187,6 +189,12 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
SectionPosition.b(BlockPosition.d(l)));
}
@Override public int[] getHeightMap(HeightMapType type) {
long[] longArray = getChunk().heightMap.get(HeightMap.Type.valueOf(type.name())).a();
BitArray bitArray = new BitArray(9, 256, longArray);
return bitArray.toRaw(new int[256]);
}
@Override
public CompoundTag getEntity(UUID uuid) {
Entity entity = world.getEntity(uuid);
@ -402,6 +410,13 @@ public class BukkitGetBlocks_1_14 extends CharGetBlocks {
}
}
Map<HeightMapType, int[]> heightMaps = set.getHeightMaps();
for (Map.Entry<HeightMapType, int[]> entry : heightMaps.entrySet()) {
BitArray bitArray = new BitArray(9, 256);
bitArray.fromRaw(entry.getValue());
nmsChunk.heightMap.get(HeightMap.Type.valueOf(entry.getKey().name())).a(bitArray.getData());
}
boolean lightUpdate = false;
// Lighting

Datei anzeigen

@ -12,6 +12,7 @@ public class BlockMaterial_1_15_2 implements BlockMaterial {
private final boolean isTranslucent;
private final CraftBlockData craftBlockData;
private final org.bukkit.Material craftMaterial;
private final int opacity;
public BlockMaterial_1_15_2(Block block) {
this(block, block.getBlockData());
@ -24,6 +25,7 @@ public class BlockMaterial_1_15_2 implements BlockMaterial {
this.craftBlockData = CraftBlockData.fromData(defaultState);
this.craftMaterial = craftBlockData.getMaterial();
this.isTranslucent = !(boolean) ReflectionUtil.getField(Block.class, block, "v");
opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
}
public Block getBlock() {
@ -94,7 +96,7 @@ public class BlockMaterial_1_15_2 implements BlockMaterial {
@Override
public int getLightOpacity() {
return !isTranslucent() ? 15 : 0;
return opacity;
}
@Override

Datei anzeigen

@ -5,6 +5,7 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.blocks.CharBlocks;
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.bukkit.adapter.mc1_15_2.nbt.LazyCompoundTag_1_15_2;
@ -15,7 +16,6 @@ import com.google.common.base.Suppliers;
import com.google.common.collect.Iterables;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.LongTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
@ -39,6 +39,7 @@ import net.minecraft.server.v1_15_R1.DataPaletteLinear;
import net.minecraft.server.v1_15_R1.Entity;
import net.minecraft.server.v1_15_R1.EntityTypes;
import net.minecraft.server.v1_15_R1.EnumSkyBlock;
import net.minecraft.server.v1_15_R1.HeightMap;
import net.minecraft.server.v1_15_R1.IBlockData;
import net.minecraft.server.v1_15_R1.LightEngine;
import net.minecraft.server.v1_15_R1.NBTTagCompound;
@ -177,6 +178,12 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
return blockLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l)));
}
@Override public int[] getHeightMap(HeightMapType type) {
long[] longArray = getChunk().heightMap.get(HeightMap.Type.valueOf(type.name())).a();
BitArray bitArray = new BitArray(9, 256, longArray);
return bitArray.toRaw(new int[256]);
}
@Override
public CompoundTag getEntity(UUID uuid) {
Entity entity = world.getEntity(uuid);
@ -391,6 +398,13 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
}
}
Map<HeightMapType, int[]> heightMaps = set.getHeightMaps();
for (Map.Entry<HeightMapType, int[]> entry : heightMaps.entrySet()) {
BitArray bitArray = new BitArray(9, 256);
bitArray.fromRaw(entry.getValue());
nmsChunk.heightMap.get(HeightMap.Type.valueOf(entry.getKey().name())).a(bitArray.getData());
}
boolean lightUpdate = false;
// Lighting

Datei anzeigen

@ -12,6 +12,7 @@ public class BlockMaterial_1_16_1 implements BlockMaterial {
private final boolean isTranslucent;
private final CraftBlockData craftBlockData;
private final org.bukkit.Material craftMaterial;
private final int opacity;
public BlockMaterial_1_16_1(Block block) {
this(block, block.getBlockData());
@ -23,7 +24,9 @@ public class BlockMaterial_1_16_1 implements BlockMaterial {
this.material = defaultState.getMaterial();
this.craftBlockData = CraftBlockData.fromData(defaultState);
this.craftMaterial = craftBlockData.getMaterial();
this.isTranslucent = !(boolean) ReflectionUtil.getField(Block.class, block, "at"); //TODO Update Mapping for 1.16.1
BlockBase.Info blockInfo = ReflectionUtil.getField(Block.class, block, "aB");
this.isTranslucent = !(boolean)ReflectionUtil.getField(BlockBase.Info.class, blockInfo, "n");
opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
}
public Block getBlock() {
@ -94,7 +97,7 @@ public class BlockMaterial_1_16_1 implements BlockMaterial {
@Override
public int getLightOpacity() {
return !isTranslucent() ? 15 : 0;
return opacity;
}
@Override

Datei anzeigen

@ -238,7 +238,7 @@ public final class BukkitAdapter_1_16_1 extends NMSAdapter {
if (num_palette == 1) {
for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0;
} else {
final BitArrayUnstretched bitArray = new BitArrayUnstretched(bitsPerEntry, blockStates);
final BitArrayUnstretched bitArray = new BitArrayUnstretched(bitsPerEntry, 4096, blockStates);
bitArray.fromRaw(blocksCopy);
}

Datei anzeigen

@ -5,11 +5,13 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.blocks.CharBlocks;
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.bukkit.adapter.mc1_16_1.nbt.LazyCompoundTag_1_16_1;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.AdaptedMap;
import com.boydti.fawe.object.collection.BitArray;
import com.boydti.fawe.object.collection.BitArrayUnstretched;
import com.google.common.base.Suppliers;
import com.google.common.collect.Iterables;
@ -143,6 +145,12 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
return blockLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l)));
}
@Override public int[] getHeightMap(HeightMapType type) {
long[] longArray = getChunk().heightMap.get(HeightMap.Type.valueOf(type.name())).a();
BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256, longArray);
return bitArray.toRaw(new int[256]);
}
@Override
public CompoundTag getEntity(UUID uuid) {
Entity entity = world.getEntity(uuid);
@ -359,6 +367,13 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
}
}
Map<HeightMapType, int[]> heightMaps = set.getHeightMaps();
for (Map.Entry<HeightMapType, int[]> entry : heightMaps.entrySet()) {
BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256);
bitArray.fromRaw(entry.getValue());
nmsChunk.heightMap.get(HeightMap.Type.valueOf(entry.getKey().name())).a(bitArray.getData());
}
boolean lightUpdate = false;
// Lighting
@ -567,7 +582,7 @@ public class BukkitGetBlocks_1_16_1 extends CharGetBlocks {
final int bitsPerEntry = (int) BukkitAdapter_1_16_1.fieldBitsPerEntry.get(bits);
final long[] blockStates = bits.a();
new BitArrayUnstretched(bitsPerEntry, blockStates).toRaw(data);
new BitArrayUnstretched(bitsPerEntry, 4096, blockStates).toRaw(data);
int num_palette;
if (palette instanceof DataPaletteLinear) {

Datei anzeigen

@ -12,6 +12,7 @@ public class BlockMaterial_1_16_2 implements BlockMaterial {
private final boolean isTranslucent;
private final CraftBlockData craftBlockData;
private final org.bukkit.Material craftMaterial;
private final int opacity;
public BlockMaterial_1_16_2(Block block) {
this(block, block.getBlockData());
@ -23,7 +24,9 @@ public class BlockMaterial_1_16_2 implements BlockMaterial {
this.material = defaultState.getMaterial();
this.craftBlockData = CraftBlockData.fromData(defaultState);
this.craftMaterial = craftBlockData.getMaterial();
this.isTranslucent = !(boolean) ReflectionUtil.getField(Block.class, block, "at"); //TODO Update Mapping for 1.16.1
BlockBase.Info blockInfo = ReflectionUtil.getField(Block.class, block, "aB");
this.isTranslucent = !(boolean)ReflectionUtil.getField(BlockBase.Info.class, blockInfo, "n");
opacity = defaultState.b(BlockAccessAir.INSTANCE, BlockPosition.ZERO);
}
public Block getBlock() {
@ -94,7 +97,7 @@ public class BlockMaterial_1_16_2 implements BlockMaterial {
@Override
public int getLightOpacity() {
return !isTranslucent() ? 15 : 0;
return opacity;
}
@Override

Datei anzeigen

@ -253,7 +253,7 @@ public final class BukkitAdapter_1_16_2 extends NMSAdapter {
if (num_palette == 1) {
for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0;
} else {
final BitArrayUnstretched bitArray = new BitArrayUnstretched(bitsPerEntry, blockStates);
final BitArrayUnstretched bitArray = new BitArrayUnstretched(bitsPerEntry, 4096, blockStates);
bitArray.fromRaw(blocksCopy);
}

Datei anzeigen

@ -5,11 +5,13 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.blocks.CharBlocks;
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.beta.implementation.queue.QueueHandler;
import com.boydti.fawe.bukkit.adapter.DelegateLock;
import com.boydti.fawe.bukkit.adapter.mc1_16_2.nbt.LazyCompoundTag_1_16_2;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.AdaptedMap;
import com.boydti.fawe.object.collection.BitArray;
import com.boydti.fawe.object.collection.BitArrayUnstretched;
import com.google.common.base.Suppliers;
import com.google.common.collect.Iterables;
@ -143,6 +145,12 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
return blockLight[layer].a(SectionPosition.b(BlockPosition.b(l)), SectionPosition.b(BlockPosition.c(l)), SectionPosition.b(BlockPosition.d(l)));
}
@Override public int[] getHeightMap(HeightMapType type) {
long[] longArray = getChunk().heightMap.get(HeightMap.Type.valueOf(type.name())).a();
BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256, longArray);
return bitArray.toRaw(new int[256]);
}
@Override
public CompoundTag getEntity(UUID uuid) {
Entity entity = world.getEntity(uuid);
@ -359,6 +367,13 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
}
}
Map<HeightMapType, int[]> heightMaps = set.getHeightMaps();
for (Map.Entry<HeightMapType, int[]> entry : heightMaps.entrySet()) {
BitArrayUnstretched bitArray = new BitArrayUnstretched(9, 256);
bitArray.fromRaw(entry.getValue());
nmsChunk.heightMap.get(HeightMap.Type.valueOf(entry.getKey().name())).a(bitArray.getData());
}
boolean lightUpdate = false;
// Lighting
@ -567,7 +582,7 @@ public class BukkitGetBlocks_1_16_2 extends CharGetBlocks {
final int bitsPerEntry = (int) BukkitAdapter_1_16_2.fieldBitsPerEntry.get(bits);
final long[] blockStates = bits.a();
new BitArrayUnstretched(bitsPerEntry, blockStates).toRaw(data);
new BitArrayUnstretched(bitsPerEntry, 4096, blockStates).toRaw(data);
int num_palette;
if (palette instanceof DataPaletteLinear) {

Datei anzeigen

@ -110,8 +110,6 @@ public final class FAWE_Spigot_v1_16_R2 extends CachedBukkitAdapter implements I
public BlockMaterial getMaterial(BlockState state) {
IBlockData bs = ((CraftBlockData) Bukkit.createBlockData(state.getAsString())).getState();
return new BlockMaterial_1_16_2(bs.getBlock(), bs);
}
public Block getBlock(BlockType blockType) {

Datei anzeigen

@ -373,7 +373,7 @@ public class FaweAPI {
}
}
NMSRelighter relighter = new NMSRelighter(queue);
NMSRelighter relighter = new NMSRelighter(queue, Settings.IMP.LIGHTING.DO_HEIGHTMAPS);
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
relighter.addChunk(x, z, null, 65535);

Datei anzeigen

@ -375,7 +375,7 @@ public enum FaweCache implements Trimable {
blockStates[0] = 0;
blockBitArrayEnd = 1;
} else {
BitArrayUnstretched bitArray = new BitArrayUnstretched(bitsPerEntry, blockStates);
BitArrayUnstretched bitArray = new BitArrayUnstretched(bitsPerEntry, 4096, blockStates);
bitArray.fromRaw(blocksCopy);
}

Datei anzeigen

@ -1,5 +1,6 @@
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.world.biome.BiomeType;
@ -29,6 +30,9 @@ public interface IChunkGet extends IBlocks, Trimable, InputExtent, ITileInput {
@Override
int getEmmittedLight(int x, int y, int z);
@Override
int[] getHeightMap(HeightMapType type);
default void optimize() {
}

Datei anzeigen

@ -1,11 +1,14 @@
package com.boydti.fawe.beta;
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.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Nullable;
@ -34,6 +37,9 @@ public interface IChunkSet extends IBlocks, OutputExtent {
@Override
void setSkyLight(int x, int y, int z, int value);
@Override
void setHeightMap(HeightMapType type, int[] heightMap);
void setLightLayer(int layer, char[] toSet);
void setSkyLightLayer(int layer, char[] toSet);
@ -76,6 +82,10 @@ public interface IChunkSet extends IBlocks, OutputExtent {
return -1;
}
default Map<HeightMapType, int[]> getHeightMaps() {
return new HashMap<>();
}
@Override
IChunkSet reset();

Datei anzeigen

@ -2,6 +2,7 @@ package com.boydti.fawe.beta.implementation.blocks;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.object.collection.MemBlockSet;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.math.BlockVector3;
@ -71,6 +72,8 @@ public class BitSetBlocks implements IChunkSet {
@Override public void setSkyLight(int x, int y, int z, int value) {}
@Override public void setHeightMap(HeightMapType type, int[] heightMap) {}
@Override public void setLightLayer(int layer, char[] toSet) {}
@Override public void setSkyLightLayer(int layer, char[] toSet) {}

Datei anzeigen

@ -2,6 +2,7 @@ package com.boydti.fawe.beta.implementation.blocks;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.beta.implementation.queue.Pool;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.collection.BlockVector3ChunkMap;
@ -14,6 +15,7 @@ import org.jetbrains.annotations.Range;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@ -32,6 +34,7 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
public BlockVector3ChunkMap<CompoundTag> tiles;
public HashSet<CompoundTag> entities;
public HashSet<UUID> entityRemoves;
public Map<HeightMapType, int[]> heightMaps;
private boolean fastMode = false;
private int bitMask = -1;
@ -73,6 +76,11 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
return entityRemoves == null ? Collections.emptySet() : entityRemoves;
}
@Override
public Map<HeightMapType, int[]> getHeightMaps() {
return heightMaps == null ? new HashMap<>() : heightMaps;
}
@Override
public boolean setBiome(int x, int y, int z, BiomeType biome) {
if (biomes == null) {
@ -138,6 +146,13 @@ public class CharSetBlocks extends CharBlocks implements IChunkSet {
skyLight[y >> 4][index] = (char) value;
}
@Override public void setHeightMap(HeightMapType type, int[] heightMap) {
if (heightMaps == null) {
heightMaps = new HashMap<>();
}
heightMaps.put(type, heightMap);
}
@Override public void setLightLayer(int layer, char[] toSet) {
if (light == null) {
light = new char[16][];

Datei anzeigen

@ -4,6 +4,7 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.IBlocks;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
@ -50,6 +51,10 @@ public class FallbackChunkGet implements IChunkGet {
return extent.getSkyLight(bx + x, y, bz + z);
}
@Override public int[] getHeightMap(HeightMapType type) {
return extent.getHeightMap(type);
}
@Override public int getEmmittedLight(int x, int y, int z) {
return extent.getEmmittedLight(bx + x, y, bz + z);
}

Datei anzeigen

@ -4,6 +4,7 @@ import com.boydti.fawe.FaweCache
import com.boydti.fawe.beta.IBlocks
import com.boydti.fawe.beta.IChunkGet
import com.boydti.fawe.beta.IChunkSet
import com.boydti.fawe.beta.implementation.lighting.HeightMapType
import com.sk89q.jnbt.CompoundTag
import com.sk89q.worldedit.math.BlockVector3
import com.sk89q.worldedit.world.biome.BiomeType
@ -72,6 +73,10 @@ object NullChunkGet : IChunkGet {
return 15
}
override fun getHeightMap(type: HeightMapType?): IntArray {
return IntArray(256)
}
override fun reset(): IBlocks? {
return null
}

Datei anzeigen

@ -8,6 +8,7 @@ import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.IQueueChunk;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.beta.implementation.queue.Pool;
import com.boydti.fawe.config.Settings;
import com.sk89q.jnbt.CompoundTag;
@ -192,6 +193,10 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
chunk.chunkSet.setSkyLightLayer(layer, toSet);
}
@Override public void setHeightMap(ChunkHolder chunk, HeightMapType type, int[] heightMap) {
chunk.chunkSet.setHeightMap(type, heightMap);
}
@Override
public BiomeType getBiome(ChunkHolder chunk, int x, int y, int z) {
return chunk.chunkExisting.getBiomeType(x, y, z);
@ -245,6 +250,10 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
public int getOpacity(ChunkHolder chunk, int x, int y, int z) {
return chunk.chunkExisting.getOpacity(x, y, z);
}
@Override public int[] getHeightMap(ChunkHolder chunk, HeightMapType type) {
return chunk.chunkExisting.getHeightMap(type);
}
};
private static final IBlockDelegate GET = new IBlockDelegate() {
@ -318,6 +327,12 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
chunk.setSkyLightLayer(layer, toSet);
}
@Override public void setHeightMap(ChunkHolder chunk, HeightMapType type, int[] heightMap) {
chunk.getOrCreateSet();
chunk.delegate = BOTH;
chunk.setHeightMap(type, heightMap);
}
@Override
public BiomeType getBiome(ChunkHolder chunk, int x, int y, int z) {
return chunk.chunkExisting.getBiomeType(x, y, z);
@ -353,6 +368,10 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
public int getOpacity(ChunkHolder chunk, int x, int y, int z) {
return chunk.chunkExisting.getOpacity(x, y, z);
}
@Override public int[] getHeightMap(ChunkHolder chunk, HeightMapType type) {
return chunk.chunkExisting.getHeightMap(type);
}
};
private static final IBlockDelegate SET = new IBlockDelegate() {
@ -409,6 +428,10 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
chunk.chunkSet.setSkyLightLayer(layer, toSet);
}
@Override public void setHeightMap(ChunkHolder chunk, HeightMapType type, int[] heightMap) {
chunk.chunkSet.setHeightMap(type, heightMap);
}
@Override
public BiomeType getBiome(ChunkHolder chunk, int x, int y, int z) {
chunk.getOrCreateGet();
@ -476,6 +499,12 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
chunk.delegate = BOTH;
return chunk.getOpacity(x, y, z);
}
@Override public int[] getHeightMap(ChunkHolder chunk, HeightMapType type) {
chunk.getOrCreateGet();
chunk.delegate = BOTH;
return chunk.getHeightMap(type);
}
};
private static final IBlockDelegate NULL = new IBlockDelegate() {
@ -575,6 +604,12 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
chunk.setSkyLightLayer(layer, toSet);
}
@Override public void setHeightMap(ChunkHolder chunk, HeightMapType type, int[] heightMap) {
chunk.getOrCreateSet();
chunk.delegate = SET;
chunk.setHeightMap(type, heightMap);
}
@Override
public int getSkyLight(ChunkHolder chunk, int x, int y, int z) {
chunk.getOrCreateGet();
@ -606,6 +641,13 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
chunk.chunkExisting.trim(false);
return chunk.getOpacity(x, y, z);
}
@Override public int[] getHeightMap(ChunkHolder chunk, HeightMapType type) {
chunk.getOrCreateGet();
chunk.delegate = GET;
chunk.chunkExisting.trim(false);
return chunk.getHeightMap(type);
}
};
@Override
@ -791,6 +833,10 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
delegate.setSkyLight(this, x, y, z, value);
}
@Override public void setHeightMap(HeightMapType type, int[] heightMap) {
delegate.setHeightMap(this, type, heightMap);
}
@Override public void removeSectionLighting(int layer, boolean sky) {
delegate.removeSectionLighting(this, layer, sky);
}
@ -834,6 +880,10 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return delegate.getOpacity(this, x, y, z);
}
@Override public int[] getHeightMap(HeightMapType type) {
return delegate.getHeightMap(this, type);
}
public interface IBlockDelegate {
<C extends Future<C>> IChunkGet get(ChunkHolder<C> chunk);
IChunkSet set(ChunkHolder chunk);
@ -860,6 +910,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
void setSkyLightLayer(ChunkHolder chunk, int layer, char[] toSet);
void setHeightMap(ChunkHolder chunk, HeightMapType type, int[] heightMap);
int getSkyLight(ChunkHolder chunk, int x, int y, int z);
int getEmmittedLight(ChunkHolder chunk, int x, int y, int z);
@ -867,5 +919,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
int getBrightness(ChunkHolder chunk, int x, int y, int z);
int getOpacity(ChunkHolder chunk, int x, int y, int z);
int[] getHeightMap(ChunkHolder chunk, HeightMapType type);
}
}

Datei anzeigen

@ -4,6 +4,7 @@ import com.boydti.fawe.beta.Filter
import com.boydti.fawe.beta.IChunkSet
import com.boydti.fawe.beta.IQueueChunk
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock
import com.boydti.fawe.beta.implementation.lighting.HeightMapType
import com.sk89q.jnbt.CompoundTag
import com.sk89q.worldedit.math.BlockVector3
import com.sk89q.worldedit.regions.Region
@ -74,6 +75,10 @@ object NullChunk : IQueueChunk<Nothing> {
return emptyArray()
}
override fun getHeightMap(type: HeightMapType?): IntArray {
return IntArray(256)
}
override fun getEmmittedLight(x: Int, y: Int, z: Int): Int {
return 15
}
@ -82,6 +87,10 @@ object NullChunk : IQueueChunk<Nothing> {
}
override fun setHeightMap(type: HeightMapType?, heightMap: IntArray?) {
}
override fun fullySupports3DBiomes(): Boolean {
return false
}

Datei anzeigen

@ -0,0 +1,5 @@
package com.boydti.fawe.beta.implementation.lighting;
public enum HeightMapType {
MOTION_BLOCKING, MOTION_BLOCKING_NO_LEAVES, OCEAN_FLOOR, WORLD_SURFACE
}

Datei anzeigen

@ -9,6 +9,7 @@ import com.boydti.fawe.object.collection.BlockVectorSet;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.registry.state.BooleanProperty;
import com.sk89q.worldedit.registry.state.DirectionalProperty;
import com.sk89q.worldedit.registry.state.EnumProperty;
import com.sk89q.worldedit.registry.state.Property;
@ -37,12 +38,14 @@ public class NMSRelighter implements Relighter {
private static final EnumProperty stairHalf;
private static final EnumProperty stairShape;
private static final EnumProperty slabHalf;
private static final BooleanProperty waterLogged;
static {
stairDirection = (DirectionalProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("facing");
stairHalf = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("half");
stairShape = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_STAIRS.getProperty("shape");
slabHalf = (EnumProperty) (Property<?>) BlockTypes.SANDSTONE_SLAB.getProperty("type");
waterLogged = (BooleanProperty) (Property<?>) BlockTypes.SANDSTONE_SLAB.getProperty("waterlogged");
}
public final MutableBlockVector3 mutableBlockPos = new MutableBlockVector3(0, 0, 0);
@ -50,20 +53,24 @@ public class NMSRelighter implements Relighter {
private final Map<Long, RelightSkyEntry> skyToRelight;
private final Object present = new Object();
private final Map<Long, Integer> chunksToSend;
private final Map<Long, Map<HeightMapType, int[]>> heightMaps;
private final ConcurrentLinkedQueue<RelightSkyEntry> extentdSkyToRelight = new ConcurrentLinkedQueue<>();
private final Map<Long, long[][][] /* z y x */> lightQueue;
private final AtomicBoolean lightLock = new AtomicBoolean(false);
private final ConcurrentHashMap<Long, long[][][]> concurrentLightQueue;
private final int maxY;
private final boolean calculateHeightMaps;
private boolean removeFirst;
public NMSRelighter(IQueueExtent<IQueueChunk> queue) {
public NMSRelighter(IQueueExtent<IQueueChunk> queue, boolean calculateHeightMaps) {
this.queue = queue;
this.skyToRelight = new Long2ObjectOpenHashMap<>(12);
this.lightQueue = new Long2ObjectOpenHashMap<>(12);
this.chunksToSend = new Long2ObjectOpenHashMap<>(12);
this.concurrentLightQueue = new ConcurrentHashMap<>(12);
this.heightMaps = new Long2ObjectOpenHashMap<>(12);
this.maxY = queue.getMaxY();
this.calculateHeightMaps = calculateHeightMaps;
}
@Override public boolean isEmpty() {
@ -93,7 +100,7 @@ public class NMSRelighter implements Relighter {
if (m2 == null) {
m2 = m1[x] = new long[4];
}
long value = m2[y >> 6] |= 1l << y;
m2[y >> 6] |= 1L << y;
}
public void addLightUpdate(int x, int y, int z) {
@ -125,11 +132,12 @@ public class NMSRelighter implements Relighter {
extentdSkyToRelight.clear();
skyToRelight.clear();
chunksToSend.clear();
heightMaps.clear();
lightQueue.clear();
}
public boolean addChunk(int cx, int cz, byte[] fix, int bitmask) {
RelightSkyEntry toPut = new RelightSkyEntry(cx, cz, fix, bitmask);
RelightSkyEntry toPut = new RelightSkyEntry(cx, cz, fix, bitmask, calculateHeightMaps);
extentdSkyToRelight.add(toPut);
return true;
}
@ -791,6 +799,14 @@ public class NMSRelighter implements Relighter {
int z = MathMan.unpairIntY(pair);
ChunkHolder<?> chunk = (ChunkHolder<?>) queue.getOrCreateChunk(x, z);
chunk.setBitMask(bitMask);
if (calculateHeightMaps && heightMaps != null) {
Map<HeightMapType, int[]> heightMapList = heightMaps.get(pair);
if (heightMapList != null) {
for (Map.Entry<HeightMapType, int[]> heightMapEntry : heightMapList.entrySet()) {
chunk.setHeightMap(heightMapEntry.getKey(), heightMapEntry.getValue());
}
}
}
iter.remove();
}
if (Settings.IMP.LIGHTING.ASYNC) {
@ -856,20 +872,35 @@ public class NMSRelighter implements Relighter {
private void fixSkyLighting(List<RelightSkyEntry> sorted) {
RelightSkyEntry[] chunks = sorted.toArray(new RelightSkyEntry[sorted.size()]);
boolean remove = this.removeFirst;
boolean heightMaps = this.calculateHeightMaps;
BlockVectorSet chunkSet = null;
if (remove || heightMaps) {
BlockVectorSet tmpSet = new BlockVectorSet();
if (remove) {
chunkSet = new BlockVectorSet();
BlockVectorSet tmpSet = new BlockVectorSet();
for (RelightSkyEntry chunk : chunks) {
tmpSet.add(chunk.x, 0, chunk.z);
}
}
for (RelightSkyEntry chunk : chunks) {
if (remove) {
int x = chunk.x;
int z = chunk.z;
if (tmpSet.contains(x + 1, 0, z) && tmpSet.contains(x - 1, 0, z) && tmpSet.contains(x, 0, z + 1) && tmpSet.contains(x, 0, z - 1)) {
if (tmpSet.contains(x + 1, 0, z) && tmpSet.contains(x - 1, 0, z) && tmpSet.contains(x, 0, z + 1) && tmpSet
.contains(x, 0, z - 1)) {
chunkSet.add(x, 0, z);
}
}
if (heightMaps) {
long pair = MathMan.pairInt(chunk.x, chunk.z);
this.heightMaps.putIfAbsent(pair, new HashMap<>());
Map<HeightMapType, int[]> heightMapList = this.heightMaps.get(pair);
heightMapList.putIfAbsent(HeightMapType.WORLD_SURFACE, new int[256]);
heightMapList.putIfAbsent(HeightMapType.OCEAN_FLOOR, new int[256]);
heightMapList.putIfAbsent(HeightMapType.MOTION_BLOCKING, new int[256]);
heightMapList.putIfAbsent(HeightMapType.MOTION_BLOCKING_NO_LEAVES, new int[256]);
}
}
}
for (int y = 255; y > 0; y--) {
for (RelightSkyEntry chunk : chunks) { // Propagate skylight
@ -893,17 +924,41 @@ public class NMSRelighter implements Relighter {
iChunk.removeSectionLighting(y >> 4, true);
}
Map<HeightMapType, int[]> heightMapList = null;
if (heightMaps) {
long pair = MathMan.pairInt(chunk.x, chunk.z);
heightMapList = this.heightMaps.get(pair);
}
for (int j = 0; j < 256; j++) {
int x = j & 15;
int z = j >> 4;
byte value = mask[j];
BlockMaterial material = iChunk.getBlock(x, y, z).getBlockType().getMaterial();
BlockState state = iChunk.getBlock(x, y, z);
BlockMaterial material = state.getMaterial();
int opacity = material.getLightOpacity();
int brightness = iChunk.getBrightness(x, y, z);
boolean solidNeedsLight = (!material.isSolid() || !material.isFullCube()) && material.getLightOpacity() > 0;
int brightness = material.getLightValue();
if (brightness > 1) {
addLightUpdate(bx + x, y, bz + z);
}
if (heightMaps) {
if (heightMapList.get(HeightMapType.WORLD_SURFACE)[j] == 0 && !material.isAir()) {
// MC Requires y+1
heightMapList.get(HeightMapType.WORLD_SURFACE)[j] = y + 1;
}
if (heightMapList.get(HeightMapType.OCEAN_FLOOR)[j] == 0 && material.isSolid()) {
heightMapList.get(HeightMapType.OCEAN_FLOOR)[j] = y + 1;
}
if (heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] == 0 && (material.isSolid() || material.isLiquid() || state.getState(waterLogged))) {
heightMapList.get(HeightMapType.MOTION_BLOCKING)[j] = y + 1;
}
if (heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] == 0 && (material.isSolid() || material.isLiquid() || state
.getState(waterLogged)) && !state.getBlockType().getId().toLowerCase().contains("leaves")) {
heightMapList.get(HeightMapType.MOTION_BLOCKING_NO_LEAVES)[j] = y + 1;
}
}
switch (value) {
case 0:
if (opacity > 1) {
@ -927,7 +982,7 @@ public class NMSRelighter implements Relighter {
case 14:
if (opacity >= value) {
mask[j] = 0;
if (solidNeedsLight) {
if (!isStairOrTrueTop(state, true) || !(isSlabOrTrueValue(state, "top") || isSlabOrTrueValue(state, "double"))) {
iChunk.setSkyLight(x, y, z, value);
} else {
iChunk.setSkyLight(x, y, z, 0);
@ -941,11 +996,11 @@ public class NMSRelighter implements Relighter {
}
break;
case 15:
if (opacity > 1) {
if (opacity > 0) {
value -= opacity;
mask[j] = value;
}
if (solidNeedsLight) {
if (!isStairOrTrueTop(state, true) || !(isSlabOrTrueValue(state, "top") || isSlabOrTrueValue(state, "double"))) {
iChunk.setSkyLight(x, y, z, value + opacity);
} else {
iChunk.setSkyLight(x, y, z, value);
@ -1081,7 +1136,7 @@ public class NMSRelighter implements Relighter {
public int bitmask;
public boolean smooth;
public RelightSkyEntry(int x, int z, byte[] fix, int bitmask) {
public RelightSkyEntry(int x, int z, byte[] fix, int bitmask, boolean heightmaps) {
this.x = x;
this.z = z;
byte[] array = new byte[256];

Datei anzeigen

@ -481,6 +481,8 @@ public class Settings extends Config {
public int MODE = 1;
@Comment({"If existing lighting should be removed before relighting"})
public boolean REMOVE_FIRST = true;
@Comment({"Calculate and set heightmaps when relighting"})
public boolean DO_HEIGHTMAPS = true;
}
public void reload(File file) {

Datei anzeigen

@ -6,6 +6,7 @@ import com.boydti.fawe.beta.IChunk;
import com.boydti.fawe.beta.IChunkSet;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.boydti.fawe.jnbt.streamer.StreamDelegate;
import com.boydti.fawe.jnbt.streamer.ValueReader;
import com.boydti.fawe.object.collection.BitArray;
@ -443,6 +444,10 @@ public class MCAChunk implements IChunk {
}
@Override public void setHeightMap(HeightMapType type, int[] heightMap) {
}
@Override public void removeSectionLighting(int layer, boolean sky) {}
@Override public void setFullBright(int layer) {}
@ -533,6 +538,10 @@ public class MCAChunk implements IChunk {
return 0;
}
@Override public int[] getHeightMap(HeightMapType type) {
return new int[256];
}
@Override
public BaseBlock getFullBlock(int x, int y, int z) {
BlockState block = getBlock(x, y, z);

Datei anzeigen

@ -1,5 +1,6 @@
package com.boydti.fawe.`object`.clipboard
import com.boydti.fawe.beta.implementation.lighting.HeightMapType
import com.sk89q.jnbt.CompoundTag
import com.sk89q.worldedit.WorldEditException
import com.sk89q.worldedit.entity.Entity
@ -49,6 +50,10 @@ object EmptyClipboard : Clipboard {
return null
}
override fun getHeightMap(type: HeightMapType?): IntArray {
return IntArray(256)
}
@Throws(WorldEditException::class)
override fun <T : BlockStateHolder<T>?> setBlock(position: BlockVector3, block: T): Boolean {
return false

Datei anzeigen

@ -11,13 +11,13 @@ public final class BitArrayUnstretched {
private final long mask;
private final int longLen;
public BitArrayUnstretched(int bitsPerEntry, long[] buffer) {
public BitArrayUnstretched(int bitsPerEntry, int arraySize, long[] buffer) {
this.bitsPerEntry = bitsPerEntry;
this.mask = (1L << bitsPerEntry) - 1L;
this.emptyBitCount = 64 % bitsPerEntry;
this.maxSeqLocIndex = 64 - (bitsPerEntry + emptyBitCount);
final int blocksPerLong = MathMan.floorZero((double) 64 / bitsPerEntry);
this.longLen = MathMan.ceilZero((float) 4096 / blocksPerLong);
this.longLen = MathMan.ceilZero((float) arraySize / blocksPerLong);
if (buffer.length < longLen) {
this.data = new long[longLen];
} else {
@ -25,6 +25,16 @@ public final class BitArrayUnstretched {
}
}
public BitArrayUnstretched(int bitsPerEntry, int arraySize) {
this.bitsPerEntry = bitsPerEntry;
this.mask = (1L << bitsPerEntry) - 1L;
this.emptyBitCount = 64 % bitsPerEntry;
this.maxSeqLocIndex = 64 - bitsPerEntry;
final int blocksPerLong = MathMan.floorZero((double) 64 / bitsPerEntry);
this.longLen = MathMan.ceilZero((float) arraySize / blocksPerLong);
this.data = new long[longLen];
}
public long[] getData() {
return data;
}
@ -61,7 +71,7 @@ public final class BitArrayUnstretched {
long l = 0;
for (int i = 0; i < longLen; i++) {
int lastVal;
for (; localStart <= maxSeqLocIndex && arrI < 4096; localStart += bitsPerEntry) {
for (; localStart <= maxSeqLocIndex && arrI < arr.length; localStart += bitsPerEntry) {
lastVal = arr[arrI++];
l |= ((long) lastVal << localStart);
}
@ -85,7 +95,7 @@ public final class BitArrayUnstretched {
for (int i = 0; i < longLen; i++) {
long l = data[i];
char lastVal;
for (; localStart <= maxSeqLocIndex && arrI < 4096; localStart += bitsPerEntry) {
for (; localStart <= maxSeqLocIndex && arrI < buffer.length; localStart += bitsPerEntry) {
lastVal = (char) (l >>> localStart & this.mask);
buffer[arrI++] = lastVal;
}
@ -104,7 +114,7 @@ public final class BitArrayUnstretched {
for (int i = 0; i < longLen; i++) {
long l = data[i];
char lastVal;
for (; localStart <= maxSeqLocIndex && arrI < 4096; localStart += bitsPerEntry) {
for (; localStart <= maxSeqLocIndex && arrI < buffer.length; localStart += bitsPerEntry) {
lastVal = (char) (l >>> localStart & this.mask);
buffer[arrI++] = lastVal;
}

Datei anzeigen

@ -0,0 +1,24 @@
package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.PassthroughExtent;
import java.util.function.Supplier;
/**
* An extent that delegates actions to another extent that may change at any time.
*/
public class SupplyingExtent extends PassthroughExtent {
private final Supplier<Extent> extentSupplier;
public SupplyingExtent(Supplier<Extent> extentSupplier) {
super(extentSupplier.get());
this.extentSupplier = extentSupplier;
}
@Override
public Extent getExtent() {
return this.extentSupplier.get();
}
}

Datei anzeigen

@ -2939,7 +2939,7 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
protected BiomeType getBiome(int x, int y, int z, BiomeType defaultBiomeType) {
environment.setCurrentBlock(x, y, z);
double scaledX = (x - zero.getX()) / unit.getX();
double scaledY = (x - zero.getY()) / unit.getX();
double scaledY = (y - zero.getY()) / unit.getY();
double scaledZ = (z - zero.getZ()) / unit.getZ();
try {

Datei anzeigen

@ -19,6 +19,7 @@
package com.sk89q.worldedit.command.argument;
import com.boydti.fawe.object.extent.SupplyingExtent;
import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@ -109,10 +110,10 @@ public class FactoryConverter<T> implements ArgumentConverter<T> {
if (extent instanceof World) {
parserContext.setWorld((World) extent);
}
parserContext.setExtent(new RequestExtent());
parserContext.setExtent(new SupplyingExtent(((Locatable) actor)::getExtent));
} else if (session.hasWorldOverride()) {
parserContext.setWorld(session.getWorldOverride());
parserContext.setExtent(new RequestExtent());
parserContext.setExtent(new SupplyingExtent(session::getWorldOverride));
}
parserContext.setSession(session);
parserContext.setRestricted(true);

Datei anzeigen

@ -19,6 +19,7 @@
package com.sk89q.worldedit.extent;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.util.DeprecationUtil;
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
@ -80,8 +81,7 @@ public interface InputExtent {
* @return the biome at the location
* @deprecated Biomes in Minecraft are 3D now, use {@link InputExtent#getBiome(BlockVector3)}
*/
@Deprecated
default BiomeType getBiome(BlockVector2 position) {
@Deprecated default BiomeType getBiome(BlockVector2 position) {
return getBiomeType(position.getX(), 0, position.getZ());
}
@ -108,11 +108,7 @@ public interface InputExtent {
* @apiNote This must be overridden by new subclasses. See {@link NonAbstractForCompatibility}
* for details
*/
@NonAbstractForCompatibility(
delegateName = "getBiome",
delegateParams = { BlockVector2.class }
)
default BiomeType getBiome(BlockVector3 position) {
@NonAbstractForCompatibility(delegateName = "getBiome", delegateParams = {BlockVector2.class}) default BiomeType getBiome(BlockVector3 position) {
DeprecationUtil.checkDelegatingOverride(getClass());
return getBiome(position.toBlockVector2());
@ -161,4 +157,8 @@ public interface InputExtent {
default int getOpacity(int x, int y, int z) {
return getFullBlock(x, y, z).getMaterial().getLightOpacity();
}
default int[] getHeightMap(HeightMapType type) {
return new int[256];
}
}

Datei anzeigen

@ -19,6 +19,7 @@
package com.sk89q.worldedit.extent;
import com.boydti.fawe.beta.implementation.lighting.HeightMapType;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.operation.Operation;
@ -158,6 +159,9 @@ public interface OutputExtent {
default void setSkyLight(int x, int y, int z, int value) {
}
default void setHeightMap(HeightMapType type, int[] heightMap) {
}
/**
* Return an {@link Operation} that should be called to tie up loose ends
* (such as to commit changes in a buffer).

Datei anzeigen

@ -311,18 +311,13 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
pasteBiomes &= Clipboard.this.hasBiomes();
MutableBlockVector3 blockVector3 = new MutableBlockVector3();
blockVector3.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
for (BlockVector3 pos : this) {
BaseBlock block = pos.getFullBlock(this);
int xx = pos.getX() + relx;
int yy = pos.getZ() + relz;
int zz = pos.getY() + rely;
if (hasBiomes() && pos.getBlockY() == 0) {
if (pasteBiomes && (xx != blockVector3.getBlockX() || zz != blockVector3.getBlockZ())) {
blockVector3.setComponents(xx, yy, zz);
extent.setBiome(blockVector3, Clipboard.this.getBiome(BlockVector3.at(pos.getX(), pos.getY(), pos.getZ())));
}
int yy = pos.getY() + rely;
int zz = pos.getZ() + relz;
if (pasteBiomes) {
extent.setBiome(xx, yy, zz, Clipboard.this.getBiome(BlockVector3.at(pos.getX(), pos.getY(), pos.getZ())));
}
if (!pasteAir && block.getBlockType().getMaterial().isAir()) {
continue;
@ -330,7 +325,7 @@ public interface Clipboard extends Extent, Iterable<BlockVector3>, Closeable {
if (pos.getY() < 0) {
throw new RuntimeException("Y-Position cannot be less than 0!");
}
extent.setBlock(xx, pos.getY() + rely, zz, block);
extent.setBlock(xx, yy, zz, block);
}
// Entity offset is the paste location subtract the clipboard origin (entity's location is already relative to the world origin)
final int entityOffsetX = to.getBlockX() - origin.getBlockX();