Hot Summer Deals are Here!
Celebrate with up to 99% off on 17,600 resources
02
Days
02
Hours
52
Mins
17
Secs

PassengerSync

Status
This thread has been locked.

VawkeNetty

github.com/vawkeio/
Banned
Feedback score
0
Posts
377
Reactions
191
Resources
0
So, I stumbled upon this while messing with some assembly stuff in Minecraft. Passengers on servers don't properly sync with clients, which basically means that if a player goes too far away from an entity with a passenger, the passenger drops off.

Simple fix:
Code:
import net.minecraft.server.v1_9_R2.PacketPlayOutMount;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;

/**
* Created by Giovanni on 12-7-2016.
*/
public class PassengerPatcher implements Runnable
{

    @Override
    public void run()
    {
        for (Player player : Bukkit.getOnlinePlayers())
        {
            for (Entity entity : player.getEntities())
            {
                if (entity.getPassenger() != null)
                {
                    PacketPlayOutMount packetPlayOutMount = new PacketPlayOutMount(((CraftEntity) entity).getHandle());
                    ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutMount);
                }
            }
        }
    }
}

For the ones which prefer forEach or just Java 8 in general:
Code:
import net.minecraft.server.v1_9_R2.PacketPlayOutMount;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;

/**
* Created by Giovanni on 12-7-2016.
*/
public class PassengerPatcher implements Runnable
{

    @Override
    public void run()
    {
        for (Player player : Bukkit.getOnlinePlayers())
        {
            player.getWorld().getEntities().stream().filter(entity -> entity.getPassenger() != null).forEach(entity -> {
                PacketPlayOutMount packetPlayOutMount = new PacketPlayOutMount(((CraftEntity) entity).getHandle());
                ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutMount);
            });
        }

    }
}
Enjoy.

This is not a plugin really. It's more for developers but idk where to put it, if you need this as plugin msg me.
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

MoeXIV

Feedback score
0
Posts
150
Reactions
52
Resources
0
What exactly is a passenger, another player?

Even then isn't that just something that can be tinkered with spigot.yml or am I thinking of something else.
 

VawkeNetty

github.com/vawkeio/
Banned
Feedback score
0
Posts
377
Reactions
191
Resources
0
What exactly is a passenger, another player?

Even then isn't that just something that can be tinkered with spigot.yml or am I thinking of something else.
A passenger is an entity riding an entity. Since 1.9, the server does not properly sync with the client which means that if a player goes out of range from an entity, the passenger 'falls off' the entity it's riding for the player, but in reality it's still riding it.

This is not something that can be fixed within Spigot.yml
 
Banned forever. Reason: Creating Multiple Accounts (SaltyFormula)
Status
This thread has been locked.
Top