Fix horizontal firework detection
This commit is contained in:
parent
3dbe0e9c30
commit
eaedd5442a
@ -39,6 +39,9 @@ import org.bukkit.event.entity.ItemSpawnEvent;
|
|||||||
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class ChunkListener implements Listener {
|
public abstract class ChunkListener implements Listener {
|
||||||
|
|
||||||
@ -219,8 +222,8 @@ public abstract class ChunkListener implements Listener {
|
|||||||
int cz = block.getZ() >> 4;
|
int cz = block.getZ() >> 4;
|
||||||
physCancelPair = MathMan.pairInt(cx, cz);
|
physCancelPair = MathMan.pairInt(cx, cz);
|
||||||
if (rateLimit <= 0) {
|
if (rateLimit <= 0) {
|
||||||
rateLimit = 20;
|
rateLimit = 20;
|
||||||
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + block.getLocation());
|
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + block.getLocation());
|
||||||
}
|
}
|
||||||
cancelNearby(cx, cz);
|
cancelNearby(cx, cz);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -328,21 +331,13 @@ public abstract class ChunkListener implements Listener {
|
|||||||
int len = className.length();
|
int len = className.length();
|
||||||
if (className != null) {
|
if (className != null) {
|
||||||
if (len > 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) {
|
if (len > 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) {
|
||||||
int chunkRange = 2;
|
for (Entity ent : world.getEntities()) {
|
||||||
for (int ocx = -chunkRange; ocx <= chunkRange; ocx++) {
|
if (ent.getType() == EntityType.FIREWORK) {
|
||||||
for (int ocz = -chunkRange; ocz <= chunkRange; ocz++) {
|
Vector velocity = ent.getVelocity();
|
||||||
int cx = chunk.getX() + ocx;
|
double vertical = Math.abs(velocity.getY());
|
||||||
int cz = chunk.getZ() + ocz;
|
if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) {
|
||||||
if (world.isChunkLoaded(cx, cz)) {
|
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation());
|
||||||
Chunk relativeChunk = world.getChunkAt(cx, cz);
|
ent.remove();
|
||||||
Entity[] ents = relativeChunk.getEntities();
|
|
||||||
for (Entity ent : ents) {
|
|
||||||
switch (ent.getType()) {
|
|
||||||
case FIREWORK:
|
|
||||||
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation());
|
|
||||||
ent.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user