Skip to content

Commit

Permalink
Fix 1.21 update breakage, fixes #777
Browse files Browse the repository at this point in the history
  • Loading branch information
libraryaddict committed Oct 22, 2024
1 parent 0bc9ba1 commit 259e54d
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Sound;
import org.bukkit.UnsafeValues;
import org.bukkit.World;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_21_R1.CraftArt;
Expand Down Expand Up @@ -83,6 +84,7 @@ public class ReflectionManager implements ReflectionManagerAbstract {
private final Field trackedEntityField;
private final AtomicInteger entityCounter;
private final Method entityDefaultSoundMethod;
private final UnsafeValues craftMagicNumbers;

@SneakyThrows
public ReflectionManager() {
Expand All @@ -105,6 +107,8 @@ public ReflectionManager() {
// Default is protected method, 1.0F on EntityLiving.class
entityDefaultSoundMethod = net.minecraft.world.entity.LivingEntity.class.getDeclaredMethod("fa");
entityDefaultSoundMethod.setAccessible(true);

craftMagicNumbers = (UnsafeValues) CraftMagicNumbers.class.getField("INSTANCE").get(null);
}

public boolean hasInvul(Entity entity) {
Expand Down Expand Up @@ -297,7 +301,7 @@ public String getSoundString(Sound sound) {

@Override
public Material getMaterial(String name) {
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
return craftMagicNumbers.getMaterial(name, craftMagicNumbers.getDataVersion());
}

@Override
Expand Down

0 comments on commit 259e54d

Please sign in to comment.