1313 */
1414public class SentinelNMSHelper {
1515
16- public static MethodHandle CRAFTENTITY_GETHANDLE , NMSENTITY_WORLDGETTER , NMSWORLD_BROADCASTENTITYEFFECT , NMSENTITY_GETDATAWATCHER , DATWATCHER_SET , LIVINGENTITY_ATTACKSTRENGTHTICKS ;
16+ public static MethodHandle CRAFTENTITY_GETHANDLE , NMSENTITY_WORLDGETTER , NMSWORLD_BROADCASTENTITYEFFECT , NMSENTITY_GETDATAWATCHER , DATWATCHER_SET ;
1717
1818 public static Object ENTITYENDERMAN_DATAWATCHER_ANGRY ;
1919
@@ -27,8 +27,6 @@ public static void init() {
2727 }
2828 // Will be like "org.bukkit.craftbukkit.v1_16_R3"
2929 String bukkitPackageName = Bukkit .getServer ().getClass ().getPackage ().getName ();
30- // Should be like "v1_16_R3"
31- String packageVersion = bukkitPackageName .substring (bukkitPackageName .lastIndexOf ('.' ) + 1 );
3230 Class craftEntity = Class .forName (bukkitPackageName + ".entity.CraftEntity" );
3331 CRAFTENTITY_GETHANDLE = NMS .getMethodHandle (craftEntity , "getHandle" , true );
3432 Class nmsEntity , nmsWorld , nmsDataWatcher , nmsDataWatcherObject , nmsEntityEnderman , nmsHuman , nmsLivingEntity ;
@@ -40,43 +38,30 @@ public static void init() {
4038 nmsDataWatcher = Class .forName ("net.minecraft.network.syncher.DataWatcher" ); // SynchedEntityData
4139 nmsDataWatcherObject = Class .forName ("net.minecraft.network.syncher.DataWatcherObject" ); // EntityDataAccessor
4240 nmsEntityEnderman = Class .forName ("net.minecraft.world.entity.monster.EntityEnderman" );
43- nmsLivingEntity = Class .forName ("net.minecraft.world.entity.EntityLiving" );
44- String attackStrengthField = null ;
45- boolean isCompat = false ;
4641 if (SentinelVersionCompat .v1_20 && !SentinelVersionCompat .vFuture ) { // 1.20 names
47- // https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.20
42+ // https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.20.2
4843 endermanAngryField = "bV" ; // net.minecraft.world.entity.monster.EnderMan#DATA_CREEPY
49- attackStrengthField = "aQ" ; // net.minecraft.world.entity.LivingEntity#attackStrengthTicker
5044 broadcastEffectMethod = "a" ; // net.minecraft.world.level.Level#broadcastEntityEvent(Entity,byte)
5145 dataWatcherSet = "a" ; // net.minecraft.network.syncher.SynchedEntityData#set
52- isCompat = true ;
5346 }
5447 else if (SentinelVersionCompat .v1_19 && !SentinelVersionCompat .v1_20 ) { // 1.19.4 names
5548 // https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.19.4
5649 endermanAngryField = "bU" ; // net.minecraft.world.entity.monster.EnderMan#DATA_CREEPY
57- attackStrengthField = "aO" ; // net.minecraft.world.entity.LivingEntity#attackStrengthTicker
5850 broadcastEffectMethod = "a" ; // net.minecraft.world.level.Level#broadcastEntityEvent(Entity,byte)
5951 dataWatcherSet = "b" ; // net.minecraft.network.syncher.SynchedEntityData#set
60- isCompat = true ;
6152 }
6253 else if (SentinelVersionCompat .v1_18 && !SentinelVersionCompat .v1_19 ) { // 1.18 names
6354 // https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.18.2
6455 endermanAngryField = "bX" ; // net.minecraft.world.entity.monster.EnderMan#DATA_CREEPY
65- attackStrengthField = "aQ" ; // net.minecraft.world.entity.LivingEntity#attackStrengthTicker
6656 broadcastEffectMethod = "a" ; // net.minecraft.world.level.Level#broadcastEntityEvent(Entity,byte)
6757 dataWatcherSet = "b" ; // net.minecraft.network.syncher.SynchedEntityData#set
68- isCompat = true ;
6958 }
7059 else if (!SentinelVersionCompat .v1_18 ) { // 1.17 names
7160 endermanAngryField = "bV" ; // EnderMan#DATA_CREEPY
72- attackStrengthField = "aQ" ; // LivingEntity#attackStrengthTicker
73- isCompat = true ;
74- }
75- if (isCompat ) {
76- LIVINGENTITY_ATTACKSTRENGTHTICKS = NMS .getSetter (nmsLivingEntity , attackStrengthField );
7761 }
7862 }
7963 else { // 1.12 through 1.16 - Original Spigot NMS versioned mappings
64+ String packageVersion = bukkitPackageName .substring (bukkitPackageName .lastIndexOf ('.' ) + 1 ); // Should be like "v1_16_R3"
8065 String nmsPackageName = "net.minecraft.server." + packageVersion ;
8166 nmsEntity = Class .forName (nmsPackageName + ".Entity" );
8267 nmsWorld = Class .forName (nmsPackageName + ".World" );
0 commit comments