PacketUpdateJigsawBlock, PacketAcknowledgePlayerDigging

This commit is contained in:
Bixilon 2020-07-24 23:24:39 +02:00
parent 4c819fae3c
commit c1b6f71452
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
7 changed files with 163 additions and 4 deletions

View File

@ -19,6 +19,7 @@ import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.PacketHandler; import de.bixilon.minosoft.protocol.protocol.PacketHandler;
public class PacketEncryptionRequest implements ClientboundPacket { public class PacketEncryptionRequest implements ClientboundPacket {
String serverId; //normally empty String serverId; //normally empty
byte[] publicKey; byte[] publicKey;
byte[] verifyToken; byte[] verifyToken;

View File

@ -0,0 +1,71 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.protocol.packets.clientbound.play;
import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Block;
import de.bixilon.minosoft.game.datatypes.objectLoader.blocks.Blocks;
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
import de.bixilon.minosoft.protocol.packets.serverbound.play.PacketPlayerDigging;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
public class PacketAcknowledgePlayerDigging implements ClientboundPacket {
BlockPosition position;
Block block;
PacketPlayerDigging.DiggingStatus status;
boolean successful;
@Override
public boolean read(InByteBuffer buffer) {
switch (buffer.getVersion()) {
case VERSION_1_14_4:
position = buffer.readPosition();
block = Blocks.getBlock(buffer.readVarInt(), buffer.getVersion());
status = PacketPlayerDigging.DiggingStatus.byId(buffer.readVarInt());
successful = buffer.readBoolean();
return true;
}
return false;
}
@Override
public void log() {
Log.protocol(String.format("Received acknowledge digging packet (position=%s, block=%s, status=%s, successful=%s)", position.toString(), block, status, successful));
}
@Override
public void handle(PacketHandler h) {
h.handle(this);
}
public BlockPosition getPosition() {
return position;
}
public Block getBlock() {
return block;
}
public PacketPlayerDigging.DiggingStatus getStatus() {
return status;
}
public boolean isSuccessful() {
return successful;
}
}

View File

@ -19,12 +19,15 @@ import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket; import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer; import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.PacketHandler; import de.bixilon.minosoft.protocol.protocol.PacketHandler;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
import de.bixilon.minosoft.util.BitByte; import de.bixilon.minosoft.util.BitByte;
public class PacketEntityEffect implements ClientboundPacket { public class PacketEntityEffect implements ClientboundPacket {
int entityId; int entityId;
StatusEffect effect; StatusEffect effect;
boolean hideParticle; boolean isAmbient;
boolean hideParticles;
boolean showIcon;
@Override @Override
@ -33,13 +36,13 @@ public class PacketEntityEffect implements ClientboundPacket {
case VERSION_1_7_10: case VERSION_1_7_10:
entityId = buffer.readInt(); entityId = buffer.readInt();
effect = new StatusEffect(StatusEffects.byId(buffer.readByte()), buffer.readByte(), buffer.readShort()); effect = new StatusEffect(StatusEffects.byId(buffer.readByte()), buffer.readByte(), buffer.readShort());
hideParticle = false; hideParticles = false;
return true; return true;
case VERSION_1_8: case VERSION_1_8:
case VERSION_1_9_4: case VERSION_1_9_4:
entityId = buffer.readVarInt(); entityId = buffer.readVarInt();
effect = new StatusEffect(StatusEffects.byId(buffer.readByte()), buffer.readByte(), buffer.readVarInt()); effect = new StatusEffect(StatusEffects.byId(buffer.readByte()), buffer.readByte(), buffer.readVarInt());
hideParticle = buffer.readBoolean(); hideParticles = buffer.readBoolean();
return true; return true;
case VERSION_1_10: case VERSION_1_10:
case VERSION_1_11_2: case VERSION_1_11_2:
@ -49,7 +52,13 @@ public class PacketEntityEffect implements ClientboundPacket {
entityId = buffer.readVarInt(); entityId = buffer.readVarInt();
effect = new StatusEffect(StatusEffects.byId(buffer.readByte()), buffer.readByte(), buffer.readVarInt()); effect = new StatusEffect(StatusEffects.byId(buffer.readByte()), buffer.readByte(), buffer.readVarInt());
byte flags = buffer.readByte(); byte flags = buffer.readByte();
hideParticle = BitByte.isBitMask(flags, 0x02); isAmbient = BitByte.isBitMask(flags, 0x01);
hideParticles = !BitByte.isBitMask(flags, 0x02);
if (buffer.getVersion().getVersionNumber() >= ProtocolVersion.VERSION_1_14_4.getVersionNumber()) {
showIcon = BitByte.isBitMask(flags, 0x04);
} else {
showIcon = true;
}
return true; return true;
} }
@ -73,4 +82,16 @@ public class PacketEntityEffect implements ClientboundPacket {
public StatusEffect getEffect() { public StatusEffect getEffect() {
return effect; return effect;
} }
public boolean hideParticles() {
return hideParticles;
}
public boolean showIcon() {
return showIcon;
}
public boolean isAmbient() {
return isAmbient;
}
} }

View File

@ -95,6 +95,16 @@ public class PacketPlayerDigging implements ServerboundPacket {
this.id = id; this.id = id;
} }
public static DiggingStatus byId(int id) {
for (DiggingStatus status : values()) {
if (status.getId() == id) {
return status;
}
}
return null;
}
public int getId() { public int getId() {
return id; return id;
} }

View File

@ -0,0 +1,52 @@
/*
* Codename Minosoft
* Copyright (C) 2020 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.protocol.packets.serverbound.play;
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.packets.ServerboundPacket;
import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
import de.bixilon.minosoft.protocol.protocol.Packets;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class PacketUpdateJigsawBlock implements ServerboundPacket {
final BlockPosition position;
final String attachmentType;
final String targetPool;
final String finalState;
public PacketUpdateJigsawBlock(BlockPosition position, String attachmentType, String targetPool, String finalState) {
this.position = position;
this.attachmentType = attachmentType;
this.targetPool = targetPool;
this.finalState = finalState;
}
@Override
public OutPacketBuffer write(ProtocolVersion version) {
OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.PLAY_UPDATE_JIGSAW_BLOCK));
switch (version) {
case VERSION_1_14_4:
buffer.writePosition(position);
break;
}
return buffer;
}
@Override
public void log() {
Log.protocol(String.format("Updating jigsaw block (position=%s, attachmentType=%s, targetPool=%s, finalState=%s)", position, attachmentType, targetPool, finalState));
}
}

View File

@ -616,4 +616,7 @@ public class PacketHandler {
public void handle(PacketOpenBook pkg) { public void handle(PacketOpenBook pkg) {
} }
public void handle(PacketAcknowledgePlayerDigging pkg) {
}
} }

View File

@ -123,6 +123,7 @@ public abstract class Protocol implements ProtocolInterface {
packetClassMapping.put(Packets.Clientbound.PLAY_OPEN_HORSE_WINDOW, PacketOpenHorseWindow.class); packetClassMapping.put(Packets.Clientbound.PLAY_OPEN_HORSE_WINDOW, PacketOpenHorseWindow.class);
packetClassMapping.put(Packets.Clientbound.PLAY_TRADE_LIST, PacketTradeList.class); packetClassMapping.put(Packets.Clientbound.PLAY_TRADE_LIST, PacketTradeList.class);
packetClassMapping.put(Packets.Clientbound.PLAY_OPEN_BOOK, PacketOpenBook.class); packetClassMapping.put(Packets.Clientbound.PLAY_OPEN_BOOK, PacketOpenBook.class);
packetClassMapping.put(Packets.Clientbound.PLAY_ACKNOWLEDGE_PLAYER_DIGGING, PacketAcknowledgePlayerDigging.class);
} }
protected final HashMap<ConnectionState, HashBiMap<Packets.Serverbound, Integer>> serverboundPacketMapping; protected final HashMap<ConnectionState, HashBiMap<Packets.Serverbound, Integer>> serverboundPacketMapping;