mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Update ServerMapDataPacket
This commit is contained in:
parent
1520ef7deb
commit
3eabf389fa
4 changed files with 63 additions and 20 deletions
|
@ -490,12 +490,23 @@ public class MagicValues {
|
|||
register(MapIconType.SMALL_WHITE_CIRCLE, 7);
|
||||
register(MapIconType.MANSION, 8);
|
||||
register(MapIconType.TEMPLE, 9);
|
||||
register(MapIconType.UNUSED_10, 10);
|
||||
register(MapIconType.UNUSED_11, 11);
|
||||
register(MapIconType.UNUSED_12, 12);
|
||||
register(MapIconType.UNUSED_13, 13);
|
||||
register(MapIconType.UNUSED_14, 14);
|
||||
register(MapIconType.UNUSED_15, 15);
|
||||
register(MapIconType.WHITE_BANNER, 10);
|
||||
register(MapIconType.ORANGE_BANNER, 11);
|
||||
register(MapIconType.MAGENTA_BANNER, 12);
|
||||
register(MapIconType.LIGHT_BLUE_BANNER, 13);
|
||||
register(MapIconType.YELLOW_BANNER, 14);
|
||||
register(MapIconType.LIME_BANNER, 15);
|
||||
register(MapIconType.PINK_BANNER, 16);
|
||||
register(MapIconType.GRAY_BANNER, 17);
|
||||
register(MapIconType.LIGHT_GRAY_BANNER, 18);
|
||||
register(MapIconType.CYAN_BANNER, 19);
|
||||
register(MapIconType.PURPLE_BANNER, 20);
|
||||
register(MapIconType.BLUE_BANNER, 21);
|
||||
register(MapIconType.BROWN_BANNER, 22);
|
||||
register(MapIconType.GREEN_BANNER, 23);
|
||||
register(MapIconType.RED_BANNER, 24);
|
||||
register(MapIconType.BLACK_BANNER, 25);
|
||||
register(MapIconType.TREASURE_MARKER, 26);
|
||||
|
||||
register(WindowType.GENERIC_INVENTORY, "minecraft:container");
|
||||
register(WindowType.ANVIL, "minecraft:anvil");
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.world.map;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.util.ObjectUtil;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class MapIcon {
|
||||
private int centerX;
|
||||
private int centerZ;
|
||||
private MapIconType iconType;
|
||||
private int iconRotation;
|
||||
private Message displayName;
|
||||
|
||||
public MapIcon(int centerX, int centerZ, MapIconType iconType, int iconRotation) {
|
||||
public MapIcon(int centerX, int centerZ, MapIconType iconType, int iconRotation, Message displayName) {
|
||||
this.centerX = centerX;
|
||||
this.centerZ = centerZ;
|
||||
this.iconType = iconType;
|
||||
this.iconRotation = iconRotation;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public int getCenterX() {
|
||||
|
@ -31,6 +36,10 @@ public class MapIcon {
|
|||
return this.iconRotation;
|
||||
}
|
||||
|
||||
public Message getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) return true;
|
||||
|
@ -40,12 +49,13 @@ public class MapIcon {
|
|||
return this.centerX == that.centerX &&
|
||||
this.centerZ == that.centerZ &&
|
||||
this.iconType == that.iconType &&
|
||||
this.iconRotation == that.iconRotation;
|
||||
this.iconRotation == that.iconRotation &&
|
||||
Objects.equals(this.displayName, that.displayName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ObjectUtil.hashCode(this.centerX, this.centerZ, this.iconType, this.iconRotation);
|
||||
return ObjectUtil.hashCode(this.centerX, this.centerZ, this.iconType, this.iconRotation, this.displayName);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,10 +11,21 @@ public enum MapIconType {
|
|||
SMALL_WHITE_CIRCLE,
|
||||
MANSION,
|
||||
TEMPLE,
|
||||
UNUSED_10,
|
||||
UNUSED_11,
|
||||
UNUSED_12,
|
||||
UNUSED_13,
|
||||
UNUSED_14,
|
||||
UNUSED_15;
|
||||
WHITE_BANNER,
|
||||
ORANGE_BANNER,
|
||||
MAGENTA_BANNER,
|
||||
LIGHT_BLUE_BANNER,
|
||||
YELLOW_BANNER,
|
||||
LIME_BANNER,
|
||||
PINK_BANNER,
|
||||
GRAY_BANNER,
|
||||
LIGHT_GRAY_BANNER,
|
||||
CYAN_BANNER,
|
||||
PURPLE_BANNER,
|
||||
BLUE_BANNER,
|
||||
BROWN_BANNER,
|
||||
GREEN_BANNER,
|
||||
RED_BANNER,
|
||||
BLACK_BANNER,
|
||||
TREASURE_MARKER;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.github.steveice10.mc.protocol.data.MagicValues;
|
|||
import com.github.steveice10.mc.protocol.data.game.world.map.MapData;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.map.MapIcon;
|
||||
import com.github.steveice10.mc.protocol.data.game.world.map.MapIconType;
|
||||
import com.github.steveice10.mc.protocol.data.message.Message;
|
||||
import com.github.steveice10.mc.protocol.packet.MinecraftPacket;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
|
@ -61,12 +62,15 @@ public class ServerMapDataPacket extends MinecraftPacket {
|
|||
this.trackingPosition = in.readBoolean();
|
||||
this.icons = new MapIcon[in.readVarInt()];
|
||||
for(int index = 0; index < this.icons.length; index++) {
|
||||
int data = in.readUnsignedByte();
|
||||
int type = (data >> 4) & 15;
|
||||
int rotation = data & 15;
|
||||
int type = in.readVarInt();
|
||||
int x = in.readUnsignedByte();
|
||||
int z = in.readUnsignedByte();
|
||||
this.icons[index] = new MapIcon(x, z, MagicValues.key(MapIconType.class, type), rotation);
|
||||
int rotation = in.readUnsignedByte();
|
||||
Message displayName = null;
|
||||
if (in.readBoolean()) {
|
||||
displayName = Message.fromString(in.readString());
|
||||
}
|
||||
this.icons[index] = new MapIcon(x, z, MagicValues.key(MapIconType.class, type), rotation, displayName);
|
||||
}
|
||||
|
||||
int columns = in.readUnsignedByte();
|
||||
|
@ -88,9 +92,16 @@ public class ServerMapDataPacket extends MinecraftPacket {
|
|||
for(int index = 0; index < this.icons.length; index++) {
|
||||
MapIcon icon = this.icons[index];
|
||||
int type = MagicValues.value(Integer.class, icon.getIconType());
|
||||
out.writeByte((type & 15) << 4 | icon.getIconRotation() & 15);
|
||||
out.writeVarInt(type);
|
||||
out.writeByte(icon.getCenterX());
|
||||
out.writeByte(icon.getCenterZ());
|
||||
out.writeByte(icon.getIconRotation());
|
||||
if (icon.getDisplayName() != null) {
|
||||
out.writeBoolean(false);
|
||||
out.writeString(icon.getDisplayName().toJsonString());
|
||||
} else {
|
||||
out.writeBoolean(true);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.data != null && this.data.getColumns() != 0) {
|
||||
|
|
Loading…
Reference in a new issue