Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

So im trying to create an item that will send particles after RMC in the way that a player is looking. But I have a problem that it isn't seen on server. I created a packet.

sendParticles

won't work for me because it just spawns particles without vector speed. And addParticle only seen on client side(?). So is there a way to send particles with vector speed like addParticle so it will be seen on server?

1 minute ago, Juski said:

So im trying to create an item that will send particles after RMC in the way that a player is looking. But I have a problem that it isn't seen on server. I created a packet.

sendParticles

won't work for me because it just spawns particles without vector speed. And addParticle only seen on client side(?). So is there a way to send particles with vector speed like addParticle so it will be seen on server?

[1.20.2]

 

  • Author
23 minutes ago, dee12452 said:

spawnParticle is an old version of sendPaticles. As I said sendParticles works just as /particle command on vanilla minecraft, you can't set vector speed to it. I didnt put version on topic but i put it in a quote 1.20.2. So yeah it wont work.

 

Edited by Juski

Brother, sendParticles literally calls addParticle.

This is forge's implementation of handling sendParticle once it gets back to the client

public void handleParticleEvent(ClientboundLevelParticlesPacket p_105026_) {
        PacketUtils.ensureRunningOnSameThread(p_105026_, this, this.minecraft);
        if (p_105026_.getCount() == 0) {
            double d0 = (double)(p_105026_.getMaxSpeed() * p_105026_.getXDist());
            double d2 = (double)(p_105026_.getMaxSpeed() * p_105026_.getYDist());
            double d4 = (double)(p_105026_.getMaxSpeed() * p_105026_.getZDist());

            try {
                this.level.addParticle(p_105026_.getParticle(), p_105026_.isOverrideLimiter(), p_105026_.getX(), p_105026_.getY(), p_105026_.getZ(), d0, d2, d4);
            } catch (Throwable var17) {
                LOGGER.warn("Could not spawn particle effect {}", p_105026_.getParticle());
            }
        } else {
            for(int i = 0; i < p_105026_.getCount(); ++i) {
                double d1 = this.random.nextGaussian() * (double)p_105026_.getXDist();
                double d3 = this.random.nextGaussian() * (double)p_105026_.getYDist();
                double d5 = this.random.nextGaussian() * (double)p_105026_.getZDist();
                double d6 = this.random.nextGaussian() * (double)p_105026_.getMaxSpeed();
                double d7 = this.random.nextGaussian() * (double)p_105026_.getMaxSpeed();
                double d8 = this.random.nextGaussian() * (double)p_105026_.getMaxSpeed();

                try {
                    this.level.addParticle(p_105026_.getParticle(), p_105026_.isOverrideLimiter(), p_105026_.getX() + d1, p_105026_.getY() + d3, p_105026_.getZ() + d5, d6, d7, d8);
                } catch (Throwable var16) {
                    LOGGER.warn("Could not spawn particle effect {}", p_105026_.getParticle());
                    return;
                }
            }
        }

    }

The last 4 of the `ServerLevel#sendParticles` function represent `xDist; yDist; zDist; maxSpeed;` of this ^ respectively. So this should in theory allow for you to mostly set a speed.

 

If you need more control, send a custom clientbound packet over the Network that directly calls level.addParticle the way you need exactly...

  • Author
12 minutes ago, dee12452 said:

Brother, sendParticles literally calls addParticle.

This is forge's implementation of handling sendParticle once it gets back to the client

public void handleParticleEvent(ClientboundLevelParticlesPacket p_105026_) {
        PacketUtils.ensureRunningOnSameThread(p_105026_, this, this.minecraft);
        if (p_105026_.getCount() == 0) {
            double d0 = (double)(p_105026_.getMaxSpeed() * p_105026_.getXDist());
            double d2 = (double)(p_105026_.getMaxSpeed() * p_105026_.getYDist());
            double d4 = (double)(p_105026_.getMaxSpeed() * p_105026_.getZDist());

            try {
                this.level.addParticle(p_105026_.getParticle(), p_105026_.isOverrideLimiter(), p_105026_.getX(), p_105026_.getY(), p_105026_.getZ(), d0, d2, d4);
            } catch (Throwable var17) {
                LOGGER.warn("Could not spawn particle effect {}", p_105026_.getParticle());
            }
        } else {
            for(int i = 0; i < p_105026_.getCount(); ++i) {
                double d1 = this.random.nextGaussian() * (double)p_105026_.getXDist();
                double d3 = this.random.nextGaussian() * (double)p_105026_.getYDist();
                double d5 = this.random.nextGaussian() * (double)p_105026_.getZDist();
                double d6 = this.random.nextGaussian() * (double)p_105026_.getMaxSpeed();
                double d7 = this.random.nextGaussian() * (double)p_105026_.getMaxSpeed();
                double d8 = this.random.nextGaussian() * (double)p_105026_.getMaxSpeed();

                try {
                    this.level.addParticle(p_105026_.getParticle(), p_105026_.isOverrideLimiter(), p_105026_.getX() + d1, p_105026_.getY() + d3, p_105026_.getZ() + d5, d6, d7, d8);
                } catch (Throwable var16) {
                    LOGGER.warn("Could not spawn particle effect {}", p_105026_.getParticle());
                    return;
                }
            }
        }

    }

The last 4 of the `ServerLevel#sendParticles` function represent `xDist; yDist; zDist; maxSpeed;` of this ^ respectively. So this should in theory allow for you to mostly set a speed.

 

If you need more control, send a custom clientbound packet over the Network that directly calls level.addParticle the way you need exactly...

Ok, about sendParticles, why I thought it's just a /particle command.
It has values (particleType,x,y,z,particleCount,xOffset,yOffset,zOffset,speed)
and addParticle(particleType,x,y,z,xSpeed,ySpeed,zSpeed)
And i need those values as xSpeed,ySpeed,zSpeed that's what make particles fly in the directions that player is looking

Quote

If you need more control, send a custom clientbound packet over the Network that directly calls level.addParticle the way you need exactly...

How exactly I can make it, could you help me out with that or just put on the right direction where can I look an information on that topic?
 

Gotchya, well this will be your best friend then if you're down to read through it and try to understand it. Networking in 1.20.2+ got a fairly large change.

https://docs.minecraftforge.net/en/1.20.x/networking/simpleimpl/

I could post my mod's 1.20.2 networking code with an example but it's going to be a lot because it's a lot to setup. Lemme know if you'd prefer that though, I don't mind.

 

 

Edited by dee12452
phrasing

  • Author

I found an answer on side.
For anyone wondering in future, you need to use sendParticles and if you put 0 for particleCount, then xOffset, yOffset, zOffset become xSpeed, ySpeed, zSpeed. And on speed you just put 1.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.