99 lines
3.0 KiB
Java
99 lines
3.0 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.network.protocol.game;
|
|
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.network.FriendlyByteBuf;
|
|
import net.minecraft.network.codec.StreamCodec;
|
|
import net.minecraft.network.protocol.Packet;
|
|
import net.minecraft.network.protocol.PacketType;
|
|
import net.minecraft.network.protocol.game.GamePacketTypes;
|
|
import net.minecraft.network.protocol.game.ServerGamePacketListener;
|
|
import net.minecraft.world.level.block.entity.CommandBlockEntity;
|
|
|
|
public class ServerboundSetCommandBlockPacket
|
|
implements Packet<ServerGamePacketListener> {
|
|
public static final StreamCodec<FriendlyByteBuf, ServerboundSetCommandBlockPacket> STREAM_CODEC = Packet.codec(ServerboundSetCommandBlockPacket::write, ServerboundSetCommandBlockPacket::new);
|
|
private static final int FLAG_TRACK_OUTPUT = 1;
|
|
private static final int FLAG_CONDITIONAL = 2;
|
|
private static final int FLAG_AUTOMATIC = 4;
|
|
private final BlockPos pos;
|
|
private final String command;
|
|
private final boolean trackOutput;
|
|
private final boolean conditional;
|
|
private final boolean automatic;
|
|
private final CommandBlockEntity.Mode mode;
|
|
|
|
public ServerboundSetCommandBlockPacket(BlockPos pos, String command, CommandBlockEntity.Mode mode, boolean trackOutput, boolean conditional, boolean automatic) {
|
|
this.pos = pos;
|
|
this.command = command;
|
|
this.trackOutput = trackOutput;
|
|
this.conditional = conditional;
|
|
this.automatic = automatic;
|
|
this.mode = mode;
|
|
}
|
|
|
|
private ServerboundSetCommandBlockPacket(FriendlyByteBuf input) {
|
|
this.pos = input.readBlockPos();
|
|
this.command = input.readUtf();
|
|
this.mode = input.readEnum(CommandBlockEntity.Mode.class);
|
|
byte flags = input.readByte();
|
|
this.trackOutput = (flags & 1) != 0;
|
|
this.conditional = (flags & 2) != 0;
|
|
this.automatic = (flags & 4) != 0;
|
|
}
|
|
|
|
private void write(FriendlyByteBuf output) {
|
|
output.writeBlockPos(this.pos);
|
|
output.writeUtf(this.command);
|
|
output.writeEnum(this.mode);
|
|
int flags = 0;
|
|
if (this.trackOutput) {
|
|
flags |= 1;
|
|
}
|
|
if (this.conditional) {
|
|
flags |= 2;
|
|
}
|
|
if (this.automatic) {
|
|
flags |= 4;
|
|
}
|
|
output.writeByte(flags);
|
|
}
|
|
|
|
@Override
|
|
public PacketType<ServerboundSetCommandBlockPacket> type() {
|
|
return GamePacketTypes.SERVERBOUND_SET_COMMAND_BLOCK;
|
|
}
|
|
|
|
@Override
|
|
public void handle(ServerGamePacketListener listener) {
|
|
listener.handleSetCommandBlock(this);
|
|
}
|
|
|
|
public BlockPos getPos() {
|
|
return this.pos;
|
|
}
|
|
|
|
public String getCommand() {
|
|
return this.command;
|
|
}
|
|
|
|
public boolean isTrackOutput() {
|
|
return this.trackOutput;
|
|
}
|
|
|
|
public boolean isConditional() {
|
|
return this.conditional;
|
|
}
|
|
|
|
public boolean isAutomatic() {
|
|
return this.automatic;
|
|
}
|
|
|
|
public CommandBlockEntity.Mode getMode() {
|
|
return this.mode;
|
|
}
|
|
}
|
|
|