GeyserMC / GeyserOptionalPack

Optional Bedrock resource pack to extend Geyser functionality
https://geysermc.org
MIT License
75 stars 14 forks source link

Particles not displaying correctly on Bedrock #43

Open Cinder4198 opened 1 year ago

Cinder4198 commented 1 year ago

Describe the bug

Geyser doesn't display particles that are spawned by a plugin correctly.

I was making a plugin and using my bedrock account to help with testing since I don't have an alt, and noticed that particles didn't align with what they should have, but only for the bedrock account. I did test it on multiple java accounts, it only affected the bedrock one.

To Reproduce

  1. Log into the server on Bedrock
  2. Have the plugin spawn the particles
  3. The particles won't be in the correct spot

Expected behaviour

The particles should be displayed how they are on java

Screenshots / Videos

Image: image

Video:

https://user-images.githubusercontent.com/67652147/206053475-d5611c6e-9381-4530-b4ea-d4b9a9871f3c.mp4

Sidenote im not actually running windows xp, its still windows 10

Server Version and Plugins

LuckPerms, WorldEdit, NBTAPI, floodgate, WorldGuard, PlugManX (PlugMan), DefClaims (the one im testing)

Geyser Dump

https://dump.geysermc.org/ftLX682s6uChU0owHWQETHPcvXJjuCgY

Geyser Version

2.1.0-SNAPSHOT (git-master-3d66d27)

Minecraft: Bedrock Edition Device/Version

1.19.50; Windows 10 Edition

Additional Context

Here's the class that I'm using for the particles, if you need the plugin itself or more of the code I can give that as well.

package net.deftera.defclaims.listeners;

import de.tr7zw.nbtapi.NBTItem;
import net.deftera.defclaims.Defclaims;
import net.deftera.defclaims.datamodels.ClaimData;
import net.deftera.defclaims.db.Database;
import net.deftera.defclaims.util.ParticleUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.block.data.type.Bed;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitScheduler;
import org.w3c.dom.ranges.Range;

import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

public class VisualizeClaims{
    public Runnable onTimer(){
        Runnable runnable = () -> {
            //List<Player> players = (List<Player>) Bukkit.getOnlinePlayers();
            try {
                Database db = Defclaims.plugin.getDatabase();
                for(Player player : Bukkit.getOnlinePlayers()) {

                    ItemStack material = new ItemStack(Material.DIAMOND_SWORD);
                    NBTItem nbtmaterial = new NBTItem(material);
                    nbtmaterial.setInteger("CustomModelData", 5);
                    material = nbtmaterial.getItem();

                    if (player.getInventory().getItemInMainHand().isSimilar(material)) {

                        long claimDataMax;
                        try {
                            claimDataMax = db.findAllClaimData().size();
                        } catch (SQLException e) {
                            throw new RuntimeException(e);
                        }

                        String maxClaimData = db.findAllClaimData().get((int) claimDataMax - 1);

                        for (long claimID = 1; claimID <= (Long.parseLong(maxClaimData)); claimID++) {

                            try {

                                if (!(db.findClaimDataByClaimID(claimID) == null)) {

                                    int claimPlayerData = db.findClaimOnePlayerTrustLevel(claimID, player.getUniqueId());

                                    Particle outline = Particle.SMOKE_NORMAL;

                                    if (claimPlayerData == 1) {
                                        outline = Particle.VILLAGER_HAPPY;
                                    }

                                    if (claimPlayerData == 2) {
                                        outline = Particle.END_ROD;
                                    }

                                    ClaimData claimData = db.findClaimDataByClaimID(claimID);
                                    long minx = claimData.getMinx();
                                    long miny = claimData.getMiny();
                                    long minz = claimData.getMinz();
                                    long maxx = claimData.getMaxx() + 1;
                                    long maxy = claimData.getMaxy() + 1;
                                    long maxz = claimData.getMaxz() + 1;

                                    for (long x = minx; x <= maxx; x++) {
                                        for (long y = miny; y <= maxy; y++) {
                                            for (long z = minz; z <= maxz; z++) {
                                                if (x == minx) {
                                                    if (player.getLocation().getX() >= x - 15) {
                                                        if (player.getLocation().getX() <= x + 15) {
                                                            player.spawnParticle(outline, x, y, z, 0);
                                                        }
                                                    }
                                                }
                                                if (x == maxx) {
                                                    if (player.getLocation().getX() >= x - 15) {
                                                        if (player.getLocation().getX() <= x + 15) {
                                                            player.spawnParticle(outline, x, y, z, 0);
                                                        }
                                                    }
                                                }
                                                if (y == miny) {
                                                    if (player.getLocation().getX() >= x - 15) {
                                                        if (player.getLocation().getX() <= x + 15) {
                                                            player.spawnParticle(outline, x, y, z, 0);
                                                        }
                                                    }
                                                }
                                                if (y == maxy) {
                                                    if (player.getLocation().getX() >= x - 15) {
                                                        if (player.getLocation().getX() <= x + 15) {
                                                            player.spawnParticle(outline, x, y, z, 0);
                                                        }
                                                    }
                                                }
                                                if (z == minz) {
                                                    if (player.getLocation().getX() >= x - 15) {
                                                        if (player.getLocation().getX() <= x + 15) {
                                                            player.spawnParticle(outline, x, y, z, 0);
                                                        }
                                                    }
                                                }
                                                if (z == maxz) {
                                                    if (player.getLocation().getX() >= x - 15) {
                                                        if (player.getLocation().getX() <= x + 15) {
                                                            player.spawnParticle(outline, x, y, z, 0);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }catch (SQLException ignore){}
                        }
                    }
                }
            }catch (Exception ex){
                ex.printStackTrace();
            }
        };
        return runnable;
    }
}
Kas-tle commented 1 year ago

This issue should be moved to GeyserOptionalPack... I have been wanting to fix this with that for a while but unfortunately it will require me to rewrite every particle's resource definition to accept count, size, and speed like Java does. It's made more complex by inconsistent behavior between particles that have a count of 0, which leads to special behavior on Java. It will likely be a long time before this is fixed.