SteamWar/BauSystem2.0
Archiviert
12
0

Hotfix TNTPrimedIterator18
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-08-20 15:30:18 +02:00
Ursprung 11ce513ec2
Commit 88e772896c

Datei anzeigen

@ -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<TNTPrimed> 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);
}
}