mirror of
https://github.com/GeyserExtensionists/GeyserModelEngine.git
synced 2025-12-19 15:09:18 +00:00
Should I even clean this up...
This commit is contained in:
@@ -123,17 +123,15 @@ public final class GeyserModelEngine extends JavaPlugin {
|
||||
enablePartVisibilityModels.addAll(getConfig().getStringList("enable-part-visibility-models"));
|
||||
|
||||
instance = this;
|
||||
if (updateTask != null) {
|
||||
updateTask.cancel(true);
|
||||
}
|
||||
if (updateTask != null) updateTask.cancel(true);
|
||||
|
||||
updateTask = scheduler.scheduleWithFixedDelay(() -> {
|
||||
try {
|
||||
for (Map<ActiveModel, ModelEntity> models : ModelEntity.ENTITIES.values()) {
|
||||
models.values().forEach(model -> model.getTask().updateEntityProperties(model.getViewers(), false));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
} catch (Throwable err) {
|
||||
throw new RuntimeException(err);
|
||||
}
|
||||
}, 10, entityPositionUpdatePeriod, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@@ -8,24 +8,25 @@ import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.bone.type.Mount;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import re.imc.geysermodelengine.GeyserModelEngine;
|
||||
|
||||
public class MountPacketListener implements PacketListener {
|
||||
|
||||
@Override
|
||||
public void onPacketReceive(PacketReceiveEvent event) {
|
||||
if (event.getPacketType() != PacketType.Play.Client.ENTITY_ACTION) {
|
||||
return;
|
||||
}
|
||||
if (!FloodgateApi.getInstance().isFloodgatePlayer(event.getUser().getUUID())) {
|
||||
return;
|
||||
}
|
||||
if (event.getPacketType() != PacketType.Play.Client.ENTITY_ACTION) return;
|
||||
if (!FloodgateApi.getInstance().isFloodgatePlayer(event.getUser().getUUID())) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
WrapperPlayClientEntityAction action = new WrapperPlayClientEntityAction(event);
|
||||
Pair<ActiveModel, Mount> seat = GeyserModelEngine.getInstance().getDrivers().get(event.getPlayer());
|
||||
if (seat != null) {
|
||||
if (action.getAction() == WrapperPlayClientEntityAction.Action.START_SNEAKING) {
|
||||
Pair<ActiveModel, Mount> seat = GeyserModelEngine.getInstance().getDrivers().get(player);
|
||||
|
||||
if (seat == null) return;
|
||||
if (action.getAction() != WrapperPlayClientEntityAction.Action.START_SNEAKING) return;
|
||||
|
||||
ModelEngineAPI.getMountPairManager().tryDismount(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
@Setter
|
||||
public class PacketEntity {
|
||||
|
||||
// public static final MinecraftVersion V1_20_5 = new MinecraftVersion("1.20.5");
|
||||
public PacketEntity(EntityType type, Set<Player> viewers, Location location) {
|
||||
this.id = ThreadLocalRandom.current().nextInt(300000000, 400000000);
|
||||
this.uuid = UUID.randomUUID();
|
||||
@@ -106,84 +105,5 @@ public class PacketEntity {
|
||||
public int getEntityId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public boolean teleport(@NotNull Location location) {
|
||||
this.location = location.clone();
|
||||
sendLocationPacket(viewers);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void remove() {
|
||||
removed = true;
|
||||
sendEntityDestroyPacket(viewers);
|
||||
}
|
||||
|
||||
public boolean isDead() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return !removed;
|
||||
}
|
||||
|
||||
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());
|
||||
});
|
||||
sendAllEquipmentPacket(players);
|
||||
// players.forEach(player -> ProtocolLibrary.getProtocolManager().sendServerPacket(player, metadataPacket.encode()));
|
||||
}
|
||||
|
||||
public void sendAllEquipmentPacket(Collection<Player> players) {
|
||||
for (Map.Entry<EnumWrappers.ItemSlot, ItemStack> e : equipment.entrySet()) {
|
||||
EntityEquipmentPacket packet = new EntityEquipmentPacket(id, e.getKey(), e.getValue());
|
||||
|
||||
players.forEach(player -> {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet.encode());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void sendLocationPacket(Collection<Player> players) {
|
||||
WrapperPacket packet = MinecraftVersion.v1_21_2.atOrAbove() ? new EntityPositionSyncPacket(id, location) : new EntityTeleportPacket(id, location);
|
||||
players.forEach(player -> ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet.encode()));
|
||||
|
||||
}
|
||||
|
||||
public void sendHurtPacket(Collection<Player> players) {
|
||||
// 1.21 error
|
||||
if (MinecraftVersion.getCurrentVersion().compareTo(V1_20_5) < 0) {
|
||||
}
|
||||
}
|
||||
EntityHurtPacket packet = new EntityHurtPacket(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()));
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setSlot(EnumWrappers.ItemSlot slot, ItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
itemStack = new ItemStack(Material.AIR);
|
||||
}
|
||||
equipment.put(slot, itemStack);
|
||||
EntityEquipmentPacket packet = new EntityEquipmentPacket(id, slot, itemStack);
|
||||
viewers.forEach(player -> {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet.encode());
|
||||
});
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user