mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 20:20:30 +00:00
Merge branch 'mc-1.16.x' into mc-1.17.x
This commit is contained in:
commit
92fd93c0e0
@ -73,42 +73,14 @@ public abstract class TileGeneric extends BlockEntity
|
||||
player.distanceToSqr( pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5 ) <= range * range;
|
||||
}
|
||||
|
||||
protected void writeDescription( @Nonnull CompoundTag nbt )
|
||||
{
|
||||
}
|
||||
|
||||
protected void readDescription( @Nonnull CompoundTag nbt )
|
||||
{
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final ClientboundBlockEntityDataPacket getUpdatePacket()
|
||||
{
|
||||
CompoundTag nbt = new CompoundTag();
|
||||
writeDescription( nbt );
|
||||
return new ClientboundBlockEntityDataPacket( worldPosition, 0, nbt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onDataPacket( Connection net, ClientboundBlockEntityDataPacket packet )
|
||||
{
|
||||
if( packet.getType() == 0 ) readDescription( packet.getTag() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundTag getUpdateTag()
|
||||
{
|
||||
CompoundTag tag = super.getUpdateTag();
|
||||
writeDescription( tag );
|
||||
return tag;
|
||||
if( packet.getType() == 0 ) handleUpdateTag( packet.getTag() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUpdateTag( @Nonnull CompoundTag tag )
|
||||
{
|
||||
super.handleUpdateTag( tag );
|
||||
readDescription( tag );
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ public abstract class BlockComputerBase<T extends TileComputerBase> extends Bloc
|
||||
super.onPlace( state, world, pos, oldState, isMoving );
|
||||
|
||||
BlockEntity tile = world.getBlockEntity( pos );
|
||||
if( tile instanceof TileComputerBase computer ) computer.updateInputsImmediately( );
|
||||
if( tile instanceof TileComputerBase computer ) computer.updateInputsImmediately();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,6 +24,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
@ -383,18 +384,27 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
||||
|
||||
// Networking stuff
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected void writeDescription( @Nonnull CompoundTag nbt )
|
||||
public final ClientboundBlockEntityDataPacket getUpdatePacket()
|
||||
{
|
||||
super.writeDescription( nbt );
|
||||
return new ClientboundBlockEntityDataPacket( worldPosition, 0, getUpdateTag() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public CompoundTag getUpdateTag()
|
||||
{
|
||||
// We need this for pick block on the client side.
|
||||
CompoundTag nbt = super.getUpdateTag();
|
||||
if( label != null ) nbt.putString( NBT_LABEL, label );
|
||||
if( computerID >= 0 ) nbt.putInt( NBT_ID, computerID );
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readDescription( @Nonnull CompoundTag nbt )
|
||||
public void handleUpdateTag( @Nonnull CompoundTag nbt )
|
||||
{
|
||||
super.readDescription( nbt );
|
||||
label = nbt.contains( NBT_LABEL ) ? nbt.getString( NBT_LABEL ) : null;
|
||||
computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import dan200.computercraft.shared.util.TickScheduler;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
@ -236,7 +237,6 @@ public class TileMonitor extends TileGeneric
|
||||
{
|
||||
// Otherwise fetch the origin and attempt to get its monitor
|
||||
// Note this may load chunks, but we don't really have a choice here.
|
||||
BlockPos pos = getBlockPos();
|
||||
BlockEntity te = level.getBlockEntity( toWorldPos( 0, 0 ) );
|
||||
if( !(te instanceof TileMonitor) ) return null;
|
||||
|
||||
@ -249,7 +249,6 @@ public class TileMonitor extends TileGeneric
|
||||
{
|
||||
if( clientMonitor != null ) return clientMonitor;
|
||||
|
||||
BlockPos pos = getBlockPos();
|
||||
BlockEntity te = level.getBlockEntity( toWorldPos( 0, 0 ) );
|
||||
if( !(te instanceof TileMonitor) ) return null;
|
||||
|
||||
@ -258,20 +257,29 @@ public class TileMonitor extends TileGeneric
|
||||
|
||||
// Networking stuff
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected void writeDescription( @Nonnull CompoundTag nbt )
|
||||
public final ClientboundBlockEntityDataPacket getUpdatePacket()
|
||||
{
|
||||
super.writeDescription( nbt );
|
||||
return new ClientboundBlockEntityDataPacket( worldPosition, 0, getUpdateTag() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public final CompoundTag getUpdateTag()
|
||||
{
|
||||
CompoundTag nbt = super.getUpdateTag();
|
||||
nbt.putInt( NBT_X, xIndex );
|
||||
nbt.putInt( NBT_Y, yIndex );
|
||||
nbt.putInt( NBT_WIDTH, width );
|
||||
nbt.putInt( NBT_HEIGHT, height );
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void readDescription( @Nonnull CompoundTag nbt )
|
||||
public final void handleUpdateTag( @Nonnull CompoundTag nbt )
|
||||
{
|
||||
super.readDescription( nbt );
|
||||
super.handleUpdateTag( nbt );
|
||||
|
||||
int oldXIndex = xIndex;
|
||||
int oldYIndex = yIndex;
|
||||
|
@ -504,17 +504,19 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
||||
|
||||
// Networking stuff
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected void writeDescription( @Nonnull CompoundTag nbt )
|
||||
public CompoundTag getUpdateTag()
|
||||
{
|
||||
super.writeDescription( nbt );
|
||||
CompoundTag nbt = super.getUpdateTag();
|
||||
brain.writeDescription( nbt );
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readDescription( @Nonnull CompoundTag nbt )
|
||||
public void handleUpdateTag( @Nonnull CompoundTag nbt )
|
||||
{
|
||||
super.readDescription( nbt );
|
||||
super.handleUpdateTag( nbt );
|
||||
brain.readDescription( nbt );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user