Update DeclareTagsPacket

This commit is contained in:
Paul Heidenreich 2019-04-28 12:21:14 +02:00
parent f1856bcd5c
commit 264db5c4a2

View file

@ -10,18 +10,21 @@ 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;
private Map<String, int[]> entityTags;
@SuppressWarnings("unused")
private ServerDeclareTagsPacket() {
}
public ServerDeclareTagsPacket(Map<String, int[]> blockTags, Map<String, int[]> itemTags, Map<String, int[]> fluidTags) {
public ServerDeclareTagsPacket(Map<String, int[]> blockTags, Map<String, int[]> itemTags, Map<String, int[]> fluidTags, Map<String, int[]> entityTags) {
this.blockTags = blockTags;
this.itemTags = itemTags;
this.fluidTags = fluidTags;
this.entityTags = entityTags;
}
public Map<String, int[]> getBlockTags() {
@ -36,18 +39,23 @@ public class ServerDeclareTagsPacket extends MinecraftPacket {
return this.fluidTags;
}
public Map<String, int[]> getEntityTags() {
return this.entityTags;
}
@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)) {
entityTags = new HashMap<>();
for (Map<String, int[]> tags : Arrays.asList(blockTags, itemTags, fluidTags, entityTags)) {
int tagsCount = in.readVarInt();
for(int i = 0; i < tagsCount; i++) {
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++) {
for (int index = 0; index < entriesCount; index++) {
entries[index] = in.readVarInt();
}
tags.put(name, entries);
@ -57,7 +65,7 @@ public class ServerDeclareTagsPacket extends MinecraftPacket {
@Override
public void write(NetOutput out) throws IOException {
for(Map<String, int[]> tags : Arrays.asList(blockTags, itemTags, fluidTags)) {
for (Map<String, int[]> tags : Arrays.asList(blockTags, itemTags, fluidTags, entityTags)) {
out.writeVarInt(tags.size());
for (Map.Entry<String, int[]> tag : tags.entrySet()) {
out.writeString(tag.getKey());