Upgradeable cores
This commit is contained in:
@@ -164,15 +164,15 @@ public abstract class SaveVersion extends SaveFileReader{
|
||||
stream.writeShort(tile.blockID());
|
||||
|
||||
//make note of whether there was an entity here
|
||||
stream.writeBoolean(tile.entity != null);
|
||||
stream.writeBoolean(tile.build != null);
|
||||
|
||||
//only write the entity for multiblocks once - in the center
|
||||
if(tile.entity != null){
|
||||
if(tile.build != null){
|
||||
if(tile.isCenter()){
|
||||
stream.writeBoolean(true);
|
||||
writeChunk(stream, true, out -> {
|
||||
out.writeByte(tile.entity.version());
|
||||
tile.entity.writeAll(Writes.get(out));
|
||||
out.writeByte(tile.build.version());
|
||||
tile.build.writeAll(Writes.get(out));
|
||||
});
|
||||
}else{
|
||||
stream.writeBoolean(false);
|
||||
@@ -249,7 +249,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
||||
try{
|
||||
readChunk(stream, true, in -> {
|
||||
byte revision = in.readByte();
|
||||
tile.entity.readAll(Reads.get(in), revision);
|
||||
tile.build.readAll(Reads.get(in), revision);
|
||||
});
|
||||
}catch(Throwable e){
|
||||
throw new IOException("Failed to read tile entity of block: " + block, e);
|
||||
|
||||
@@ -54,7 +54,7 @@ public abstract class LegacySaveVersion extends SaveVersion{
|
||||
if(block == null) block = Blocks.air;
|
||||
|
||||
//occupied by multiblock part
|
||||
boolean occupied = tile.entity != null && !tile.isCenter() && (tile.entity.block() == block || block == Blocks.air);
|
||||
boolean occupied = tile.build != null && !tile.isCenter() && (tile.build.block() == block || block == Blocks.air);
|
||||
|
||||
//do not override occupied cells
|
||||
if(!occupied){
|
||||
@@ -66,7 +66,7 @@ public abstract class LegacySaveVersion extends SaveVersion{
|
||||
readChunk(stream, true, in -> {
|
||||
byte version = in.readByte();
|
||||
//legacy impl of Building#read()
|
||||
tile.entity.health(stream.readUnsignedShort());
|
||||
tile.build.health(stream.readUnsignedShort());
|
||||
byte packedrot = stream.readByte();
|
||||
byte team = Pack.leftByte(packedrot) == 8 ? stream.readByte() : Pack.leftByte(packedrot);
|
||||
byte rotation = Pack.rightByte(packedrot);
|
||||
@@ -74,13 +74,13 @@ public abstract class LegacySaveVersion extends SaveVersion{
|
||||
tile.setTeam(Team.get(team));
|
||||
tile.rotation(rotation);
|
||||
|
||||
if(tile.entity.items != null) tile.entity.items.read(Reads.get(stream));
|
||||
if(tile.entity.power != null) tile.entity.power.read(Reads.get(stream));
|
||||
if(tile.entity.liquids != null) tile.entity.liquids.read(Reads.get(stream));
|
||||
if(tile.entity.cons() != null) tile.entity.cons().read(Reads.get(stream));
|
||||
if(tile.build.items != null) tile.build.items.read(Reads.get(stream));
|
||||
if(tile.build.power != null) tile.build.power.read(Reads.get(stream));
|
||||
if(tile.build.liquids != null) tile.build.liquids.read(Reads.get(stream));
|
||||
if(tile.build.cons() != null) tile.build.cons().read(Reads.get(stream));
|
||||
|
||||
//read only from subclasses!
|
||||
tile.entity.read(Reads.get(in), version);
|
||||
tile.build.read(Reads.get(in), version);
|
||||
});
|
||||
}catch(Throwable e){
|
||||
throw new IOException("Failed to read tile entity of block: " + block, e);
|
||||
|
||||
Reference in New Issue
Block a user