1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-08-31 01:27:55 +00:00

time to make a diff of the fabric branch with ours to see what we are miss

This commit is contained in:
Devan-Kerman
2020-08-30 08:35:07 -05:00
parent afb12eb342
commit c64644b9ec
2 changed files with 54 additions and 45 deletions

View File

@@ -3,43 +3,48 @@
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
*/ */
package dan200.computercraft.shared.network.container; package dan200.computercraft.shared.network.container;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.shared.computer.core.ComputerFamily; import dan200.computercraft.shared.computer.core.ComputerFamily;
import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.computer.core.ServerComputer;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.Identifier;
public class ComputerContainerData implements ContainerData public class ComputerContainerData implements ContainerData {
{ private static final Identifier IDENTIFIER = new Identifier(ComputerCraft.MOD_ID, "computerContainerData");
private final int id; private int id;
private final ComputerFamily family; private ComputerFamily family;
public ComputerContainerData( ServerComputer computer ) public ComputerContainerData(ServerComputer computer) {
{
this.id = computer.getInstanceID(); this.id = computer.getInstanceID();
this.family = computer.getFamily(); this.family = computer.getFamily();
} }
public ComputerContainerData( PacketByteBuf buf ) @Override
{ public Identifier getId() {
this.id = buf.readInt(); return IDENTIFIER;
this.family = buf.readEnumConstant( ComputerFamily.class );
} }
@Override @Override
public void toBytes( PacketByteBuf buf ) public void fromBytes(PacketByteBuf buf) {
{ this.id = buf.readInt();
buf.writeInt( id ); this.family = buf.readEnumConstant(ComputerFamily.class);
buf.writeEnumConstant( family );
} }
public int getInstanceId() @Override
{ public void toBytes(PacketByteBuf buf) {
buf.writeInt(id);
buf.writeEnumConstant(family);
}
public int getInstanceId() {
return id; return id;
} }
public ComputerFamily getFamily() public ComputerFamily getFamily() {
{
return family; return family;
} }
} }

View File

@@ -3,60 +3,64 @@
* Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission. * Copyright Daniel Ratcliffe, 2011-2020. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
*/ */
package dan200.computercraft.shared.network.container; package dan200.computercraft.shared.network.container;
import javax.annotation.Nonnull;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.core.terminal.Terminal; import dan200.computercraft.core.terminal.Terminal;
import dan200.computercraft.shared.computer.core.ServerComputer; import dan200.computercraft.shared.computer.core.ServerComputer;
import javax.annotation.Nonnull;
import net.minecraft.network.PacketByteBuf; import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.Identifier;
/** /**
* View an arbitrary computer on the client. * View an arbitrary computer on the client.
* *
* @see dan200.computercraft.shared.command.CommandComputerCraft * @see dan200.computercraft.shared.command.CommandComputerCraft
*/ */
public class ViewComputerContainerData extends ComputerContainerData public class ViewComputerContainerData extends ComputerContainerData {
{ private int width;
private final int width; private int height;
private final int height;
public ViewComputerContainerData( ServerComputer computer ) public ViewComputerContainerData(ServerComputer computer) {
{ super(computer);
super( computer );
Terminal terminal = computer.getTerminal(); Terminal terminal = computer.getTerminal();
if( terminal != null ) if (terminal != null) {
{
width = terminal.getWidth(); width = terminal.getWidth();
height = terminal.getHeight(); height = terminal.getHeight();
} } else {
else
{
width = height = 0; width = height = 0;
} }
} }
public ViewComputerContainerData( PacketByteBuf buffer ) private static final Identifier IDENTIFIER = new Identifier(ComputerCraft.MOD_ID, "viewComputerContainerData");
{
super( buffer ); @Override
width = buffer.readVarInt(); public Identifier getId() {
height = buffer.readVarInt(); return IDENTIFIER;
} }
@Override @Override
public void toBytes( @Nonnull PacketByteBuf buf ) public void fromBytes(PacketByteBuf buf) {
{ super.fromBytes(buf);
super.toBytes( buf ); width = buf.readVarInt();
buf.writeVarInt( width ); height = buf.readVarInt();
buf.writeVarInt( height );
} }
public int getWidth() @Override
{ public void toBytes(@Nonnull PacketByteBuf buf) {
super.toBytes(buf);
buf.writeVarInt(width);
buf.writeVarInt(height);
}
public int getWidth() {
return width; return width;
} }
public int getHeight() public int getHeight() {
{
return height; return height;
} }
} }