Skip to content

Commit a04e459

Browse files
committed
code pattern tweak
no idea if this changes much in practice or not
1 parent 4af845d commit a04e459

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import org.bukkit.Bukkit;
44
import org.bukkit.Location;
55
import org.bukkit.Material;
6+
import org.bukkit.Particle;
7+
import org.bukkit.attribute.Attribute;
68
import org.bukkit.enchantments.Enchantment;
79
import org.bukkit.entity.*;
810
import org.bukkit.inventory.ItemStack;
@@ -291,7 +293,7 @@ public void fireEvokerFangs(Location target) {
291293
sentinel.stats_evokerFangsSpawned++;
292294
sentinel.faceLocation(target);
293295
if (SentinelVersionCompat.v1_13) {
294-
getLivingEntity().getWorld().spawnParticle(SentinelAPIBreakageFix.PARTICLE_SPELL, getLivingEntity().getEyeLocation().add(0, 1, 0), 10, 1, 1, 1);
296+
getLivingEntity().getWorld().spawnParticle((Particle) SentinelAPIBreakageFix.PARTICLE_SPELL, getLivingEntity().getEyeLocation().add(0, 1, 0), 10, 1, 1, 1);
295297
}
296298
Vector forward = getLivingEntity().getEyeLocation().getDirection().setY(0).normalize();
297299
Location start = getLivingEntity().getLocation().clone().add(forward.clone().multiply(Math.max(3, sentinel.firingMinimumRange())));
@@ -395,7 +397,7 @@ public void knockback(LivingEntity entity, float force) {
395397
return;
396398
}
397399
if (SentinelVersionCompat.v1_12) {
398-
float resist = (float) entity.getAttribute(SentinelAPIBreakageFix.ATTRIBUTE_GENERIC_KNOCKBACK_RESISTANCE).getValue();
400+
float resist = (float) entity.getAttribute((Attribute) SentinelAPIBreakageFix.ATTRIBUTE_GENERIC_KNOCKBACK_RESISTANCE).getValue();
399401
if (resist > 0.0 && resist <= 1.0) {
400402
force *= (1.0 - resist);
401403
}

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,20 @@ public class SentinelAPIBreakageFix {
2929

3030
public static PotionType POTION_TYPE_UNCRAFTABLE = _getEnumValue(PotionType.class, "UNCRAFTABLE"); // NOTE: Null after 1.21
3131

32-
public static Particle PARTICLE_SPELL = _getEnumValue(Particle.class, "SPELL", "EFFECT");
32+
public static Object PARTICLE_SPELL;
3333

34-
public static Attribute ATTRIBUTE_GENERIC_KNOCKBACK_RESISTANCE = _getEnumValue(Attribute.class, "GENERIC_KNOCKBACK_RESISTANCE", "KNOCKBACK_RESISTANCE");
34+
public static Object ATTRIBUTE_GENERIC_KNOCKBACK_RESISTANCE;
35+
36+
static {
37+
try {
38+
PARTICLE_SPELL = _getEnumValue(Particle.class, "SPELL", "EFFECT");
39+
}
40+
catch (Throwable ex) {};
41+
try {
42+
ATTRIBUTE_GENERIC_KNOCKBACK_RESISTANCE = _getEnumValue(Attribute.class, "GENERIC_KNOCKBACK_RESISTANCE", "KNOCKBACK_RESISTANCE");
43+
}
44+
catch (Throwable ex) {};
45+
}
3546

3647
/**
3748
* Note: not necessarily actually an enum.

0 commit comments

Comments
 (0)