PacketUpdateSignSending

This commit is contained in:
bixilon 2020-06-16 18:32:16 +02:00
parent fef2f20bc9
commit 0b71e739e4
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
4 changed files with 55 additions and 3 deletions

View File

@ -20,7 +20,7 @@ import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
public class PacketUpdateSign implements ClientboundPacket {
public class PacketUpdateSignReceiving implements ClientboundPacket {
BlockPosition position;
String[] lines = new String[4];

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 PacketUpdateSignSending implements ServerboundPacket {
final BlockPosition position;
final String[] lines;
public PacketUpdateSignSending(BlockPosition position, String[] lines) {
this.position = position;
this.lines = lines;
log();
}
@Override
public OutPacketBuffer write(ProtocolVersion v) {
OutPacketBuffer buffer = new OutPacketBuffer(v.getPacketCommand(Packets.Serverbound.PLAY_UPDATE_SIGN));
switch (v) {
case VERSION_1_7_10:
buffer.writeBlockPosition(position);
for (int i = 0; i < 4; i++) {
buffer.writeString(lines[i]);
}
break;
}
return buffer;
}
@Override
public void log() {
Log.protocol(String.format("Sending Sign Update: %s", position.toString()));
}
}

View File

@ -253,7 +253,7 @@ public class PacketHandler {
connection.getPlayer().getWorld().getEntity(pkg.getEntityId()).removeEffect(pkg.getEffect());
}
public void handle(PacketUpdateSign pkg) {
public void handle(PacketUpdateSignReceiving pkg) {
connection.getPlayer().getWorld().updateSign(pkg.getPosition(), pkg.getLines());
}

View File

@ -76,7 +76,7 @@ public interface Protocol {
packetClassMapping.put(Packets.Clientbound.PLAY_CHUNK_DATA, PacketChunkData.class);
packetClassMapping.put(Packets.Clientbound.PLAY_ENTITY_EFFECT, PacketEntityEffect.class);
packetClassMapping.put(Packets.Clientbound.PLAY_REMOVE_ENTITY_EFFECT, PacketRemoveEntityEffect.class);
packetClassMapping.put(Packets.Clientbound.PLAY_UPDATE_SIGN, PacketUpdateSign.class);
packetClassMapping.put(Packets.Clientbound.PLAY_UPDATE_SIGN, PacketUpdateSignReceiving.class);
packetClassMapping.put(Packets.Clientbound.PLAY_ENTITY_ANIMATION, PacketEntityAnimation.class);
packetClassMapping.put(Packets.Clientbound.PLAY_ENTITY_STATUS, PacketEntityStatus.class);
packetClassMapping.put(Packets.Clientbound.PLAY_SOUND_EFFECT, PacketSoundEffect.class);