mirror of
https://github.com/xSquishyLiam/mc-GeyserModelEngine-plugin.git
synced 2025-12-19 14:59:19 +00:00
Added safety register for properties, also doing a debug value using "visibility" property
This commit is contained in:
Binary file not shown.
@@ -8,6 +8,7 @@ import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.zimzaza4.geyserutils.common.animation.Animation;
|
||||
import me.zimzaza4.geyserutils.spigot.GeyserUtils;
|
||||
import me.zimzaza4.geyserutils.spigot.api.PlayerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -40,6 +41,7 @@ public class EntityTask {
|
||||
boolean firstAnimation = true;
|
||||
boolean spawnAnimationPlayed = false;
|
||||
boolean removed = false;
|
||||
boolean registered = false;
|
||||
|
||||
String lastAnimation = "";
|
||||
boolean looping = true;
|
||||
@@ -199,11 +201,14 @@ public class EntityTask {
|
||||
if (animationCooldown.get() > 0) {
|
||||
animationCooldown.decrementAndGet();
|
||||
}
|
||||
|
||||
updateVisibility(model.getViewers());
|
||||
}
|
||||
|
||||
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());
|
||||
registerProperties(player);
|
||||
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(GeyserModelEngine.getInstance(), () -> {
|
||||
// PlayerUtils.sendCustomSkin(player, model.getEntity(), model.getActiveModel().getBlueprint().getName());
|
||||
@@ -218,6 +223,16 @@ public class EntityTask {
|
||||
}, delay);
|
||||
}
|
||||
|
||||
// the only reason I do it here is for safety, it's also done in the Pack generator (just like adding the custom entity)
|
||||
public void registerProperties(Player player) {
|
||||
Entity entity = model.getEntity();
|
||||
PlayerUtils.registerProperty(player, entity, "nm_raccoon:visibility", Boolean.class);
|
||||
|
||||
model.getActiveModel().getBones().forEach((s,bone) -> {
|
||||
PlayerUtils.registerProperty(player, entity, "nm_raccoon:" + s, Boolean.class);
|
||||
});
|
||||
}
|
||||
|
||||
public void sendScale(Player player) {
|
||||
// todo?
|
||||
}
|
||||
@@ -348,6 +363,14 @@ public class EntityTask {
|
||||
|
||||
}
|
||||
|
||||
public void updateVisibility(Set<Player> viewers) {
|
||||
Entity entity = model.getEntity();
|
||||
|
||||
for (Player viewer : viewers) {
|
||||
PlayerUtils.sendBoolProperty(viewer, entity, "nm_raccoon:visibility", true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canSee(Player player, Entity entity) {
|
||||
if (!player.isOnline()) {
|
||||
return false;
|
||||
|
||||
@@ -6,7 +6,10 @@ 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.zimzaza4.geyserutils.spigot.api.PlayerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
@@ -41,7 +44,6 @@ public class ModelEntity {
|
||||
this.activeModel = model;
|
||||
this.entity = spawnEntity();
|
||||
runEntityTask();
|
||||
|
||||
}
|
||||
|
||||
public void teleportToModel() {
|
||||
|
||||
Reference in New Issue
Block a user