mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 17:37:58 -04:00
1.12.2: all remaining packets
This commit is contained in:
parent
db8b603eed
commit
ab4bf090b3
@ -20,7 +20,7 @@ import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
|
|||||||
import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
|
import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
|
||||||
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
||||||
|
|
||||||
public class PacketChatMessage implements ClientboundPacket {
|
public class PacketChatMessageReceiving implements ClientboundPacket {
|
||||||
TextComponent c;
|
TextComponent c;
|
||||||
TextPosition position;
|
TextPosition position;
|
||||||
|
|
@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* 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.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 PacketAdvancementTab implements ServerboundPacket {
|
||||||
|
final AdvancementTabStatus action;
|
||||||
|
final String tabToOpen;
|
||||||
|
|
||||||
|
public PacketAdvancementTab(AdvancementTabStatus action) {
|
||||||
|
this.action = action;
|
||||||
|
tabToOpen = null;
|
||||||
|
log();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketAdvancementTab(AdvancementTabStatus action, String tabToOpen) {
|
||||||
|
this.action = action;
|
||||||
|
this.tabToOpen = tabToOpen;
|
||||||
|
log();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OutPacketBuffer write(ProtocolVersion version) {
|
||||||
|
OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.PLAY_ADVANCEMENT_TAB));
|
||||||
|
switch (version) {
|
||||||
|
case VERSION_1_12_2:
|
||||||
|
buffer.writeVarInt(action.getId());
|
||||||
|
if (action == AdvancementTabStatus.OPEN_TAB) {
|
||||||
|
buffer.writeString(tabToOpen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void log() {
|
||||||
|
Log.protocol(String.format("Sending advancement tab packet (action=%s, tabToOpen=%s)", action.name(), tabToOpen));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum AdvancementTabStatus {
|
||||||
|
OPEN_TAB(0),
|
||||||
|
CLOSE_TAB(1);
|
||||||
|
|
||||||
|
final int id;
|
||||||
|
|
||||||
|
|
||||||
|
AdvancementTabStatus(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AdvancementTabStatus byId(int id) {
|
||||||
|
for (AdvancementTabStatus action : values()) {
|
||||||
|
if (action.getId() == id) {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,11 +19,11 @@ import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
|
|||||||
import de.bixilon.minosoft.protocol.protocol.Packets;
|
import de.bixilon.minosoft.protocol.protocol.Packets;
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||||
|
|
||||||
public class PacketChatMessage implements ServerboundPacket {
|
public class PacketChatMessageSending implements ServerboundPacket {
|
||||||
|
|
||||||
final String message;
|
final String message;
|
||||||
|
|
||||||
public PacketChatMessage(String message) {
|
public PacketChatMessageSending(String message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
log();
|
log();
|
||||||
}
|
}
|
@ -0,0 +1,102 @@
|
|||||||
|
/*
|
||||||
|
* 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.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 PacketCraftingBookData implements ServerboundPacket {
|
||||||
|
final BookDataStatus action;
|
||||||
|
|
||||||
|
final int recipeId;
|
||||||
|
|
||||||
|
final boolean craftingBookOpen;
|
||||||
|
final boolean craftingFilter;
|
||||||
|
|
||||||
|
public PacketCraftingBookData(BookDataStatus action, int recipeId) {
|
||||||
|
this.action = action;
|
||||||
|
this.recipeId = recipeId;
|
||||||
|
craftingBookOpen = false;
|
||||||
|
craftingFilter = false;
|
||||||
|
log();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PacketCraftingBookData(BookDataStatus action, boolean craftingBookOpen, boolean craftingFilter) {
|
||||||
|
this.action = action;
|
||||||
|
this.recipeId = 0;
|
||||||
|
this.craftingBookOpen = craftingBookOpen;
|
||||||
|
this.craftingFilter = craftingFilter;
|
||||||
|
log();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OutPacketBuffer write(ProtocolVersion version) {
|
||||||
|
OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.PLAY_RECIPE_BOOK_DATA));
|
||||||
|
switch (version) {
|
||||||
|
case VERSION_1_12_2:
|
||||||
|
buffer.writeVarInt(action.getId());
|
||||||
|
switch (action) {
|
||||||
|
case DISPLAY_RECIPE:
|
||||||
|
buffer.writeVarInt(recipeId);
|
||||||
|
break;
|
||||||
|
case CRAFTING_BOOK_STATUS:
|
||||||
|
buffer.writeBoolean(craftingBookOpen);
|
||||||
|
buffer.writeBoolean(craftingFilter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void log() {
|
||||||
|
switch (action) {
|
||||||
|
case DISPLAY_RECIPE:
|
||||||
|
Log.protocol(String.format("Sending crafting book status (action=%s, recipeId=%d)", action.name(), recipeId));
|
||||||
|
break;
|
||||||
|
case CRAFTING_BOOK_STATUS:
|
||||||
|
Log.protocol(String.format("Sending crafting book status (action=%s, craftingBookOpen=%s, craftingFilter=%s)", action.name(), craftingBookOpen, craftingFilter));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum BookDataStatus {
|
||||||
|
DISPLAY_RECIPE(0),
|
||||||
|
CRAFTING_BOOK_STATUS(1);
|
||||||
|
|
||||||
|
final int id;
|
||||||
|
|
||||||
|
|
||||||
|
BookDataStatus(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BookDataStatus byId(int id) {
|
||||||
|
for (BookDataStatus action : values()) {
|
||||||
|
if (action.getId() == id) {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* 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.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 PacketCraftingRecipeRequest implements ServerboundPacket {
|
||||||
|
final byte windowId;
|
||||||
|
final int recipeId;
|
||||||
|
|
||||||
|
public PacketCraftingRecipeRequest(byte windowId, int recipeId) {
|
||||||
|
this.windowId = windowId;
|
||||||
|
this.recipeId = recipeId;
|
||||||
|
log();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OutPacketBuffer write(ProtocolVersion version) {
|
||||||
|
OutPacketBuffer buffer = new OutPacketBuffer(version, version.getPacketCommand(Packets.Serverbound.PLAY_CRAFT_RECIPE_REQUEST));
|
||||||
|
switch (version) {
|
||||||
|
case VERSION_1_12_2:
|
||||||
|
buffer.writeByte(windowId);
|
||||||
|
buffer.writeVarInt(recipeId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void log() {
|
||||||
|
Log.protocol(String.format("Sending entity action packet (windowId=%d, recipeId=%d)", windowId, recipeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -181,7 +181,7 @@ public class PacketHandler {
|
|||||||
connection.getPlayer().setSpawnLocation(pkg.getSpawnLocation());
|
connection.getPlayer().setSpawnLocation(pkg.getSpawnLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PacketChatMessage pkg) {
|
public void handle(PacketChatMessageReceiving pkg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PacketDisconnect pkg) {
|
public void handle(PacketDisconnect pkg) {
|
||||||
@ -574,4 +574,5 @@ public class PacketHandler {
|
|||||||
|
|
||||||
public void handle(PacketAdvancements pkg) {
|
public void handle(PacketAdvancements pkg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class PacketSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendChatMessage(String message) {
|
public void sendChatMessage(String message) {
|
||||||
connection.sendPacket(new PacketChatMessage(message));
|
connection.sendPacket(new PacketChatMessageSending(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void spectateEntity(UUID entityUUID) {
|
public void spectateEntity(UUID entityUUID) {
|
||||||
|
@ -77,7 +77,7 @@ public abstract class Protocol implements ProtocolInterface {
|
|||||||
packetClassMapping.put(Packets.Clientbound.PLAY_UPDATE_HEALTH, PacketUpdateHealth.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_UPDATE_HEALTH, PacketUpdateHealth.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_PLUGIN_MESSAGE, PacketPluginMessageReceiving.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_PLUGIN_MESSAGE, PacketPluginMessageReceiving.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_SPAWN_POSITION, PacketSpawnLocation.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_SPAWN_POSITION, PacketSpawnLocation.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_CHAT_MESSAGE, PacketChatMessage.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_CHAT_MESSAGE, PacketChatMessageReceiving.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_DISCONNECT, PacketDisconnect.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_DISCONNECT, PacketDisconnect.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_HELD_ITEM_CHANGE, PacketHeldItemChangeReceiving.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_HELD_ITEM_CHANGE, PacketHeldItemChangeReceiving.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_SET_EXPERIENCE, PacketSetExperience.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_SET_EXPERIENCE, PacketSetExperience.class);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user