9
0
mirror of https://github.com/GeyserExtensionists/GeyserUtils.git synced 2025-12-19 15:09:24 +00:00
This commit is contained in:
zimzaza4
2024-07-24 14:06:15 +08:00
parent 2973fad195
commit f5063bf955
2 changed files with 40 additions and 0 deletions

View File

@@ -112,6 +112,7 @@ public class GeyserUtils implements Extension {
replaceTranslator();
logger().info("Defined " + LOADED_ENTITY_DEFINITIONS.size() + " entities");
particlesMappings.read(dataFolder().resolve("item_particles_mappings.json"));
MountFix.start();
}
// the static here is crazy ;(

View File

@@ -0,0 +1,39 @@
package me.zimzaza4.geyserutils.geyser;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityLinkData;
import org.cloudburstmc.protocol.bedrock.packet.SetEntityLinkPacket;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.entity.EntityDefinitions;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.session.GeyserSession;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class MountFix {
public static void start() {
// just keep send SetEntityLinkPacket to fix the mount bug
// https://github.com/GeyserMC/Geyser/issues/3302
// if the vehicle is too fast, the problem appear
Executors.newSingleThreadScheduledExecutor()
.scheduleAtFixedRate(() -> {
for (GeyserSession session : GeyserImpl.getInstance().onlineConnections()) {
Entity v = session.getPlayerEntity().getVehicle();
if (v != null && v.getDefinition() == EntityDefinitions.ARMOR_STAND) {
long vehicleBedrockId = v.getGeyserId();
if (session.getPlayerEntity().getVehicle().getGeyserId() == vehicleBedrockId) {
// The Bedrock client, as of 1.19.51, dismounts on its end. The server may not agree with this.
// If the server doesn't agree with our dismount (sends a packet saying we dismounted),
// then remount the player.
SetEntityLinkPacket linkPacket = new SetEntityLinkPacket();
linkPacket.setEntityLink(new EntityLinkData(vehicleBedrockId, session.getPlayerEntity().getGeyserId(), EntityLinkData.Type.RIDER, true, false));
session.sendUpstreamPacket(linkPacket);
}
}
}
}, 2000, 80, TimeUnit.MILLISECONDS);
}
}