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.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ChunkListener implements Listener {
|
||||
|
||||
@ -328,17 +331,11 @@ public abstract class ChunkListener implements Listener {
|
||||
int len = className.length();
|
||||
if (className != null) {
|
||||
if (len > 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) {
|
||||
int chunkRange = 2;
|
||||
for (int ocx = -chunkRange; ocx <= chunkRange; ocx++) {
|
||||
for (int ocz = -chunkRange; ocz <= chunkRange; ocz++) {
|
||||
int cx = chunk.getX() + ocx;
|
||||
int cz = chunk.getZ() + ocz;
|
||||
if (world.isChunkLoaded(cx, cz)) {
|
||||
Chunk relativeChunk = world.getChunkAt(cx, cz);
|
||||
Entity[] ents = relativeChunk.getEntities();
|
||||
for (Entity ent : ents) {
|
||||
switch (ent.getType()) {
|
||||
case FIREWORK:
|
||||
for (Entity ent : world.getEntities()) {
|
||||
if (ent.getType() == EntityType.FIREWORK) {
|
||||
Vector velocity = ent.getVelocity();
|
||||
double vertical = Math.abs(velocity.getY());
|
||||
if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) {
|
||||
Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation());
|
||||
ent.remove();
|
||||
}
|
||||
@ -349,8 +346,6 @@ public abstract class ChunkListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onItemSpawn(ItemSpawnEvent event) {
|
||||
|
Loading…
Reference in New Issue
Block a user