mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Add ServerDeclareTagsPacket
This commit is contained in:
parent
e9686ac487
commit
e632e480cd
2 changed files with 73 additions and 1 deletions
|
@ -45,6 +45,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.server.ServerChatPacket;
|
|||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerCombatPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDeclareCommandsPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDeclareRecipesPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDeclareTagsPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDifficultyPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerDisconnectPacket;
|
||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
||||
|
@ -430,7 +431,7 @@ public class MinecraftProtocol extends PacketProtocol {
|
|||
this.registerIncoming(0x52, ServerEntityPropertiesPacket.class);
|
||||
this.registerIncoming(0x53, ServerEntityEffectPacket.class);
|
||||
this.registerIncoming(0x54, ServerDeclareRecipesPacket.class);
|
||||
// FIXME: 55
|
||||
this.registerIncoming(0x55, ServerDeclareTagsPacket.class);
|
||||
|
||||
this.registerOutgoing(0x00, ClientTeleportConfirmPacket.class);
|
||||
// FIXME: 01
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.server;
|
||||
|
||||
import com.github.steveice10.mc.protocol.packet.MinecraftPacket;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ServerDeclareTagsPacket extends MinecraftPacket {
|
||||
private Map<String, int[]> blockTags;
|
||||
private Map<String, int[]> itemTags;
|
||||
private Map<String, int[]> fluidTags;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private ServerDeclareTagsPacket() {
|
||||
}
|
||||
|
||||
public ServerDeclareTagsPacket(Map<String, int[]> blockTags, Map<String, int[]> itemTags, Map<String, int[]> fluidTags) {
|
||||
this.blockTags = blockTags;
|
||||
this.itemTags = itemTags;
|
||||
this.fluidTags = fluidTags;
|
||||
}
|
||||
|
||||
public Map<String, int[]> getBlockTags() {
|
||||
return this.blockTags;
|
||||
}
|
||||
|
||||
public Map<String, int[]> getItemTags() {
|
||||
return this.itemTags;
|
||||
}
|
||||
|
||||
public Map<String, int[]> getFluidTags() {
|
||||
return this.fluidTags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NetInput in) throws IOException {
|
||||
blockTags = new HashMap<>();
|
||||
itemTags = new HashMap<>();
|
||||
fluidTags = new HashMap<>();
|
||||
for(Map<String, int[]> tags : Arrays.asList(blockTags, itemTags, fluidTags)) {
|
||||
int tagsCount = in.readVarInt();
|
||||
for(int i = 0; i < tagsCount; i++) {
|
||||
String name = in.readString();
|
||||
int entriesCount = in.readVarInt();
|
||||
int[] entries = new int[entriesCount];
|
||||
for(int index = 0; index < entriesCount; index++) {
|
||||
entries[index] = in.readVarInt();
|
||||
}
|
||||
tags.put(name, entries);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(NetOutput out) throws IOException {
|
||||
for(Map<String, int[]> tags : Arrays.asList(blockTags, itemTags, fluidTags)) {
|
||||
out.writeVarInt(tags.size());
|
||||
for (Map.Entry<String, int[]> tag : tags.entrySet()) {
|
||||
out.writeString(tag.getKey());
|
||||
out.writeVarInt(tag.getValue().length);
|
||||
for (int id : tag.getValue()) {
|
||||
out.writeVarInt(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue