v1.6.4: Added support for 1.20.5, 1.20.6 and 1.21 #30

Merged
stijnb1234 merged 9 commits from development into master 2024-06-30 22:46:01 +02:00
2 changed files with 12 additions and 7 deletions
Showing only changes of commit f25c727a15 - Show all commits

View file

@ -113,8 +113,6 @@ public class MapSender {
final int id = -id0;
Object packet;
if (supports(20, 4)) { //1.20.5+
//TODO: Implement 1.20.5+ map sending
Object updateData = ReflectionUtil.callConstructor(worldMapData,
content.minX, //X pos
content.minY, //Y pos
@ -123,8 +121,10 @@ public class MapSender {
content.array //Data
);
Object mapId = ReflectionUtil.callConstructor(getNMSClass("world.level.saveddata.maps", "MapId"), id);
packet = ReflectionUtil.callConstructor(packetPlayOutMapClass,
id, //ID
mapId, //ID
(byte) 0, //Scale, 0 = 1 block per pixel
false, //Show icons
new ReflectionUtil.CollectionParam<>(), //Icons

View file

@ -165,8 +165,8 @@ public class MapWrapper extends AbstractMapWrapper {
String inventoryMenuName;
if (supports(20)) {
//>= 1.20.2 = bR, 1.20(.1) = bQ
inventoryMenuName = supports(20, 2) ? "bR" : "bQ";
//1.20.5 = cb, 1.20.2 - 1.20.4 = bR, 1.20(.1) = bQ
inventoryMenuName = supports(20, 4) ? "cb" : supports(20, 2) ? "bR" : "bQ";
} else if (supports(19)) {
//1.19.4 = bO, >= 1.19.3 = bT
inventoryMenuName = supports(19, 3) ? "bO" : "bT";
@ -286,7 +286,12 @@ public class MapWrapper extends AbstractMapWrapper {
Object nmsStack = ReflectionUtil.callMethod(craftStackClass, "asNMSCopy", stack);
if (supports(13)) {
//1.20.5 uses new NBT compound system
if (supports(20, 4)) {
Object mapIdComponent = ReflectionUtil.getDeclaredField(getNMSClass("core.component", "DataComponents"), "B");
Object mapId1 = ReflectionUtil.callConstructor(getNMSClass("world.level.saveddata.maps", "MapId"), mapId);
ReflectionUtil.callMethod(nmsStack, "b", mapIdComponent, mapId1);
} else if (supports(13)) {
String nbtObjectName;
if (supports(20)) { //1.20
nbtObjectName = "w";
@ -328,7 +333,7 @@ public class MapWrapper extends AbstractMapWrapper {
Object packet;
if (supports(19, 3)) { //1.19.3
Class<?> dataWatcherRecordClass = getNMSClass("network.syncher", "DataWatcher$b");
Class<?> dataWatcherRecordClass = getNMSClass("network.syncher", supports(20, 4) ? "DataWatcher$c" : "DataWatcher$b"); //1.20.5 = c, lower is b
// Sadly not possible to use ReflectionUtil (in its current state), because of the Object parameter
Object dataWatcherItem;
try {