Skip to content

Commit 2bd2c52

Browse files
committed
target MC 1.21.3
1 parent a3c9fa5 commit 2bd2c52

5 files changed

Lines changed: 27 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Sentinel NPCs: Combat NPCs for Spigot!
2222

2323
![AnimatedSentinel](https://i.imgur.com/VDwTzrs.gif)
2424

25-
**Version 2.9.1**: Compatible with Spigot 1.8.8 through 1.21 (Primarily targeted at 1.21 - see 'Common Issues' section below if on older supported versions)
25+
**Version 2.9.2**: Compatible with Spigot 1.8.8 through 1.21.3 (Primarily targeted at 1.21.3 - see 'Common Issues' section below if on older supported versions)
2626

2727
### Downloads
2828

@@ -345,7 +345,7 @@ If you're building a separate plugin you would like to integrate into Sentinel,
345345
<dependency>
346346
<groupId>org.mcmonkey</groupId>
347347
<artifactId>sentinel</artifactId>
348-
<version>2.9.1-SNAPSHOT</version>
348+
<version>2.9.2-SNAPSHOT</version>
349349
<type>jar</type>
350350
<scope>provided</scope>
351351
<exclusions>

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
<groupId>org.mcmonkey</groupId>
88
<artifactId>sentinel</artifactId>
99
<packaging>jar</packaging>
10-
<version>2.9.1-SNAPSHOT</version>
10+
<version>2.9.2-SNAPSHOT</version>
1111
<name>Sentinel</name>
1212
<description>Combat NPCs for Spigot</description>
1313

1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16-
<bukkit.version>1.21-R0.1-SNAPSHOT</bukkit.version>
17-
<citizens.version>2.0.35-SNAPSHOT</citizens.version>
16+
<bukkit.version>1.21.3-R0.1-SNAPSHOT</bukkit.version>
17+
<citizens.version>2.0.36-SNAPSHOT</citizens.version>
1818
<BUILD_NUMBER>Unknown</BUILD_NUMBER>
1919
</properties>
2020

src/main/java/org/mcmonkey/sentinel/SentinelWeaponHelper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.bukkit.Bukkit;
44
import org.bukkit.Location;
55
import org.bukkit.Material;
6-
import org.bukkit.attribute.Attribute;
76
import org.bukkit.enchantments.Enchantment;
87
import org.bukkit.entity.*;
98
import org.bukkit.inventory.ItemStack;
@@ -396,7 +395,7 @@ public void knockback(LivingEntity entity, float force) {
396395
return;
397396
}
398397
if (SentinelVersionCompat.v1_12) {
399-
float resist = (float) entity.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).getValue();
398+
float resist = (float) entity.getAttribute(SentinelAPIBreakageFix.ATTRIBUTE_GENERIC_KNOCKBACK_RESISTANCE).getValue();
400399
if (resist > 0.0 && resist <= 1.0) {
401400
force *= (1.0 - resist);
402401
}

src/main/java/org/mcmonkey/sentinel/utilities/SentinelAPIBreakageFix.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.mcmonkey.sentinel.utilities;
22

33
import org.bukkit.Particle;
4+
import org.bukkit.attribute.Attribute;
45
import org.bukkit.enchantments.Enchantment;
56
import org.bukkit.entity.EntityType;
67
import org.bukkit.potion.PotionType;
@@ -30,6 +31,8 @@ public class SentinelAPIBreakageFix {
3031

3132
public static Particle PARTICLE_SPELL = _getEnumValue(Particle.class, "SPELL", "EFFECT");
3233

34+
public static Attribute ATTRIBUTE_GENERIC_KNOCKBACK_RESISTANCE = _getEnumValue(Attribute.class, "GENERIC_KNOCKBACK_RESISTANCE", "KNOCKBACK_RESISTANCE");
35+
3336
/**
3437
* Note: not necessarily actually an enum.
3538
*/

src/main/java/org/mcmonkey/sentinel/utilities/SentinelNMSHelper.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ public class SentinelNMSHelper {
2222

2323
public static MethodHandle INVENTORYCLOSEEVENT_GETVIEW, INVENTORYVIEW_GETTITLE;
2424

25+
public static Class<?> getOptionalFieldType(Class<?> clazz, String fieldName) {
26+
try {
27+
return clazz.getDeclaredField(fieldName).getType();
28+
}
29+
catch (NoSuchFieldException ex) {
30+
return null;
31+
}
32+
}
33+
2534
public static void init() {
2635
try {
2736
if (SentinelVersionCompat.v1_10) {
@@ -46,15 +55,21 @@ public static void init() {
4655
nmsDataWatcherObject = Class.forName("net.minecraft.network.syncher.DataWatcherObject"); // EntityDataAccessor
4756
nmsEntityEnderman = Class.forName("net.minecraft.world.entity.monster.EntityEnderman");
4857
if (SentinelVersionCompat.v1_21 && !SentinelVersionCompat.vFuture) { // 1.21 names
49-
// https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.21
50-
endermanAngryField = "ce"; // net.minecraft.world.entity.monster.EnderMan#DATA_CREEPY
58+
// https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.21.3
59+
if (getOptionalFieldType(nmsEntityEnderman, "cc") == nmsDataWatcherObject) {
60+
endermanAngryField = "cc"; // net.minecraft.world.entity.monster.EnderMan#DATA_CREEPY
61+
}
62+
else {
63+
// https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.21
64+
endermanAngryField = "ce"; // net.minecraft.world.entity.monster.EnderMan#DATA_CREEPY
65+
}
5166
broadcastEffectMethod = "a"; // net.minecraft.world.level.Level#broadcastEntityEvent(Entity,byte)
5267
dataWatcherSet = "a"; // net.minecraft.network.syncher.SynchedEntityData#set
5368
}
5469
else if (SentinelVersionCompat.v1_20 && !SentinelVersionCompat.v1_21) { // 1.20 names
5570
try {
5671
// https://minidigger.github.io/MiniMappingViewer/#/mojang/server/1.20.2
57-
if (nmsEntityEnderman.getDeclaredField("bV") != null) {
72+
if (getOptionalFieldType(nmsEntityEnderman, "bV") == nmsDataWatcherObject) {
5873
endermanAngryField = "bV"; // net.minecraft.world.entity.monster.EnderMan#DATA_CREEPY
5974
}
6075
}

0 commit comments

Comments
 (0)