custom entity

This commit is contained in:
zimzaza4
2024-04-14 19:37:25 +08:00
parent 3e2c9026fc
commit 2a263f60d5
5 changed files with 70 additions and 21 deletions

View File

@@ -6,9 +6,16 @@ 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.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
import me.libraryaddict.disguise.disguisetypes.MobDisguise;
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import me.zimzaza4.geyserutils.spigot.api.PlayerUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.geysermc.floodgate.api.FloodgateApi;
@@ -74,11 +81,23 @@ public class ModelEntity {
}
public LivingEntity spawnEntity() {
entity = (LivingEntity) modeledEntity.getBase().getLocation().getWorld().spawnEntity(modeledEntity.getBase().getLocation(), GeyserModelEngine.getInstance().getModelEntityType());
applyFeatures(entity, "model." + activeModel.getBlueprint().getName());
ModelEntity model = this;
int lastEntityId = ReflectionManager.getNewEntityId();
// System.out.println("RID:" + entityId);
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
if (FloodgateApi.getInstance().isFloodgatePlayer(onlinePlayer.getUniqueId())) {
PlayerUtils.setCustomEntity(onlinePlayer, lastEntityId + 1, "modelengine:" + model.getActiveModel().getBlueprint().getName());
}
}
entity = (LivingEntity) modeledEntity.getBase().getLocation().getWorld().spawnEntity(modeledEntity.getBase().getLocation(), GeyserModelEngine.getInstance().getModelEntityType());
int id = entity.getEntityId();
MODEL_ENTITIES.put(id, model);
applyFeatures(entity, "model." + activeModel.getBlueprint().getName());
controllerEntity = new BukkitEntity(entity);
return entity;
}
@@ -102,15 +121,17 @@ public class ModelEntity {
display.setPersistent(false);
// armorStand.setVisible(false);
/*
String uuid = UUID.randomUUID().toString();
PlayerDisguise disguise = new PlayerDisguise(name + "_" + uuid);
MobDisguise disguise = new MobDisguise(DisguiseType.getType(entity.getType()));
disguise.setDisguiseName(uuid);
DisguiseAPI.disguiseEntity(display, disguise.setNameVisible(false));
DisguiseAPI.disguiseEntity(display, disguise);
*/
}
}