mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 08:58:02 -04:00
PacketUpdateJigsawBlock, PacketAcknowledgePlayerDigging
This commit is contained in:
parent
4c819fae3c
commit
c1b6f71452
@ -19,6 +19,7 @@ import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
|
||||
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
||||
|
||||
public class PacketEncryptionRequest implements ClientboundPacket {
|
||||
|
||||
String serverId; //normally empty
|
||||
byte[] publicKey;
|
||||
byte[] verifyToken;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -19,12 +19,15 @@ import de.bixilon.minosoft.logging.Log;
|
||||
import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
|
||||
import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
|
||||
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||
import de.bixilon.minosoft.util.BitByte;
|
||||
|
||||
public class PacketEntityEffect implements ClientboundPacket {
|
||||
int entityId;
|
||||
StatusEffect effect;
|
||||
boolean hideParticle;
|
||||
boolean isAmbient;
|
||||
boolean hideParticles;
|
||||
boolean showIcon;
|
||||
|
||||
|
||||
@Override
|
||||
@ -33,13 +36,13 @@ public class PacketEntityEffect implements ClientboundPacket {
|
||||
case VERSION_1_7_10:
|
||||
entityId = buffer.readInt();
|
||||
effect = new StatusEffect(StatusEffects.byId(buffer.readByte()), buffer.readByte(), buffer.readShort());
|
||||
hideParticle = false;
|
||||
hideParticles = false;
|
||||
return true;
|
||||
case VERSION_1_8:
|
||||
case VERSION_1_9_4:
|
||||
entityId = buffer.readVarInt();
|
||||
effect = new StatusEffect(StatusEffects.byId(buffer.readByte()), buffer.readByte(), buffer.readVarInt());
|
||||
hideParticle = buffer.readBoolean();
|
||||
hideParticles = buffer.readBoolean();
|
||||
return true;
|
||||
case VERSION_1_10:
|
||||
case VERSION_1_11_2:
|
||||
@ -49,7 +52,13 @@ public class PacketEntityEffect implements ClientboundPacket {
|
||||
entityId = buffer.readVarInt();
|
||||
effect = new StatusEffect(StatusEffects.byId(buffer.readByte()), buffer.readByte(), buffer.readVarInt());
|
||||
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;
|
||||
}
|
||||
|
||||
@ -73,4 +82,16 @@ public class PacketEntityEffect implements ClientboundPacket {
|
||||
public StatusEffect getEffect() {
|
||||
return effect;
|
||||
}
|
||||
|
||||
public boolean hideParticles() {
|
||||
return hideParticles;
|
||||
}
|
||||
|
||||
public boolean showIcon() {
|
||||
return showIcon;
|
||||
}
|
||||
|
||||
public boolean isAmbient() {
|
||||
return isAmbient;
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +95,16 @@ public class PacketPlayerDigging implements ServerboundPacket {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public static DiggingStatus byId(int id) {
|
||||
for (DiggingStatus status : values()) {
|
||||
if (status.getId() == id) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
@ -616,4 +616,7 @@ public class PacketHandler {
|
||||
|
||||
public void handle(PacketOpenBook pkg) {
|
||||
}
|
||||
|
||||
public void handle(PacketAcknowledgePlayerDigging pkg) {
|
||||
}
|
||||
}
|
||||
|
@ -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_TRADE_LIST, PacketTradeList.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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user