From 88e772896c2f6482edb5c6e99731d09ee8bd202d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 20 Aug 2023 15:30:18 +0200 Subject: [PATCH] Hotfix TNTPrimedIterator18 Signed-off-by: yoyosource --- .../features/tracer/record/TNTPrimedIterator18.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/BauSystem_18/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator18.java b/BauSystem_18/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator18.java index 0ae4692b..05dd5a32 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator18.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.tracer.record; import com.comphenix.tinyprotocol.Reflection; import net.minecraft.server.level.WorldServer; -import net.minecraft.world.entity.item.EntityTNTPrimed; import net.minecraft.world.level.entity.LevelEntityGetter; import org.bukkit.Bukkit; import org.bukkit.entity.TNTPrimed; @@ -34,12 +33,15 @@ public class TNTPrimedIterator18 implements TNTPrimedIterator { private static final Reflection.MethodInvoker getWorld = Reflection.getMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle"); private static final Reflection.MethodInvoker getWorldEntities = Reflection.getTypedMethod(WorldServer.class, null, LevelEntityGetter.class); private static final Reflection.MethodInvoker getIterable = Reflection.getTypedMethod(LevelEntityGetter.class, null, Iterable.class); + public static final Class primedTnt = Reflection.getClass("{nms.world.entity.item}.EntityTNTPrimed"); + private static final Reflection.MethodInvoker getBukkitEntity = Reflection.getTypedMethod(Reflection.getClass("{nms.world.entity}.Entity"), "getBukkitEntity", null); @Override public Stream iterator() { return StreamSupport.stream(((Iterable) getIterable.invoke(getWorldEntities.invoke(getWorld.invoke(Bukkit.getWorlds().get(0))))).spliterator(), false) - .filter(EntityTNTPrimed.class::isInstance) - .map(entity -> (TNTPrimed) (((EntityTNTPrimed) entity).getBukkitEntity())); + .filter(primedTnt::isInstance) + .map(getBukkitEntity::invoke) + .map(TNTPrimed.class::cast); } }