mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 20:16:41 +00:00
wip upstream merge
This commit is contained in:
@ -29,24 +29,7 @@ public class FaweCache {
|
||||
*/
|
||||
public final static byte[][] CACHE_Z = new byte[16][];
|
||||
|
||||
/**
|
||||
* Immutable biome cache
|
||||
*/
|
||||
public final static BiomeType[] CACHE_BIOME = new BiomeType[256];
|
||||
|
||||
public static final BiomeType getBiome(int id) {
|
||||
return CACHE_BIOME[id];
|
||||
}
|
||||
|
||||
static {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
CACHE_BIOME[i] = new BiomeType(i) {
|
||||
@Override
|
||||
public void setId(int id) {
|
||||
throw new IllegalStateException("Cannot set id");
|
||||
}
|
||||
};
|
||||
}
|
||||
CACHE_X[0] = new byte[4096];
|
||||
CACHE_Z[0] = new byte[4096];
|
||||
for (int y = 0; y < 16; y++) {
|
||||
|
@ -529,9 +529,9 @@ public class CFICommands extends MethodCommands {
|
||||
@CommandPermissions("worldedit.anvil.cfi")
|
||||
public void biome(FawePlayer fp, BiomeType biome, @Optional FawePrimitiveBinding.ImageUri image, @Optional Mask mask, @Switch('w') boolean disableWhiteOnly) throws ParameterException{
|
||||
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
|
||||
if (image != null) gen.setBiome(load(image), (byte) biome.getId(), !disableWhiteOnly);
|
||||
else if (mask != null) gen.setBiome(mask, (byte) biome.getId());
|
||||
else gen.setBiome((byte) biome.getId());
|
||||
if (image != null) gen.setBiome(load(image), biome, !disableWhiteOnly);
|
||||
else if (mask != null) gen.setBiome(mask, biome);
|
||||
else gen.setBiome(biome);
|
||||
msg("Set biome!").send(fp);
|
||||
assertSettings(fp).resetComponent();
|
||||
component(fp);
|
||||
|
@ -753,7 +753,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
int cx = x >> 4;
|
||||
int cz = z >> 4;
|
||||
lastSectionY = -1;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.boydti.fawe.jnbt.anvil;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.example.SimpleIntFaweChunk;
|
||||
import com.boydti.fawe.object.*;
|
||||
import com.boydti.fawe.object.brush.visualization.VirtualWorld;
|
||||
@ -17,6 +16,7 @@ import com.boydti.fawe.util.image.ImageViewer;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
@ -744,7 +744,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
int index = z * getWidth() + x;
|
||||
if (index < 0 || index >= getArea()) return false;
|
||||
biomes.setByte(index, (byte) biome.getId());
|
||||
biomes.setByte(index, (byte) biome.getInternalId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -920,7 +920,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
int index = z * getWidth() + x;
|
||||
if (index < 0 || index >= getArea()) index = Math.floorMod(index, getArea());
|
||||
return biomes.getByte(index) & 0xFF;
|
||||
@ -1011,7 +1011,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return FaweCache.CACHE_BIOME[getBiomeId(position.getBlockX(), position.getBlockZ())];
|
||||
return BiomeTypes.get(getBiomeType(position.getBlockX(), position.getBlockZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1069,9 +1069,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
return heights.getByte(index) & 0xFF;
|
||||
}
|
||||
|
||||
public void setBiome(BufferedImage img, byte biome, boolean white) {
|
||||
public void setBiome(BufferedImage img, BiomeType biome, boolean white) {
|
||||
if (img.getWidth() != getWidth() || img.getHeight() != getLength())
|
||||
throw new IllegalArgumentException("Input image dimensions do not match the current height map!");
|
||||
byte biomeByte = (byte) biome.getInternalId();
|
||||
biomes.record(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -1082,7 +1083,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
int height = img.getRGB(x, z) & 0xFF;
|
||||
if (height == 255 || height > 0 && !white && ThreadLocalRandom.current()
|
||||
.nextInt(256) <= height) {
|
||||
biomeArr[index] = biome;
|
||||
biomeArr[index] = biomeByte;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1317,8 +1318,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}));
|
||||
}
|
||||
|
||||
public void setBiome(Mask mask, byte biome) {
|
||||
public void setBiome(Mask mask, BiomeType biome) {
|
||||
int index = 0;
|
||||
byte biomeByte = (byte) biome.getInternalId();
|
||||
for (int z = 0; z < getLength(); z++) {
|
||||
mutable.mutZ(z);
|
||||
for (int x = 0; x < getWidth(); x++, index++) {
|
||||
@ -1326,7 +1328,7 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
if (mask.test(mutable)) {
|
||||
biomes.setByte(index, biome);
|
||||
biomes.setByte(index, biomeByte);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1528,8 +1530,8 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
|
||||
}
|
||||
}
|
||||
|
||||
public void setBiome(int biome) {
|
||||
biomes.record(() -> Arrays.fill(biomes.get(), (byte) biome));
|
||||
public void setBiome(BiomeType biome) {
|
||||
biomes.record(() -> Arrays.fill(biomes.get(), (byte) biome.getInternalId()));
|
||||
}
|
||||
|
||||
public void setFloor(Pattern value) {
|
||||
|
@ -90,7 +90,7 @@ public class MCAQueue extends NMSMappedFaweQueue<FaweQueue, FaweChunk, FaweChunk
|
||||
if (faweChunk instanceof MCAChunk) {
|
||||
return ((MCAChunk) faweChunk).getBiomeArray()[((z & 0xF) << 4 | x & 0xF)];
|
||||
} else if (parent != null) {
|
||||
return parent.getBiomeId(x, z);
|
||||
return parent.getBiomeType(x, z);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public class DeleteBiomeFilterSimple extends MCAFilterCounter {
|
||||
private final int id;
|
||||
|
||||
public DeleteBiomeFilterSimple(BiomeType biome) {
|
||||
this.id = biome.getId();
|
||||
this.id = biome.getInternalId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,9 +45,9 @@ public class ChangeSetFaweQueue extends DelegateFaweQueue {
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, BiomeType biome) {
|
||||
if (super.setBiome(x, z, biome)) {
|
||||
int oldBiome = getParent().getBiomeId(x, z);
|
||||
if (oldBiome != biome.getId()) {
|
||||
set.addBiomeChange(x, z, FaweCache.getBiome(oldBiome), biome);
|
||||
BiomeType oldBiome = getParent().getBiomeType(x, z);
|
||||
if (oldBiome != biome) {
|
||||
set.addBiomeChange(x, z, oldBiome, biome);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract byte[] getBiomeArray();
|
||||
public abstract BiomeType[] getBiomeArray();
|
||||
|
||||
public void forEachQueuedBlock(FaweChunkVisitor onEach) {
|
||||
for (int y = 0; y < HEIGHT; y++) {
|
||||
@ -290,7 +290,7 @@ public abstract class FaweChunk<T> implements Callable<FaweChunk> {
|
||||
public abstract CompoundTag getTile(int x, int y, int z);
|
||||
|
||||
public void setBiome(final int x, final int z, final BiomeType biome) {
|
||||
setBiome(x, z, (byte) biome.getId());
|
||||
setBiome(x, z, biome);
|
||||
}
|
||||
|
||||
public abstract void setBiome(final int x, final int z, final byte biome);
|
||||
|
@ -400,7 +400,7 @@ public interface FaweQueue extends HasFaweQueue, Extent {
|
||||
return getCombinedId4Data(x, y, z) != 0;
|
||||
}
|
||||
|
||||
int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException;
|
||||
BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException;
|
||||
|
||||
int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException;
|
||||
|
||||
|
@ -9,6 +9,7 @@ import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.util.SetQueue;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
@ -62,7 +63,7 @@ public abstract class ImmutableVirtualWorld implements VirtualWorld {
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return FaweCache.getBiome(0);
|
||||
return BiomeTypes.FOREST;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,31 +5,32 @@ import com.sk89q.worldedit.history.UndoContext;
|
||||
import com.sk89q.worldedit.history.change.Change;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
|
||||
public class MutableBiomeChange implements Change {
|
||||
|
||||
private MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
private BiomeType from;
|
||||
private BiomeType to;
|
||||
private int from;
|
||||
private int to;
|
||||
|
||||
public MutableBiomeChange() {
|
||||
this.from = new BiomeType(0);
|
||||
this.to = new BiomeType(0);
|
||||
this.from = 0;
|
||||
this.to = 0;
|
||||
}
|
||||
|
||||
public void setBiome(int x, int z, int from, int to) {
|
||||
mutable.setComponents(x, z);
|
||||
this.from.setId(from);
|
||||
this.to.setId(to);
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void undo(UndoContext context) throws WorldEditException {
|
||||
context.getExtent().setBiome(mutable, from);
|
||||
context.getExtent().setBiome(mutable, BiomeTypes.get(from));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redo(UndoContext context) throws WorldEditException {
|
||||
context.getExtent().setBiome(mutable, to);
|
||||
context.getExtent().setBiome(mutable, BiomeTypes.get(to));
|
||||
}
|
||||
}
|
||||
|
@ -268,16 +268,16 @@ public abstract class FaweChangeSet implements ChangeSet {
|
||||
synchronized (FaweChangeSet.this) {
|
||||
// Biome changes
|
||||
if (previous.getBiomeArray() != null) {
|
||||
byte[] previousBiomes = previous.getBiomeArray();
|
||||
byte[] nextBiomes = next.getBiomeArray();
|
||||
BiomeType[] previousBiomes = previous.getBiomeArray();
|
||||
BiomeType[] nextBiomes = next.getBiomeArray();
|
||||
int index = 0;
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int zz = bz + z;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
byte idFrom = previousBiomes[index];
|
||||
byte idTo = nextBiomes[index];
|
||||
if (idFrom != idTo && idTo != 0) {
|
||||
addBiomeChange(bx + x, zz, FaweCache.getBiome(idFrom & 0xFF), FaweCache.getBiome(idTo & 0xFF));
|
||||
BiomeType idFrom = previousBiomes[index];
|
||||
BiomeType idTo = nextBiomes[index];
|
||||
if (idFrom != idTo && idTo != null) {
|
||||
addBiomeChange(bx + x, zz, idFrom, idTo);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
@ -337,8 +337,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
os.write((byte) (z >> 16));
|
||||
os.write((byte) (z >> 8));
|
||||
os.write((byte) (z));
|
||||
os.write(from.getId());
|
||||
os.write(to.getId());
|
||||
((FaweOutputStream) os).writeVarInt(from.getInternalId());
|
||||
((FaweOutputStream) os).writeVarInt(to.getInternalId());
|
||||
} catch (Throwable e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
@ -462,8 +462,8 @@ public abstract class FaweStreamChangeSet extends FaweChangeSet {
|
||||
if (int1 != -1) {
|
||||
int x = ((int1 << 24) + (is.read() << 16) + (is.read() << 8) + (is.read() << 0));
|
||||
int z = ((is.read() << 24) + (is.read() << 16) + (is.read() << 8) + (is.read() << 0));
|
||||
int from = is.read();
|
||||
int to = is.read();
|
||||
int from = ((FaweInputStream) is).readVarInt();
|
||||
int to = ((FaweInputStream) is).readVarInt();
|
||||
change.setBiome(x, z, from, to);
|
||||
return change;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
private int area;
|
||||
private int volume;
|
||||
|
||||
private byte[] biomes = null;
|
||||
private BiomeType[] biomes = null;
|
||||
private int[] states;
|
||||
|
||||
private final HashMap<IntegerTrio, CompoundTag> nbtMapLoc;
|
||||
@ -65,11 +65,11 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int index, int biome) {
|
||||
public void setBiome(int index, BiomeType biome) {
|
||||
if (biomes == null) {
|
||||
biomes = new byte[area];
|
||||
biomes = new BiomeType[area];
|
||||
}
|
||||
biomes[index] = (byte) biome;
|
||||
biomes[index] = biome;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,7 +88,7 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
||||
if (!hasBiomes()) {
|
||||
return null;
|
||||
}
|
||||
return FaweCache.CACHE_BIOME[biomes[index] & 0xFF];
|
||||
return biomes[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,7 +71,7 @@ public abstract class ReadOnlyClipboard extends FaweClipboard {
|
||||
int index = 0;
|
||||
for (int z = 0; z <= dim.getBlockZ(); z++) {
|
||||
for (int x = 0; x <= dim.getBlockX(); x++, index++) {
|
||||
task.run(index, getBiome(x, z).getId());
|
||||
task.run(index, getBiome(x, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,11 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.HasFaweQueue;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.jnbt.*;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
@ -18,7 +17,6 @@ import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
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;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -107,7 +105,7 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(final BlockVector2 position) {
|
||||
return FaweCache.CACHE_BIOME[queue.getBiomeId(position.getBlockX(), position.getBlockZ())];
|
||||
return BiomeTypes.get(queue.getBiomeType(position.getBlockX(), position.getBlockZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,7 +103,7 @@ public class PatternExtent extends AbstractPattern implements Extent {
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
return new BiomeType(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,8 +58,8 @@ public class FaweQueueDelegateExtent extends DelegateFaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return parentExtent.getBiome(BlockVector2.at(x, z)).getId();
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return parentExtent.getBiome(BlockVector2.at(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -343,8 +343,8 @@ public interface IDelegateFaweQueue extends FaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
default int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return getQueue().getBiomeId(x, z);
|
||||
default BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return getQueue().getBiomeType(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -183,7 +183,7 @@ public class NullFaweQueue implements FaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -578,7 +578,7 @@ public class SchemVis extends ImmutableVirtualWorld {
|
||||
public void sendChunk(int x, int z, int bitMask) { /* do nothing - never used*/ }
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
public BiomeType getBiomeType(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
// TODO later (currently not used)
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.biome.Biomes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -94,7 +95,7 @@ public class FaweLocalBlockQueue extends LocalBlockQueue {
|
||||
if (reg == null) {
|
||||
reg = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.USER_COMMANDS).getRegistries().getBiomeRegistry();
|
||||
}
|
||||
List<BiomeType> biomes = reg.getBiomes();
|
||||
List<BiomeType> biomes = BiomeTypes.values();
|
||||
lastBiome = biome;
|
||||
this.biome = Biomes.findBiomeByName(biomes, biome, reg);
|
||||
}
|
||||
|
@ -12,6 +12,9 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import jdk.internal.reflect.ConstructorAccessor;
|
||||
import jdk.internal.reflect.FieldAccessor;
|
||||
import sun.reflect.ConstructorAccessor;
|
||||
import sun.reflect.FieldAccessor;
|
||||
import sun.reflect.ReflectionFactory;
|
||||
|
Reference in New Issue
Block a user