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

Improve block tracing performance

Dieser Commit ist enthalten in:
SirYwell 2023-03-08 20:04:29 +01:00
Ursprung 0faaaa55ee
Commit 00b13399d1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
3 geänderte Dateien mit 7 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -243,6 +243,7 @@ public final class PaperweightFaweAdapter extends FaweAdapter<net.minecraft.nbt.
final ServerLevel handle = getServerLevel(location.getWorld()); final ServerLevel handle = getServerLevel(location.getWorld());
LevelChunk chunk; LevelChunk chunk;
if (Fawe.isTickThread()) { if (Fawe.isTickThread()) {
// TODO check if is owned by this thread, else synchronize
chunk = handle.getChunk(x >> 4, z >> 4); chunk = handle.getChunk(x >> 4, z >> 4);
} else { } else {
chunk = TaskManager.taskManager().syncAt(() -> handle.getChunk(x >> 4, z >> 4), BukkitAdapter.adapt(location)); chunk = TaskManager.taskManager().syncAt(() -> handle.getChunk(x >> 4, z >> 4), BukkitAdapter.adapt(location));

Datei anzeigen

@ -3,7 +3,6 @@ package com.fastasyncworldedit.bukkit.util;
import com.fastasyncworldedit.core.util.TaskManager; import com.fastasyncworldedit.core.util.TaskManager;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

Datei anzeigen

@ -10,6 +10,7 @@ import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.PlayerProxy; import com.sk89q.worldedit.extension.platform.PlayerProxy;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
@ -17,6 +18,7 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.util.TargetBlock;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import org.jetbrains.annotations.Nullable;
public class AsyncPlayer extends PlayerProxy { public class AsyncPlayer extends PlayerProxy {
@ -177,19 +179,13 @@ public class AsyncPlayer extends PlayerProxy {
} }
@Override @Override
public Location getBlockTrace(int range, boolean useLastBlock) { public Location getBlockTrace(final int range, final boolean useLastBlock, @Nullable final Mask stopMask) {
return TaskManager.taskManager().sync(() -> { return TaskManager.taskManager().syncAt(() -> super.getBlockTrace(range, useLastBlock, stopMask), getLocation());
TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D);
return useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock();
});
} }
@Override @Override
public Location getBlockTraceFace(int range, boolean useLastBlock) { public Location getBlockTraceFace(final int range, final boolean useLastBlock, @Nullable final Mask stopMask) {
return TaskManager.taskManager().sync(() -> { return TaskManager.taskManager().syncAt(() -> super.getBlockTraceFace(range, useLastBlock, stopMask), getLocation());
TargetBlock tb = new TargetBlock(AsyncPlayer.this, range, 0.2D);
return useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace();
});
} }
@Override @Override