mirror of
https://github.com/GeyserExtensionists/GeyserModelEngine.git
synced 2025-12-23 00:49:18 +00:00
uhhh
This commit is contained in:
@@ -3,7 +3,6 @@ package re.imc.geysermodelengine.model;
|
||||
import com.ticxo.modelengine.api.animation.BlueprintAnimation;
|
||||
import com.ticxo.modelengine.api.entity.BaseEntity;
|
||||
import com.ticxo.modelengine.api.entity.BukkitEntity;
|
||||
import com.ticxo.modelengine.api.entity.Hitbox;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import lombok.Getter;
|
||||
@@ -19,7 +18,6 @@ import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import re.imc.geysermodelengine.GeyserModelEngine;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -33,6 +31,7 @@ public class EntityTask {
|
||||
ModelEntity model;
|
||||
|
||||
int tick = 0;
|
||||
int syncTick = 0;
|
||||
|
||||
AtomicInteger animationCooldown = new AtomicInteger(0);
|
||||
AtomicInteger currentAnimationPriority = new AtomicInteger(0);
|
||||
@@ -53,9 +52,23 @@ public class EntityTask {
|
||||
}
|
||||
|
||||
public void runSync() {
|
||||
|
||||
syncTick ++;
|
||||
if (syncTick > 400) {
|
||||
syncTick = 0;
|
||||
}
|
||||
|
||||
if (syncTick % 5 == 0) {
|
||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (!FloodgateApi.getInstance().isFloodgatePlayer(onlinePlayer.getUniqueId())) {
|
||||
onlinePlayer.hideEntity(GeyserModelEngine.getInstance(), model.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (model.getEntity().isDead()) {
|
||||
model.spawnEntity();
|
||||
}
|
||||
|
||||
model.getEntity().setVisualFire(false);
|
||||
model.teleportToModel();
|
||||
}
|
||||
@@ -95,9 +108,8 @@ public class EntityTask {
|
||||
if (tick > 1 && tick % 5 == 0) {
|
||||
|
||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (!FloodgateApi.getInstance().isFloodgatePlayer(onlinePlayer.getUniqueId())) {
|
||||
onlinePlayer.hideEntity(GeyserModelEngine.getInstance(), entity);
|
||||
} else {
|
||||
if (FloodgateApi.getInstance().isFloodgatePlayer(onlinePlayer.getUniqueId())) {
|
||||
|
||||
if (canSee(onlinePlayer, model.getEntity())) {
|
||||
|
||||
if (!viewers.contains(onlinePlayer)) {
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package re.imc.geysermodelengine.model;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.ticxo.modelengine.api.entity.BukkitEntity;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import lombok.Getter;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import re.imc.geysermodelengine.GeyserModelEngine;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -24,6 +28,7 @@ public class ModelEntity {
|
||||
public static Map<Integer, ModelEntity> MODEL_ENTITIES = new ConcurrentHashMap<>();
|
||||
|
||||
private LivingEntity entity;
|
||||
private BukkitEntity controllerEntity;
|
||||
|
||||
private final Set<Player> viewers = Sets.newConcurrentHashSet();
|
||||
|
||||
@@ -42,14 +47,28 @@ public class ModelEntity {
|
||||
}
|
||||
|
||||
public void teleportToModel() {
|
||||
entity.teleportAsync(modeledEntity.getBase().getLocation());
|
||||
Location location = modeledEntity.getBase().getLocation();
|
||||
/*
|
||||
location.setPitch(modeledEntity.getXHeadRot());
|
||||
location.setYaw(modeledEntity.getYHeadRot());
|
||||
for (Player viewer : viewers) {
|
||||
viewer.sendActionBar("X:" + modeledEntity.getXHeadRot() + ", Y:" + modeledEntity.getYHeadRot());
|
||||
}
|
||||
*/
|
||||
|
||||
entity.teleportAsync(location);
|
||||
if (modeledEntity.getBase() instanceof BukkitEntity bukkitEntity && bukkitEntity.getOriginal() instanceof LivingEntity livingEntity) {
|
||||
controllerEntity.getLookController().setHeadYaw(livingEntity.getEyeLocation().getYaw());
|
||||
controllerEntity.getLookController().setPitch(livingEntity.getEyeLocation().getPitch());
|
||||
controllerEntity.getLookController().setBodyYaw(livingEntity.getBodyYaw());
|
||||
}
|
||||
|
||||
}
|
||||
public static ModelEntity create(ModeledEntity entity, ActiveModel model) {
|
||||
ModelEntity modelEntity = new ModelEntity(entity, model);
|
||||
int id = entity.getBase().getEntityId();
|
||||
Map<ActiveModel, ModelEntity> map = ENTITIES.computeIfAbsent(id, k -> new HashMap<>());
|
||||
map.put(model, modelEntity);
|
||||
ENTITIES.put(id, map);
|
||||
|
||||
return modelEntity;
|
||||
}
|
||||
@@ -60,6 +79,7 @@ public class ModelEntity {
|
||||
ModelEntity model = this;
|
||||
int id = entity.getEntityId();
|
||||
MODEL_ENTITIES.put(id, model);
|
||||
controllerEntity = new BukkitEntity(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user