mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Support v2 schematics properly. No 3D biomes are supported by it as yet. (#2716)
This commit is contained in:
@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -34,6 +35,10 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
BiomeType biome = world.G_SCH_B.get(MathMan.pair(relativeX, relativeZ));
|
||||
if (biome != null) {
|
||||
result.setBiome(x, z, biome);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void generateChunk(@NotNull ScopedLocalBlockQueue result, @NotNull PlotArea settings) {
|
||||
|
@ -118,6 +118,12 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
BiomeType biome = hybridPlotWorld.G_SCH_B.get(MathMan.pair(absX, absZ));
|
||||
if (biome != null) {
|
||||
queue.setBiome(x, z, biome);
|
||||
} else {
|
||||
queue.setBiome(x, z, hybridPlotWorld.PLOT_BIOME);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,12 @@ import com.sk89q.jnbt.CompoundTagBuilder;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||
import com.sk89q.worldedit.internal.helper.MCDirections;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -36,6 +38,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
public short PATH_WIDTH_LOWER;
|
||||
public short PATH_WIDTH_UPPER;
|
||||
public HashMap<Integer, BaseBlock[]> G_SCH;
|
||||
public HashMap<Integer, BiomeType> G_SCH_B;
|
||||
public int SCHEM_Y;
|
||||
private Location SIGN_LOCATION;
|
||||
|
||||
@ -211,6 +214,10 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
id, false, h3);
|
||||
}
|
||||
}
|
||||
BiomeType biome = blockArrayClipboard3
|
||||
.getBiome(BlockVector2.at(x + min.getBlockX(), z + min.getBlockZ()));
|
||||
addOverlayBiome((short) (x + shift + oddshift + centerShiftX),
|
||||
(short) (z + shift + oddshift + centerShiftZ), biome);
|
||||
}
|
||||
}
|
||||
/* HashMap<BlockLoc, CompoundTag> items = schematic3.getTiles();
|
||||
@ -319,4 +326,19 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
}
|
||||
existing[y] = id;
|
||||
}
|
||||
|
||||
public void addOverlayBiome(short x, short z, BiomeType id) {
|
||||
if (z < 0) {
|
||||
z += this.SIZE;
|
||||
} else if (z >= this.SIZE) {
|
||||
z -= this.SIZE;
|
||||
}
|
||||
if (x < 0) {
|
||||
x += this.SIZE;
|
||||
} else if (x >= this.SIZE) {
|
||||
x -= this.SIZE;
|
||||
}
|
||||
int pair = MathMan.pair(x, z);
|
||||
this.G_SCH_B.put(pair, id);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
@ -613,6 +614,14 @@ public abstract class HybridUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
BiomeType biome = plotWorld.G_SCH_B.get(MathMan.pair(absX, absZ));
|
||||
if (biome != null) {
|
||||
queue.setBiome(finalX + X + plotWorld.ROAD_OFFSET_X,
|
||||
finalZ + Z + plotWorld.ROAD_OFFSET_Z, biome);
|
||||
} else {
|
||||
queue.setBiome(finalX + X + plotWorld.ROAD_OFFSET_X,
|
||||
finalZ + Z + plotWorld.ROAD_OFFSET_Z, plotWorld.PLOT_BIOME);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -234,6 +235,11 @@ public abstract class SchematicHandler {
|
||||
BaseBlock id = blockArrayClipboard
|
||||
.getFullBlock(BlockVector3.at(rx, ry, rz));
|
||||
queue.setBlock(xx, yy, zz, id);
|
||||
if (ry == 0) {
|
||||
BiomeType biome =
|
||||
blockArrayClipboard.getBiome(BlockVector2.at(rx, rz));
|
||||
queue.setBiome(xx, zz, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -392,7 +398,7 @@ public abstract class SchematicHandler {
|
||||
TaskManager.runTask(whenDone);
|
||||
return;
|
||||
}
|
||||
MainUtil.upload(uuid, file, "schematic", new RunnableVal<OutputStream>() {
|
||||
MainUtil.upload(uuid, file, "schem", new RunnableVal<OutputStream>() {
|
||||
@Override public void run(OutputStream output) {
|
||||
try (NBTOutputStream nos = new NBTOutputStream(
|
||||
new GZIPOutputStream(output, true))) {
|
||||
@ -444,7 +450,7 @@ public abstract class SchematicHandler {
|
||||
}
|
||||
|
||||
|
||||
public class UnsupportedFormatException extends Exception {
|
||||
public static class UnsupportedFormatException extends Exception {
|
||||
/**
|
||||
* Throw with a message.
|
||||
*
|
||||
|
@ -24,6 +24,7 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue {
|
||||
private LocalChunk lastWrappedChunk;
|
||||
private int lastX = Integer.MIN_VALUE;
|
||||
private int lastZ = Integer.MIN_VALUE;
|
||||
private boolean setbiome = false;
|
||||
|
||||
public BasicLocalBlockQueue(String world) {
|
||||
super(world);
|
||||
@ -139,9 +140,14 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue {
|
||||
}
|
||||
}
|
||||
result.setBiome(x & 15, z & 15, biomeType);
|
||||
setbiome = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public final boolean setBiome() {
|
||||
return setbiome;
|
||||
}
|
||||
|
||||
public final void setChunk(LocalChunk chunk) {
|
||||
LocalChunk previous = this.blockChunks.put(chunk.longHash(), chunk);
|
||||
if (previous != null) {
|
||||
|
@ -80,6 +80,10 @@ public class DelegateLocalBlockQueue extends LocalBlockQueue {
|
||||
return parent.setBiome(x, z, biome);
|
||||
}
|
||||
|
||||
@Override public boolean setBiome() {
|
||||
return parent.setBiome();
|
||||
}
|
||||
|
||||
@Override public String getWorld() {
|
||||
return parent.getWorld();
|
||||
}
|
||||
|
@ -73,6 +73,8 @@ public abstract class LocalBlockQueue {
|
||||
|
||||
public abstract boolean setBiome(int x, int z, BiomeType biome);
|
||||
|
||||
public abstract boolean setBiome();
|
||||
|
||||
public abstract String getWorld();
|
||||
|
||||
public abstract void flush();
|
||||
|
Reference in New Issue
Block a user