mirror of
https://github.com/xSquishyLiam/mc-GeyserModelEngine-plugin.git
synced 2025-12-20 15:29:26 +00:00
fix
This commit is contained in:
@@ -110,7 +110,7 @@ public class EntityTask {
|
|||||||
spawnAnimationPlayed = true;
|
spawnAnimationPlayed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tick > 1 && tick % 5 == 0) {
|
if (tick % 5 == 0) {
|
||||||
|
|
||||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||||
if (FloodgateApi.getInstance().isFloodgatePlayer(onlinePlayer.getUniqueId())) {
|
if (FloodgateApi.getInstance().isFloodgatePlayer(onlinePlayer.getUniqueId())) {
|
||||||
@@ -134,12 +134,13 @@ public class EntityTask {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (viewers.contains(onlinePlayer)) {
|
||||||
entity.sendEntityDestroyPacket(Collections.singletonList(onlinePlayer));
|
entity.sendEntityDestroyPacket(Collections.singletonList(onlinePlayer));
|
||||||
viewers.remove(onlinePlayer);
|
viewers.remove(onlinePlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tick % 40 == 0) {
|
if (tick % 40 == 0) {
|
||||||
|
|
||||||
@@ -212,18 +213,16 @@ public class EntityTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendEntityData(Player player, int delay) {
|
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());
|
PlayerUtils.setCustomEntity(player, model.getEntity().getEntityId(), "modelengine:" + model.getActiveModel().getBlueprint().getName().toLowerCase());
|
||||||
|
|
||||||
model.getEntity().sendSpawnPacket(Collections.singletonList(player));
|
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(GeyserModelEngine.getInstance(), () -> {
|
Bukkit.getScheduler().runTaskLaterAsynchronously(GeyserModelEngine.getInstance(), () -> {
|
||||||
// PlayerUtils.sendCustomSkin(player, model.getEntity(), model.getActiveModel().getBlueprint().getName());
|
// PlayerUtils.sendCustomSkin(player, model.getEntity(), model.getActiveModel().getBlueprint().getName());
|
||||||
|
model.getEntity().sendSpawnPacket(Collections.singletonList(player));
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskLaterAsynchronously(GeyserModelEngine.getInstance(), () -> {
|
||||||
if (looping) {
|
if (looping) {
|
||||||
playBedrockAnimation(lastAnimation, Set.of(player), looping, 0f);
|
playBedrockAnimation(lastAnimation, Set.of(player), looping, 0f);
|
||||||
}
|
}
|
||||||
sendHitBox(player);
|
|
||||||
sendScale(player, true);
|
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(GeyserModelEngine.getInstance(), () -> {
|
|
||||||
sendHitBox(player);
|
sendHitBox(player);
|
||||||
sendScale(player, true);
|
sendScale(player, true);
|
||||||
updateVisibility(player, true);
|
updateVisibility(player, true);
|
||||||
@@ -411,9 +410,6 @@ public class EntityTask {
|
|||||||
if (player.isDead()) {
|
if (player.isDead()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (player.getWorld() != entity.getWorld()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (GeyserModelEngine.getInstance().getJoinedPlayer() != null && GeyserModelEngine.getInstance().getJoinedPlayer().getIfPresent(player) != null) {
|
if (GeyserModelEngine.getInstance().getJoinedPlayer() != null && GeyserModelEngine.getInstance().getJoinedPlayer().getIfPresent(player) != null) {
|
||||||
return false;
|
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(0, loc.getX());
|
||||||
packet.getDoubles().write(1, loc.getY());
|
packet.getDoubles().write(1, loc.getY());
|
||||||
packet.getDoubles().write(2, loc.getZ());
|
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;
|
return packet;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,7 @@ import org.bukkit.util.BoundingBox;
|
|||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import re.imc.geysermodelengine.packet.EntityDestroyPacket;
|
import re.imc.geysermodelengine.packet.*;
|
||||||
import re.imc.geysermodelengine.packet.EntityHurtAnimationPacket;
|
|
||||||
import re.imc.geysermodelengine.packet.EntitySpawnPacket;
|
|
||||||
import re.imc.geysermodelengine.packet.EntityTeleportPacket;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -52,7 +49,7 @@ public class PacketEntity implements Entity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(@NotNull Location location) {
|
public boolean teleport(@NotNull Location location) {
|
||||||
this.location = location;
|
this.location = location.clone();
|
||||||
sendLocationPacket(viewers);
|
sendLocationPacket(viewers);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -77,7 +74,9 @@ public class PacketEntity implements Entity {
|
|||||||
|
|
||||||
public void sendSpawnPacket(Collection<Player> players) {
|
public void sendSpawnPacket(Collection<Player> players) {
|
||||||
EntitySpawnPacket packet = new EntitySpawnPacket(id, uuid, type, location);
|
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, packet.encode()));
|
||||||
|
players.forEach(player -> ProtocolLibrary.getProtocolManager().sendServerPacket(player, metadataPacket.encode()));
|
||||||
}
|
}
|
||||||
public void sendLocationPacket(Collection<Player> players) {
|
public void sendLocationPacket(Collection<Player> players) {
|
||||||
EntityTeleportPacket packet = new EntityTeleportPacket(id, location);
|
EntityTeleportPacket packet = new EntityTeleportPacket(id, location);
|
||||||
@@ -88,13 +87,16 @@ public class PacketEntity implements Entity {
|
|||||||
public void sendHurtPacket(Collection<Player> players) {
|
public void sendHurtPacket(Collection<Player> players) {
|
||||||
EntityHurtAnimationPacket packet = new EntityHurtAnimationPacket(id);
|
EntityHurtAnimationPacket packet = new EntityHurtAnimationPacket(id);
|
||||||
players.forEach(player -> ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet.encode()));
|
players.forEach(player -> ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet.encode()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendEntityDestroyPacket(Collection<Player> players) {
|
public void sendEntityDestroyPacket(Collection<Player> players) {
|
||||||
EntityDestroyPacket packet = new EntityDestroyPacket(id);
|
EntityDestroyPacket packet = new EntityDestroyPacket(id);
|
||||||
players.forEach(player -> ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet.encode()));
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getEntityId() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFireTicks() {
|
public int getFireTicks() {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
data-send-delay: 0
|
data-send-delay: 5
|
||||||
entity-view-distance: 50
|
entity-view-distance: 50
|
||||||
join-send-delay: 20
|
join-send-delay: 20
|
||||||
model-entity-type: BAT # must be a living entity
|
model-entity-type: BAT # must be a living entity
|
||||||
|
|||||||
Reference in New Issue
Block a user