mirror of
https://github.com/xSquishyLiam/mc-GeyserModelEngine-plugin.git
synced 2025-12-19 14:59:19 +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"));
|
enablePartVisibilityModels.addAll(getConfig().getStringList("enable-part-visibility-models"));
|
||||||
|
|
||||||
instance = this;
|
instance = this;
|
||||||
if (updateTask != null) {
|
if (updateTask != null) updateTask.cancel(true);
|
||||||
updateTask.cancel(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateTask = scheduler.scheduleWithFixedDelay(() -> {
|
updateTask = scheduler.scheduleWithFixedDelay(() -> {
|
||||||
try {
|
try {
|
||||||
for (Map<ActiveModel, ModelEntity> models : ModelEntity.ENTITIES.values()) {
|
for (Map<ActiveModel, ModelEntity> models : ModelEntity.ENTITIES.values()) {
|
||||||
models.values().forEach(model -> model.getTask().updateEntityProperties(model.getViewers(), false));
|
models.values().forEach(model -> model.getTask().updateEntityProperties(model.getViewers(), false));
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable err) {
|
||||||
t.printStackTrace();
|
throw new RuntimeException(err);
|
||||||
}
|
}
|
||||||
}, 10, entityPositionUpdatePeriod, TimeUnit.MILLISECONDS);
|
}, 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.ActiveModel;
|
||||||
import com.ticxo.modelengine.api.model.bone.type.Mount;
|
import com.ticxo.modelengine.api.model.bone.type.Mount;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.geysermc.floodgate.api.FloodgateApi;
|
import org.geysermc.floodgate.api.FloodgateApi;
|
||||||
import re.imc.geysermodelengine.GeyserModelEngine;
|
import re.imc.geysermodelengine.GeyserModelEngine;
|
||||||
|
|
||||||
public class MountPacketListener implements PacketListener {
|
public class MountPacketListener implements PacketListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceive(PacketReceiveEvent event) {
|
public void onPacketReceive(PacketReceiveEvent event) {
|
||||||
if (event.getPacketType() != PacketType.Play.Client.ENTITY_ACTION) {
|
if (event.getPacketType() != PacketType.Play.Client.ENTITY_ACTION) return;
|
||||||
return;
|
if (!FloodgateApi.getInstance().isFloodgatePlayer(event.getUser().getUUID())) return;
|
||||||
}
|
|
||||||
if (!FloodgateApi.getInstance().isFloodgatePlayer(event.getUser().getUUID())) {
|
Player player = event.getPlayer();
|
||||||
return;
|
|
||||||
}
|
|
||||||
WrapperPlayClientEntityAction action = new WrapperPlayClientEntityAction(event);
|
WrapperPlayClientEntityAction action = new WrapperPlayClientEntityAction(event);
|
||||||
Pair<ActiveModel, Mount> seat = GeyserModelEngine.getInstance().getDrivers().get(event.getPlayer());
|
Pair<ActiveModel, Mount> seat = GeyserModelEngine.getInstance().getDrivers().get(player);
|
||||||
if (seat != null) {
|
|
||||||
if (action.getAction() == WrapperPlayClientEntityAction.Action.START_SNEAKING) {
|
if (seat == null) return;
|
||||||
|
if (action.getAction() != WrapperPlayClientEntityAction.Action.START_SNEAKING) return;
|
||||||
|
|
||||||
ModelEngineAPI.getMountPairManager().tryDismount(event.getPlayer());
|
ModelEngineAPI.getMountPairManager().tryDismount(event.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
@Setter
|
@Setter
|
||||||
public class PacketEntity {
|
public class PacketEntity {
|
||||||
|
|
||||||
// public static final MinecraftVersion V1_20_5 = new MinecraftVersion("1.20.5");
|
|
||||||
public PacketEntity(EntityType type, Set<Player> viewers, Location location) {
|
public PacketEntity(EntityType type, Set<Player> viewers, Location location) {
|
||||||
this.id = ThreadLocalRandom.current().nextInt(300000000, 400000000);
|
this.id = ThreadLocalRandom.current().nextInt(300000000, 400000000);
|
||||||
this.uuid = UUID.randomUUID();
|
this.uuid = UUID.randomUUID();
|
||||||
@@ -106,84 +105,5 @@ public class PacketEntity {
|
|||||||
public int getEntityId() {
|
public int getEntityId() {
|
||||||
return id;
|
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