mirror of
https://github.com/GeyserExtensionists/GeyserModelEngine.git
synced 2025-12-20 07:29:26 +00:00
fix
This commit is contained in:
@@ -110,7 +110,7 @@ public class EntityTask {
|
||||
spawnAnimationPlayed = true;
|
||||
}
|
||||
|
||||
if (tick > 1 && tick % 5 == 0) {
|
||||
if (tick % 5 == 0) {
|
||||
|
||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (FloodgateApi.getInstance().isFloodgatePlayer(onlinePlayer.getUniqueId())) {
|
||||
@@ -134,9 +134,10 @@ public class EntityTask {
|
||||
*/
|
||||
}
|
||||
} else {
|
||||
|
||||
entity.sendEntityDestroyPacket(Collections.singletonList(onlinePlayer));
|
||||
viewers.remove(onlinePlayer);
|
||||
if (viewers.contains(onlinePlayer)) {
|
||||
entity.sendEntityDestroyPacket(Collections.singletonList(onlinePlayer));
|
||||
viewers.remove(onlinePlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -212,18 +213,16 @@ public class EntityTask {
|
||||
}
|
||||
|
||||
public void sendEntityData(Player player, int delay) {
|
||||
// System.out.println("TYPE: " + "modelengine:" + model.getActiveModel().getBlueprint().getName().toLowerCase());
|
||||
PlayerUtils.setCustomEntity(player, model.getEntity().getEntityId(), "modelengine:" + model.getActiveModel().getBlueprint().getName().toLowerCase());
|
||||
|
||||
model.getEntity().sendSpawnPacket(Collections.singletonList(player));
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(GeyserModelEngine.getInstance(), () -> {
|
||||
// PlayerUtils.sendCustomSkin(player, model.getEntity(), model.getActiveModel().getBlueprint().getName());
|
||||
if (looping) {
|
||||
playBedrockAnimation(lastAnimation, Set.of(player), looping, 0f);
|
||||
}
|
||||
sendHitBox(player);
|
||||
sendScale(player, true);
|
||||
model.getEntity().sendSpawnPacket(Collections.singletonList(player));
|
||||
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(GeyserModelEngine.getInstance(), () -> {
|
||||
if (looping) {
|
||||
playBedrockAnimation(lastAnimation, Set.of(player), looping, 0f);
|
||||
}
|
||||
sendHitBox(player);
|
||||
sendScale(player, true);
|
||||
updateVisibility(player, true);
|
||||
@@ -411,9 +410,6 @@ public class EntityTask {
|
||||
if (player.isDead()) {
|
||||
return false;
|
||||
}
|
||||
if (player.getWorld() != entity.getWorld()) {
|
||||
return false;
|
||||
}
|
||||
if (GeyserModelEngine.getInstance().getJoinedPlayer() != null && GeyserModelEngine.getInstance().getJoinedPlayer().getIfPresent(player) != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package re.imc.geysermodelengine.packet;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
|
||||
public class EntityMetadataPacket implements WrapperPacket {
|
||||
private final int id;
|
||||
|
||||
public EntityMetadataPacket(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketContainer encode() {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||
packet.getIntegers().write(0, id);
|
||||
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
||||
packet.getWatchableCollectionModifier().writeSafely(0, watcher.getWatchableObjects());
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ public class EntityTeleportPacket implements WrapperPacket {
|
||||
packet.getDoubles().write(0, loc.getX());
|
||||
packet.getDoubles().write(1, loc.getY());
|
||||
packet.getDoubles().write(2, loc.getZ());
|
||||
packet.getBytes().write(1, (byte) (loc.getPitch() * 256.0F / 360.0F));
|
||||
packet.getBytes().write(0, (byte) (loc.getYaw() * 256.0F / 360.0F));
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,7 @@ import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import re.imc.geysermodelengine.packet.EntityDestroyPacket;
|
||||
import re.imc.geysermodelengine.packet.EntityHurtAnimationPacket;
|
||||
import re.imc.geysermodelengine.packet.EntitySpawnPacket;
|
||||
import re.imc.geysermodelengine.packet.EntityTeleportPacket;
|
||||
import re.imc.geysermodelengine.packet.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -52,7 +49,7 @@ public class PacketEntity implements Entity {
|
||||
|
||||
@Override
|
||||
public boolean teleport(@NotNull Location location) {
|
||||
this.location = location;
|
||||
this.location = location.clone();
|
||||
sendLocationPacket(viewers);
|
||||
return true;
|
||||
}
|
||||
@@ -77,7 +74,9 @@ public class PacketEntity implements Entity {
|
||||
|
||||
public void sendSpawnPacket(Collection<Player> players) {
|
||||
EntitySpawnPacket packet = new EntitySpawnPacket(id, uuid, type, location);
|
||||
EntityMetadataPacket metadataPacket = new EntityMetadataPacket(id);
|
||||
players.forEach(player -> ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet.encode()));
|
||||
players.forEach(player -> ProtocolLibrary.getProtocolManager().sendServerPacket(player, metadataPacket.encode()));
|
||||
}
|
||||
public void sendLocationPacket(Collection<Player> players) {
|
||||
EntityTeleportPacket packet = new EntityTeleportPacket(id, location);
|
||||
@@ -88,13 +87,16 @@ public class PacketEntity implements Entity {
|
||||
public void sendHurtPacket(Collection<Player> players) {
|
||||
EntityHurtAnimationPacket packet = new EntityHurtAnimationPacket(id);
|
||||
players.forEach(player -> ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet.encode()));
|
||||
|
||||
}
|
||||
|
||||
public void sendEntityDestroyPacket(Collection<Player> players) {
|
||||
EntityDestroyPacket packet = new EntityDestroyPacket(id);
|
||||
players.forEach(player -> ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet.encode()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEntityId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
// ----------------
|
||||
@@ -181,10 +183,7 @@ public class PacketEntity implements Entity {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEntityId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getFireTicks() {
|
||||
|
||||
Reference in New Issue
Block a user