Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 18:40:05 +01:00
Added initial support for AddBlocks (4096 ids) in schematics
Dieser Commit ist enthalten in:
Ursprung
127b0ec6f4
Commit
0d279e7706
@ -34,7 +34,7 @@ public class BaseBlock {
|
|||||||
/**
|
/**
|
||||||
* BaseBlock data.
|
* BaseBlock data.
|
||||||
*/
|
*/
|
||||||
private byte data = 0;
|
private short data = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the block with its type.
|
* Construct the block with its type.
|
||||||
@ -53,7 +53,7 @@ public class BaseBlock {
|
|||||||
*/
|
*/
|
||||||
public BaseBlock(int type, int data) {
|
public BaseBlock(int type, int data) {
|
||||||
this.type = (short) type;
|
this.type = (short) type;
|
||||||
this.data = (byte) data;
|
this.data = (short) data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,7 +81,7 @@ public class BaseBlock {
|
|||||||
* @param data the data to set
|
* @param data the data to set
|
||||||
*/
|
*/
|
||||||
public void setData(int data) {
|
public void setData(int data) {
|
||||||
this.data = (byte) data;
|
this.data = (short) data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,7 +98,7 @@ public class BaseBlock {
|
|||||||
*/
|
*/
|
||||||
public int rotate90() {
|
public int rotate90() {
|
||||||
int newData = BlockData.rotate90(type, data);
|
int newData = BlockData.rotate90(type, data);
|
||||||
this.data = (byte) newData;
|
this.data = (short) newData;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ public class BaseBlock {
|
|||||||
*/
|
*/
|
||||||
public int rotate90Reverse() {
|
public int rotate90Reverse() {
|
||||||
int newData = BlockData.rotate90Reverse(type, data);
|
int newData = BlockData.rotate90Reverse(type, data);
|
||||||
this.data = (byte) newData;
|
this.data = (short) newData;
|
||||||
return newData;
|
return newData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ public class BaseBlock {
|
|||||||
*/
|
*/
|
||||||
public int cycleData(int increment) {
|
public int cycleData(int increment) {
|
||||||
int newData = BlockData.cycle(this.type, this.data, increment);
|
int newData = BlockData.cycle(this.type, this.data, increment);
|
||||||
this.data = (byte) newData;
|
this.data = (short) newData;
|
||||||
return newData;
|
return newData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ public class BaseBlock {
|
|||||||
* Flip this block.
|
* Flip this block.
|
||||||
*/
|
*/
|
||||||
public BaseBlock flip() {
|
public BaseBlock flip() {
|
||||||
data = (byte) BlockData.flip(type, data);
|
data = (short) BlockData.flip(type, data);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ public class BaseBlock {
|
|||||||
* @param direction
|
* @param direction
|
||||||
*/
|
*/
|
||||||
public BaseBlock flip(FlipDirection direction) {
|
public BaseBlock flip(FlipDirection direction) {
|
||||||
data = (byte) BlockData.flip(type, data, direction);
|
data = (short) BlockData.flip(type, data, direction);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,8 +107,19 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get blocks
|
// Get blocks
|
||||||
byte[] blocks = getChildTag(schematic, "Blocks", ByteArrayTag.class).getValue();
|
byte[] rawBlocks = getChildTag(schematic, "Blocks", ByteArrayTag.class).getValue();
|
||||||
byte[] blockData = getChildTag(schematic, "Data", ByteArrayTag.class).getValue();
|
byte[] blockData = getChildTag(schematic, "Data", ByteArrayTag.class).getValue();
|
||||||
|
short[] blocks = new short[rawBlocks.length];
|
||||||
|
|
||||||
|
if (schematic.containsKey("AddBlocks")) {
|
||||||
|
byte[] addBlockIds = getChildTag(schematic, "AddBlocks", ByteArrayTag.class).getValue();
|
||||||
|
for (int i = 0, index = 0; i < addBlockIds.length && index < blocks.length; ++i) {
|
||||||
|
blocks[index] = (short) (addBlockIds[i] & 0xF << 8 + rawBlocks[index++]);
|
||||||
|
if (index < blocks.length) {
|
||||||
|
blocks[index] = (short) (((addBlockIds[i] << 4) & 0xF) << 8 + rawBlocks[index++]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Need to pull out tile entities
|
// Need to pull out tile entities
|
||||||
List<Tag> tileEntities = getChildTag(schematic, "TileEntities", ListTag.class)
|
List<Tag> tileEntities = getChildTag(schematic, "TileEntities", ListTag.class)
|
||||||
@ -201,6 +212,7 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
|||||||
|
|
||||||
// Copy
|
// Copy
|
||||||
byte[] blocks = new byte[width * height * length];
|
byte[] blocks = new byte[width * height * length];
|
||||||
|
byte[] addBlocks = null;
|
||||||
byte[] blockData = new byte[width * height * length];
|
byte[] blockData = new byte[width * height * length];
|
||||||
ArrayList<Tag> tileEntities = new ArrayList<Tag>();
|
ArrayList<Tag> tileEntities = new ArrayList<Tag>();
|
||||||
|
|
||||||
@ -209,6 +221,15 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
|||||||
for (int z = 0; z < length; ++z) {
|
for (int z = 0; z < length; ++z) {
|
||||||
int index = y * width * length + z * width + x;
|
int index = y * width * length + z * width + x;
|
||||||
BaseBlock block = clipboard.getPoint(new BlockVector(x, y, z));
|
BaseBlock block = clipboard.getPoint(new BlockVector(x, y, z));
|
||||||
|
if (block.getType() > 255) {
|
||||||
|
if (addBlocks == null) {
|
||||||
|
addBlocks = new byte[blocks.length >> 1];
|
||||||
|
}
|
||||||
|
addBlocks[index >> 1] = (byte) (((index & 1) == 0) ?
|
||||||
|
addBlocks[index >> 1] & 0xF0 | (block.getType() >> 8) & 0xF
|
||||||
|
: addBlocks[index >> 1] & 0xF | ((block.getType() >> 8) & 0xF) << 4);
|
||||||
|
}
|
||||||
|
|
||||||
blocks[index] = (byte) block.getType();
|
blocks[index] = (byte) block.getType();
|
||||||
blockData[index] = (byte) block.getData();
|
blockData[index] = (byte) block.getData();
|
||||||
|
|
||||||
@ -238,6 +259,9 @@ public class MCEditSchematicFormat extends SchematicFormat {
|
|||||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
||||||
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
||||||
|
if (addBlocks != null) {
|
||||||
|
schematic.put("AddBlocks", new ByteArrayTag("AddBlocks", addBlocks));
|
||||||
|
}
|
||||||
|
|
||||||
// Build and output
|
// Build and output
|
||||||
CompoundTag schematicTag = new CompoundTag("Schematic", schematic);
|
CompoundTag schematicTag = new CompoundTag("Schematic", schematic);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren