3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-20 09:50:06 +01:00

Cache MethodHandle

Dieser Commit ist enthalten in:
Hannes Greule 2021-04-10 14:53:31 +02:00
Ursprung 5812b94608
Commit a74e5fe122

Datei anzeigen

@ -8,6 +8,7 @@ import com.boydti.fawe.beta.implementation.lighting.Relighter;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import net.minecraft.server.v1_16_R3.BlockPosition; import net.minecraft.server.v1_16_R3.BlockPosition;
import net.minecraft.server.v1_16_R3.ChunkCoordIntPair; import net.minecraft.server.v1_16_R3.ChunkCoordIntPair;
import net.minecraft.server.v1_16_R3.LightEngineThreaded;
import net.minecraft.server.v1_16_R3.MCUtil; import net.minecraft.server.v1_16_R3.MCUtil;
import net.minecraft.server.v1_16_R3.WorldServer; import net.minecraft.server.v1_16_R3.WorldServer;
@ -24,28 +25,31 @@ import java.util.function.IntConsumer;
public class TuinityRelighter_1_16_5 implements Relighter { public class TuinityRelighter_1_16_5 implements Relighter {
private static final IntConsumer nothingIntConsumer = i -> {}; private static final IntConsumer nothingIntConsumer = i -> {};
private static final MethodHandle relight;
private final WorldServer world; private final WorldServer world;
private final MethodHandle relight;
private final ReentrantLock lock = new ReentrantLock(); private final ReentrantLock lock = new ReentrantLock();
private final IQueueExtent<IQueueChunk> queue; private final IQueueExtent<IQueueChunk> queue;
public TuinityRelighter_1_16_5(WorldServer world, IQueueExtent<IQueueChunk> queue) { static {
this.queue = queue; MethodHandle tmp = null;
MethodHandle methodHandle = null;
try { try {
Method relightMethod = world.getChunkProvider().getLightEngine().getClass().getMethod( Method relightMethod = LightEngineThreaded.class.getMethod(
"relight", "relight",
Set.class, Set.class,
Consumer.class, Consumer.class,
IntConsumer.class IntConsumer.class
); );
methodHandle = MethodHandles.lookup().unreflect(relightMethod); tmp = MethodHandles.lookup().unreflect(relightMethod);
} catch (NoSuchMethodException | IllegalAccessException e) { } catch (NoSuchMethodException | IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
this.relight = methodHandle; relight = tmp;
}
public TuinityRelighter_1_16_5(WorldServer world, IQueueExtent<IQueueChunk> queue) {
this.queue = queue;
this.world = world; this.world = world;
} }