Upgradeable cores

This commit is contained in:
Anuken
2020-06-27 19:16:39 -04:00
parent 313cadb763
commit 80332e37d5
63 changed files with 365 additions and 290 deletions

View File

@@ -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);