mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Various
Add some 1.9 blocks to chest content with schematic paste Restructure tileentity placement from schematic (will soon add signs etc) Prepare for release 3.3.3
This commit is contained in:
@ -169,6 +169,7 @@ public class AugmentedUtils {
|
||||
toReturn = true;
|
||||
}
|
||||
generator.generateChunk(secondaryMask, area, r);
|
||||
generator.populateChunk(secondaryMask, area, r);
|
||||
}
|
||||
if (lazyChunk.get() != null) {
|
||||
lazyChunk.get().addToQueue();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
@ -7,7 +8,7 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@ -167,7 +168,8 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
}
|
||||
result.setBlock(x, hpw.PLOT_HEIGHT, z, hpw.TOP_BLOCK[random.random(hpw.TOP_BLOCK.length)]);
|
||||
if (hpw.PLOT_SCHEMATIC) {
|
||||
HashMap<Integer, PlotBlock> map = sch.get(MathMan.pair(rx[x], rz[z]));
|
||||
int pair = MathMan.pair(rx[x], rz[z]);
|
||||
HashMap<Integer, PlotBlock> map = sch.get(pair);
|
||||
if (map != null) {
|
||||
for (Entry<Integer, PlotBlock> entry : map.entrySet()) {
|
||||
result.setBlock(x, entry.getKey(), z, entry.getValue());
|
||||
@ -180,6 +182,59 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean populateChunk(PlotChunk<?> result, PlotArea settings, PseudoRandom random) {
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
||||
if (hpw.G_SCH_STATE != null) {
|
||||
int cx = result.getX();
|
||||
int cz = result.getZ();
|
||||
int p1x = cx << 4;
|
||||
int p1z = cz << 4;
|
||||
int bx = p1x - hpw.ROAD_OFFSET_X;
|
||||
int bz = p1z - hpw.ROAD_OFFSET_Z;
|
||||
short rbx;
|
||||
if (bx < 0) {
|
||||
rbx = (short) (hpw.SIZE + (bx % hpw.SIZE));
|
||||
} else {
|
||||
rbx = (short) (bx % hpw.SIZE);
|
||||
}
|
||||
short rbz;
|
||||
if (bz < 0) {
|
||||
rbz = (short) (hpw.SIZE + (bz % hpw.SIZE));
|
||||
} else {
|
||||
rbz = (short) (bz % hpw.SIZE);
|
||||
}
|
||||
short[] rx = new short[16];
|
||||
for (short i = 0; i < 16; i++) {
|
||||
short v = (short) (rbx + i);
|
||||
if (v >= hpw.SIZE) {
|
||||
v -= hpw.SIZE;
|
||||
}
|
||||
rx[i] = v;
|
||||
}
|
||||
short[] rz = new short[16];
|
||||
for (short i = 0; i < 16; i++) {
|
||||
short v = (short) (rbz + i);
|
||||
if (v >= hpw.SIZE) {
|
||||
v -= hpw.SIZE;
|
||||
}
|
||||
rz[i] = v;
|
||||
}
|
||||
for (short x = 0; x < 16; x++) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
int pair = MathMan.pair(rx[x], rz[z]);
|
||||
HashMap<Integer, CompoundTag> map = hpw.G_SCH_STATE.get(pair);
|
||||
if (map != null) {
|
||||
for (Entry<Integer, CompoundTag> entry : map.entrySet()) {
|
||||
SchematicHandler.manager.restoreTile(hpw.worldname, entry.getValue(), p1x + x, entry.getKey(), p1z + z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||
return new HybridPlotWorld(world, id, this, min, max);
|
||||
|
@ -1,21 +1,21 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
|
||||
@ -25,7 +25,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
public short PATH_WIDTH_LOWER;
|
||||
public short PATH_WIDTH_UPPER;
|
||||
public HashMap<Integer, HashMap<Integer, PlotBlock>> G_SCH;
|
||||
public HashMap<Integer, HashSet<PlotItem>> G_SCH_STATE;
|
||||
public HashMap<Integer, HashMap<Integer, CompoundTag>> G_SCH_STATE;
|
||||
|
||||
public HybridPlotWorld(String worldName, String id, IndependentPlotGenerator generator, PlotId min, PlotId max) {
|
||||
super(worldName, id, generator, min, max);
|
||||
@ -181,10 +181,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
Schematic schematic2 = SchematicHandler.manager.getSchematic(schematic2File);
|
||||
Schematic schematic3 = SchematicHandler.manager.getSchematic(schem3File);
|
||||
int shift = this.ROAD_WIDTH / 2;
|
||||
int oddshift = 0;
|
||||
if ((this.ROAD_WIDTH & 1) != 0) {
|
||||
oddshift = 1;
|
||||
}
|
||||
int oddshift = (this.ROAD_WIDTH & 1) == 0 ? 0 : 1;
|
||||
if (schematic3 != null) {
|
||||
this.PLOT_SCHEMATIC = true;
|
||||
short[] ids = schematic3.getIds();
|
||||
@ -215,24 +212,21 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
}
|
||||
}
|
||||
}
|
||||
HashSet<PlotItem> items = schematic3.getItems();
|
||||
if (items != null) {
|
||||
HashMap<BlockLoc, CompoundTag> items = schematic3.getTiles();
|
||||
if (items.size() > 0) {
|
||||
this.G_SCH_STATE = new HashMap<>();
|
||||
for (PlotItem item : items) {
|
||||
item.x += shift + oddshift + centerShiftX;
|
||||
item.z += shift + oddshift + centerShiftZ;
|
||||
item.y += this.PLOT_HEIGHT;
|
||||
short x = (short) item.x;
|
||||
short z = (short) item.z;
|
||||
for (Map.Entry<BlockLoc, CompoundTag> entry : items.entrySet()) {
|
||||
BlockLoc loc = entry.getKey();
|
||||
short x = (short) (loc.x + shift + oddshift + centerShiftX);
|
||||
short z = (short) (loc.z + shift + oddshift + centerShiftZ);
|
||||
short y = (short) (loc.y + this.PLOT_HEIGHT);
|
||||
int pair = MathMan.pair(x, z);
|
||||
|
||||
|
||||
HashSet<PlotItem> existing = this.G_SCH_STATE.get(pair);
|
||||
HashMap<Integer, CompoundTag> existing = this.G_SCH_STATE.get(pair);
|
||||
if (existing == null) {
|
||||
existing = new HashSet<>();
|
||||
existing = new HashMap<>();
|
||||
this.G_SCH_STATE.put(pair, existing);
|
||||
}
|
||||
existing.add(item);
|
||||
existing.put((int) y, entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,10 @@ public abstract class IndependentPlotGenerator {
|
||||
*/
|
||||
public abstract void generateChunk(PlotChunk<?> result, PlotArea settings, PseudoRandom random);
|
||||
|
||||
public boolean populateChunk(PlotChunk<?> result, PlotArea settings, PseudoRandom random) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a new PlotArea object.
|
||||
* @param world world name
|
||||
|
@ -598,7 +598,23 @@ public enum ItemType {
|
||||
STRAD_DISC("record_strad", 2264),
|
||||
WARD_DISC("record_ward", 2265),
|
||||
DISC_11("record_11", 2266),
|
||||
WAIT_DISC("record_wait", 2267);
|
||||
WAIT_DISC("record_wait", 2267),
|
||||
END_ROD("end_rod",198),
|
||||
CHORUS_PLANT("chorus_plant",199),
|
||||
CHORUS_FLOWER("chorus_flower",200),
|
||||
PURPUR_BLOCK("purpur_block",201),
|
||||
PURPUR_PILLAR("purpur_pillar",202),
|
||||
PURPUR_STAIRS("purpur_stairs",203),
|
||||
PURPUR_DOUBLE_SLAB("purpur_double_slab",204),
|
||||
PURPUR_SLAB("purpur_slab",205),
|
||||
END_BRICKS("end_bricks",206),
|
||||
BEETROOTS("beetroots",207),
|
||||
GRASS_PATH("grass_path",208),
|
||||
END_GATEWAY("end_gateway",209),
|
||||
REPEATING_COMMAND_BLOCK("repeating_command_block",210),
|
||||
CHAIN_COMMAND_BLOCK("chain_command_block",211),
|
||||
FROSTED_ICE("frosted_ice",212),
|
||||
STRUCTURE_BLOCK("structure_block",255);
|
||||
|
||||
private static final Map<String, Integer> ids = new HashMap<>();
|
||||
private static final Map<String, Byte> datas = new HashMap<>();
|
||||
|
@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.generator.ClassicPlotWorld;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -23,8 +24,6 @@ import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -41,7 +40,6 @@ import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -349,7 +347,10 @@ public abstract class SchematicHandler {
|
||||
SetQueue.IMP.addTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pasteStates(schematic, plot, xOffset, zOffset);
|
||||
for (Map.Entry<BlockLoc, CompoundTag> entry : schematic.getTiles().entrySet()) {
|
||||
BlockLoc loc = entry.getKey();
|
||||
restoreTile(plot.getArea().worldname, entry.getValue(), p1x + xOffset + loc.x, loc.y + y_offset_actual, p1z + zOffset + loc.z);
|
||||
}
|
||||
if (whenDone != null) {
|
||||
whenDone.value = true;
|
||||
whenDone.run();
|
||||
@ -367,35 +368,6 @@ public abstract class SchematicHandler {
|
||||
});
|
||||
}
|
||||
|
||||
public boolean pasteStates(Schematic schematic, Plot plot, int xOffset, int zOffset) {
|
||||
if (schematic == null) {
|
||||
PS.debug("Schematic == null :|");
|
||||
return false;
|
||||
}
|
||||
HashSet<PlotItem> items = schematic.getItems();
|
||||
if (items == null) {
|
||||
return false;
|
||||
}
|
||||
RegionWrapper region = plot.getLargestRegion();
|
||||
Location location = new Location(plot.getArea().worldname, region.minX + xOffset, 1, region.minZ + zOffset);
|
||||
int sy = MainUtil.getHeighestBlock(plot.getArea().worldname, location.getX() + 1, location.getZ() + 1);
|
||||
Dimension demensions = schematic.getSchematicDimension();
|
||||
int height = demensions.getY();
|
||||
if (height < 255) {
|
||||
location = location.add(0, sy - 1, 0);
|
||||
}
|
||||
int x = location.getX() + xOffset;
|
||||
int y = location.getY();
|
||||
int z = location.getZ() + zOffset;
|
||||
for (PlotItem item : items) {
|
||||
item.x += x;
|
||||
item.y += y;
|
||||
item.z += z;
|
||||
WorldUtil.IMP.addItems(plot.getArea().worldname, item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Schematic getSchematic(CompoundTag tag) {
|
||||
Map<String, Tag> tagMap = tag.getValue();
|
||||
// Slow
|
||||
@ -447,7 +419,6 @@ public abstract class SchematicHandler {
|
||||
|
||||
Dimension dimensions = new Dimension(width, height, length);
|
||||
Schematic schem = new Schematic(block, data, dimensions, flags);
|
||||
|
||||
// Slow
|
||||
try {
|
||||
List<Tag> blockStates = ListTag.class.cast(tagMap.get("TileEntities")).getValue();
|
||||
@ -458,7 +429,7 @@ public abstract class SchematicHandler {
|
||||
short x = IntTag.class.cast(state.get("x")).getValue().shortValue();
|
||||
short y = IntTag.class.cast(state.get("y")).getValue().shortValue();
|
||||
short z = IntTag.class.cast(state.get("z")).getValue().shortValue();
|
||||
manager.restoreTag(ct, x, y, z, schem);
|
||||
schem.addTile(new BlockLoc(x, y, z), ct);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -469,7 +440,7 @@ public abstract class SchematicHandler {
|
||||
return schem;
|
||||
}
|
||||
|
||||
public abstract void restoreTag(CompoundTag ct, short x, short y, short z, Schematic schematic);
|
||||
public abstract void restoreTile(String world, CompoundTag tag, int x, int y, int z);
|
||||
|
||||
/**
|
||||
* Get a schematic
|
||||
@ -700,7 +671,7 @@ public abstract class SchematicHandler {
|
||||
private final byte[] datas;
|
||||
private final Dimension schematicDimension;
|
||||
private Map<String, Tag> flags;
|
||||
private HashSet<PlotItem> items;
|
||||
private HashMap<BlockLoc, CompoundTag> tiles;
|
||||
|
||||
public Schematic(short[] i, byte[] b, Dimension d, Map<String, Tag> flags) {
|
||||
this.ids = i;
|
||||
@ -718,22 +689,23 @@ public abstract class SchematicHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an item to the schematic
|
||||
* @param item
|
||||
* Add a tile entity
|
||||
* @param loc
|
||||
* @param tag
|
||||
*/
|
||||
public void addItem(PlotItem item) {
|
||||
if (this.items == null) {
|
||||
this.items = new HashSet<>();
|
||||
public void addTile(BlockLoc loc, CompoundTag tag) {
|
||||
if (this.tiles == null) {
|
||||
this.tiles = new HashMap<>();
|
||||
}
|
||||
this.items.add(item);
|
||||
this.tiles.put(loc, tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get any items associated with this schematic.
|
||||
* @return
|
||||
* Get the tile entities
|
||||
* @return Map of block location to tag
|
||||
*/
|
||||
public HashSet<PlotItem> getItems() {
|
||||
return this.items;
|
||||
public HashMap<BlockLoc, CompoundTag> getTiles() {
|
||||
return this.tiles;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user