mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-09 09:59:48 +01:00
Merge remote-tracking branch 'origin/breaking' into breaking
This commit is contained in:
commit
1ca50cdbd2
@ -3,14 +3,10 @@ package com.github.intellectualsites.plotsquared.plot.generator;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
public class HybridGen extends IndependentPlotGenerator {
|
public class HybridGen extends IndependentPlotGenerator {
|
||||||
|
|
||||||
@ -21,12 +17,11 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX,
|
private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX,
|
||||||
short relativeZ, int x, int z) {
|
short relativeZ, int x, int z) {
|
||||||
int minY = Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT);
|
int minY = Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT);
|
||||||
String[] blocks = world.G_SCH.get(MathMan.pair(relativeX, relativeZ));
|
BaseBlock[] blocks = world.G_SCH.get(MathMan.pair(relativeX, relativeZ));
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (int y = 0; y < blocks.length; y++) {
|
for (int y = 0; y < blocks.length; y++) {
|
||||||
if (blocks[y] != null) {
|
if (blocks[y] != null) {
|
||||||
PlotBlock block = PlotBlock.get(blocks[y]);
|
result.setBlock(x, minY + y, z, blocks[y]);
|
||||||
result.setBlock(x, minY + y, z, block);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +86,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// generation
|
// generation
|
||||||
HashMap<Integer, String[]> sch = hpw.G_SCH;
|
HashMap<Integer, BaseBlock[]> sch = hpw.G_SCH;
|
||||||
for (short x = 0; x < 16; x++) {
|
for (short x = 0; x < 16; x++) {
|
||||||
if (gx[x]) {
|
if (gx[x]) {
|
||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
@ -160,7 +155,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean populateChunk(ScopedLocalBlockQueue result, PlotArea settings) {
|
/* @Override public boolean populateChunk(ScopedLocalBlockQueue result, PlotArea settings) {
|
||||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
||||||
if (hpw.G_SCH_STATE != null) {
|
if (hpw.G_SCH_STATE != null) {
|
||||||
Location min = result.getMin();
|
Location min = result.getMin();
|
||||||
@ -220,7 +215,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
@Override public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||||
return new HybridPlotWorld(world, id, this, min, max);
|
return new HybridPlotWorld(world, id, this, min, max);
|
||||||
|
@ -9,6 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -89,12 +90,11 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
if (absZ < 0) {
|
if (absZ < 0) {
|
||||||
absZ += size;
|
absZ += size;
|
||||||
}
|
}
|
||||||
String[] blocks = hpw.G_SCH.get(MathMan.pair(absX, absZ));
|
BaseBlock[] blocks = hpw.G_SCH.get(MathMan.pair(absX, absZ));
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (int y = 0; y < blocks.length; y++) {
|
for (int y = 0; y < blocks.length; y++) {
|
||||||
if (blocks[y] != null) {
|
if (blocks[y] != null) {
|
||||||
PlotBlock block = PlotBlock.get(blocks[y]);
|
queue.setBlock(x, minY + y, z, blocks[y]);
|
||||||
queue.setBlock(x, minY + y, z, block);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,10 @@ package com.github.intellectualsites.plotsquared.plot.generator;
|
|||||||
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
|
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||||
@ -15,11 +18,14 @@ import com.sk89q.worldedit.internal.helper.MCDirections;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
|
import com.sk89q.worldedit.registry.state.DirectionalProperty;
|
||||||
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class HybridPlotWorld extends ClassicPlotWorld {
|
public class HybridPlotWorld extends ClassicPlotWorld {
|
||||||
|
|
||||||
@ -28,8 +34,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
public boolean PLOT_SCHEMATIC = false;
|
public boolean PLOT_SCHEMATIC = false;
|
||||||
public short PATH_WIDTH_LOWER;
|
public short PATH_WIDTH_LOWER;
|
||||||
public short PATH_WIDTH_UPPER;
|
public short PATH_WIDTH_UPPER;
|
||||||
public HashMap<Integer, String[]> G_SCH;
|
public HashMap<Integer, BaseBlock[]> G_SCH;
|
||||||
public HashMap<Integer, HashMap<Integer, CompoundTag>> G_SCH_STATE;
|
|
||||||
private Location SIGN_LOCATION;
|
private Location SIGN_LOCATION;
|
||||||
|
|
||||||
public HybridPlotWorld(String worldName, String id, IndependentPlotGenerator generator,
|
public HybridPlotWorld(String worldName, String id, IndependentPlotGenerator generator,
|
||||||
@ -54,10 +59,37 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
// FIXME depends on block ids
|
// FIXME depends on block ids
|
||||||
// Possibly make abstract?
|
// Possibly make abstract?
|
||||||
public static BaseBlock rotate(BaseBlock id) {
|
public static BaseBlock rotate(BaseBlock id) {
|
||||||
CompoundTag tag = id.toBaseBlock().getNbtData();
|
Map<Property<?>, Object> stateMap = id.getStates();
|
||||||
|
|
||||||
|
if (stateMap != null) {
|
||||||
|
for (Map.Entry<Property<?>, Object> entry : stateMap.entrySet()) {
|
||||||
|
if (entry.getKey() instanceof DirectionalProperty) {
|
||||||
|
Direction dir = (Direction) entry.getValue();
|
||||||
|
Property property = entry.getKey();
|
||||||
|
switch (dir) {
|
||||||
|
case NORTH:
|
||||||
|
id = id.with(property, Direction.EAST);
|
||||||
|
break;
|
||||||
|
case EAST:
|
||||||
|
id = id.with(property, Direction.SOUTH);
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
id = id.with(property, Direction.WEST);
|
||||||
|
break;
|
||||||
|
case WEST:
|
||||||
|
id = id.with(property, Direction.NORTH);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompoundTag tag = id.getNbtData();
|
||||||
|
|
||||||
if (tag != null) {
|
if (tag != null) {
|
||||||
// Handle blocks which store their rotation in NBT
|
// Handle blocks which store their rotation in NBT
|
||||||
|
PlotSquared.log(tag.getValue().toString());
|
||||||
if (tag.containsKey("Rot")) {
|
if (tag.containsKey("Rot")) {
|
||||||
int rot = tag.asInt("Rot");
|
int rot = tag.asInt("Rot");
|
||||||
|
|
||||||
@ -172,7 +204,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
for (short y = 0; y < h3; y++) {
|
for (short y = 0; y < h3; y++) {
|
||||||
BaseBlock id = blockArrayClipboard3.getFullBlock(BlockVector3.at(x, y, z))
|
BaseBlock id = blockArrayClipboard3.getFullBlock(BlockVector3.at(x, y, z))
|
||||||
.toBaseBlock();
|
.toBaseBlock();
|
||||||
if (!id.getBlockType().getId().toLowerCase().contains("air")) {
|
if (!id.getBlockType().getMaterial().isAir()) {
|
||||||
addOverlayBlock((short) (x + shift + oddshift + centerShiftX),
|
addOverlayBlock((short) (x + shift + oddshift + centerShiftX),
|
||||||
(short) (y + startY), (short) (z + shift + oddshift + centerShiftZ),
|
(short) (y + startY), (short) (z + shift + oddshift + centerShiftZ),
|
||||||
id, false, h3);
|
id, false, h3);
|
||||||
@ -237,7 +269,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
for (short y = 0; y < h1; y++) {
|
for (short y = 0; y < h1; y++) {
|
||||||
BaseBlock id =
|
BaseBlock id =
|
||||||
blockArrayClipboard1.getFullBlock(BlockVector3.at(x, y, z)).toBaseBlock();
|
blockArrayClipboard1.getFullBlock(BlockVector3.at(x, y, z)).toBaseBlock();
|
||||||
if (!id.getBlockType().getId().toLowerCase().contains("air")) {
|
if (!id.getBlockType().getMaterial().isAir()) {
|
||||||
addOverlayBlock((short) (x - shift), (short) (y + startY),
|
addOverlayBlock((short) (x - shift), (short) (y + startY),
|
||||||
(short) (z + shift + oddshift), id, false, h1);
|
(short) (z + shift + oddshift), id, false, h1);
|
||||||
addOverlayBlock((short) (z + shift + oddshift), (short) (y + startY),
|
addOverlayBlock((short) (z + shift + oddshift), (short) (y + startY),
|
||||||
@ -250,7 +282,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
for (short z = 0; z < l2; z++) {
|
for (short z = 0; z < l2; z++) {
|
||||||
for (short y = 0; y < h2; y++) {
|
for (short y = 0; y < h2; y++) {
|
||||||
BaseBlock id = blockArrayClipboard2.getFullBlock(BlockVector3.at(x, y, z));
|
BaseBlock id = blockArrayClipboard2.getFullBlock(BlockVector3.at(x, y, z));
|
||||||
if (!id.getBlockType().getId().toLowerCase().contains("air")) {
|
if (!id.getBlockType().getMaterial().isAir()) {
|
||||||
addOverlayBlock((short) (x - shift), (short) (y + startY),
|
addOverlayBlock((short) (x - shift), (short) (y + startY),
|
||||||
(short) (z - shift), id, false, h2);
|
(short) (z - shift), id, false, h2);
|
||||||
}
|
}
|
||||||
@ -275,11 +307,11 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
id = rotate(id);
|
id = rotate(id);
|
||||||
}
|
}
|
||||||
int pair = MathMan.pair(x, z);
|
int pair = MathMan.pair(x, z);
|
||||||
String[] existing = this.G_SCH.get(pair);
|
BaseBlock[] existing = this.G_SCH.get(pair);
|
||||||
if (existing == null) {
|
if (existing == null) {
|
||||||
existing = new String[height];
|
existing = new BaseBlock[height];
|
||||||
this.G_SCH.put(pair, existing);
|
this.G_SCH.put(pair, existing);
|
||||||
}
|
}
|
||||||
existing[y] = id.getBlockType().getId();
|
existing[y] = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
|
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -352,7 +353,7 @@ public abstract class HybridUtils {
|
|||||||
condition = !gx || !gz || !lx || !lz;
|
condition = !gx || !gz || !lx || !lz;
|
||||||
}
|
}
|
||||||
if (condition) {
|
if (condition) {
|
||||||
String[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ));
|
BaseBlock[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ));
|
||||||
int minY = Math.min(plotWorld.PLOT_HEIGHT, plotWorld.ROAD_HEIGHT);
|
int minY = Math.min(plotWorld.PLOT_HEIGHT, plotWorld.ROAD_HEIGHT);
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (int y = 0; y < blocks.length; y++) {
|
for (int y = 0; y < blocks.length; y++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user