v1.6.4: Added support for 1.20.5, 1.20.6 and 1.21 #30
6 changed files with 34 additions and 18 deletions
4
.github/workflows/maven.yml
vendored
4
.github/workflows/maven.yml
vendored
|
@ -10,10 +10,10 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: Set up JDK 11
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 11
|
||||
java-version: 21
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -30,7 +30,7 @@
|
|||
</set>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
|
@ -69,7 +69,7 @@ public class MapReflectionAPI extends JavaPlugin {
|
|||
getLogger().info("Made by © Copyright SBDevelopment 2023");
|
||||
|
||||
if (!supports(12)) {
|
||||
getLogger().severe("MapReflectionAPI only supports Minecraft 1.12 - 1.19.4!");
|
||||
getLogger().severe("MapReflectionAPI only supports Minecraft 1.12 - 1.20.5!");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,25 @@ public class MapSender {
|
|||
}
|
||||
|
||||
Object packet;
|
||||
if (supports(17)) { //1.17+
|
||||
if (supports(20, 4)) { //1.20.5+
|
||||
Object updateData = ReflectionUtil.callConstructor(worldMapData,
|
||||
content.minX, //X pos
|
||||
content.minY, //Y pos
|
||||
content.maxX, //X size (2nd X pos)
|
||||
content.maxY, //Y size (2nd Y pos)
|
||||
content.array //Data
|
||||
);
|
||||
|
||||
Object mapId = ReflectionUtil.callConstructor(getNMSClass("world.level.saveddata.maps", "MapId"), id);
|
||||
|
||||
packet = ReflectionUtil.callConstructor(packetPlayOutMapClass,
|
||||
mapId, //ID
|
||||
(byte) 0, //Scale, 0 = 1 block per pixel
|
||||
false, //Show icons
|
||||
new ReflectionUtil.CollectionParam<>(), //Icons
|
||||
updateData
|
||||
);
|
||||
} else if (supports(17)) { //1.17+
|
||||
Object updateData = ReflectionUtil.callConstructor(worldMapData,
|
||||
content.minX, //X pos
|
||||
content.minY, //Y pos
|
||||
|
|
|
@ -170,8 +170,8 @@ public class MapWrapper extends AbstractMapWrapper {
|
|||
//1.21 = cc
|
||||
inventoryMenuName = "cc";
|
||||
} else 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";
|
||||
|
@ -291,14 +291,12 @@ public class MapWrapper extends AbstractMapWrapper {
|
|||
|
||||
Object nmsStack = ReflectionUtil.callMethod(craftStackClass, "asNMSCopy", stack);
|
||||
|
||||
if (supports(21)) { //1.21 method
|
||||
Object minecraftKey = ReflectionUtil.callDeclaredMethod(minecraftKeyClass, "a", "minecraft:map_id");
|
||||
Object dataComponentTypeRegistery = ReflectionUtil.getDeclaredField(builtInRegistriesClass, "aq");
|
||||
Object dataComponentType = ReflectionUtil.callMethod(dataComponentTypeRegistery, "a", minecraftKey);
|
||||
|
||||
Object dataComponentMap = ReflectionUtil.callMethod(nmsStack, "a");
|
||||
ReflectionUtil.callMethod(dataComponentMap, "a", dataComponentType, mapId);
|
||||
} else if (supports(13)) { //1.13 - 1.20 method
|
||||
//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";
|
||||
|
@ -342,7 +340,7 @@ public class MapWrapper extends AbstractMapWrapper {
|
|||
|
||||
Object packet;
|
||||
if (supports(19, 3)) { //1.19.3
|
||||
Class<?> dataWatcherRecordClass = getNMSClass("network.syncher", "DataWatcher$" + (supports(21) ? "c" : "b"));
|
||||
Class<?> dataWatcherRecordClass = getNMSClass("network.syncher", "DataWatcher$" + (supports(20, 4) ? "c" : "b"));
|
||||
// Sadly not possible to use ReflectionUtil (in its current state), because of the Object parameter
|
||||
Object dataWatcherItem;
|
||||
try {
|
||||
|
|
|
@ -140,8 +140,8 @@ public class PacketListener implements Listener {
|
|||
} else if (packet.getClass().isAssignableFrom(packetPlayInSetCreativeSlotClass)) {
|
||||
Object packetPlayInSetCreativeSlot = packetPlayInSetCreativeSlotClass.cast(packet);
|
||||
|
||||
int slot = (int) ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, supports(21) ? "b" : supports(19, 4) ? "a" : supports(13) ? "b" : "a"); //1.21 = b, 1.19.4 = a, 1.19.3 - 1.13 = b, 1.12 = a
|
||||
Object nmsStack = ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, supports(21) ? "e" : supports(20, 2) ? "d" : supports(18) ? "c" : "getItemStack"); //1.21 = e, 1.20.2 = d, >= 1.18 = c, 1.17 = getItemStack
|
||||
int slot = (int) ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, supports(20, 4) ? "b" : supports(19, 4) ? "a" : supports(13) ? "b" : "a"); //1.20.4 - 1.19.4 = a, 1.19.3 - 1.13 and 1.20.5 = b, 1.12 = a
|
||||
Object nmsStack = ReflectionUtil.callDeclaredMethod(packetPlayInSetCreativeSlot, supports(20, 4) ? "e" : supports(20, 2) ? "d" : supports(18) ? "c" : "getItemStack"); //1.20.5 = e, 1.20.2-1.20.4 = d, >= 1.18 = c, 1.17 = getItemStack
|
||||
ItemStack craftStack = (ItemStack) ReflectionUtil.callMethod(craftStackClass, "asBukkitCopy", nmsStack);
|
||||
|
||||
boolean async = !MapReflectionAPI.getInstance().getServer().isPrimaryThread();
|
||||
|
|
Loading…
Add table
Reference in a new issue