From a69bb91f649433735bbfd5557b834a97aa9528d3 Mon Sep 17 00:00:00 2001 From: Bixilon Date: Fri, 3 Jul 2020 14:14:20 +0200 Subject: [PATCH] PacketSetCooldown --- .../clientbound/play/PacketSetCooldown.java | 57 +++++++++++++++++++ .../protocol/protocol/PacketHandler.java | 3 + 2 files changed, 60 insertions(+) create mode 100644 src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSetCooldown.java diff --git a/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSetCooldown.java b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSetCooldown.java new file mode 100644 index 000000000..b40db5f05 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/protocol/packets/clientbound/play/PacketSetCooldown.java @@ -0,0 +1,57 @@ +/* + * 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 . + * + * 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.entities.Items; +import de.bixilon.minosoft.logging.Log; +import de.bixilon.minosoft.protocol.packets.ClientboundPacket; +import de.bixilon.minosoft.protocol.protocol.InPacketBuffer; +import de.bixilon.minosoft.protocol.protocol.PacketHandler; + +public class PacketSetCooldown implements ClientboundPacket { + + Items item; + int cooldownTicks; + + + @Override + public boolean read(InPacketBuffer buffer) { + switch (buffer.getVersion()) { + case VERSION_1_9_4: + item = Items.byLegacy(buffer.readVarInt()); + cooldownTicks = buffer.readVarInt(); + return true; + } + + return false; + } + + @Override + public void log() { + Log.protocol(String.format("Receiving item cooldown (item=%s, coolDown=%dt)", item.name(), cooldownTicks)); + } + + @Override + public void handle(PacketHandler h) { + h.handle(this); + } + + public Items getItem() { + return item; + } + + public int getCooldownTicks() { + return cooldownTicks; + } +} diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java index f7d5e956b..0329d72e6 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java +++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/PacketHandler.java @@ -549,4 +549,7 @@ public class PacketHandler { public void handle(PacketSetPassenger pkg) { //ToDo } + + public void handle(PacketSetCooldown pkg) { + } }