forked from GeyserMC/Geyser
MapItemTranslator: support map tag being of short value (#1475)
GSigns sends this as a short. Who knows why.
This commit is contained in:
parent
e0f5deb329
commit
ca1f87d464
1 changed files with 15 additions and 10 deletions
|
@ -25,10 +25,7 @@
|
||||||
|
|
||||||
package org.geysermc.connector.network.translators.item.translators.nbt;
|
package org.geysermc.connector.network.translators.item.translators.nbt;
|
||||||
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
|
import com.github.steveice10.opennbt.tag.builtin.*;
|
||||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.IntTag;
|
|
||||||
import com.github.steveice10.opennbt.tag.builtin.LongTag;
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.ItemRemapper;
|
import org.geysermc.connector.network.translators.ItemRemapper;
|
||||||
import org.geysermc.connector.network.translators.item.ItemEntry;
|
import org.geysermc.connector.network.translators.item.ItemEntry;
|
||||||
|
@ -39,15 +36,23 @@ public class MapItemTranslator extends NbtItemStackTranslator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translateToBedrock(GeyserSession session, CompoundTag itemTag, ItemEntry itemEntry) {
|
public void translateToBedrock(GeyserSession session, CompoundTag itemTag, ItemEntry itemEntry) {
|
||||||
IntTag mapId = itemTag.get("map");
|
// Can be either an IntTag or ShortTag
|
||||||
|
Tag mapId = itemTag.get("map");
|
||||||
|
if (mapId == null) return;
|
||||||
|
|
||||||
if (mapId != null) {
|
int mapValue;
|
||||||
itemTag.put(new LongTag("map_uuid", mapId.getValue()));
|
if (mapId.getValue() instanceof Short) {
|
||||||
itemTag.put(new IntTag("map_name_index", mapId.getValue()));
|
// Convert to int if necessary
|
||||||
|
mapValue = (int) (short) mapId.getValue();
|
||||||
|
} else {
|
||||||
|
mapValue = (int) mapId.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
itemTag.put(new LongTag("map_uuid", mapValue));
|
||||||
|
itemTag.put(new IntTag("map_name_index", mapValue));
|
||||||
itemTag.put(new ByteTag("map_display_players", (byte) 1));
|
itemTag.put(new ByteTag("map_display_players", (byte) 1));
|
||||||
itemTag.remove("map");
|
itemTag.remove("map");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translateToJava(CompoundTag itemTag, ItemEntry itemEntry) {
|
public void translateToJava(CompoundTag itemTag, ItemEntry itemEntry) {
|
||||||
|
|
Loading…
Reference in a new issue