mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-04 00:46:08 +00:00
fix async tile state
This commit is contained in:
parent
d275466e1e
commit
b6457e47e6
@ -35,6 +35,7 @@ import com.volmit.iris.util.plugin.IrisService;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.S;
|
||||
import com.volmit.iris.util.scheduling.SR;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -53,10 +54,12 @@ import org.bukkit.util.Vector;
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public class WandSVC implements IrisService {
|
||||
private static final Particle CRIT_MAGIC = E.getOrDefault(Particle.class, "CRIT_MAGIC", "CRIT");
|
||||
private static final Particle REDSTONE = E.getOrDefault(Particle.class, "REDSTONE", "DUST");
|
||||
private static final int BLOCKS_PER_TICK = Integer.parseInt(System.getProperty("iris.blocks_per_tick", "100"));
|
||||
|
||||
private static ItemStack dust;
|
||||
private static ItemStack wand;
|
||||
@ -80,6 +83,8 @@ public class WandSVC implements IrisService {
|
||||
Location[] f = getCuboid(p);
|
||||
Cuboid c = new Cuboid(f[0], f[1]);
|
||||
IrisObject s = new IrisObject(c.getSizeX(), c.getSizeY(), c.getSizeZ());
|
||||
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
for (Block b : c) {
|
||||
if (b.getType().equals(Material.AIR)) {
|
||||
continue;
|
||||
@ -89,6 +94,32 @@ public class WandSVC implements IrisService {
|
||||
s.setUnsigned(bv.getBlockX(), bv.getBlockY(), bv.getBlockZ(), b);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
var it = c.iterator();
|
||||
var latch = new CountDownLatch(1);
|
||||
new SR() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = 0; i < BLOCKS_PER_TICK; i++) {
|
||||
if (!it.hasNext()) {
|
||||
cancel();
|
||||
latch.countDown();
|
||||
return;
|
||||
}
|
||||
|
||||
var b = it.next();
|
||||
if (b.getType().equals(Material.AIR))
|
||||
continue;
|
||||
|
||||
BlockVector bv = b.getLocation().subtract(c.getLowerNE().toVector()).toVector().toBlockVector();
|
||||
s.setUnsigned(bv.getBlockX(), bv.getBlockY(), bv.getBlockZ(), b);
|
||||
}
|
||||
}
|
||||
};
|
||||
latch.await();
|
||||
|
||||
return s;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
Loading…
x
Reference in New Issue
Block a user