9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-31 12:56:28 +00:00
This commit is contained in:
XiaoMoMi
2025-05-11 04:36:47 +08:00
parent 84a8fd8692
commit 31e4172140
4 changed files with 13 additions and 6 deletions

View File

@@ -13,7 +13,6 @@ import net.momirealms.craftengine.core.item.Item;
import net.momirealms.craftengine.core.plugin.scheduler.SchedulerTask;
import net.momirealms.craftengine.core.util.VersionHelper;
import org.bukkit.Bukkit;
import org.bukkit.Particle;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Projectile;
@@ -29,7 +28,6 @@ import org.bukkit.inventory.ItemStack;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
public class BukkitProjectileManager implements Listener, ProjectileManager {
private static BukkitProjectileManager instance;

View File

@@ -55,10 +55,9 @@ public class ProjectilePacketHandler implements EntityPacketHandler {
@Override
public void handleMoveAndRotate(NetWorkUser user, NMSPacketEvent event, Object packet) {
int entityId = BukkitInjector.internalFieldAccessor().field$ClientboundMoveEntityPacket$entityId(packet);
Object converted = convertCustomProjectileMovePacket(packet, entityId);
event.replacePacket(FastNMS.INSTANCE.constructor$ClientboundBundlePacket(List.of(
this.cachedPacket,
converted
convertCustomProjectileMovePacket(packet, entityId)
)));
}
@@ -127,4 +126,15 @@ public class ProjectilePacketHandler implements EntityPacketHandler {
onGround
);
}
private Object convertCustomProjectileTeleportPacket(Object packet, int entityId) {
float xRot = MCUtils.unpackDegrees(FastNMS.INSTANCE.field$ClientboundMoveEntityPacket$xRot(packet));
float yRot = MCUtils.unpackDegrees(FastNMS.INSTANCE.field$ClientboundMoveEntityPacket$yRot(packet));
boolean onGround = FastNMS.INSTANCE.field$ClientboundMoveEntityPacket$onGround(packet);
return FastNMS.INSTANCE.constructor$ClientboundTeleportEntityPacket(
entityId, this.projectile.projectile().x(), this.projectile.projectile().y(), this.projectile.projectile().z(),
MCUtils.packDegrees(-yRot), MCUtils.packDegrees(MCUtils.clamp(-xRot, -90.0F, 90.0F)),
onGround
);
}
}