1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-08-04 18:10:40 +00:00

save -> saveAdditional

Also add in a janky workabround for handleUpdateTag not being called.
Being an early porter is always fun :D:.
This commit is contained in:
Jonathan Coates 2021-12-01 23:16:54 +00:00
parent 87988a705b
commit 23c17075be
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
7 changed files with 21 additions and 21 deletions

View File

@ -188,16 +188,15 @@ protected void serverTick()
protected abstract void updateBlockState( ComputerState newState );
@Nonnull
@Override
public CompoundTag save( @Nonnull CompoundTag nbt )
public void saveAdditional( @Nonnull CompoundTag nbt )
{
// Save ID, label and power state
if( computerID >= 0 ) nbt.putInt( NBT_ID, computerID );
if( label != null ) nbt.putString( NBT_LABEL, label );
nbt.putBoolean( NBT_ON, on );
return super.save( nbt );
super.saveAdditional( nbt );
}
@Override

View File

@ -137,9 +137,8 @@ public void load( @Nonnull CompoundTag nbt )
}
}
@Nonnull
@Override
public CompoundTag save( @Nonnull CompoundTag nbt )
public void saveAdditional( @Nonnull CompoundTag nbt )
{
if( customName != null ) nbt.putString( NBT_NAME, Component.Serializer.toJson( customName ) );
@ -149,7 +148,7 @@ public CompoundTag save( @Nonnull CompoundTag nbt )
diskStack.save( item );
nbt.put( NBT_ITEM, item );
}
return super.save( nbt );
super.saveAdditional( nbt );
}
void serverTick()

View File

@ -292,13 +292,12 @@ public void load( @Nonnull CompoundTag nbt )
peripheral.read( nbt, "" );
}
@Nonnull
@Override
public CompoundTag save( CompoundTag nbt )
public void saveAdditional( CompoundTag nbt )
{
nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed );
peripheral.write( nbt, "" );
return super.save( nbt );
super.saveAdditional( nbt );
}
private void updateBlockState()

View File

@ -241,13 +241,12 @@ public void load( @Nonnull CompoundTag nbt )
for( int i = 0; i < peripherals.length; i++ ) peripherals[i].read( nbt, Integer.toString( i ) );
}
@Nonnull
@Override
public CompoundTag save( CompoundTag nbt )
public void saveAdditional( CompoundTag nbt )
{
nbt.putBoolean( NBT_PERIPHERAL_ENABLED, peripheralAccessAllowed );
for( int i = 0; i < peripherals.length; i++ ) peripherals[i].write( nbt, Integer.toString( i ) );
return super.save( nbt );
super.saveAdditional( nbt );
}
private void updateBlockState()

View File

@ -127,20 +127,26 @@ public InteractionResult onActivate( Player player, InteractionHand hand, BlockH
return InteractionResult.PASS;
}
@Nonnull
@Override
public CompoundTag save( CompoundTag tag )
public void saveAdditional( CompoundTag tag )
{
tag.putInt( NBT_X, xIndex );
tag.putInt( NBT_Y, yIndex );
tag.putInt( NBT_WIDTH, width );
tag.putInt( NBT_HEIGHT, height );
return super.save( tag );
super.saveAdditional( tag );
}
@Override
public void load( @Nonnull CompoundTag nbt )
{
if( level != null && level.isClientSide )
{
// TODO: Remove once https://github.com/MinecraftForge/MinecraftForge/pull/8237 is merged.
handleUpdateTag( nbt );
return;
}
super.load( nbt );
xIndex = nbt.getInt( NBT_X );

View File

@ -113,9 +113,8 @@ public void load( @Nonnull CompoundTag nbt )
ContainerHelper.loadAllItems( nbt, inventory );
}
@Nonnull
@Override
public CompoundTag save( @Nonnull CompoundTag nbt )
public void saveAdditional( @Nonnull CompoundTag nbt )
{
if( customName != null ) nbt.putString( NBT_NAME, Component.Serializer.toJson( customName ) );
@ -130,7 +129,7 @@ public CompoundTag save( @Nonnull CompoundTag nbt )
// Write inventory
ContainerHelper.saveAllItems( nbt, inventory );
return super.save( nbt );
super.saveAdditional( nbt );
}
boolean isPrinting()

View File

@ -289,9 +289,8 @@ public void load( @Nonnull CompoundTag nbt )
brain.readFromNBT( nbt );
}
@Nonnull
@Override
public CompoundTag save( @Nonnull CompoundTag nbt )
public void saveAdditional( @Nonnull CompoundTag nbt )
{
// Write inventory
ListTag nbttaglist = new ListTag();
@ -310,7 +309,7 @@ public CompoundTag save( @Nonnull CompoundTag nbt )
// Write brain
nbt = brain.writeToNBT( nbt );
return super.save( nbt );
super.saveAdditional( nbt );
}
@Override