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;
|
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
|
@Override
|
||||||
public final void onDataPacket( Connection net, ClientboundBlockEntityDataPacket packet )
|
public final void onDataPacket( Connection net, ClientboundBlockEntityDataPacket packet )
|
||||||
{
|
{
|
||||||
if( packet.getType() == 0 ) readDescription( packet.getTag() );
|
if( packet.getType() == 0 ) handleUpdateTag( packet.getTag() );
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
@Override
|
|
||||||
public CompoundTag getUpdateTag()
|
|
||||||
{
|
|
||||||
CompoundTag tag = super.getUpdateTag();
|
|
||||||
writeDescription( tag );
|
|
||||||
return tag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleUpdateTag( @Nonnull CompoundTag tag )
|
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 );
|
super.onPlace( state, world, pos, oldState, isMoving );
|
||||||
|
|
||||||
BlockEntity tile = world.getBlockEntity( pos );
|
BlockEntity tile = world.getBlockEntity( pos );
|
||||||
if( tile instanceof TileComputerBase computer ) computer.updateInputsImmediately( );
|
if( tile instanceof TileComputerBase computer ) computer.updateInputsImmediately();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,6 +24,7 @@ import net.minecraft.nbt.CompoundTag;
|
|||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
import net.minecraft.network.chat.TextComponent;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
import net.minecraft.network.chat.TranslatableComponent;
|
import net.minecraft.network.chat.TranslatableComponent;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.MenuProvider;
|
import net.minecraft.world.MenuProvider;
|
||||||
@ -383,18 +384,27 @@ public abstract class TileComputerBase extends TileGeneric implements IComputerT
|
|||||||
|
|
||||||
// Networking stuff
|
// Networking stuff
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@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( label != null ) nbt.putString( NBT_LABEL, label );
|
||||||
if( computerID >= 0 ) nbt.putInt( NBT_ID, computerID );
|
if( computerID >= 0 ) nbt.putInt( NBT_ID, computerID );
|
||||||
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
label = nbt.contains( NBT_LABEL ) ? nbt.getString( NBT_LABEL ) : null;
|
||||||
computerID = nbt.contains( NBT_ID ) ? nbt.getInt( NBT_ID ) : -1;
|
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.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||||
import net.minecraft.world.InteractionHand;
|
import net.minecraft.world.InteractionHand;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
import net.minecraft.world.entity.player.Player;
|
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
|
// Otherwise fetch the origin and attempt to get its monitor
|
||||||
// Note this may load chunks, but we don't really have a choice here.
|
// Note this may load chunks, but we don't really have a choice here.
|
||||||
BlockPos pos = getBlockPos();
|
|
||||||
BlockEntity te = level.getBlockEntity( toWorldPos( 0, 0 ) );
|
BlockEntity te = level.getBlockEntity( toWorldPos( 0, 0 ) );
|
||||||
if( !(te instanceof TileMonitor) ) return null;
|
if( !(te instanceof TileMonitor) ) return null;
|
||||||
|
|
||||||
@ -249,7 +249,6 @@ public class TileMonitor extends TileGeneric
|
|||||||
{
|
{
|
||||||
if( clientMonitor != null ) return clientMonitor;
|
if( clientMonitor != null ) return clientMonitor;
|
||||||
|
|
||||||
BlockPos pos = getBlockPos();
|
|
||||||
BlockEntity te = level.getBlockEntity( toWorldPos( 0, 0 ) );
|
BlockEntity te = level.getBlockEntity( toWorldPos( 0, 0 ) );
|
||||||
if( !(te instanceof TileMonitor) ) return null;
|
if( !(te instanceof TileMonitor) ) return null;
|
||||||
|
|
||||||
@ -258,20 +257,29 @@ public class TileMonitor extends TileGeneric
|
|||||||
|
|
||||||
// Networking stuff
|
// Networking stuff
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@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_X, xIndex );
|
||||||
nbt.putInt( NBT_Y, yIndex );
|
nbt.putInt( NBT_Y, yIndex );
|
||||||
nbt.putInt( NBT_WIDTH, width );
|
nbt.putInt( NBT_WIDTH, width );
|
||||||
nbt.putInt( NBT_HEIGHT, height );
|
nbt.putInt( NBT_HEIGHT, height );
|
||||||
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 oldXIndex = xIndex;
|
||||||
int oldYIndex = yIndex;
|
int oldYIndex = yIndex;
|
||||||
|
@ -504,17 +504,19 @@ public class TileTurtle extends TileComputerBase implements ITurtleTile, Default
|
|||||||
|
|
||||||
// Networking stuff
|
// Networking stuff
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
protected void writeDescription( @Nonnull CompoundTag nbt )
|
public CompoundTag getUpdateTag()
|
||||||
{
|
{
|
||||||
super.writeDescription( nbt );
|
CompoundTag nbt = super.getUpdateTag();
|
||||||
brain.writeDescription( nbt );
|
brain.writeDescription( nbt );
|
||||||
|
return nbt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readDescription( @Nonnull CompoundTag nbt )
|
public void handleUpdateTag( @Nonnull CompoundTag nbt )
|
||||||
{
|
{
|
||||||
super.readDescription( nbt );
|
super.handleUpdateTag( nbt );
|
||||||
brain.readDescription( nbt );
|
brain.readDescription( nbt );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user