This commit is contained in:
TJ committed 2026-11-22 20:14:28 +01:00
commit 428877fbf6
1072 files changed
+160209

No files matched your search

+8
View File
@@ -0,0 +1,8 @@
dependencies {
compileOnly(project(":api"))
compileOnly(project(":core"))
listOf("v1_20_R4", "v1_21_R1", "v1_21_R2", "v1_21_R3", "v1_21_R4", "v1_21_R5", "v1_21_R6", "v1_21_R7")
.forEach { compileOnly(project(":nms:$it")) }
compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT")
compileOnly("io.lumine:Mythic-Dist:5.14.0") { isTransitive = false }
}
@@ -0,0 +1,47 @@
package com.ticxo.modelengine.core21;
import com.ticxo.modelengine.api.nms.NMSHandler;
import com.ticxo.modelengine.api.utils.CompatibilityManager;
import com.ticxo.modelengine.core.ModelEngine;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.compatibility.MythicCompatibility;
import com.ticxo.modelengine.v1_20_R4.NMSHandler_v1_20_R4;
import com.ticxo.modelengine.v1_21_R1.NMSHandler_v1_21_R1;
import com.ticxo.modelengine.v1_21_R2.NMSHandler_v1_21_R2;
import com.ticxo.modelengine.v1_21_R3.NMSHandler_v1_21_R3;
import com.ticxo.modelengine.v1_21_R4.NMSHandler_v1_21_R4;
import com.ticxo.modelengine.v1_21_R5.NMSHandler_v1_21_R5;
import com.ticxo.modelengine.v1_21_R6.NMSHandler_v1_21_R6;
import com.ticxo.modelengine.v1_21_R7.NMSHandler_v1_21_R7;
import java.io.File;
import java.util.List;
public class Java21Helper {
private static MythicCompatibility mythicCompatibility;
public static void registerCompatibility(CompatibilityManager compatibilityManager, ModelEngine plugin) {
compatibilityManager.registerSupport("MythicMobs", () -> mythicCompatibility = new MythicCompatibility(plugin));
}
public static NMSHandler createNMSHandler(String version) {
return (NMSHandler)(switch (version) {
case "1.20.5", "1.20.6" -> new NMSHandler_v1_20_R4();
case "1.21", "1.21.1" -> new NMSHandler_v1_21_R1();
case "1.21.2", "1.21.3" -> new NMSHandler_v1_21_R2();
case "1.21.4" -> new NMSHandler_v1_21_R3();
case "1.21.5" -> new NMSHandler_v1_21_R4();
case "1.21.6", "1.21.7", "1.21.8" -> new NMSHandler_v1_21_R5();
case "1.21.9", "1.21.10" -> new NMSHandler_v1_21_R6();
case "1.21.11" -> new NMSHandler_v1_21_R7();
default -> null;
});
}
public static List<File> getMythicPackModelFiles() {
return MythicUtils.getPackModelFiles();
}
public static MythicCompatibility getMythicCompatibility() {
return mythicCompatibility;
}
}
@@ -0,0 +1,216 @@
package com.ticxo.modelengine.core21.mythic;
import com.google.common.collect.Lists;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.generator.blueprint.ModelBlueprint;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.api.mount.controller.MountControllerSupplier;
import com.ticxo.modelengine.core21.Java21Helper;
import com.ticxo.modelengine.core21.mythic.compatibility.MythicMountController;
import com.ticxo.modelengine.core21.mythic.compatibility.ProjectileEntity;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.packs.Pack;
import io.lumine.mythic.api.skills.IParentSkill;
import io.lumine.mythic.api.skills.Skill;
import io.lumine.mythic.api.skills.SkillCaster;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.core.skills.auras.AuraAttachment.AttachmentTracker;
import io.lumine.mythic.core.skills.auras.attachment.MEGAttachment.MEGAttachmentTracker;
import io.lumine.mythic.core.skills.placeholders.PlaceholderMeta;
import io.lumine.mythic.core.skills.projectiles.ProjectileBulletableTracker;
import io.lumine.mythic.core.skills.projectiles.ProjectileBullet.BulletTracker;
import io.lumine.mythic.core.skills.projectiles.bullet.MEGBullet.MEGBulletTracker;
import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Consumer;
import org.bukkit.Color;
import org.jetbrains.annotations.Nullable;
public class MythicUtils {
public static String getOrNull(@Nullable PlaceholderString placeholderString) {
return placeholderString == null ? null : placeholderString.get();
}
public static String getOrNull(@Nullable PlaceholderString placeholderString, PlaceholderMeta meta) {
return placeholderString == null ? null : placeholderString.get(meta);
}
public static String getOrNull(@Nullable PlaceholderString placeholderString, AbstractEntity entity) {
return placeholderString == null ? null : placeholderString.get(entity);
}
public static String getOrNull(@Nullable PlaceholderString placeholderString, PlaceholderMeta meta, AbstractEntity entity) {
return placeholderString == null ? null : placeholderString.get(meta, entity);
}
public static String getOrNull(@Nullable PlaceholderString placeholderString, SkillCaster caster) {
return placeholderString == null ? null : placeholderString.get(caster);
}
public static String getOrNullLowercase(@Nullable PlaceholderString placeholderString) {
return placeholderString == null ? null : placeholderString.get().toLowerCase(Locale.ENGLISH);
}
public static String getOrNullLowercase(@Nullable PlaceholderString placeholderString, PlaceholderMeta meta) {
return placeholderString == null ? null : placeholderString.get(meta).toLowerCase(Locale.ENGLISH);
}
public static String getOrNullLowercase(@Nullable PlaceholderString placeholderString, AbstractEntity entity) {
return placeholderString == null ? null : placeholderString.get(entity).toLowerCase(Locale.ENGLISH);
}
public static String getOrNullLowercase(@Nullable PlaceholderString placeholderString, PlaceholderMeta meta, AbstractEntity entity) {
return placeholderString == null ? null : placeholderString.get(meta, entity).toLowerCase(Locale.ENGLISH);
}
public static String getOrNullLowercase(@Nullable PlaceholderString placeholderString, SkillCaster caster) {
return placeholderString == null ? null : placeholderString.get(caster).toLowerCase(Locale.ENGLISH);
}
public static Color getColor(@Nullable String colorString) {
if (colorString == null) {
return Color.WHITE;
} else {
if (colorString.startsWith("#")) {
colorString = colorString.substring(1);
}
return Color.fromRGB(Integer.parseInt(colorString, 16));
}
}
public static ActiveModel getActiveModelOrNull(ModeledEntity entity, @Nullable String modelId) {
return modelId == null ? null : entity.getModel(modelId.toLowerCase(Locale.ENGLISH)).orElse(null);
}
public static ModelBlueprint getBlueprintOrNull(@Nullable String modelid) {
return modelid == null ? null : ModelEngineAPI.getBlueprint(modelid);
}
public static ProjectileEntity<?> getProjectileEntity(SkillMetadata meta) {
return castProjectileEntity(meta).map(tracker -> Java21Helper.getMythicCompatibility().getMythicSupport().getTrackers().get(tracker)).orElse(null);
}
public static <T extends ProjectileBulletableTracker & IParentSkill> Optional<T> castProjectileEntity(SkillMetadata metadata) {
return metadata.getCallingEvent() instanceof ProjectileBulletableTracker tracker ? castProjectileEntity(tracker) : Optional.empty();
}
public static <T extends ProjectileBulletableTracker & IParentSkill> Optional<T> castProjectileEntity(ProjectileBulletableTracker tracker) {
return tracker instanceof IParentSkill ? Optional.of((T)tracker) : Optional.empty();
}
public static UUID getVFXUniqueId(SkillMetadata meta) {
ProjectileEntity<?> base = getProjectileEntity(meta);
return base != null ? base.getUUID() : meta.getCaster().getEntity().getUniqueId();
}
public static void executeOptModelId(ModeledEntity entity, String modelId, Consumer<ActiveModel> consumer) {
if (modelId == null) {
for (ActiveModel activeModel : entity.getModels().values()) {
consumer.accept(activeModel);
}
} else {
ActiveModel activeModel = getActiveModelOrNull(entity, modelId);
if (activeModel != null) {
consumer.accept(activeModel);
}
}
}
public static void executeBoneChild(boolean child, ModelBone bone, Consumer<ModelBone> boneConsumer) {
boneConsumer.accept(bone);
if (child) {
LinkedList<ModelBone> queue = new LinkedList<>(bone.getChildren().values());
while (!queue.isEmpty()) {
ModelBone childBone = queue.pop();
boneConsumer.accept(childBone);
queue.addAll(childBone.getChildren().values());
}
}
}
public static MountControllerSupplier createControllerSupplier(Skill skill, SkillMetadata metadata) {
return (entity, mount) -> new MythicMountController(entity, mount, skill, metadata);
}
public static List<File> getPackModelFiles() {
List<File> files = Lists.newArrayList();
for (Pack pack : MythicBukkit.inst().getPackManager().getPacks()) {
File folder = pack.getPackFolder("Models");
if (folder.exists()) {
addFilesRecursively(folder, files);
}
folder = new File(pack.getPackFolder("Assets"), "modelengine");
if (folder.exists()) {
addFilesRecursively(folder, files);
}
}
return files;
}
private static void addFilesRecursively(File folder, List<File> files) {
File[] fileList = folder.listFiles();
if (fileList != null) {
for (File file : fileList) {
if (file.isFile() && file.getName().endsWith(".bbmodel")) {
files.add(file);
} else if (file.isDirectory()) {
addFilesRecursively(file, files);
}
}
}
}
public static Optional<ModeledEntity> findSkillableModel(SkillMetadata data, UUID target) {
if (target != null) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target);
if (model != null) {
return Optional.of(model);
}
}
return getParentVFXModel(data);
}
public static Optional<ModeledEntity> getParentVFXModel(SkillMetadata meta) {
Optional<Object> maybeBullet = meta.getMetadata("bullet");
if (maybeBullet.isPresent()) {
return getParentVFXModel((BulletTracker)maybeBullet.get());
} else {
Optional<Object> maybeAttachment = meta.getMetadata("attachment");
return maybeAttachment.isPresent() ? getParentVFXModel((AttachmentTracker)maybeAttachment.get()) : Optional.empty();
}
}
private static Optional<ModeledEntity> getParentVFXModel(BulletTracker bulletTracker) {
if (bulletTracker instanceof MEGBulletTracker megBulletTracker) {
UUID entityId = megBulletTracker.getEntityId();
ModeledEntity model = ModelEngineAPI.getModeledEntity(entityId);
return Optional.ofNullable(model);
} else {
return Optional.empty();
}
}
private static Optional<ModeledEntity> getParentVFXModel(AttachmentTracker bulletTracker) {
if (bulletTracker instanceof MEGAttachmentTracker megBulletTracker) {
UUID entityId = megBulletTracker.getEntityId();
ModeledEntity model = ModelEngineAPI.getModeledEntity(entityId);
return Optional.ofNullable(model);
} else {
return Optional.empty();
}
}
}
@@ -0,0 +1,50 @@
package com.ticxo.modelengine.core21.mythic.animation;
import com.ticxo.modelengine.api.animation.property.IAnimationProperty;
import com.ticxo.modelengine.api.animation.script.ScriptReader;
import com.ticxo.modelengine.api.generator.blueprint.ModelBlueprint;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.utils.logger.TLogger;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.core.mobs.ActiveMob;
import org.bukkit.entity.Entity;
public class MythicScriptReader implements ScriptReader {
@Override
public void read(IAnimationProperty property, String script) {
ActiveModel model = property.getModel();
ModelBlueprint blueprint = model.getBlueprint();
if (model.getModeledEntity().getBase().getOriginal() instanceof Entity entity) {
float power = 1.0F;
ActiveMob activeMob = MythicBukkit.inst().getAPIHelper().getMythicMobInstance(entity);
if (activeMob != null) {
power = activeMob.getPower();
}
String[] scriptSplit = script.split("\\{", 2);
String skillName = scriptSplit[0];
boolean succeed = MythicBukkit.inst().getAPIHelper().castSkill(entity, skillName, power, meta -> {
if (scriptSplit.length == 2) {
String[] parameters = scriptSplit[1].substring(0, scriptSplit[1].length() - 1).split(";");
for (String param : parameters) {
String[] entry = param.split("=", 2);
meta.getParameters().put(entry[0], entry.length == 2 ? this.getAnimationPlaceholder(blueprint, entry[1].strip()) : "");
}
}
});
if (!succeed) {
TLogger.warn("Unknown MythicMobs script: " + script);
}
}
}
private String getAnimationPlaceholder(ModelBlueprint blueprint, String placeholder) {
if (placeholder.startsWith("<") && placeholder.endsWith(">")) {
String key = placeholder.substring(1, placeholder.length() - 1);
return blueprint.getAnimationsPlaceholders().getOrDefault(key, placeholder);
} else {
return placeholder;
}
}
}
@@ -0,0 +1,144 @@
package com.ticxo.modelengine.core21.mythic.compatibility;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.animation.BlueprintAnimation;
import com.ticxo.modelengine.api.animation.handler.AnimationHandler;
import com.ticxo.modelengine.api.animation.handler.IStateMachineHandler;
import com.ticxo.modelengine.api.animation.property.IAnimationProperty;
import com.ticxo.modelengine.api.animation.property.SimpleProperty;
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
import com.ticxo.modelengine.api.generator.blueprint.ModelBlueprint;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.api.model.bone.type.Segment;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.bukkit.compatibility.AbstractModelEngineSupport.MEGAttachment;
import io.lumine.mythic.bukkit.compatibility.AbstractModelEngineSupport.MEGAttachmentData;
import io.lumine.mythic.core.logging.MythicLogger;
import java.util.UUID;
import java.util.Map.Entry;
import org.bukkit.Color;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class AuraAttachment implements MEGAttachment {
private Entity entity;
private FakeEntity attachedEntity;
private ModelBlueprint modelBlueprint;
private ActiveModel activeModel;
private ModeledEntity modeledEntity;
public AuraAttachment(MEGAttachmentData modelData, AbstractEntity target) {
this.entity = BukkitAdapter.adapt(target);
String modelId = modelData.getModelId();
String state = modelData.getState();
double scale = modelData.getScale();
String color = modelData.getColor();
boolean enchanted = modelData.isEnchanted();
boolean glowing = modelData.isGlowing();
String glowColor = modelData.getGlowColor();
Integer brightness = modelData.getBrightness();
this.modelBlueprint = ModelEngineAPI.getBlueprint(modelId);
if (this.modelBlueprint == null) {
MythicLogger.error("Failed to spawn Aura Attachment: Model " + modelId + " not found");
} else {
this.activeModel = ModelEngineAPI.createActiveModel(this.modelBlueprint);
this.activeModel.setCanHurt(false);
this.activeModel.setScale(scale);
this.activeModel.setHitboxScale(0.0);
if (color != null) {
if (color.startsWith("#")) {
color = color.substring(1);
}
this.activeModel.setDefaultTint(Color.fromRGB(Integer.parseInt(color, 16)));
}
if (brightness != null) {
this.activeModel.setBlockLight(brightness);
this.activeModel.setSkyLight(brightness);
}
for (Entry<String, ModelBone> entry : this.activeModel.getBones().entrySet()) {
ModelBone bone = entry.getValue();
if (enchanted) {
bone.setEnchanted(true);
}
bone.getBoneBehavior(BoneBehaviorTypes.SEGMENT).ifPresent(segment -> ((Segment)segment).setBounded(false));
}
if (state != null) {
AnimationHandler handler = this.activeModel.getAnimationHandler();
if (handler instanceof IStateMachineHandler stateMachineHandler) {
IAnimationProperty property = stateMachineHandler.playAnimation(100, state, 0.0, 0.0, 1.0, true);
if (property != null) {
property.setForceLoopMode(BlueprintAnimation.LoopMode.LOOP);
}
} else {
IAnimationProperty property = handler.playAnimation(state, 0.0, 0.0, 1.0, true);
if (property != null) {
property.setForceLoopMode(BlueprintAnimation.LoopMode.LOOP);
}
}
}
this.attachedEntity = new FakeEntity(this.entity, modelData.getOffset(), modelData.getAnchor());
this.attachedEntity.setCollidableWith(this.entity, false);
this.modeledEntity = ModelEngineAPI.createModeledEntity(this.attachedEntity);
this.modeledEntity.getAnimationLodHandler().setEnabled(modelData.isUseALOD());
this.modeledEntity.getBase().getBodyRotationController().setPlayerMode(true);
this.modeledEntity.setBaseEntityVisible(true);
this.modeledEntity.addModel(this.activeModel, false);
this.activeModel.setPivotOverride(ModelEngineAPI.getPivotOverrideRegistry().getOrCreate(this.entity));
if (glowing) {
this.activeModel.setGlowing(true);
if (glowColor != null) {
if (glowColor.startsWith("#")) {
glowColor = glowColor.substring(1);
}
this.activeModel.setGlowColor(Integer.parseInt(glowColor, 16));
}
}
if (this.entity instanceof Player player && this.modeledEntity.getBase().getData() instanceof BukkitEntityData data) {
data.getTracked().addForcedPairing(player.getUniqueId());
}
}
}
public UUID getEntityId() {
return this.attachedEntity.getUUID();
}
public void setRenderRadius(int radius) {
BukkitEntityData data = this.attachedEntity.getData();
}
public void disableCulling() {
BukkitEntityData data = this.attachedEntity.getData();
data.setVerticalCull(false);
data.setBackCull(false);
data.setBlockedCull(false);
data.cullUpdate();
}
public void close() throws Exception {
BlueprintAnimation animation = this.modelBlueprint.getAnimations().get("death");
if (animation == null) {
ModelEngineAPI.removeModeledEntity(this.attachedEntity.getUUID());
} else {
SimpleProperty property = new SimpleProperty(this.activeModel, animation, 1.0, 0.0, 1.0);
property.setForceLoopMode(BlueprintAnimation.LoopMode.ONCE);
property.setForceOverride(BlueprintAnimation.OverrideMode.OVERRIDE);
property.setOnEndTask(() -> ModelEngineAPI.removeModeledEntity(this.attachedEntity.getUUID()));
if (!this.activeModel.getAnimationHandler().playAnimation(property, true)) {
ModelEngineAPI.removeModeledEntity(this.attachedEntity.getUUID());
}
}
}
}
@@ -0,0 +1,68 @@
package com.ticxo.modelengine.core21.mythic.compatibility;
import com.ticxo.modelengine.api.entity.BukkitEntity;
import com.ticxo.modelengine.api.nms.entity.wrapper.BodyRotationController;
import io.lumine.mythic.bukkit.compatibility.AbstractModelEngineSupport.MEGAttachmentAnchor;
import io.lumine.mythic.bukkit.utils.serialize.Orient;
import java.util.UUID;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
public class FakeEntity extends BukkitEntity {
private final UUID uuid = UUID.randomUUID();
private final Vector offset;
private final double yaw;
private final double pitch;
private final MEGAttachmentAnchor anchor;
public FakeEntity(@NotNull Entity entity, Orient orient, MEGAttachmentAnchor anchor) {
super(entity);
this.offset = orient.getLocus().toVector();
this.yaw = Math.toRadians(orient.getDirection().getYaw());
this.pitch = Math.toRadians(orient.getDirection().getPitch());
this.anchor = anchor;
this.getBodyRotationController().setMaxHeadAngle(45.0F);
this.getBodyRotationController().setMaxBodyAngle(45.0F);
this.getBodyRotationController().setStableAngle(5.0F);
}
@Override
public UUID getUUID() {
return this.uuid;
}
@Override
public Location getLocation() {
BodyRotationController controller = this.getBodyRotationController();
Location location = this.getOriginal().getLocation();
Vector offset;
if (this.anchor == MEGAttachmentAnchor.HEAD) {
double pYaw = Math.toRadians(location.getYaw());
double pPitch = Math.toRadians(location.getPitch());
offset = rotateYaw(rotatePitch(this.offset.clone(), this.pitch + pPitch), this.yaw + pYaw);
} else {
double pYaw = Math.toRadians(controller == null ? this.getYBodyRot() : controller.getYBodyRot());
offset = rotateYaw(this.offset.clone(), this.yaw + pYaw);
}
return location.add(offset);
}
public static Vector rotatePitch(Vector vec, double pitch) {
double sin = Math.sin(pitch);
double cos = Math.cos(pitch);
double y = vec.getY() * cos - vec.getZ() * sin;
double z = vec.getY() * sin + vec.getZ() * cos;
return vec.setY(y).setZ(z);
}
public static Vector rotateYaw(Vector vec, double yaw) {
double sin = Math.sin(yaw);
double cos = Math.cos(yaw);
double x = vec.getX() * cos - vec.getZ() * sin;
double z = vec.getX() * sin + vec.getZ() * cos;
return vec.setX(x).setZ(z);
}
}
@@ -0,0 +1,108 @@
package com.ticxo.modelengine.core21.mythic.compatibility;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.ServerInfo;
import com.ticxo.modelengine.api.entity.BukkitEntity;
import com.ticxo.modelengine.api.generator.blueprint.ModelBlueprint;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes;
import com.ticxo.modelengine.api.model.bone.manager.MountManager;
import com.ticxo.modelengine.api.model.bone.type.NameTag;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicConfig;
import io.lumine.mythic.api.mobs.MythicMob;
import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.core.logging.MythicLogger;
import io.lumine.mythic.core.mobs.model.MobModel;
import java.util.Locale;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.entity.Entity;
public class MEGModel extends MobModel {
private final String id;
private String nameplate = "";
private double stepHeight = 0.5;
private int viewRadius = 0;
private double scale = 1.0;
private double hitboxScale = 1.0;
private boolean useHitbox = true;
private boolean invisible = true;
private boolean doDamageTint = true;
private boolean canDrive = false;
private boolean canRide = false;
private boolean lockPitch = false;
private boolean lockYaw = false;
public MEGModel(MythicMob baseMob, MythicConfig config) {
super(baseMob, config);
if (config.isConfigurationSection("Model")) {
String tempId = config.getString("Model.Id", null);
this.id = tempId == null ? null : tempId.toLowerCase(Locale.ENGLISH);
this.nameplate = config.getString("Model.Nameplate", null);
this.stepHeight = config.getDouble("Model.Step", 0.5);
this.viewRadius = config.getInteger("Model.ViewRadius", 0);
this.useHitbox = config.getBoolean("Model.Hitbox", true);
this.invisible = config.getBoolean("Model.Invisible", true);
this.doDamageTint = config.getBoolean("Model.DamageTint", true);
this.canDrive = config.getBoolean("Model.Drive", false);
this.canRide = config.getBoolean("Model.Ride", false);
this.lockPitch = config.getBoolean("Model.LockPitch", false);
this.lockYaw = config.getBoolean("Model.LockYaw", false);
this.scale = config.getDouble("Model.Scale", 1.0);
this.hitboxScale = config.getDouble("Model.HitboxScale", this.scale);
} else {
this.id = config.getString("Model");
}
}
public void apply(AbstractEntity entity) {
if (this.id == null) {
MythicLogger.error("ModelEngine ID not specified");
} else {
ModelBlueprint blueprint = ModelEngineAPI.getBlueprint(this.id);
if (blueprint == null) {
MythicLogger.error("Unable to find model with ID {0}", new Object[]{this.id});
} else {
Entity bukkitTarget = BukkitAdapter.adapt(entity);
ModeledEntity model = ModelEngineAPI.getOrCreateModeledEntity(bukkitTarget.getUniqueId(), () -> {
BukkitEntity baseEntity = new BukkitEntity(bukkitTarget);
baseEntity.setMaxStepHeight(this.stepHeight);
if (this.viewRadius > 0) {
baseEntity.setRenderRadius(this.viewRadius);
}
return baseEntity;
});
if (model.getModel(this.id).isPresent()) {
MythicLogger.error("Entity already contains model with ID {0}", new Object[]{this.id});
} else {
model.setBaseEntityVisible(!this.invisible);
ActiveModel activeModel = ModelEngineAPI.createActiveModel(blueprint);
activeModel.setScale(this.scale);
activeModel.setHitboxScale(this.hitboxScale);
activeModel.getMountManager().ifPresent(mountManager -> {
((MountManager)mountManager).setCanDrive(this.canDrive);
((MountManager)mountManager).setCanRide(this.canRide);
});
activeModel.setCanHurt(this.doDamageTint);
activeModel.setLockPitch(this.lockPitch);
activeModel.setLockYaw(this.lockYaw);
model.addModel(activeModel, this.useHitbox).ifPresent(ActiveModel::destroy);
activeModel.getBone(this.nameplate)
.flatMap(modelBone -> modelBone.getBoneBehavior(BoneBehaviorTypes.NAMETAG))
.ifPresent(nameTag -> ((NameTag)nameTag).setComponentSupplier(() -> {
if (ServerInfo.IS_PAPER) {
Component name = ServerInfo.IS_FOLIA ? ModelEngineAPI.getEntityHandler().getCustomName(bukkitTarget) : bukkitTarget.customName();
return (Component)(name == null ? Component.empty() : name);
} else {
String name = bukkitTarget.getCustomName();
return name == null ? null : LegacyComponentSerializer.legacyAmpersand().deserialize(name);
}
}));
}
}
}
}
}
@@ -0,0 +1,129 @@
package com.ticxo.modelengine.core21.mythic.compatibility;
import com.google.common.collect.Maps;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.generator.ModelGenerator;
import com.ticxo.modelengine.api.generator.blueprint.BlueprintBone;
import com.ticxo.modelengine.api.generator.blueprint.ModelBlueprint;
import com.ticxo.modelengine.api.nms.entity.HitboxEntity;
import com.ticxo.modelengine.api.utils.math.OrientedBoundingBox;
import com.ticxo.modelengine.api.utils.math.TMath;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.adapters.AbstractLocation;
import io.lumine.mythic.api.config.MythicConfig;
import io.lumine.mythic.api.mobs.MythicMob;
import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.bukkit.compatibility.AbstractModelEngineSupport;
import io.lumine.mythic.bukkit.compatibility.AbstractModelEngineSupport.MEGAttachment;
import io.lumine.mythic.bukkit.compatibility.AbstractModelEngineSupport.MEGAttachmentData;
import io.lumine.mythic.bukkit.compatibility.AbstractModelEngineSupport.MEGProjectile;
import io.lumine.mythic.bukkit.compatibility.AbstractModelEngineSupport.MEGProjectileData;
import io.lumine.mythic.bukkit.compatibility.AbstractModelEngineSupport.ModelConfig;
import io.lumine.mythic.core.logging.MythicLogger;
import io.lumine.mythic.core.mobs.model.MobModel;
import io.lumine.mythic.core.skills.projectiles.ProjectileBulletableTracker;
import java.util.Map;
import java.util.UUID;
import org.bukkit.entity.Entity;
import org.bukkit.util.BoundingBox;
import org.joml.Vector3f;
public class ModelEngineSupportImpl extends AbstractModelEngineSupport {
private final Map<ProjectileBulletableTracker, ProjectileEntity<?>> trackers = Maps.newConcurrentMap();
public ModelEngineSupportImpl() {
super(MythicBukkit.inst());
}
public boolean isSubHitbox(UUID uuid) {
return ModelEngineAPI.getInteractionTracker().getHitbox(uuid) != null;
}
public boolean isBoundToSubHitbox(UUID subHitbox, UUID bound) {
HitboxEntity hitbox = ModelEngineAPI.getInteractionTracker().getHitbox(subHitbox);
return hitbox != null && hitbox.getSubHitbox().getBoundEntities().containsKey(bound);
}
public String getSubHitboxBoneId(UUID uuid) {
HitboxEntity hitbox = ModelEngineAPI.getInteractionTracker().getHitbox(uuid);
return hitbox == null ? null : hitbox.getBone().getBoneId();
}
public UUID getParentUUID(UUID uuid) {
HitboxEntity hitbox = ModelEngineAPI.getInteractionTracker().getHitbox(uuid);
return hitbox == null ? uuid : hitbox.getBone().getActiveModel().getModeledEntity().getBase().getUUID();
}
public AbstractEntity getParent(AbstractEntity abstractEntity) {
HitboxEntity hitbox = ModelEngineAPI.getInteractionTracker().getHitbox(abstractEntity.getUniqueId());
if (hitbox == null) {
return abstractEntity;
} else {
return hitbox.getBone().getActiveModel().getModeledEntity().getBase().getOriginal() instanceof Entity entity
? BukkitAdapter.adapt(entity)
: abstractEntity;
}
}
public boolean overlapsOOBB(BoundingBox boundingBox, AbstractEntity abstractEntity) {
HitboxEntity hitbox = ModelEngineAPI.getInteractionTracker().getHitbox(abstractEntity.getUniqueId());
if (hitbox == null) {
return false;
} else {
OrientedBoundingBox obb = hitbox.getOrientedBoundingBox();
return obb != null && obb.intersects(boundingBox);
}
}
public ModelConfig getBoneModel(String modelId, String boneId) throws IllegalArgumentException {
ModelBlueprint blueprint = ModelEngineAPI.getBlueprint(modelId);
if (blueprint == null) {
throw new IllegalArgumentException("Unknown model " + modelId + ".");
} else {
BlueprintBone blueprintBone = blueprint.getFlatMap().get(boneId);
if (blueprintBone == null) {
throw new IllegalArgumentException("Unknown bone " + boneId + ".");
} else if (!blueprintBone.isRenderer()) {
throw new IllegalArgumentException(boneId + " is not a renderer bone.");
} else {
return new ModelConfig(blueprintBone.getDataId(), blueprintBone.getBaseItem().getMaterial(), false);
}
}
}
public MobModel createMobModel(MythicMob mythicMob, MythicConfig mythicConfig) {
return new MEGModel(mythicMob, mythicConfig);
}
public MEGProjectile createMEGBullet(MEGProjectileData model, AbstractLocation location) {
return new ProjectileBullet(model, location);
}
public MEGAttachment createMEGAttachment(MEGAttachmentData model, AbstractEntity entity) {
return new AuraAttachment(model, entity);
}
public void queuePostModelRegistration(Runnable runnable) {
ModelEngineAPI.getAPI().getModelGenerator().queueTask(ModelGenerator.Phase.POST_ASSETS, runnable);
}
public double distanceSquaredToSubHitbox(AbstractLocation abstractLocation, AbstractEntity abstractEntity) {
HitboxEntity hitbox = ModelEngineAPI.getInteractionTracker().getHitbox(abstractEntity.getUniqueId());
OrientedBoundingBox obb = hitbox.getOrientedBoundingBox();
return obb != null
? obb.distanceSquared(new Vector3f((float)abstractLocation.getX(), (float)abstractLocation.getY(), (float)abstractLocation.getZ()))
: TMath.distanceSquaredToBoundingBox(abstractLocation.toLocus().toVector(), abstractEntity.getBukkitEntity().getBoundingBox());
}
public void load(MythicBukkit mythicBukkit) {
MythicLogger.log("Model Engine Compatibility Loaded.");
}
public void unload() {
}
public Map<ProjectileBulletableTracker, ProjectileEntity<?>> getTrackers() {
return this.trackers;
}
}
@@ -0,0 +1,66 @@
package com.ticxo.modelengine.core21.mythic.compatibility;
import com.ticxo.modelengine.api.events.ModelDismountEvent;
import com.ticxo.modelengine.api.utils.CompatibilityManager;
import com.ticxo.modelengine.core.ModelEngine;
import com.ticxo.modelengine.core21.mythic.animation.MythicScriptReader;
import com.ticxo.modelengine.core21.mythic.utils.ModelEngineComponentRegistry;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.bukkit.utils.Events;
import io.lumine.mythic.core.skills.EventExecutor;
import io.lumine.mythic.core.skills.SkillTriggers;
import io.lumine.mythic.core.skills.TriggeredSkill;
import java.util.ArrayList;
import java.util.Optional;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
public class MythicCompatibility implements CompatibilityManager.CompatibilityConfiguration {
private final ModelEngine plugin;
private ModelEngineSupportImpl mythicSupport;
private ModelEngineComponentRegistry customComponentRegistry;
public MythicCompatibility(ModelEngine plugin) {
this.plugin = plugin;
}
@Override
public boolean tryApply(Plugin plugin) {
this.customComponentRegistry = new ModelEngineComponentRegistry(this.plugin, new ArrayList<String>() {
{
this.add("com.ticxo.modelengine.core21.mythic.conditions");
this.add("com.ticxo.modelengine.core21.mythic.mechanics");
this.add("com.ticxo.modelengine.core21.mythic.targeters");
this.add("com.ticxo.modelengine.core21.mythic.placeholders");
}
});
this.plugin.getScriptReaderRegistry().register("mm", new MythicScriptReader());
this.mythicSupport = new ModelEngineSupportImpl();
MythicBukkit.inst().getCompatibility().setModelEngine(Optional.of(this.mythicSupport));
Bukkit.getPluginManager().registerEvents(this.customComponentRegistry, plugin);
this.plugin.getModelGenerator().importModels(true);
Events.subscribe(ModelDismountEvent.class).handler(this::onDismounted);
return true;
}
void onDismounted(ModelDismountEvent event) {
MythicBukkit.inst().getMobManager().getActiveMob(event.getVehicle().getModeledEntity().getBase().getUUID()).ifPresent(mob -> {
EventExecutor eventBus = MythicBukkit.inst().getSkillManager().getEventBus();
SkillMetadata data = eventBus.buildSkillMetadata(SkillTriggers.DISMOUNTED, mob, BukkitAdapter.adapt(event.getPassenger()), mob.getLocation(), false);
TriggeredSkill ts = eventBus.processTriggerMechanics(data);
if (ts.getCancelled()) {
event.setCancelled(true);
}
});
}
public ModelEngineSupportImpl getMythicSupport() {
return this.mythicSupport;
}
public ModelEngineComponentRegistry getCustomComponentRegistry() {
return this.customComponentRegistry;
}
}
@@ -0,0 +1,68 @@
package com.ticxo.modelengine.core21.mythic.compatibility;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.bone.type.Mount;
import com.ticxo.modelengine.api.mount.controller.impl.AbstractMountController;
import com.ticxo.modelengine.api.nms.entity.wrapper.MoveController;
import io.lumine.mythic.api.skills.Skill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.core.skills.variables.VariableRegistry;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
import org.joml.Vector3f;
public class MythicMountController extends AbstractMountController {
private final Skill skill;
private final SkillMetadata metadata;
private final VariableRegistry variableRegistry;
public MythicMountController(Entity entity, Mount mount, Skill skill, SkillMetadata data) {
super(entity, mount);
this.skill = skill;
this.metadata = MythicBukkit.inst()
.getSkillManager()
.getEventBus()
.buildSkillMetadata(data.getCause(), data.getCaster(), data.getTrigger(), data.getOrigin(), !data.isAsync());
this.metadata.setTrigger(BukkitAdapter.adapt(entity));
this.variableRegistry = this.metadata.getVariables();
}
@Override
public void updateDriverMovement(MoveController controller, ActiveModel model) {
this.callSkillAs(controller, model, "driver");
}
@Override
public void updatePassengerMovement(MoveController controller, ActiveModel model) {
this.callSkillAs(controller, model, "passenger");
}
public void callSkillAs(MoveController controller, ActiveModel model, String mode) {
if (this.skill.isUsable(this.metadata) && !this.skill.onCooldown(this.metadata.getCaster())) {
Vector3f location = this.getMount().getGlobalLocation();
this.metadata.setOrigin(BukkitAdapter.adapt(new Location(this.entity.getWorld(), location.x, location.y, location.z)));
this.metadata.setMetadata("meg:active_model", model);
this.metadata.setMetadata("meg:move_controller", controller);
this.variableRegistry.putString("meg:rider", mode);
this.variableRegistry.putFloat("meg:front", this.input.getFront());
this.variableRegistry.putFloat("meg:side", this.input.getSide());
this.variableRegistry.putFloat("meg:forward", this.input.isForward() ? 1.0F : 0.0F);
this.variableRegistry.putFloat("meg:backward", this.input.isBackward() ? 1.0F : 0.0F);
this.variableRegistry.putFloat("meg:left", this.input.isLeft() ? 1.0F : 0.0F);
this.variableRegistry.putFloat("meg:right", this.input.isRight() ? 1.0F : 0.0F);
this.variableRegistry.putInt("meg:jump", this.input.isJump() ? 1 : 0);
this.variableRegistry.putInt("meg:sneak", this.input.isSneak() ? 1 : 0);
this.variableRegistry.putInt("meg:sprint", this.input.isSprint() ? 1 : 0);
this.variableRegistry.putInt("meg:on_ground", controller.isOnGround() ? 1 : 0);
this.variableRegistry.putFloat("meg:speed", controller.getSpeed());
Vector vector = controller.getVelocity();
this.variableRegistry.putFloat("meg:vx", (float)vector.getX());
this.variableRegistry.putFloat("meg:vy", (float)vector.getY());
this.variableRegistry.putFloat("meg:vz", (float)vector.getZ());
this.skill.execute(this.metadata);
}
}
}
@@ -0,0 +1,160 @@
package com.ticxo.modelengine.core21.mythic.compatibility;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.animation.BlueprintAnimation;
import com.ticxo.modelengine.api.animation.handler.AnimationHandler;
import com.ticxo.modelengine.api.animation.handler.IStateMachineHandler;
import com.ticxo.modelengine.api.animation.property.IAnimationProperty;
import com.ticxo.modelengine.api.animation.property.SimpleProperty;
import com.ticxo.modelengine.api.entity.Dummy;
import com.ticxo.modelengine.api.entity.data.DummyEntityData;
import com.ticxo.modelengine.api.generator.blueprint.ModelBlueprint;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.api.model.bone.type.Segment;
import com.ticxo.modelengine.api.nms.entity.wrapper.BodyRotationController;
import io.lumine.mythic.api.adapters.AbstractLocation;
import io.lumine.mythic.api.adapters.AbstractVector;
import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.bukkit.compatibility.AbstractModelEngineSupport.MEGProjectile;
import io.lumine.mythic.bukkit.compatibility.AbstractModelEngineSupport.MEGProjectileData;
import io.lumine.mythic.core.logging.MythicLogger;
import java.util.UUID;
import java.util.Map.Entry;
import org.bukkit.Color;
public class ProjectileBullet implements MEGProjectile {
private Dummy<?> entity = new Dummy();
private ModelBlueprint modelBlueprint;
private ActiveModel activeModel;
private ModeledEntity modeledEntity;
public ProjectileBullet(MEGProjectileData modelData, AbstractLocation location) {
String modelId = modelData.getModelId();
String state = modelData.getState();
double scale = modelData.getScale();
String color = modelData.getColor();
boolean enchanted = modelData.isEnchanted();
boolean glowing = modelData.isGlowing();
String glowColor = modelData.getGlowColor();
Integer brightness = modelData.getBrightness();
this.entity.setLocation(BukkitAdapter.adapt(location));
this.modelBlueprint = ModelEngineAPI.getBlueprint(modelId);
if (this.modelBlueprint == null) {
MythicLogger.error("Failed to spawn Projectile Bullet: Model " + modelId + " not found");
} else {
this.modeledEntity = ModelEngineAPI.createModeledEntity(this.entity);
this.activeModel = ModelEngineAPI.createActiveModel(this.modelBlueprint);
this.activeModel.setScale(scale);
this.activeModel.setHitboxScale(0.0);
if (color != null) {
if (color.startsWith("#")) {
color = color.substring(1);
}
this.activeModel.setDefaultTint(Color.fromRGB(Integer.parseInt(color, 16)));
}
if (glowing) {
this.activeModel.setGlowing(true);
if (glowColor != null) {
if (glowColor.startsWith("#")) {
glowColor = glowColor.substring(1);
}
this.activeModel.setGlowColor(Integer.parseInt(glowColor, 16));
}
}
if (brightness != null) {
this.activeModel.setBlockLight(brightness);
this.activeModel.setSkyLight(brightness);
}
this.modeledEntity.getAnimationLodHandler().setEnabled(modelData.isUseALOD());
this.modeledEntity.addModel(this.activeModel, true);
BodyRotationController rotationController = this.modeledEntity.getBase().getBodyRotationController();
rotationController.setMaxHeadAngle(0.0F);
rotationController.setMinHeadAngle(0.0F);
rotationController.setMaxBodyAngle(0.0F);
rotationController.setMinBodyAngle(0.0F);
rotationController.setRotationDelay(0);
rotationController.setRotationDuration(0);
for (Entry<String, ModelBone> entry : this.activeModel.getBones().entrySet()) {
ModelBone bone = entry.getValue();
if (enchanted) {
bone.setEnchanted(true);
}
bone.getBoneBehavior(BoneBehaviorTypes.SEGMENT).ifPresent(segment -> ((Segment)segment).setBounded(false));
}
if (state != null) {
AnimationHandler handler = this.activeModel.getAnimationHandler();
if (handler instanceof IStateMachineHandler stateMachineHandler) {
IAnimationProperty property = stateMachineHandler.playAnimation(100, state, 0.0, 0.0, 1.0, true);
if (property != null) {
property.setForceLoopMode(BlueprintAnimation.LoopMode.LOOP);
}
} else {
IAnimationProperty property = handler.playAnimation(state, 0.0, 0.0, 1.0, true);
if (property != null) {
property.setForceLoopMode(BlueprintAnimation.LoopMode.LOOP);
}
}
}
}
}
public UUID getEntityId() {
return this.entity.getUUID();
}
public void setLocation(AbstractLocation location) {
this.entity.setLocation(BukkitAdapter.adapt(location));
}
public void setDirection(AbstractVector direction) {
double yaw = Math.toDegrees(Math.atan2(-direction.getX(), direction.getZ()));
double pitch = -Math.toDegrees(Math.asin(direction.getY() / direction.length()));
this.entity.setXHeadRot((float)pitch);
this.entity.setYHeadRot((float)yaw);
this.entity.setYBodyRot((float)yaw);
}
public void setRenderRadius(int radius) {
DummyEntityData<?> data = this.entity.getData();
data.setRenderRadius(radius);
}
public void disableCulling() {
DummyEntityData<?> data = this.entity.getData();
data.setVerticalCull(false);
data.setBackCull(false);
data.setBlockedCull(false);
data.cullUpdate();
}
public void close() throws Exception {
BlueprintAnimation animation = this.modelBlueprint.getAnimations().get("death");
if (animation == null) {
ModelEngineAPI.removeModeledEntity(this.entity.getUUID());
this.entity.setRemoved(true);
} else {
SimpleProperty property = new SimpleProperty(this.activeModel, animation, 0.0, 0.0, 1.0);
property.setForceLoopMode(BlueprintAnimation.LoopMode.ONCE);
property.setForceOverride(BlueprintAnimation.OverrideMode.OVERRIDE);
property.setOnEndTask(() -> {
ModelEngineAPI.removeModeledEntity(this.entity.getUUID());
this.entity.setRemoved(true);
});
if (!this.activeModel.getAnimationHandler().playAnimation(property, true)) {
ModelEngineAPI.removeModeledEntity(this.entity.getUUID());
this.entity.setRemoved(true);
}
}
}
}
@@ -0,0 +1,176 @@
package com.ticxo.modelengine.core21.mythic.compatibility;
import com.google.common.collect.ImmutableSet;
import com.ticxo.modelengine.api.entity.BaseEntity;
import com.ticxo.modelengine.api.entity.CullType;
import com.ticxo.modelengine.api.entity.cull.BasicCulling;
import com.ticxo.modelengine.api.entity.cull.ModelCuller;
import com.ticxo.modelengine.api.entity.data.AbstractEntityData;
import com.ticxo.modelengine.api.entity.data.TrackingMap;
import io.lumine.mythic.api.skills.IParentSkill;
import io.lumine.mythic.bukkit.BukkitAdapter;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class ProjectileData extends AbstractEntityData {
private final ProjectileEntity<?> projectileEntity;
protected final ModelCuller culler;
private final AtomicBoolean isAlive = new AtomicBoolean(true);
private final AtomicReference<Location> location = new AtomicReference<>();
private final Set<UUID> syncTracking = new HashSet<>();
private final TrackingMap trackingMap = new TrackingMap();
private final Map<UUID, CullType> asyncTracking = this.trackingMap;
private final Queue<UUID> startTrackingQueue = new ConcurrentLinkedQueue<>();
private final Set<UUID> startTracking = new HashSet<>();
private final Queue<UUID> stopTrackingQueue = new ConcurrentLinkedQueue<>();
private final Set<UUID> stopTracking = new HashSet<>();
public ProjectileData(ProjectileEntity<?> projectileEntity) {
this(projectileEntity, new BasicCulling());
}
public ProjectileData(ProjectileEntity<?> projectileEntity, ModelCuller culler) {
this.projectileEntity = projectileEntity;
this.culler = culler;
culler.setData(this);
this.syncUpdate();
this.asyncUpdate();
}
@Override
public void asyncUpdate() {
while (!this.startTrackingQueue.isEmpty()) {
UUID player = this.startTrackingQueue.poll();
this.startTracking.add(player);
this.asyncTracking.put(player, CullType.NO_CULL);
}
while (!this.stopTrackingQueue.isEmpty()) {
UUID player = this.stopTrackingQueue.poll();
this.stopTracking.add(player);
if (this.asyncTracking.get(player) != CullType.CULLED) {
this.asyncTracking.remove(player);
}
}
}
@Override
public void syncUpdate() {
Location location = BukkitAdapter.adapt(this.projectileEntity.getOriginal().getCurrentLocation());
this.location.set(location);
this.isAlive.set(!((IParentSkill)this.projectileEntity.getOriginal()).getCancelled());
if (!this.isDataValid()) {
this.projectileEntity.removeSelf();
}
HashSet<UUID> updatedTracking = new HashSet<>();
int radiusSqr = this.projectileEntity.getRenderRadius() * this.projectileEntity.getRenderRadius();
World world = location.getWorld();
double lx = location.getX();
double ly = location.getY();
double lz = location.getZ();
for (Player player : Bukkit.getOnlinePlayers()) {
if (world.equals(player.getWorld())) {
double dx = player.getX() - lx;
double dy = player.getY() - ly;
double dz = player.getZ() - lz;
if (dx * dx + dy * dy + dz * dz <= radiusSqr) {
updatedTracking.add(player.getUniqueId());
}
}
}
for (UUID playerx : updatedTracking) {
if (!this.syncTracking.contains(playerx)) {
this.startTrackingQueue.add(playerx);
}
}
for (UUID playerxx : this.syncTracking) {
if (!updatedTracking.contains(playerxx)) {
this.stopTrackingQueue.add(playerxx);
}
}
this.syncTracking.clear();
this.syncTracking.addAll(updatedTracking);
}
@Override
public void cullUpdate() {
this.culler.updateCulledPlayer();
}
@Override
public void cleanup() {
this.startTracking.clear();
this.stopTracking.clear();
}
@Override
public void destroy() {
}
@Override
public BaseEntity<?> getBaseEntity() {
return this.projectileEntity;
}
@Override
public boolean isDataValid() {
return this.isAlive.get();
}
@Override
public Location getLocation() {
return this.location.get();
}
@Override
public List<Entity> getPassengers() {
return List.of();
}
@Override
public Set<UUID> getStartTracking() {
return ImmutableSet.copyOf(this.startTracking);
}
@Override
public Map<UUID, CullType> getMutableTracking() {
return this.asyncTracking;
}
@Override
public Map<UUID, CullType> getTracking() {
return this.trackingMap.snapshot();
}
@Override
public Set<UUID> getStopTracking() {
return ImmutableSet.copyOf(this.stopTracking);
}
@Override
public boolean hasTracking() {
return !this.asyncTracking.isEmpty();
}
@Override
public boolean isBaseGlowing() {
return false;
}
}
@@ -0,0 +1,232 @@
package com.ticxo.modelengine.core21.mythic.compatibility;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.entity.BaseEntity;
import com.ticxo.modelengine.api.nms.entity.EntityHandler;
import com.ticxo.modelengine.api.nms.entity.HitboxEntity;
import com.ticxo.modelengine.api.nms.entity.wrapper.BodyRotationController;
import com.ticxo.modelengine.api.nms.entity.wrapper.LookController;
import com.ticxo.modelengine.api.nms.entity.wrapper.MoveController;
import com.ticxo.modelengine.api.nms.impl.EmptyBodyRotationController;
import com.ticxo.modelengine.api.nms.impl.EmptyLookController;
import com.ticxo.modelengine.api.nms.impl.EmptyMoveController;
import com.ticxo.modelengine.core21.Java21Helper;
import io.lumine.mythic.api.adapters.AbstractVector;
import io.lumine.mythic.api.skills.IParentSkill;
import io.lumine.mythic.core.skills.projectiles.ProjectileBulletableTracker;
import io.lumine.mythic.core.skills.projectiles.Projectile.ProjectileTracker;
import java.util.UUID;
import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.util.BoundingBox;
import org.jetbrains.annotations.Nullable;
public class ProjectileEntity<T extends ProjectileBulletableTracker & IParentSkill> implements BaseEntity<T> {
private final T original;
private final ProjectileData data;
private final int entityId;
private final UUID uuid;
private final BodyRotationController bodyRotationController = new EmptyBodyRotationController();
private final MoveController moveController = new EmptyMoveController();
private final LookController lookController = new EmptyLookController();
private int renderRadius = 32;
public ProjectileEntity(T original) {
this.original = original;
this.entityId = ModelEngineAPI.getEntityHandler().getNextEntityId();
this.uuid = UUID.randomUUID();
this.data = new ProjectileData(this);
Java21Helper.getMythicCompatibility().getMythicSupport().getTrackers().put(original, this);
}
@Override
public void registerData() {
ModelEngineAPI.getAPI().getDataTrackers().execute(this.getUUID(), (uuid, tracker) -> tracker.putEntityData(uuid, this.data));
}
@Override
public boolean isVisible() {
return true;
}
@Override
public void setVisible(boolean flag) {
}
@Override
public boolean isRemoved() {
return !this.data.isDataValid();
}
@Override
public boolean isAlive() {
return this.data.isDataValid();
}
@Override
public boolean isForcedAlive() {
return false;
}
@Override
public void setForcedAlive(boolean flag) {
}
@Override
public UUID getUUID() {
return this.uuid;
}
@Override
public double getMaxStepHeight() {
return 0.0;
}
@Override
public void setMaxStepHeight(double stepHeight) {
}
@Override
public void setCollidableWith(Entity entity, boolean flag) {
}
@Override
public boolean isGlowing() {
return false;
}
@Override
public int getGlowColor() {
return -1;
}
@Override
public boolean isOnFire() {
return false;
}
@Override
public boolean hurt(@Nullable HumanEntity player, Object nmsDamageCause, float damage) {
return false;
}
@Override
public boolean hurt(HitboxEntity hitbox, @Nullable HumanEntity player, Object nmsDamageCause, float damage) {
return false;
}
@Override
public EntityHandler.InteractionResult interact(HumanEntity player, EquipmentSlot slot) {
return null;
}
@Override
public EntityHandler.InteractionResult interact(HitboxEntity hitbox, HumanEntity player, EquipmentSlot slot) {
return null;
}
@Override
public float getYRot() {
AbstractVector vel = this.original.getCurrentVelocity();
return vel == null ? 0.0F : (float)Math.toDegrees(Math.atan2(-vel.getX(), vel.getZ()));
}
@Override
public float getYHeadRot() {
return this.getYRot();
}
@Override
public float getXHeadRot() {
AbstractVector vel = this.original.getCurrentVelocity();
if (vel == null) {
return 0.0F;
} else {
double hMag = Math.sqrt(vel.getX() * vel.getX() + vel.getZ() * vel.getZ());
return (float)Math.toDegrees(-Math.atan2(vel.getY(), hMag));
}
}
@Override
public float getYBodyRot() {
return this.getYRot();
}
@Override
public boolean isWalking() {
return false;
}
@Override
public boolean isStrafing() {
return false;
}
@Override
public boolean isJumping() {
return false;
}
@Override
public boolean isFlying() {
return false;
}
@Override
public float getHealth() {
return 0.0F;
}
@Override
public float getMaxHealth() {
return 0.0F;
}
@Override
public BoundingBox getBoundingBox() {
return this.original instanceof ProjectileTracker tracker ? tracker.getHitbox() : new BoundingBox();
}
public void removeSelf() {
Java21Helper.getMythicCompatibility().getMythicSupport().getTrackers().remove(this.original, this);
}
public T getOriginal() {
return this.original;
}
public ProjectileData getData() {
return this.data;
}
@Override
public int getEntityId() {
return this.entityId;
}
@Override
public BodyRotationController getBodyRotationController() {
return this.bodyRotationController;
}
@Override
public MoveController getMoveController() {
return this.moveController;
}
@Override
public LookController getLookController() {
return this.lookController;
}
@Override
public int getRenderRadius() {
return this.renderRadius;
}
@Override
public void setRenderRadius(int renderRadius) {
this.renderRadius = renderRadius;
}
}
@@ -0,0 +1,51 @@
package com.ticxo.modelengine.core21.mythic.conditions;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicCondition;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.conditions.IEntityCondition;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
@MythicCondition(
name = "hasmodel"
)
public class HasModelCondition implements IEntityCondition {
private final PlaceholderString modelId;
private final PlaceholderString state;
public HasModelCondition(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.state = mlc.getPlaceholderString(new String[]{"s", "state"}, null, new String[0]);
}
public boolean check(AbstractEntity abstractEntity) {
ModeledEntity modeledEntity = ModelEngineAPI.getModeledEntity(abstractEntity.getUniqueId());
if (modeledEntity == null) {
return false;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, abstractEntity);
String state = MythicUtils.getOrNullLowercase(this.state, abstractEntity);
if (modelId == null) {
if (state == null) {
return !modeledEntity.getModels().isEmpty();
} else {
for (ActiveModel activeModel : modeledEntity.getModels().values()) {
if (activeModel.getAnimationHandler().isPlayingAnimation(state)) {
return true;
}
}
return false;
}
} else {
Optional<ActiveModel> maybeModel = modeledEntity.getModel(modelId);
return maybeModel.isEmpty() ? false : state == null || maybeModel.get().getAnimationHandler().isPlayingAnimation(state);
}
}
}
}
@@ -0,0 +1,30 @@
package com.ticxo.modelengine.core21.mythic.conditions;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.core21.mythic.utils.MythicCondition;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.conditions.ISkillMetaCondition;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.bukkit.events.MythicConditionLoadEvent;
@MythicCondition(
name = "hitbox"
)
public class HitboxCondition implements ISkillMetaCondition {
private PlaceholderString hitbox;
public HitboxCondition(ModelEngineAPI plugin, MythicConditionLoadEvent loader) {
MythicLineConfig config = loader.getConfig();
this.hitbox = config.getPlaceholderString(new String[]{"hitbox", "hb", "h", "ob"}, loader.getArgument(), new String[0]);
}
public boolean check(SkillMetadata skillMetadata) {
if (!skillMetadata.getVariables().has("hitbox")) {
return false;
} else {
String hitbox = skillMetadata.getVariables().getString("hitbox");
return hitbox.equalsIgnoreCase(this.hitbox.get(skillMetadata));
}
}
}
@@ -0,0 +1,31 @@
package com.ticxo.modelengine.core21.mythic.conditions;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.core21.mythic.utils.MythicCondition;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.conditions.ISkillMetaCondition;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.bukkit.events.MythicConditionLoadEvent;
@MythicCondition(
name = "hitboxissubhitbox",
aliases = {"issubhitbox"}
)
public class HitboxIsSubHitboxCondition implements ISkillMetaCondition {
private PlaceholderString hitbox;
public HitboxIsSubHitboxCondition(ModelEngineAPI plugin, MythicConditionLoadEvent loader) {
MythicLineConfig config = loader.getConfig();
this.hitbox = config.getPlaceholderString(new String[]{"hitbox", "hb", "h", "ob"}, loader.getArgument(), new String[0]);
}
public boolean check(SkillMetadata skillMetadata) {
if (!skillMetadata.getVariables().has("hitbox")) {
return false;
} else {
String hitbox = skillMetadata.getVariables().getString("hitbox");
return hitbox.equalsIgnoreCase(this.hitbox.get(skillMetadata));
}
}
}
@@ -0,0 +1,31 @@
package com.ticxo.modelengine.core21.mythic.conditions;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.manager.BehaviorManager;
import com.ticxo.modelengine.api.model.bone.manager.MountData;
import com.ticxo.modelengine.api.model.bone.manager.MountManager;
import com.ticxo.modelengine.core21.mythic.utils.MythicCondition;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.skills.conditions.IEntityCondition;
@MythicCondition(
name = "drivingmodel"
)
public class IsDrivingModelCondition implements IEntityCondition {
public boolean check(AbstractEntity abstractEntity) {
ActiveModel model = ModelEngineAPI.getMountPairManager().getMountedPair(abstractEntity.getUniqueId());
if (model == null) {
return false;
} else {
ModeledEntity modeledEntity = model.getModeledEntity();
if (modeledEntity == null) {
return false;
} else {
BehaviorManager mountManager = ((MountData)modeledEntity.getMountData()).getMainMountManager();
return mountManager == null ? false : ((MountManager)mountManager).getDriver() == abstractEntity.getBukkitEntity();
}
}
}
}
@@ -0,0 +1,31 @@
package com.ticxo.modelengine.core21.mythic.conditions;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.bone.manager.BehaviorManager;
import com.ticxo.modelengine.api.model.bone.manager.MountManager;
import com.ticxo.modelengine.core21.mythic.utils.MythicCondition;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.skills.conditions.IEntityCondition;
import java.util.Optional;
@MythicCondition(
name = "ridingmodel"
)
public class IsRidingModelCondition implements IEntityCondition {
public boolean check(AbstractEntity abstractEntity) {
ActiveModel model = ModelEngineAPI.getMountPairManager().getMountedPair(abstractEntity.getUniqueId());
if (model == null) {
return false;
} else {
Optional maybeManager = model.getMountManager();
if (maybeManager.isEmpty()) {
return false;
} else {
BehaviorManager mountManager = (BehaviorManager)maybeManager.get();
Optional mount = ((MountManager)mountManager).getMount(abstractEntity.getBukkitEntity());
return mount.isPresent() && mount.get() != ((MountManager)mountManager).getDriverBone();
}
}
}
}
@@ -0,0 +1,33 @@
package com.ticxo.modelengine.core21.mythic.conditions;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.manager.BehaviorManager;
import com.ticxo.modelengine.api.model.bone.manager.MountManager;
import com.ticxo.modelengine.core21.mythic.utils.MythicCondition;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.skills.conditions.IEntityCondition;
import java.util.Optional;
@MythicCondition(
name = "modelhasdriver",
aliases = {"modeldriver"}
)
public class ModelHasDriverCondition implements IEntityCondition {
public boolean check(AbstractEntity abstractEntity) {
ModeledEntity modeledEntity = ModelEngineAPI.getModeledEntity(abstractEntity.getUniqueId());
if (modeledEntity == null) {
return false;
} else {
for (ActiveModel activeModel : modeledEntity.getModels().values()) {
Optional maybeMountManager = activeModel.getMountManager();
if (!maybeMountManager.isEmpty() && ((MountManager)((BehaviorManager)maybeMountManager.get())).isControlled()) {
return true;
}
}
return false;
}
}
}
@@ -0,0 +1,155 @@
package com.ticxo.modelengine.core21.mythic.conditions;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.behavior.BoneBehavior;
import com.ticxo.modelengine.api.model.bone.manager.BehaviorManager;
import com.ticxo.modelengine.api.model.bone.manager.MountManager;
import com.ticxo.modelengine.api.model.bone.type.Mount;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicCondition;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.conditions.IEntityCondition;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Locale;
import java.util.Optional;
@MythicCondition(
name = "modelhaspassengers",
aliases = {"modelhaspassenger", "modelpassengers", "modelpassenger"}
)
public class ModelHasPassengerCondition implements IEntityCondition {
private final PlaceholderString modelId;
private final PlaceholderString pbone;
private final String mode;
public ModelHasPassengerCondition(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.pbone = mlc.getPlaceholderString(new String[]{"p", "pbone", "seat"}, null, new String[0]);
this.mode = mlc.getString(new String[]{"mode"}, "AND", new String[0]).toUpperCase(Locale.ENGLISH);
}
public boolean check(AbstractEntity abstractEntity) {
ModeledEntity modeledEntity = ModelEngineAPI.getModeledEntity(abstractEntity.getUniqueId());
if (modeledEntity == null) {
return false;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, abstractEntity);
if (modelId == null) {
return this.noModelIdCheck(modeledEntity, abstractEntity);
} else {
Optional<ActiveModel> maybeModel = modeledEntity.getModel(modelId);
if (maybeModel.isEmpty()) {
return false;
} else {
ActiveModel activeModel = maybeModel.get();
Optional maybeMountManager = activeModel.getMountManager();
if (maybeMountManager.isEmpty()) {
return false;
} else {
BehaviorManager mountManager = (BehaviorManager)maybeMountManager.get();
String pBone = MythicUtils.getOrNullLowercase(this.pbone, abstractEntity);
if (pBone != null && !pBone.isBlank()) {
String[] seats = pBone.split(",");
String var10 = this.mode;
switch (var10) {
case "OR":
for (String seatId : seats) {
Optional maybeSeatx = ((MountManager)mountManager).getSeat(seatId);
if (!maybeSeatx.isEmpty()
&& ((MountManager)mountManager).getDriverBone() != maybeSeatx.get()
&& !((Mount)((BoneBehavior)maybeSeatx.get())).getPassengers().isEmpty()) {
return true;
}
}
return false;
case "AND":
for (String seatId : seats) {
Optional maybeSeat = ((MountManager)mountManager).getSeat(seatId);
if (maybeSeat.isEmpty()) {
return false;
}
if (((MountManager)mountManager).getDriverBone() != maybeSeat.get()
&& ((Mount)((BoneBehavior)maybeSeat.get())).getPassengers().isEmpty()) {
return false;
}
}
return true;
default:
return false;
}
} else {
return ((MountManager)mountManager).hasPassengers();
}
}
}
}
}
}
private boolean noModelIdCheck(ModeledEntity modeledEntity, AbstractEntity abstractEntity) {
String pBone = MythicUtils.getOrNullLowercase(this.pbone, abstractEntity);
if (pBone != null && !pBone.isBlank()) {
String[] seats = pBone.split(",");
String var17 = this.mode;
switch (var17) {
case "OR":
for (ActiveModel activeModel : modeledEntity.getModels().values()) {
Optional maybeMountManager = activeModel.getMountManager();
if (!maybeMountManager.isEmpty()) {
BehaviorManager mountManager = (BehaviorManager)maybeMountManager.get();
for (String seatId : seats) {
Optional maybeSeat = ((MountManager)mountManager).getSeat(seatId);
if (!maybeSeat.isEmpty()
&& ((MountManager)mountManager).getDriverBone() != maybeSeat.get()
&& !((Mount)((BoneBehavior)maybeSeat.get())).getPassengers().isEmpty()) {
return true;
}
}
}
}
return false;
case "AND":
for (ActiveModel activeModelx : modeledEntity.getModels().values()) {
Optional maybeMountManager = activeModelx.getMountManager();
if (maybeMountManager.isEmpty()) {
return false;
}
BehaviorManager mountManager = (BehaviorManager)maybeMountManager.get();
for (String seatIdx : seats) {
Optional maybeSeat = ((MountManager)mountManager).getSeat(seatIdx);
if (maybeSeat.isEmpty()) {
return false;
}
if (((MountManager)mountManager).getDriverBone() != maybeSeat.get() && ((Mount)((BoneBehavior)maybeSeat.get())).getPassengers().isEmpty()) {
return false;
}
}
}
return true;
default:
return false;
}
} else {
for (ActiveModel activeModelx : modeledEntity.getModels().values()) {
Optional maybeMountManager = activeModelx.getMountManager();
if (!maybeMountManager.isEmpty() && ((MountManager)((BehaviorManager)maybeMountManager.get())).hasPassengers()) {
return true;
}
}
return false;
}
}
}
@@ -0,0 +1,201 @@
package com.ticxo.modelengine.core21.mythic.mechanics.bone;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.api.model.bone.SimpleManualAnimator;
import com.ticxo.modelengine.api.utils.logger.TLogger;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Locale;
import java.util.Optional;
import java.util.Map.Entry;
import org.joml.Quaternionf;
import org.joml.Vector3f;
@MythicMechanic(
name = "animatemodel",
aliases = {}
)
public class AnimateModelMechanic implements ITargetedEntitySkill, INoTargetSkill {
private static final String[] POSITION = new String[]{"pos", "position"};
private static final String[] ROTATION = new String[]{"rot", "rotation"};
private static final String[] SCALE = new String[]{"scl", "scale"};
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final boolean exactMatch;
private final boolean relative;
private final boolean override;
private final boolean copy;
private final PlaceholderDouble[] position = new PlaceholderDouble[3];
private final boolean hasPosition;
private final PlaceholderDouble[] rotation = new PlaceholderDouble[3];
private final boolean hasRotation;
private final PlaceholderDouble[] scale = new PlaceholderDouble[3];
private final boolean hasScale;
private final PlaceholderString rotationModeString;
private AnimateModelMechanic.RotationMode rotationMode;
public AnimateModelMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, "", new String[0]);
this.exactMatch = mlc.getBoolean(new String[]{"em", "exact", "match", "exactmatch"}, true);
this.relative = mlc.getBoolean(new String[]{"r", "rel", "relative"}, false);
this.override = mlc.getBoolean(new String[]{"o", "ov", "override"}, false);
this.copy = mlc.getBoolean(new String[]{"copy"}, true);
this.hasPosition = this.readTransform(mlc, POSITION, this.position, "position", "0");
this.hasRotation = this.readTransform(mlc, ROTATION, this.rotation, "rotation", "0");
this.hasScale = this.readTransform(mlc, SCALE, this.scale, "scale", "1");
this.rotationModeString = mlc.getPlaceholderString(new String[]{"rm", "rotmode"}, "LOCAL", new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
this.rotationMode = AnimateModelMechanic.RotationMode.get(this.rotationModeString.get(meta, target).toUpperCase(Locale.ENGLISH));
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.transform(activeModel, partId, meta, target));
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String partId = MythicUtils.getOrNullLowercase(this.partId, meta);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
this.rotationMode = AnimateModelMechanic.RotationMode.get(this.rotationModeString.get(meta).toUpperCase(Locale.ENGLISH));
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.transform(activeModel, partId, meta, null));
return SkillResult.SUCCESS;
}
}
private boolean readTransform(MythicLineConfig mlc, String[] attrs, PlaceholderDouble[] axis, String axisName, String def) {
String coords = mlc.getString(attrs, null, new String[0]);
if (coords == null) {
return false;
} else {
String[] split = coords.split(",");
try {
axis[0] = PlaceholderDouble.of(split[0]);
axis[1] = PlaceholderDouble.of(split[1]);
axis[2] = PlaceholderDouble.of(split[2]);
} catch (Exception var9) {
TLogger.error("The '" + axisName + "' attribute must be in the format " + axisName + "=x,y,z.");
axis[0] = PlaceholderDouble.of(def);
axis[1] = PlaceholderDouble.of(def);
axis[2] = PlaceholderDouble.of(def);
}
return true;
}
}
private void transform(ActiveModel activeModel, String partId, SkillMetadata meta, AbstractEntity target) {
if (this.override) {
if (this.exactMatch) {
activeModel.getBone(partId).ifPresent(bone -> this.transform(this.getAnimator(bone), meta, target));
return;
}
for (Entry<String, ModelBone> entry : activeModel.getBones().entrySet()) {
if (entry.getKey().contains(partId)) {
this.transform(this.getAnimator(entry.getValue()), meta, target);
}
}
} else {
if (this.exactMatch) {
activeModel.getBone(partId).ifPresent(bone -> bone.setManualAnimator(null));
return;
}
for (Entry<String, ModelBone> entryx : activeModel.getBones().entrySet()) {
if (entryx.getKey().contains(partId)) {
entryx.getValue().setManualAnimator(null);
}
}
}
}
private SimpleManualAnimator getAnimator(ModelBone bone) {
if (bone.getManualAnimator() instanceof SimpleManualAnimator animator) {
return animator;
} else {
SimpleManualAnimator a = this.copy ? new SimpleManualAnimator(bone) : new SimpleManualAnimator();
bone.setManualAnimator(a);
return a;
}
}
private void transform(SimpleManualAnimator animator, SkillMetadata meta, AbstractEntity target) {
this.transform(this.hasPosition, animator.getPosition(), this.position, meta, target);
this.transformRotation(this.hasRotation, animator.getRotation(), this.rotation, meta, target);
this.transform(this.hasScale, animator.getScale(), this.scale, meta, target);
}
private void transform(boolean hasValue, Vector3f data, PlaceholderDouble[] values, SkillMetadata meta, AbstractEntity target) {
if (hasValue) {
if (this.relative) {
data.add((float)values[0].get(meta, target), (float)values[1].get(meta, target), (float)values[2].get(meta, target));
} else {
data.set((float)values[0].get(meta, target), (float)values[1].get(meta, target), (float)values[2].get(meta, target));
}
}
}
private void transformRotation(boolean hasValue, Quaternionf data, PlaceholderDouble[] values, SkillMetadata meta, AbstractEntity target) {
if (hasValue) {
Quaternionf delta = new Quaternionf()
.rotationZYX(
(float)values[2].get(meta, target) * (float) (Math.PI / 180.0),
(float)values[1].get(meta, target) * (float) (Math.PI / 180.0),
(float)values[0].get(meta, target) * (float) (Math.PI / 180.0)
);
if (this.relative) {
switch (this.rotationMode) {
case LOCAL:
data.mul(delta);
break;
case GLOBAL:
delta.mul(data, data);
}
} else {
data.set(delta);
}
}
}
static enum RotationMode {
LOCAL,
GLOBAL;
static AnimateModelMechanic.RotationMode get(String value) {
try {
return valueOf(value);
} catch (Exception var2) {
return LOCAL;
}
}
}
}
@@ -0,0 +1,99 @@
package com.ticxo.modelengine.core21.mythic.mechanics.bone;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Locale;
import java.util.Optional;
import java.util.Map.Entry;
import org.bukkit.entity.Display.Billboard;
@MythicMechanic(
name = "billboard",
aliases = {}
)
public class BillboardMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final PlaceholderString billboard;
private final boolean exactMatch;
private final boolean child;
public BillboardMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, "", new String[0]);
this.billboard = mlc.getPlaceholderString(new String[]{"b", "bb", "bill", "billboard"}, null, new String[0]);
this.exactMatch = mlc.getBoolean(new String[]{"em", "exact", "match", "exactmatch"}, true);
this.child = mlc.getBoolean(new String[]{"c", "child"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
try {
String billboard = MythicUtils.getOrNull(this.billboard, meta, target).toUpperCase(Locale.ENGLISH);
Billboard bb = Billboard.valueOf(billboard);
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.billboard(activeModel, partId, bb));
return SkillResult.SUCCESS;
} catch (Exception var9) {
var9.printStackTrace();
return SkillResult.ERROR;
}
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
try {
String billboard = MythicUtils.getOrNull(this.billboard, meta).toUpperCase(Locale.ENGLISH);
Billboard bb = Billboard.valueOf(billboard);
String partId = MythicUtils.getOrNullLowercase(this.partId, meta);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.billboard(activeModel, partId, bb));
return SkillResult.SUCCESS;
} catch (Exception var8) {
var8.printStackTrace();
return SkillResult.ERROR;
}
}
}
private void billboard(ActiveModel activeModel, String partId, Billboard billboard) {
if (partId.isBlank()) {
activeModel.setBillboard(billboard);
} else if (this.exactMatch) {
activeModel.getBone(partId).ifPresent(bone -> MythicUtils.executeBoneChild(this.child, bone, v -> v.setBillboard(billboard)));
} else {
for (Entry<String, ModelBone> entry : activeModel.getBones().entrySet()) {
if (entry.getKey().contains(partId)) {
MythicUtils.executeBoneChild(this.child, entry.getValue(), bone -> bone.setBillboard(billboard));
}
}
}
}
}
@@ -0,0 +1,99 @@
package com.ticxo.modelengine.core21.mythic.mechanics.bone;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
import java.util.Map.Entry;
@MythicMechanic(
name = "brightness",
aliases = {"light"}
)
public class BrightnessMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final PlaceholderInt blockLight;
private final PlaceholderInt skyLight;
private final boolean exactMatch;
private final boolean child;
public BrightnessMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, "", new String[0]);
this.blockLight = mlc.getPlaceholderInteger(new String[]{"block", "b"}, -1, new String[0]);
this.skyLight = mlc.getPlaceholderInteger(new String[]{"sky", "s"}, -1, new String[0]);
this.exactMatch = mlc.getBoolean(new String[]{"em", "exact", "match", "exactmatch"}, true);
this.child = mlc.getBoolean(new String[]{"c", "child"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
int block = this.blockLight.get(meta, target);
int sky = this.skyLight.get(meta, target);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.light(activeModel, partId, block, sky));
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<Object> maybeBullet = meta.getMetadata("bullet");
if (maybeBullet.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
Optional<ModeledEntity> maybeModel = MythicUtils.getParentVFXModel(meta);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String partId = MythicUtils.getOrNullLowercase(this.partId, meta);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
int block = this.blockLight.get(meta);
int sky = this.skyLight.get(meta);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.light(activeModel, partId, block, sky));
return SkillResult.SUCCESS;
}
}
}
private void light(ActiveModel activeModel, String partId, int block, int sky) {
if (partId.isBlank()) {
activeModel.setBlockLight(block);
activeModel.setSkyLight(sky);
} else if (this.exactMatch) {
activeModel.getBone(partId).ifPresent(bone -> MythicUtils.executeBoneChild(this.child, bone, v -> this.setLight(v, block, sky)));
} else {
for (Entry<String, ModelBone> entry : activeModel.getBones().entrySet()) {
if (entry.getKey().contains(partId)) {
MythicUtils.executeBoneChild(this.child, entry.getValue(), bone -> this.setLight(bone, block, sky));
}
}
}
}
private void setLight(ModelBone bone, int block, int sky) {
bone.setBlockLight(block);
bone.setSkyLight(sky);
}
}
@@ -0,0 +1,81 @@
package com.ticxo.modelengine.core21.mythic.mechanics.bone;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
@MythicMechanic(
name = "changeparent",
aliases = {}
)
public class ChangeParentMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString parentPart;
private final PlaceholderString childPart;
public ChangeParentMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.parentPart = mlc.getPlaceholderString(new String[]{"p", "parent"}, null, new String[0]);
this.childPart = mlc.getPlaceholderString(new String[]{"c", "child"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
ActiveModel activeModel = MythicUtils.getActiveModelOrNull(model, modelId);
if (activeModel == null) {
return SkillResult.CONDITION_FAILED;
} else {
String parentPart = MythicUtils.getOrNullLowercase(this.parentPart, meta, target);
String childPart = MythicUtils.getOrNullLowercase(this.childPart, meta, target);
activeModel.getBone(parentPart)
.ifPresent(parent -> activeModel.getBone(childPart).ifPresent(child -> model.registerTickTask(ModeledEntity.Phase.PRE_MODEL_TICK, entity -> {
child.setParent(parent);
return true;
})));
return SkillResult.SUCCESS;
}
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
ActiveModel activeModel = MythicUtils.getActiveModelOrNull(model, modelId);
if (activeModel == null) {
return SkillResult.CONDITION_FAILED;
} else {
String parentPart = MythicUtils.getOrNullLowercase(this.parentPart, meta);
String childPart = MythicUtils.getOrNullLowercase(this.childPart, meta);
activeModel.getBone(parentPart)
.ifPresent(parent -> activeModel.getBone(childPart).ifPresent(child -> model.registerTickTask(ModeledEntity.Phase.PRE_MODEL_TICK, entity -> {
child.setParent(parent);
return true;
})));
return SkillResult.SUCCESS;
}
}
}
}
@@ -0,0 +1,99 @@
package com.ticxo.modelengine.core21.mythic.mechanics.bone;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.generator.blueprint.BlueprintBone;
import com.ticxo.modelengine.api.generator.blueprint.ModelBlueprint;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
@MythicMechanic(
name = "changepart",
aliases = {}
)
public class ChangePartMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final PlaceholderString nModelId;
private final PlaceholderString nPartId;
public ChangePartMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, null, new String[0]);
this.nModelId = mlc.getPlaceholderString(new String[]{"nm", "nmid", "newmodel", "newmodelid"}, null, new String[0]);
this.nPartId = mlc.getPlaceholderString(new String[]{"np", "npid", "newpart", "newpartid"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
String nModelId = MythicUtils.getOrNullLowercase(this.nModelId, meta, target);
String nPartId = MythicUtils.getOrNullLowercase(this.nPartId, meta, target);
if (modelId != null && partId != null && nModelId != null && nPartId != null) {
model.getModel(modelId).flatMap(activeModel -> activeModel.getBone(partId)).ifPresent(bone -> {
if (bone.isRenderer()) {
ModelBlueprint blueprint = ModelEngineAPI.getBlueprint(nModelId);
if (blueprint != null) {
BlueprintBone blueprintBone = blueprint.getFlatMap().get(nPartId);
if (blueprintBone != null && blueprintBone.isRenderer()) {
bone.setModelScale(blueprintBone.getScale());
bone.setModel(blueprintBone);
}
}
}
});
return SkillResult.SUCCESS;
} else {
return SkillResult.INVALID_CONFIG;
}
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
String partId = MythicUtils.getOrNullLowercase(this.partId, meta);
String nModelId = MythicUtils.getOrNullLowercase(this.nModelId, meta);
String nPartId = MythicUtils.getOrNullLowercase(this.nPartId, meta);
if (modelId != null && partId != null && nModelId != null && nPartId != null) {
model.getModel(modelId).flatMap(activeModel -> activeModel.getBone(partId)).ifPresent(bone -> {
if (bone.isRenderer()) {
ModelBlueprint blueprint = ModelEngineAPI.getBlueprint(nModelId);
if (blueprint != null) {
BlueprintBone blueprintBone = blueprint.getFlatMap().get(nPartId);
if (blueprintBone != null && blueprintBone.isRenderer()) {
bone.setModelScale(blueprintBone.getScale());
bone.setModel(blueprintBone);
}
}
}
});
return SkillResult.SUCCESS;
} else {
return SkillResult.INVALID_CONFIG;
}
}
}
}
@@ -0,0 +1,112 @@
package com.ticxo.modelengine.core21.mythic.mechanics.bone;
import com.google.common.collect.Lists;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.generator.blueprint.BlueprintBone;
import com.ticxo.modelengine.api.generator.blueprint.ModelBlueprint;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.api.utils.scheduling.PlatformTask;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.bukkit.utils.terminable.Terminable;
import java.util.Arrays;
import java.util.List;
@MythicMechanic(
name = "cycleparts",
aliases = {}
)
public class CyclePartsMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final PlaceholderString nModelId;
private final List<String> cycledParts = Lists.newArrayList();
private final int startingFrame = 0;
private final int interval;
private final int duration;
public CyclePartsMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, null, new String[0]);
this.nModelId = mlc.getPlaceholderString(new String[]{"nm", "nmid", "newmodel", "newmodelid"}, null, new String[0]);
String nPartId = mlc.getString(new String[]{"np", "npid", "newpart", "newpartid", "newparts", "cycledparts"}, "", new String[0]);
this.cycledParts.addAll(Arrays.asList(nPartId.split(",")));
this.interval = mlc.getInteger(new String[]{"interval", "i"}, 1);
this.duration = mlc.getInteger(new String[]{"duration", "d"}, this.cycledParts.size() - 1);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
String nModelId = MythicUtils.getOrNullLowercase(this.nModelId, meta, target);
model.getModel(modelId).flatMap(activeModel -> activeModel.getBone(partId)).ifPresent(bone -> {
if (bone.isRenderer()) {
ModelBlueprint blueprint = ModelEngineAPI.getBlueprint(nModelId);
if (blueprint != null) {
new CyclePartsMechanic.Animator(meta, target, bone, blueprint);
}
}
});
return SkillResult.SUCCESS;
}
}
private class Animator implements Runnable, Terminable {
private final SkillMetadata data;
private final AbstractEntity target;
private final ModelBone bone;
private final ModelBlueprint modelBlueprint;
private final PlatformTask task;
private int frame = 0;
private int iteration = 0;
public Animator(SkillMetadata data, AbstractEntity target, ModelBone bone, ModelBlueprint modelBlueprint) {
this.data = data;
this.target = target;
this.bone = bone;
this.modelBlueprint = modelBlueprint;
this.task = ModelEngineAPI.getAPI()
.getScheduler()
.scheduleRepeating(ModelEngineAPI.getAPI(), target.getBukkitEntity(), this, 0L, (long)CyclePartsMechanic.this.interval);
}
@Override
public void run() {
if (this.target.isDead()) {
this.terminate();
} else if (this.iteration++ > CyclePartsMechanic.this.duration) {
this.terminate();
} else {
String nextPart = CyclePartsMechanic.this.cycledParts.get(this.frame);
BlueprintBone data = this.modelBlueprint.getFlatMap().get(nextPart);
if (data == null) {
this.terminate();
} else {
this.bone.setModel(data);
this.bone.setModelScale(data.getScale());
this.frame = (this.frame + 1) % CyclePartsMechanic.this.cycledParts.size();
}
}
}
public void close() {
this.task.cancel();
}
}
}
@@ -0,0 +1,85 @@
package com.ticxo.modelengine.core21.mythic.mechanics.bone;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
import java.util.Map.Entry;
@MythicMechanic(
name = "enchant",
aliases = {}
)
public class EnchantMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final boolean enchant;
private final boolean exactMatch;
private final boolean child;
public EnchantMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, "", new String[0]);
this.enchant = mlc.getBoolean(new String[]{"en", "enchant"}, true);
this.exactMatch = mlc.getBoolean(new String[]{"em", "exact", "match", "exactmatch"}, true);
this.child = mlc.getBoolean(new String[]{"c", "child"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.enchant(activeModel, partId));
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
String partId = MythicUtils.getOrNullLowercase(this.partId, meta);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.enchant(activeModel, partId));
return SkillResult.SUCCESS;
}
}
private void enchant(ActiveModel activeModel, String partId) {
if (!partId.isBlank()) {
if (this.exactMatch) {
activeModel.getBone(partId).ifPresent(bone -> MythicUtils.executeBoneChild(this.child, bone, v -> v.setEnchanted(this.enchant)));
} else {
for (Entry<String, ModelBone> entry : activeModel.getBones().entrySet()) {
if (entry.getKey().contains(partId)) {
MythicUtils.executeBoneChild(this.child, entry.getValue(), bone -> bone.setEnchanted(this.enchant));
}
}
}
} else {
for (ModelBone value : activeModel.getBones().values()) {
value.setEnchanted(this.enchant);
}
}
}
}
@@ -0,0 +1,140 @@
package com.ticxo.modelengine.core21.mythic.mechanics.bone;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.adapters.AbstractPlayer;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.core.skills.SkillAudience;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.Map.Entry;
import org.jetbrains.annotations.Nullable;
@MythicMechanic(
name = "glow",
aliases = {"glowbone"}
)
public class GlowMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final PlaceholderString color;
private final boolean glowing;
private final boolean exactMatch;
private final boolean child;
private final SkillAudience audience;
public GlowMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, "", new String[0]);
this.glowing = mlc.getBoolean(new String[]{"g", "glow"}, true);
this.color = mlc.getPlaceholderString(new String[]{"c", "color"}, null, new String[0]);
this.exactMatch = mlc.getBoolean(new String[]{"em", "exact", "match", "exactmatch"}, true);
this.child = mlc.getBoolean(new String[]{"c", "child"}, false);
this.audience = mlc.getAudience("audience", null);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String colorString = MythicUtils.getOrNull(this.color, meta, target);
Integer color;
if (colorString != null) {
if (colorString.startsWith("#")) {
colorString = colorString.substring(1);
}
color = Integer.parseInt(colorString, 16);
} else {
color = null;
}
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
Set<UUID> audienceSet = this.resolveAudience(meta, target);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.glow(activeModel, partId, color, audienceSet));
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String colorString = MythicUtils.getOrNull(this.color, meta);
Integer color;
if (colorString != null) {
if (colorString.startsWith("#")) {
colorString = colorString.substring(1);
}
color = Integer.parseInt(colorString, 16);
} else {
color = null;
}
String partId = MythicUtils.getOrNullLowercase(this.partId, meta);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
Set<UUID> audienceSet = this.resolveAudience(meta, null);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.glow(activeModel, partId, color, audienceSet));
return SkillResult.SUCCESS;
}
}
@Nullable
private Set<UUID> resolveAudience(SkillMetadata meta, @Nullable AbstractEntity target) {
if (this.audience == null) {
return null;
} else {
Set<UUID> uuids = new HashSet<>();
for (AbstractPlayer player : this.audience.get(meta, target)) {
uuids.add(player.getUniqueId());
}
return uuids;
}
}
private void glow(ActiveModel activeModel, String partId, Integer color, @Nullable Set<UUID> audienceSet) {
if (partId.isBlank()) {
activeModel.setGlowing(this.glowing);
activeModel.setGlowColor(color);
activeModel.setGlowAudience(audienceSet);
} else if (this.exactMatch) {
activeModel.getBone(partId).ifPresent(bone -> MythicUtils.executeBoneChild(this.child, bone, bone1 -> this.setGlow(bone1, color, audienceSet)));
} else {
for (Entry<String, ModelBone> entry : activeModel.getBones().entrySet()) {
if (entry.getKey().contains(partId)) {
MythicUtils.executeBoneChild(this.child, entry.getValue(), bone -> this.setGlow(bone, color, audienceSet));
}
}
}
}
private void setGlow(ModelBone bone, Integer color, @Nullable Set<UUID> audienceSet) {
bone.setGlowing(this.glowing);
bone.setGlowColor(color);
bone.setGlowAudience(audienceSet);
}
}
@@ -0,0 +1,155 @@
package com.ticxo.modelengine.core21.mythic.mechanics.bone;
import com.destroystokyo.paper.profile.PlayerProfile;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.api.model.bone.type.PlayerLimb;
import com.ticxo.modelengine.api.model.bone.type.UserLimb;
import com.ticxo.modelengine.api.utils.MojangAPI;
import com.ticxo.modelengine.api.utils.math.TMath;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.List;
import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.profile.PlayerTextures;
import org.bukkit.profile.PlayerTextures.SkinModel;
@MythicMechanic(
name = "modelplayerskin",
aliases = {"modelskin"}
)
public class ModelSkinMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final PlaceholderString pbone;
private final PlaceholderString username;
private final PlaceholderString uuid;
private final PlaceholderString skin;
private final Boolean isSlim;
public ModelSkinMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.pbone = mlc.getPlaceholderString(new String[]{"p", "pbone", "limbs"}, null, new String[0]);
this.uuid = mlc.getPlaceholderString(new String[]{"uuid"}, null, new String[0]);
this.username = mlc.getPlaceholderString(new String[]{"user", "name", "username"}, null, new String[0]);
this.skin = mlc.getPlaceholderString(new String[]{"s", "skin"}, null, new String[0]);
String slim = mlc.getString(new String[]{"slim"}, null, new String[0]);
this.isSlim = slim == null ? null : Boolean.parseBoolean(slim);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
AbstractEntity caster = meta.getCaster().getEntity();
ModeledEntity model = ModelEngineAPI.getModeledEntity(caster.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String username = MythicUtils.getOrNull(this.username, meta, target);
if (username != null) {
MojangAPI.getUUIDFromUsernamePromise(username)
.thenApplyAsync(MojangAPI::fromUUID)
.thenAcceptAsync(profilex -> this.apply(model, profilex, meta, target));
return SkillResult.SUCCESS;
} else {
String uuidString = MythicUtils.getOrNull(this.uuid, meta, target);
if (uuidString != null) {
UUID uuid = TMath.parseUUID(uuidString);
MojangAPI.fromUUIDPromise(uuid).thenAcceptAsync(profilex -> this.apply(model, profilex, meta, target));
return SkillResult.SUCCESS;
} else {
String skin = MythicUtils.getOrNull(this.skin, meta, target);
PlayerProfile profile;
if (skin == null) {
if (!(target.getBukkitEntity() instanceof Player player)) {
return SkillResult.INVALID_TARGET;
}
profile = player.getPlayerProfile();
} else {
profile = MojangAPI.fromBase64(skin);
}
return this.apply(model, profile, meta, target);
}
}
}
}
public boolean getTargetsCreatives() {
return true;
}
private SkillResult apply(ModeledEntity model, PlayerProfile profile, SkillMetadata meta, AbstractEntity target) {
PlayerProfile finalProfile = this.forceModel(profile);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
String pbone = MythicUtils.getOrNullLowercase(this.pbone, meta, target);
if (modelId == null && pbone == null) {
for (ActiveModel activeModel : model.getModels().values()) {
for (ModelBone modelBone : activeModel.getBones().values()) {
modelBone.getBoneBehavior(BoneBehaviorTypes.PLAYER_LIMB).ifPresent(playerLimb -> ((PlayerLimb)playerLimb).setTexture(finalProfile));
modelBone.getBoneBehavior(BoneBehaviorTypes.USER_LIMB).ifPresent(playerLimb -> ((UserLimb)playerLimb).setTexture(finalProfile));
}
}
return SkillResult.SUCCESS;
} else {
List<String> limbs = pbone == null ? null : List.of(pbone.split(","));
if (modelId == null) {
for (ActiveModel activeModel : model.getModels().values()) {
for (String limb : limbs) {
activeModel.getBone(limb).ifPresent(modelBone -> {
modelBone.getBoneBehavior(BoneBehaviorTypes.PLAYER_LIMB).ifPresent(playerLimb -> ((PlayerLimb)playerLimb).setTexture(finalProfile));
modelBone.getBoneBehavior(BoneBehaviorTypes.USER_LIMB).ifPresent(playerLimb -> ((UserLimb)playerLimb).setTexture(finalProfile));
});
}
}
} else {
model.getModel(modelId).ifPresent(activeModelx -> {
if (limbs == null) {
for (ModelBone modelBone : activeModelx.getBones().values()) {
modelBone.getBoneBehavior(BoneBehaviorTypes.PLAYER_LIMB).ifPresent(playerLimb -> ((PlayerLimb)playerLimb).setTexture(finalProfile));
modelBone.getBoneBehavior(BoneBehaviorTypes.USER_LIMB).ifPresent(playerLimb -> ((UserLimb)playerLimb).setTexture(finalProfile));
}
} else {
for (String seat : limbs) {
activeModelx.getBone(seat).ifPresent(modelBone -> {
modelBone.getBoneBehavior(BoneBehaviorTypes.PLAYER_LIMB).ifPresent(playerLimb -> ((PlayerLimb)playerLimb).setTexture(finalProfile));
modelBone.getBoneBehavior(BoneBehaviorTypes.USER_LIMB).ifPresent(playerLimb -> ((UserLimb)playerLimb).setTexture(finalProfile));
});
}
}
});
}
return SkillResult.SUCCESS;
}
}
private PlayerProfile forceModel(PlayerProfile profile) {
if (this.isSlim == null) {
return profile;
} else {
PlayerTextures texture = profile.getTextures();
SkinModel model = this.isSlim ? SkinModel.SLIM : SkinModel.CLASSIC;
if (model != texture.getSkinModel()) {
texture.setSkin(texture.getSkin(), model);
profile.setTextures(texture);
}
return profile;
}
}
}
@@ -0,0 +1,79 @@
package com.ticxo.modelengine.core21.mythic.mechanics.bone;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
import java.util.Map.Entry;
@MythicMechanic(
name = "partvisibility",
aliases = {"partvis"}
)
public class PartVisibilityMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final boolean visible;
private final boolean exactMatch;
private final boolean child;
public PartVisibilityMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, "", new String[0]);
this.visible = mlc.getBoolean(new String[]{"v", "visible", "visibility"}, false);
this.exactMatch = mlc.getBoolean(new String[]{"em", "exact", "match", "exactmatch"}, true);
this.child = mlc.getBoolean(new String[]{"c", "ch", "child"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.partVis(activeModel, partId));
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String partId = MythicUtils.getOrNullLowercase(this.partId, meta);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.partVis(activeModel, partId));
return SkillResult.SUCCESS;
}
}
private void partVis(ActiveModel activeModel, String partId) {
if (this.exactMatch) {
activeModel.getBone(partId).ifPresent(bonex -> MythicUtils.executeBoneChild(this.child, bonex, bone1 -> bone1.setVisible(this.visible)));
} else {
for (Entry<String, ModelBone> bone : activeModel.getBones().entrySet()) {
if (bone.getKey().contains(partId)) {
MythicUtils.executeBoneChild(this.child, bone.getValue(), bone1 -> bone1.setVisible(this.visible));
}
}
}
}
}
@@ -0,0 +1,236 @@
package com.ticxo.modelengine.core21.mythic.mechanics.bone;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.api.model.bone.type.Segment;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderBoolean;
import io.lumine.mythic.api.skills.placeholders.PlaceholderFloat;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
import java.util.Map.Entry;
@MythicMechanic(
name = "segment",
aliases = {"seg"}
)
public class SegmentMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final PlaceholderBoolean bounded;
private final PlaceholderFloat angleLimit;
private final PlaceholderFloat x;
private final PlaceholderFloat y;
private final PlaceholderFloat z;
private final PlaceholderFloat minX;
private final PlaceholderFloat maxX;
private final PlaceholderFloat minY;
private final PlaceholderFloat maxY;
private final PlaceholderFloat minZ;
private final PlaceholderFloat maxZ;
private final PlaceholderFloat extendRate;
private final PlaceholderFloat elasticity;
private final boolean exactMatch;
public SegmentMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, "", new String[0]);
this.bounded = mlc.getPlaceholderBoolean(new String[]{"b", "bd", "bounded"}, null);
this.angleLimit = mlc.getPlaceholderFloat(new String[]{"a", "al", "angle", "anglelimit"}, null, new String[0]);
this.x = mlc.getPlaceholderFloat(new String[]{"x"}, null, new String[0]);
this.y = mlc.getPlaceholderFloat(new String[]{"y"}, null, new String[0]);
this.z = mlc.getPlaceholderFloat(new String[]{"z"}, null, new String[0]);
this.minX = mlc.getPlaceholderFloat(new String[]{"minx"}, null, new String[0]);
this.maxX = mlc.getPlaceholderFloat(new String[]{"maxx"}, null, new String[0]);
this.minY = mlc.getPlaceholderFloat(new String[]{"miny"}, null, new String[0]);
this.maxY = mlc.getPlaceholderFloat(new String[]{"maxy"}, null, new String[0]);
this.minZ = mlc.getPlaceholderFloat(new String[]{"minz"}, null, new String[0]);
this.maxZ = mlc.getPlaceholderFloat(new String[]{"maxz"}, null, new String[0]);
this.extendRate = mlc.getPlaceholderFloat(new String[]{"e", "er", "extend", "extendrate"}, null, new String[0]);
this.elasticity = mlc.getPlaceholderFloat(new String[]{"el", "elasticity"}, null, new String[0]);
this.exactMatch = mlc.getBoolean(new String[]{"em", "exact", "match", "exactmatch"}, true);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
Boolean bounded = this.bounded == null ? null : this.bounded.get(meta, target);
Float angleLimit = this.angleLimit == null ? null : this.angleLimit.get(meta, target);
Float x = this.x == null ? angleLimit : this.x.get(meta, target);
Float y = this.y == null ? angleLimit : this.y.get(meta, target);
Float z = this.z == null ? angleLimit : this.z.get(meta, target);
Float minX = this.minX == null ? this.negate(x) : this.minX.get(meta, target);
Float maxX = this.maxX == null ? x : this.maxX.get(meta, target);
Float minY = this.minY == null ? this.negate(y) : this.minY.get(meta, target);
Float maxY = this.maxY == null ? y : this.maxY.get(meta, target);
Float minZ = this.minZ == null ? this.negate(z) : this.minZ.get(meta, target);
Float maxZ = this.maxZ == null ? z : this.maxZ.get(meta, target);
Float extendRate = this.extendRate == null ? null : this.extendRate.get(meta, target);
Float elasticity = this.elasticity == null ? null : this.elasticity.get(meta, target);
MythicUtils.executeOptModelId(
model, modelId, activeModel -> this.segment(activeModel, partId, bounded, minX, maxX, minY, maxY, minZ, maxZ, extendRate, elasticity)
);
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String partId = MythicUtils.getOrNullLowercase(this.partId, meta);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
Boolean bounded = this.bounded == null ? null : this.bounded.get(meta);
Float angleLimit = this.angleLimit == null ? null : this.angleLimit.get(meta);
Float x = this.x == null ? angleLimit : this.x.get(meta);
Float y = this.y == null ? angleLimit : this.y.get(meta);
Float z = this.z == null ? angleLimit : this.z.get(meta);
Float minX = this.minX == null ? this.negate(x) : this.minX.get(meta);
Float maxX = this.maxX == null ? x : this.maxX.get(meta);
Float minY = this.minY == null ? this.negate(y) : this.minY.get(meta);
Float maxY = this.maxY == null ? y : this.maxY.get(meta);
Float minZ = this.minZ == null ? this.negate(z) : this.minZ.get(meta);
Float maxZ = this.maxZ == null ? z : this.maxZ.get(meta);
Float extendRate = this.extendRate == null ? null : this.extendRate.get(meta);
Float elasticity = this.elasticity == null ? null : this.elasticity.get(meta);
MythicUtils.executeOptModelId(
model, modelId, activeModel -> this.segment(activeModel, partId, bounded, minX, maxX, minY, maxY, minZ, maxZ, extendRate, elasticity)
);
return SkillResult.SUCCESS;
}
}
private Float negate(Float val) {
return val == null ? null : -val;
}
private void segment(
ActiveModel activeModel,
String partId,
Boolean bounded,
Float minX,
Float maxX,
Float minY,
Float maxY,
Float minZ,
Float maxZ,
Float extendRate,
Float elasticity
) {
if (!partId.isBlank()) {
if (this.exactMatch) {
activeModel.getBone(partId).ifPresent(bone -> this.setIfSegment(bone, bounded, minX, maxX, minY, maxY, minZ, maxZ, extendRate, elasticity));
} else {
for (Entry<String, ModelBone> entry : activeModel.getBones().entrySet()) {
if (entry.getKey().contains(partId)) {
this.setIfSegment(entry.getValue(), bounded, minX, maxX, minY, maxY, minZ, maxZ, extendRate, elasticity);
}
}
}
} else {
for (Entry<String, ModelBone> entryx : activeModel.getBones().entrySet()) {
this.setIfSegment(entryx.getValue(), bounded, minX, maxX, minY, maxY, minZ, maxZ, extendRate, elasticity);
}
}
}
private void setIfSegment(
ModelBone bone, Boolean bounded, Float minX, Float maxX, Float minY, Float maxY, Float minZ, Float maxZ, Float extendRate, Float elasticity
) {
bone.getBoneBehavior(BoneBehaviorTypes.SEGMENT).ifPresent(segment -> {
if (bounded != null) {
((Segment)segment).setBounded(bounded);
}
if (minX != null) {
((Segment)segment).setMinX(minX);
}
if (maxX != null) {
((Segment)segment).setMaxX(maxX);
}
if (minY != null) {
((Segment)segment).setMinY(minY);
}
if (maxY != null) {
((Segment)segment).setMaxY(maxY);
}
if (minZ != null) {
((Segment)segment).setMinZ(minZ);
}
if (maxZ != null) {
((Segment)segment).setMaxZ(maxZ);
}
if (extendRate != null) {
((Segment)segment).setAlignRate(extendRate);
}
if (elasticity != null) {
((Segment)segment).setElasticity(elasticity);
}
});
bone.getBoneBehavior(BoneBehaviorTypes.TAIL).ifPresent(segment -> {
if (bounded != null) {
((Segment)segment).setBounded(bounded);
}
if (minX != null) {
((Segment)segment).setMinX(minX);
}
if (maxX != null) {
((Segment)segment).setMaxX(maxX);
}
if (minY != null) {
((Segment)segment).setMinY(minY);
}
if (maxY != null) {
((Segment)segment).setMaxY(maxY);
}
if (minZ != null) {
((Segment)segment).setMinZ(minZ);
}
if (maxZ != null) {
((Segment)segment).setMaxZ(maxZ);
}
if (extendRate != null) {
((Segment)segment).setAlignRate(extendRate);
}
if (elasticity != null) {
((Segment)segment).setElasticity(elasticity);
}
});
}
}
@@ -0,0 +1,108 @@
package com.ticxo.modelengine.core21.mythic.mechanics.bone;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
import java.util.Map.Entry;
import org.bukkit.Color;
@MythicMechanic(
name = "tint",
aliases = {"color"}
)
public class TintMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final PlaceholderString color;
private final boolean damageTint;
private final boolean exactMatch;
private final boolean child;
public TintMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, "", new String[0]);
this.damageTint = mlc.getBoolean(new String[]{"d", "dmg", "damage", "damagetint"}, false);
this.color = mlc.getPlaceholderString(new String[]{"c", "color"}, this.damageTint ? "FF6666" : "FFFFFF", new String[0]);
this.exactMatch = mlc.getBoolean(new String[]{"em", "exact", "match", "exactmatch"}, true);
this.child = mlc.getBoolean(new String[]{"c", "child"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String colorString = MythicUtils.getOrNull(this.color, meta, target);
if (colorString.startsWith("#")) {
colorString = colorString.substring(1);
}
Color color = Color.fromRGB(Integer.parseInt(colorString, 16));
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.color(activeModel, partId, color));
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String colorString = MythicUtils.getOrNull(this.color, meta);
if (colorString.startsWith("#")) {
colorString = colorString.substring(1);
}
Color color = Color.fromRGB(Integer.parseInt(colorString, 16));
String partId = MythicUtils.getOrNullLowercase(this.partId, meta);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.color(activeModel, partId, color));
return SkillResult.SUCCESS;
}
}
private void color(ActiveModel activeModel, String partId, Color color) {
if (partId.isBlank()) {
if (this.damageTint) {
activeModel.setDamageTint(color);
} else {
activeModel.setDefaultTint(color);
}
} else if (this.exactMatch) {
activeModel.getBone(partId).ifPresent(bone -> MythicUtils.executeBoneChild(this.child, bone, v -> this.setColor(v, color)));
} else {
for (Entry<String, ModelBone> entry : activeModel.getBones().entrySet()) {
if (entry.getKey().contains(partId)) {
MythicUtils.executeBoneChild(this.child, entry.getValue(), bone -> this.setColor(bone, color));
}
}
}
}
private void setColor(ModelBone bone, Color color) {
if (this.damageTint) {
bone.setDamageTint(color);
} else {
bone.setDefaultTint(color);
}
}
}
@@ -0,0 +1,32 @@
package com.ticxo.modelengine.core21.mythic.mechanics.controller;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.nms.entity.wrapper.MoveController;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
@MythicMechanic(
name = "jump",
aliases = {}
)
public class JumpMechanic implements ITargetedEntitySkill {
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
if (meta.getMetadata("meg:move_controller").orElseGet(() -> {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
return model == null ? null : model.getBase().getMoveController();
}) instanceof MoveController moveController) {
moveController.jump();
}
return SkillResult.SUCCESS;
}
}
@@ -0,0 +1,64 @@
package com.ticxo.modelengine.core21.mythic.mechanics.controller;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.nms.entity.wrapper.MoveController;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
@MythicMechanic(
name = "move",
aliases = {}
)
public class MoveMechanic implements ITargetedEntitySkill {
private final PlaceholderDouble x;
private final PlaceholderDouble y;
private final PlaceholderDouble z;
private final PlaceholderDouble speedModifier;
private final boolean global;
private final boolean queue;
public MoveMechanic(MythicLineConfig mlc) {
this.x = mlc.getPlaceholderDouble(new String[]{"side", "x"}, "0", new String[0]);
this.y = mlc.getPlaceholderDouble(new String[]{"up", "y"}, "0", new String[0]);
this.z = mlc.getPlaceholderDouble(new String[]{"front", "z"}, "0", new String[0]);
this.speedModifier = mlc.getPlaceholderDouble(new String[]{"speed"}, "1", new String[0]);
this.global = mlc.getBoolean(new String[]{"global", "g"}, false);
this.queue = mlc.getBoolean(new String[]{"queue", "q"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
if (meta.getMetadata("meg:move_controller").orElseGet(() -> {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
return model == null ? null : model.getBase().getMoveController();
}) instanceof MoveController moveController) {
float x = (float)this.x.get(meta, target);
float y = (float)this.y.get(meta, target);
float z = (float)this.z.get(meta, target);
float speed = (float)this.speedModifier.get(meta, target);
if (this.global) {
if (this.queue) {
moveController.queuePostTick(() -> moveController.globalMove(x, y, z, speed));
} else {
moveController.globalMove(x, y, z, speed);
}
} else if (this.queue) {
moveController.queuePostTick(() -> moveController.move(x, y, z, speed));
} else {
moveController.move(x, y, z, speed);
}
}
return SkillResult.SUCCESS;
}
}
@@ -0,0 +1,32 @@
package com.ticxo.modelengine.core21.mythic.mechanics.controller;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.nms.entity.wrapper.MoveController;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
@MythicMechanic(
name = "nofall",
aliases = {"cancelfall", "cancelfalldamage"}
)
public class NoFallMechanic implements ITargetedEntitySkill {
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
if (meta.getMetadata("meg:move_controller").orElseGet(() -> {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
return model == null ? null : model.getBase().getMoveController();
}) instanceof MoveController moveController) {
moveController.nullifyFallDistance();
}
return SkillResult.SUCCESS;
}
}
@@ -0,0 +1,61 @@
package com.ticxo.modelengine.core21.mythic.mechanics.controller;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.nms.entity.EntityHandler;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import java.util.Locale;
import org.bukkit.entity.Entity;
@MythicMechanic(
name = "syncyaw",
aliases = {}
)
public class SyncYawMechanic implements ITargetedEntitySkill {
private final String target;
private final String body;
public SyncYawMechanic(MythicLineConfig mlc) {
this.target = mlc.getString(new String[]{"target", "t", "to"}, "yaw", new String[0]);
this.body = mlc.getString(new String[]{"body", "b", "src", "from"}, "head", new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Entity entity = target.getBukkitEntity();
EntityHandler handler = ModelEngineAPI.getEntityHandler();
String var6 = this.body.toLowerCase(Locale.ENGLISH);
float yaw = switch (var6) {
case "yaw" -> handler.getYRot(entity);
case "body", "true" -> handler.getYBodyRot(entity);
default -> handler.getYHeadRot(entity);
};
var6 = this.target.toLowerCase(Locale.ENGLISH);
switch (var6) {
case "yaw":
handler.setYRot(entity, yaw);
break;
case "body":
handler.setYBodyRot(entity, yaw);
break;
case "head":
handler.setYHeadRot(entity, yaw);
break;
case "all":
handler.setYRot(entity, yaw);
handler.setYBodyRot(entity, yaw);
handler.setYHeadRot(entity, yaw);
}
return SkillResult.SUCCESS;
}
}
@@ -0,0 +1,70 @@
package com.ticxo.modelengine.core21.mythic.mechanics.disguise;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.ServerInfo;
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
import com.ticxo.modelengine.api.generator.blueprint.ModelBlueprint;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import org.bukkit.entity.Player;
@MythicMechanic(
name = "disguise",
aliases = {"modeldisguise"}
)
public class DisguiseMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final boolean viewSelf;
public DisguiseMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.viewSelf = mlc.getBoolean(new String[]{"s", "see", "seeself"}, true);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
if (ServerInfo.scheduleOnRegion(target.getBukkitEntity(), () -> this.castAtEntity(meta, target))) {
return SkillResult.SUCCESS;
} else if (!target.isPlayer()) {
return SkillResult.INVALID_TARGET;
} else {
Player player = (Player)target.getBukkitEntity();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
ModelBlueprint blueprint = MythicUtils.getBlueprintOrNull(modelId);
if (blueprint == null) {
return SkillResult.INVALID_CONFIG;
} else {
ModeledEntity modeledEntity = ModelEngineAPI.getOrCreateModeledEntity(player);
modeledEntity.getBase().getBodyRotationController().setPlayerMode(true);
modeledEntity.setBaseEntityVisible(false);
if (modeledEntity.getBase().getData() instanceof BukkitEntityData data && this.viewSelf) {
data.getTracked().addForcedPairing(player.getUniqueId());
}
ModelEngineAPI.getEntityHandler().setForcedInvisible(player, true);
if (modeledEntity.getModel(modelId).isEmpty()) {
ActiveModel activeModel = ModelEngineAPI.createActiveModel(blueprint);
modeledEntity.addModel(activeModel, false).ifPresent(ActiveModel::destroy);
}
return SkillResult.SUCCESS;
}
}
}
public boolean getTargetsCreatives() {
return true;
}
}
@@ -0,0 +1,64 @@
package com.ticxo.modelengine.core21.mythic.mechanics.disguise;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.ServerInfo;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import org.bukkit.entity.Player;
@MythicMechanic(
name = "undisguise",
aliases = {"modelundisguise"}
)
public class UndisguiseMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
public UndisguiseMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
if (ServerInfo.scheduleOnRegion(target.getBukkitEntity(), () -> this.castAtEntity(meta, target))) {
return SkillResult.SUCCESS;
} else if (!target.isPlayer()) {
return SkillResult.INVALID_TARGET;
} else {
Player player = (Player)target.getBukkitEntity();
ModeledEntity modeledEntity = ModelEngineAPI.getModeledEntity(player);
if (modeledEntity != null) {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
if (modelId == null) {
modeledEntity.setBaseEntityVisible(true);
modeledEntity.markRemoved();
ModelEngineAPI.getEntityHandler().setForcedInvisible(player, false);
} else {
modeledEntity.removeModel(modelId).ifPresent(ActiveModel::destroy);
if (modeledEntity.getModels().isEmpty()) {
modeledEntity.setBaseEntityVisible(true);
modeledEntity.markRemoved();
ModelEngineAPI.getEntityHandler().setForcedInvisible(player, false);
}
}
}
return SkillResult.SUCCESS;
}
}
public boolean getTargetsCreatives() {
return true;
}
}
@@ -0,0 +1,94 @@
package com.ticxo.modelengine.core21.mythic.mechanics.entity;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.nms.entity.wrapper.BodyRotationController;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderFloat;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import java.util.Optional;
@MythicMechanic(
name = "bodyrotation",
aliases = {"bodyclamp"}
)
public class BodyRotationMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final MythicLineConfig config;
public BodyRotationMechanic(MythicLineConfig mlc) {
this.config = mlc;
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
BodyRotationController controller = model.getBase().getBodyRotationController();
boolean headUneven = this.config.getBoolean(new String[]{"hu", "head", "headuneven"}, controller.isHeadClampUneven());
PlaceholderFloat maxHeadAngle = this.config.getPlaceholderFloat(new String[]{"mh", "mxh", "maxhead"}, controller.getMaxHeadAngle(), new String[0]);
PlaceholderFloat minHeadAngle = this.config.getPlaceholderFloat(new String[]{"mnh", "minhead"}, controller.getMinHeadAngle(), new String[0]);
boolean bodyUneven = this.config.getBoolean(new String[]{"bu", "body", "bodyuneven"}, controller.isBodyClampUneven());
PlaceholderFloat maxBodyAngle = this.config.getPlaceholderFloat(new String[]{"mb", "mxb", "maxbody"}, controller.getMaxBodyAngle(), new String[0]);
PlaceholderFloat minBodyAngle = this.config.getPlaceholderFloat(new String[]{"mnb", "minbody"}, controller.getMinBodyAngle(), new String[0]);
boolean mode = this.config.getBoolean(new String[]{"m", "mode", "player", "playermode"}, controller.isPlayerMode());
PlaceholderFloat stableAngle = this.config.getPlaceholderFloat(new String[]{"s", "stable"}, controller.getStableAngle(), new String[0]);
PlaceholderInt rotationDelay = this.config.getPlaceholderInteger(new String[]{"rde", "rdelay"}, controller.getRotationDelay(), new String[0]);
PlaceholderInt rotationDuration = this.config.getPlaceholderInteger(new String[]{"rdu", "rduration"}, controller.getRotationDuration(), new String[0]);
controller.setHeadClampUneven(headUneven);
controller.setMaxHeadAngle(maxHeadAngle.get(meta, target));
controller.setMinHeadAngle(minHeadAngle.get(meta, target));
controller.setBodyClampUneven(bodyUneven);
controller.setMaxBodyAngle(maxBodyAngle.get(meta, target));
controller.setMinBodyAngle(minBodyAngle.get(meta, target));
controller.setPlayerMode(mode);
controller.setStableAngle(stableAngle.get(meta, target));
controller.setRotationDelay(rotationDelay.get(meta, target));
controller.setRotationDuration(rotationDuration.get(meta, target));
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
BodyRotationController controller = model.getBase().getBodyRotationController();
boolean headUneven = this.config.getBoolean(new String[]{"hu", "head", "headuneven"}, controller.isHeadClampUneven());
PlaceholderFloat maxHeadAngle = this.config.getPlaceholderFloat(new String[]{"mh", "mxh", "maxhead"}, controller.getMaxHeadAngle(), new String[0]);
PlaceholderFloat minHeadAngle = this.config.getPlaceholderFloat(new String[]{"mnh", "minhead"}, controller.getMinHeadAngle(), new String[0]);
boolean bodyUneven = this.config.getBoolean(new String[]{"bu", "body", "bodyuneven"}, controller.isBodyClampUneven());
PlaceholderFloat maxBodyAngle = this.config.getPlaceholderFloat(new String[]{"mb", "mxb", "maxbody"}, controller.getMaxBodyAngle(), new String[0]);
PlaceholderFloat minBodyAngle = this.config.getPlaceholderFloat(new String[]{"mnb", "minbody"}, controller.getMinBodyAngle(), new String[0]);
boolean mode = this.config.getBoolean(new String[]{"m", "mode", "player", "playermode"}, controller.isPlayerMode());
PlaceholderFloat stableAngle = this.config.getPlaceholderFloat(new String[]{"s", "stable"}, controller.getStableAngle(), new String[0]);
PlaceholderInt rotationDelay = this.config.getPlaceholderInteger(new String[]{"rde", "rdelay"}, controller.getRotationDelay(), new String[0]);
PlaceholderInt rotationDuration = this.config.getPlaceholderInteger(new String[]{"rdu", "rduration"}, controller.getRotationDuration(), new String[0]);
controller.setHeadClampUneven(headUneven);
controller.setMaxHeadAngle(maxHeadAngle.get(meta));
controller.setMinHeadAngle(minHeadAngle.get(meta));
controller.setBodyClampUneven(bodyUneven);
controller.setMaxBodyAngle(maxBodyAngle.get(meta));
controller.setMinBodyAngle(minBodyAngle.get(meta));
controller.setPlayerMode(mode);
controller.setStableAngle(stableAngle.get(meta));
controller.setRotationDelay(rotationDelay.get(meta));
controller.setRotationDuration(rotationDuration.get(meta));
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,127 @@
package com.ticxo.modelengine.core21.mythic.mechanics.entity;
import com.ticxo.modelengine.api.entity.CullType;
import com.ticxo.modelengine.api.entity.data.IEntityData;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.utils.math.TMath;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
import java.util.function.Function;
@MythicMechanic(
name = "cullconfig",
aliases = {"cull"}
)
public class ConfigureCullMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final MythicLineConfig config;
public ConfigureCullMechanic(MythicLineConfig mlc) {
this.config = mlc;
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
IEntityData data = model.getBase().getData();
Integer cullInterval = this.getOrDefault(meta, target, Integer::parseInt, data.getCullInterval(), "ci", "cullinterval");
Boolean verticalCull = this.getOrDefault(meta, target, Boolean::parseBoolean, data.getVerticalCull(), "vc", "verticalcull");
Double verticalCullDistance = this.getOrDefault(meta, target, Double::parseDouble, data.getVerticalCullDistance(), "vcd", "verticalculldistance");
CullType verticalCullType = this.getOrDefault(meta, target, CullType::get, data.getVerticalCullType(), "vct", "verticalculltype");
Boolean backCull = this.getOrDefault(meta, target, Boolean::parseBoolean, data.getBackCull(), "bkc", "backcull");
Double backCullAngle = this.getOrDefault(meta, target, val -> {
double degree = Double.parseDouble(val);
return Math.cos(TMath.clamp(degree, 0.0, 360.0) * 0.5 * (float) (Math.PI / 180.0));
}, data.getBackCullAngle(), "bkca", "backcullangle");
Double backCullIgnoreRadius = this.getOrDefault(meta, target, Double::parseDouble, data.getBackCullIgnoreRadius(), "bkcr", "backcullignoreradius");
CullType backCullType = this.getOrDefault(meta, target, CullType::get, data.getBackCullType(), "bkct", "backculltype");
Boolean blockedCull = this.getOrDefault(meta, target, Boolean::parseBoolean, data.getBlockedCull(), "blc", "blockedcull");
Double blockedCullIgnoreRadius = this.getOrDefault(
meta, target, Double::parseDouble, data.getBlockedCullIgnoreRadius(), "blcr", "blockedcullignoreradius"
);
CullType blockedCullType = this.getOrDefault(meta, target, CullType::get, data.getBlockedCullType(), "blct", "blockedculltype");
data.setCullInterval(cullInterval);
data.setVerticalCull(verticalCull);
data.setVerticalCullDistance(verticalCullDistance);
data.setVerticalCullType(verticalCullType);
data.setBackCull(backCull);
data.setBackCullAngle(backCullAngle);
data.setBackCullIgnoreRadius(backCullIgnoreRadius);
data.setBackCullType(backCullType);
data.setBlockedCull(blockedCull);
data.setBlockedCullIgnoreRadius(blockedCullIgnoreRadius);
data.setBlockedCullType(blockedCullType);
Boolean animationLod = this.getOrDefault(meta, target, Boolean::parseBoolean, model.getAnimationLodHandler().getEnabled(), "alod", "animationlod");
model.getAnimationLodHandler().setEnabled(animationLod);
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
IEntityData data = model.getBase().getData();
Integer cullInterval = this.getOrDefault(meta, null, Integer::parseInt, data.getCullInterval(), "ci", "cullinterval");
Boolean verticalCull = this.getOrDefault(meta, null, Boolean::parseBoolean, data.getVerticalCull(), "vc", "verticalcull");
Double verticalCullDistance = this.getOrDefault(meta, null, Double::parseDouble, data.getVerticalCullDistance(), "vcd", "verticalculldistance");
CullType verticalCullType = this.getOrDefault(meta, null, CullType::get, data.getVerticalCullType(), "vct", "verticalculltype");
Boolean backCull = this.getOrDefault(meta, null, Boolean::parseBoolean, data.getBackCull(), "bkc", "backcull");
Double backCullAngle = this.getOrDefault(meta, null, val -> {
double degree = Double.parseDouble(val);
return Math.cos(TMath.clamp(degree, 0.0, 360.0) * 0.5 * (float) (Math.PI / 180.0));
}, data.getBackCullAngle(), "bkca", "backcullangle");
Double backCullIgnoreRadius = this.getOrDefault(meta, null, Double::parseDouble, data.getBackCullIgnoreRadius(), "bkcr", "backcullignoreradius");
CullType backCullType = this.getOrDefault(meta, null, CullType::get, data.getBackCullType(), "bkct", "backculltype");
Boolean blockedCull = this.getOrDefault(meta, null, Boolean::parseBoolean, data.getBlockedCull(), "blc", "blockedcull");
Double blockedCullIgnoreRadius = this.getOrDefault(
meta, null, Double::parseDouble, data.getBlockedCullIgnoreRadius(), "blcr", "blockedcullignoreradius"
);
CullType blockedCullType = this.getOrDefault(meta, null, CullType::get, data.getBlockedCullType(), "blct", "blockedculltype");
data.setCullInterval(cullInterval);
data.setVerticalCull(verticalCull);
data.setVerticalCullDistance(verticalCullDistance);
data.setVerticalCullType(verticalCullType);
data.setBackCull(backCull);
data.setBackCullAngle(backCullAngle);
data.setBackCullIgnoreRadius(backCullIgnoreRadius);
data.setBackCullType(backCullType);
data.setBlockedCull(blockedCull);
data.setBlockedCullIgnoreRadius(blockedCullIgnoreRadius);
data.setBlockedCullType(blockedCullType);
Boolean animationLod = this.getOrDefault(meta, null, Boolean::parseBoolean, model.getAnimationLodHandler().getEnabled(), "alod", "animationlod");
model.getAnimationLodHandler().setEnabled(animationLod);
return SkillResult.SUCCESS;
}
}
private <T> T getOrDefault(SkillMetadata meta, AbstractEntity target, Function<String, T> function, T def, String... alias) {
PlaceholderString placeholder = this.config.getPlaceholderString(alias, null, new String[0]);
if (placeholder != null && placeholder.isPresent()) {
try {
return function.apply(placeholder.get(meta, target));
} catch (Exception var8) {
return def;
}
} else {
return def;
}
}
}
@@ -0,0 +1,187 @@
package com.ticxo.modelengine.core21.mythic.mechanics.entity;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.ServerInfo;
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.operation.ModelOperation;
import com.ticxo.modelengine.api.model.operation.OperationResult;
import com.ticxo.modelengine.api.model.operation.OperationType;
import com.ticxo.modelengine.api.nms.entity.wrapper.TrackedEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderBoolean;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.bukkit.BukkitAdapter;
import org.bukkit.entity.Player;
@MythicMechanic(
name = "model",
aliases = {}
)
public class ModelMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final PlaceholderBoolean hitbox;
private final PlaceholderBoolean remove;
private final PlaceholderBoolean killOwner;
private final PlaceholderString invisible;
private final PlaceholderBoolean doDamageTint;
private final PlaceholderString nametag;
private final PlaceholderBoolean canDrive;
private final PlaceholderBoolean canRide;
private final PlaceholderBoolean lockPitch;
private final PlaceholderBoolean lockYaw;
private final PlaceholderDouble stepHeight;
private final PlaceholderInt viewRadius;
private final PlaceholderDouble viewRange;
private final PlaceholderDouble scale;
private final PlaceholderDouble hitboxScale;
private final PlaceholderBoolean useStateMachine;
private final PlaceholderBoolean invisUpdate;
private final PlaceholderBoolean initRenderer;
private final PlaceholderBoolean showHitbox;
private final PlaceholderBoolean showShadow;
private final PlaceholderBoolean syncBodyYaw;
private final PlaceholderBoolean shouldSave;
private final PlaceholderBoolean viewSelf;
private final PlaceholderBoolean shouldTrack;
private final PlaceholderBoolean pivotOverride;
private final PlaceholderBoolean cameraPivot;
private final PlaceholderBoolean renderFire;
private final PlaceholderBoolean forceFire;
private final PlaceholderString rootBone;
public ModelMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.hitbox = mlc.getPlaceholderBoolean(new String[]{"h", "hitbox"}, true);
this.remove = mlc.getPlaceholderBoolean(new String[]{"r", "remove"}, false);
this.killOwner = mlc.getPlaceholderBoolean(new String[]{"ko", "killowner"}, false);
this.invisible = mlc.getPlaceholderString(new String[]{"i", "invis", "invisible"}, null, new String[0]);
this.doDamageTint = mlc.getPlaceholderBoolean(new String[]{"d", "tint", "damagetint"}, true);
this.nametag = mlc.getPlaceholderString(new String[]{"n", "name", "nametag"}, null, new String[0]);
this.canDrive = mlc.getPlaceholderBoolean(new String[]{"drive"}, false);
this.canRide = mlc.getPlaceholderBoolean(new String[]{"ride"}, false);
this.lockPitch = mlc.getPlaceholderBoolean(new String[]{"lp", "lpitch", "lockpitch"}, false);
this.lockYaw = mlc.getPlaceholderBoolean(new String[]{"ly", "lyaw", "lockyaw"}, false);
this.stepHeight = mlc.getPlaceholderDouble(new String[]{"s", "step"}, (String)null, new String[0]);
this.viewRadius = mlc.getPlaceholderInteger(new String[]{"rad", "radius"}, 0, new String[0]);
this.viewRange = mlc.getPlaceholderDouble(new String[]{"vr", "viewrange"}, "4096", new String[0]);
this.scale = mlc.getPlaceholderDouble(new String[]{"scale"}, "1", new String[0]);
this.hitboxScale = mlc.getPlaceholderDouble(new String[]{"hitboxscale"}, this.scale, new String[0]);
this.useStateMachine = mlc.getPlaceholderBoolean(new String[]{"usm", "state", "statemachine", "usestatemachine"}, false);
this.invisUpdate = mlc.getPlaceholderBoolean(new String[]{"iu", "invisupdate"}, false);
this.initRenderer = mlc.getPlaceholderBoolean(new String[]{"init", "initrender"}, true);
this.showHitbox = mlc.getPlaceholderBoolean(new String[]{"showhitbox"}, true);
this.showShadow = mlc.getPlaceholderBoolean(new String[]{"showshadow"}, true);
this.syncBodyYaw = mlc.getPlaceholderBoolean(new String[]{"syncbody"}, true);
this.shouldSave = mlc.getPlaceholderBoolean(new String[]{"save"}, false);
this.viewSelf = mlc.getPlaceholderBoolean(new String[]{"vs", "see", "seeself"}, true);
this.shouldTrack = mlc.getPlaceholderBoolean(new String[]{"track"}, null);
this.pivotOverride = mlc.getPlaceholderBoolean(new String[]{"pv", "pivot"}, false);
this.cameraPivot = mlc.getPlaceholderBoolean(new String[]{"campivot", "camerapivot"}, false);
this.renderFire = mlc.getPlaceholderBoolean(new String[]{"rf", "renderfire"}, null);
this.forceFire = mlc.getPlaceholderBoolean(new String[]{"ff", "forcefire"}, null);
this.rootBone = mlc.getPlaceholderString(new String[]{"rt", "root", "rootbone"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
return ServerInfo.scheduleOnRegion(BukkitAdapter.adapt(target), () -> this.castAtEntitySync(meta, target))
? SkillResult.SUCCESS
: this.castAtEntitySync(meta, target);
}
private SkillResult castAtEntitySync(SkillMetadata meta, AbstractEntity target) {
return this.remove.get(meta, target) ? this.removeModel(meta, target) : this.addModel(meta, target);
}
private SkillResult removeModel(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
boolean disguise = target.isPlayer();
String id = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
if (id == null) {
for (ActiveModel activeModel : model.getModels().values()) {
model.removeModel(activeModel.getBlueprint().getName()).ifPresent(ActiveModel::destroy);
}
} else {
model.removeModel(id).ifPresent(ActiveModel::destroy);
}
if (this.killOwner.get(meta, target)) {
target.remove();
return SkillResult.SUCCESS;
} else {
if (model.getModels().isEmpty()) {
model.setBaseEntityVisible(true);
ModelEngineAPI.removeModeledEntity(target.getUniqueId());
ModelEngineAPI.getEntityHandler().setForcedInvisible(BukkitAdapter.adapt(target), false);
if (disguise) {
Player player = BukkitAdapter.adapt(target.asPlayer());
if (model.getBase().getData() instanceof BukkitEntityData data) {
data.getTracked().setBaseRange(data.getTracked().getInitialBaseRange());
data.getTracked().setPlayerPredicate(TrackedEntity.DEFAULT_PREDICATE);
}
}
} else {
String strInvis = MythicUtils.getOrNullLowercase(this.invisible, meta, target);
if (strInvis != null) {
model.setBaseEntityVisible(Boolean.parseBoolean(strInvis));
}
}
return SkillResult.SUCCESS;
}
}
}
private SkillResult addModel(SkillMetadata meta, AbstractEntity target) {
String strInvis = MythicUtils.getOrNullLowercase(this.invisible, meta, target);
OperationResult result = ModelOperation.builder()
.bukkitEntity(BukkitAdapter.adapt(target))
.modelId(MythicUtils.getOrNullLowercase(this.modelId, meta, target))
.overrideHitbox(this.hitbox.get(meta, target))
.stepHeight(this.stepHeight == null ? null : this.stepHeight.get(meta, target))
.viewRadius(this.viewRadius.get(meta, target))
.viewRange((float)this.viewRange.get(meta, target))
.scale(this.scale.get(meta, target))
.hitboxScale(this.hitboxScale.get(meta, target))
.shouldSave(this.shouldSave.get(meta, target))
.baseInvisible(strInvis == null || Boolean.parseBoolean(strInvis))
.doDamageTint(this.doDamageTint.get(meta, target))
.lockPitch(this.lockPitch.get(meta, target))
.lockYaw(this.lockYaw.get(meta, target))
.invisibleUpdate(this.invisUpdate.get(meta, target))
.initializeRenderer(this.initRenderer.get(meta, target))
.syncBodyYaw(this.syncBodyYaw.get(meta, target))
.useStateMachine(this.useStateMachine.get(meta, target))
.useBaseAsPivot(this.pivotOverride.get(meta, target))
.cameraPivot(this.cameraPivot.get(meta, target))
.showHitbox(this.showHitbox.get(meta, target))
.showShadow(this.showShadow.get(meta, target))
.drivable(this.canDrive.get(meta, target))
.rideable(this.canRide.get(meta, target))
.nametagBone(MythicUtils.getOrNullLowercase(this.nametag, meta, target))
.rootBone(MythicUtils.getOrNullLowercase(this.rootBone, meta, target))
.renderFire(this.renderFire == null ? null : this.renderFire.get(meta, target))
.forceFire(this.forceFire == null ? null : this.forceFire.get(meta, target))
.viewSelf(this.viewSelf.get(meta, target))
.playerPredicate(this.shouldTrack == null ? null : (this.shouldTrack.get(meta, target) ? TrackedEntity.DEFAULT_PREDICATE : player -> false))
.operate(OperationType.ADD_MODEL);
return result.isSuccessful() ? SkillResult.SUCCESS : SkillResult.ERROR;
}
}
@@ -0,0 +1,60 @@
package com.ticxo.modelengine.core21.mythic.mechanics.entity;
import com.ticxo.modelengine.api.entity.data.BukkitEntityData;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import java.util.Optional;
import org.bukkit.entity.Player;
@MythicMechanic(
name = "pairmodel",
aliases = {}
)
public class PairModelMechanic implements ITargetedEntitySkill {
private final boolean hidden;
private final boolean remove;
public PairModelMechanic(MythicLineConfig mlc) {
this.hidden = mlc.getBoolean(new String[]{"h", "hidden"}, false);
this.remove = mlc.getBoolean(new String[]{"r", "remove"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, meta.getCaster().getEntity().getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
if (model.getBase().getData() instanceof BukkitEntityData data && target.getBukkitEntity() instanceof Player player) {
if (this.hidden) {
if (this.remove) {
data.getTracked().removeForcedHidden(player.getUniqueId());
} else {
data.getTracked().addForcedHidden(player.getUniqueId());
}
} else if (this.remove) {
data.getTracked().removeForcedPairing(player.getUniqueId());
} else {
data.getTracked().addForcedPairing(player.getUniqueId());
}
}
return SkillResult.SUCCESS;
}
}
public boolean getTargetsCreatives() {
return true;
}
}
@@ -0,0 +1,40 @@
package com.ticxo.modelengine.core21.mythic.mechanics.entity;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
@MythicMechanic(
name = "petrify",
aliases = {}
)
public class PetrifyMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
public PetrifyMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
model.getModel(modelId).ifPresent(activeModel -> activeModel.getModelRenderer().createRealEntities());
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,116 @@
package com.ticxo.modelengine.core21.mythic.mechanics.hitbox;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.api.model.bone.type.SubHitbox;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.adapters.AbstractLocation;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.mobs.MythicMob;
import io.lumine.mythic.api.mobs.entities.SpawnReason;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillCaster;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.bukkit.adapters.BukkitEntityType;
import io.lumine.mythic.core.logging.MythicLogger;
import io.lumine.mythic.core.mobs.ActiveMob;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.joml.Vector3f;
@MythicMechanic(
name = "bindhitbox",
aliases = {}
)
public class BindHitboxMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final String strType;
private final boolean inheritFaction;
private MythicMob mm;
private BukkitEntityType me;
public BindHitboxMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, null, new String[0]);
this.strType = mlc.getString(new String[]{"type", "t", "mob", "m"}, "SKELETON", new String[0]);
this.inheritFaction = mlc.getBoolean(new String[]{"inheritfaction", "if"}, true);
this.getPlugin().getSkillManager().queueSecondPass(() -> {
this.mm = (MythicMob)this.getPlugin().getMobManager().getMythicMob(this.strType).orElse(null);
if (this.mm == null) {
this.me = BukkitEntityType.getMythicEntity(this.strType);
if (this.me == null) {
MythicLogger.errorGenericConfig(mlc, "The 'type' attribute must be a valid MythicMob or MythicEntity type.");
}
}
});
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
model.getModel(modelId).ifPresent(activeModel -> {
String pbone = MythicUtils.getOrNullLowercase(this.partId, meta, target);
if (pbone != null) {
List<String> hitboxes = List.of(pbone.split(","));
ArrayList<SubHitbox> subHitboxes = new ArrayList<>();
for (String hitboxId : hitboxes) {
Optional<ModelBone> maybeBone = activeModel.getBone(hitboxId);
if (!maybeBone.isEmpty()) {
ModelBone bone = maybeBone.get();
Optional maybeHitbox = bone.getBoneBehavior(BoneBehaviorTypes.SUB_HITBOX);
if (!maybeHitbox.isEmpty()) {
subHitboxes.add((SubHitbox)maybeHitbox.get());
}
}
}
this.createBoundEntity(meta.getCaster(), subHitboxes);
}
});
return SkillResult.SUCCESS;
}
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
private void createBoundEntity(SkillCaster caster, List<SubHitbox> subHitboxes) {
if (!subHitboxes.isEmpty()) {
AbstractEntity abstractCaster = caster.getEntity();
Vector3f vec = subHitboxes.get(0).getLocation();
AbstractLocation l = new AbstractLocation(abstractCaster.getWorld(), vec.x, vec.y, vec.z);
if (this.mm != null) {
ActiveMob ams = this.mm.spawn(l, caster.getLevel(), SpawnReason.SUMMON, entity -> {
for (SubHitbox hitbox : subHitboxes) {
hitbox.addBoundEntity(entity);
}
});
ams.setParent(caster);
ams.setOwnerUUID(abstractCaster.getUniqueId());
if (this.inheritFaction && caster instanceof ActiveMob am) {
ams.setFaction(am.getFaction());
}
} else if (this.me != null) {
this.me.spawn(l, SpawnReason.SUMMON, entity -> {
for (SubHitbox hitbox : subHitboxes) {
hitbox.addBoundEntity(entity);
}
});
}
}
}
}
@@ -0,0 +1,55 @@
package com.ticxo.modelengine.core21.mythic.mechanics.hitbox;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes;
import com.ticxo.modelengine.api.model.bone.type.SubHitbox;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
@MythicMechanic(
name = "hitboxconfig",
aliases = {}
)
public class ConfigureHitboxMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final PlaceholderDouble shouldPass;
public ConfigureHitboxMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, null, new String[0]);
this.shouldPass = mlc.getPlaceholderDouble(new String[]{"pass"}, "1", new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
model.getModel(modelId)
.ifPresent(
activeModel -> {
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
activeModel.getBone(partId)
.flatMap(modelBone -> modelBone.getBoneBehavior(BoneBehaviorTypes.SUB_HITBOX))
.ifPresent(subHitbox -> ((SubHitbox)subHitbox).setDamageMultiplier((float)this.shouldPass.get(meta, target)));
}
);
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,70 @@
package com.ticxo.modelengine.core21.mythic.mechanics.item;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes;
import com.ticxo.modelengine.api.model.bone.type.HeldItem;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.core.drops.EquipSlot;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.EquipmentSlot;
@MythicMechanic(
name = "linkitembone",
aliases = {}
)
public class LinkItemBoneMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final PlaceholderString slot;
public LinkItemBoneMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"b", "bone", "p", "pid", "part", "partid"}, null, new String[0]);
this.slot = mlc.getPlaceholderString(new String[]{"s", "slot"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
model.getModel(modelId).ifPresent(activeModel -> {
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
activeModel.getBone(partId).ifPresent(modelBone -> modelBone.getBoneBehavior(BoneBehaviorTypes.ITEM).ifPresent(heldItem -> {
String slotString = MythicUtils.getOrNull(this.slot, meta, target);
if (slotString == null) {
((HeldItem)heldItem).clearItemProvider();
} else {
EquipmentSlot bukkitSlot = EquipSlot.of(slotString).getBukkitSlot();
if (bukkitSlot == null) {
((HeldItem)heldItem).clearItemProvider();
} else {
if (target.getBukkitEntity() instanceof LivingEntity livingEntity) {
if (livingEntity.getEquipment() == null) {
return;
}
((HeldItem)heldItem).setItemProvider(new HeldItem.EquipmentSupplier(livingEntity, bukkitSlot));
}
}
}
}));
});
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,137 @@
package com.ticxo.modelengine.core21.mythic.mechanics.item;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.generator.blueprint.BlueprintBone;
import com.ticxo.modelengine.api.generator.blueprint.ModelBlueprint;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes;
import com.ticxo.modelengine.api.model.bone.type.HeldItem;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.adapters.AbstractItemStack;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.core.items.MythicItem;
import io.lumine.mythic.core.skills.placeholders.PlaceholderContext;
import io.lumine.mythic.core.skills.variables.types.ItemVariable;
import java.util.Optional;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@MythicMechanic(
name = "setitemmodel",
aliases = {}
)
public class SetItemModelMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final PlaceholderString strMat;
private final PlaceholderInt data;
private final PlaceholderString color;
private final boolean enchanted;
public SetItemModelMechanic(MythicLineConfig config) {
this.modelId = config.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = config.getPlaceholderString(new String[]{"b", "bone", "p", "pid", "part", "partid"}, null, new String[0]);
this.strMat = config.getPlaceholderString(new String[]{"i", "item", "mat", "material"}, null, new String[0]);
this.data = config.getPlaceholderInteger(new String[]{"data"}, 0, new String[0]);
this.color = config.getPlaceholderString(new String[]{"color"}, null, new String[0]);
this.enchanted = config.getBoolean(new String[]{"enchant"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
model.getModel(modelId).ifPresent(activeModel -> {
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
activeModel.getBone(partId).ifPresent(modelBone -> modelBone.getBoneBehavior(BoneBehaviorTypes.ITEM).ifPresent(heldItem -> {
ItemStack stack = BukkitAdapter.adapt(this.getItem(meta, target));
((HeldItem)heldItem).setItemProvider(new HeldItem.StaticItemStackSupplier(stack));
}));
});
return SkillResult.SUCCESS;
}
}
private AbstractItemStack getItem(SkillMetadata meta, AbstractEntity target) {
AbstractItemStack itemStack = null;
String strMat = MythicUtils.getOrNull(this.strMat, meta, target);
try {
return ItemVariable.fromStringWithContext(strMat, PlaceholderContext.ofMeta(meta));
} catch (Exception var15) {
int data = this.data.get(meta, target);
String color = MythicUtils.getOrNull(this.color, meta, target);
boolean isMI = false;
try {
isMI = true;
if (strMat.contains(":")) {
isMI = false;
String[] mat = strMat.split(":", 2);
String mId = mat[0];
String pId = mat[1];
ModelBlueprint blueprint = MythicUtils.getBlueprintOrNull(mId);
if (blueprint == null) {
isMI = true;
} else {
BlueprintBone bone = blueprint.getFlatMap().get(pId);
if (bone == null) {
isMI = true;
} else {
int mData = bone.getDataId();
if (mData == -1) {
isMI = true;
} else {
itemStack = BukkitAdapter.adapt(bone.getBaseItem().getMaterial()).modelData(mData);
}
}
}
}
if (isMI) {
Optional<MythicItem> maybeMI = this.getPlugin().getItemManager().getItem(strMat);
if (maybeMI.isPresent()) {
itemStack = maybeMI.get().generateItemStack(1);
} else {
Material mat = Material.valueOf(strMat.toUpperCase());
itemStack = BukkitAdapter.adapt(mat).modelData(data);
}
}
} catch (Exception var14) {
var14.printStackTrace();
itemStack = BukkitAdapter.adapt(Material.STONE);
}
if (itemStack == null) {
itemStack = BukkitAdapter.adapt(Material.STONE);
}
if (!isMI) {
if (color != null) {
itemStack.color(color);
}
if (this.enchanted) {
itemStack.enchantmentGlow(true);
}
}
return itemStack;
}
}
}
@@ -0,0 +1,62 @@
package com.ticxo.modelengine.core21.mythic.mechanics.leash;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.ServerInfo;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.manager.LeashManager;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
@MythicMechanic(
name = "leash",
aliases = {}
)
public class LeashMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final PlaceholderString sourceId;
private final boolean flag;
public LeashMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.sourceId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, null, new String[0]);
this.flag = mlc.getBoolean(new String[]{"l", "leash"}, true);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
if (ServerInfo.scheduleOnRegion(target.getBukkitEntity(), () -> this.castAtEntity(meta, target))) {
return SkillResult.SUCCESS;
} else {
AbstractEntity caster = meta.getCaster().getEntity();
ModeledEntity model = ModelEngineAPI.getModeledEntity(caster.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
model.getModel(modelId).ifPresent(activeModel -> activeModel.getLeashManager().ifPresent(leashManager -> {
String sourceId = MythicUtils.getOrNullLowercase(this.sourceId, meta, target);
if (this.flag) {
((LeashManager)leashManager).connectLeash(target.getBukkitEntity(), sourceId);
} else {
((LeashManager)leashManager).disconnect(sourceId);
}
}));
return SkillResult.SUCCESS;
}
}
}
public boolean getTargetsCreatives() {
return true;
}
}
@@ -0,0 +1,50 @@
package com.ticxo.modelengine.core21.mythic.mechanics.leash;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.manager.LeashManager;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
@MythicMechanic(
name = "leashself",
aliases = {}
)
public class LeashSelfMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final PlaceholderString sourceId;
private final PlaceholderString destId;
public LeashSelfMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.sourceId = mlc.getPlaceholderString(new String[]{"s", "sid", "src", "source", "sourceid"}, null, new String[0]);
this.destId = mlc.getPlaceholderString(new String[]{"d", "did", "dest", "destid"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
AbstractEntity caster = meta.getCaster().getEntity();
ModeledEntity model = ModelEngineAPI.getModeledEntity(caster.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
model.getModel(modelId).ifPresent(activeModel -> activeModel.getLeashManager().ifPresent(leashManager -> {
String sourceId = MythicUtils.getOrNullLowercase(this.sourceId, meta, target);
String destId = MythicUtils.getOrNullLowercase(this.destId, meta, target);
((LeashManager)leashManager).connectLeash(destId, sourceId);
}));
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,86 @@
package com.ticxo.modelengine.core21.mythic.mechanics.model;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.animation.ModelState;
import com.ticxo.modelengine.api.animation.handler.AnimationHandler;
import com.ticxo.modelengine.api.animation.handler.IPriorityHandler;
import com.ticxo.modelengine.api.animation.handler.IStateMachineHandler;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.utils.MiscUtils;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderBoolean;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import it.unimi.dsi.fastutil.Pair;
@MythicMechanic(
name = "defaultstate",
aliases = {"defaultanimation"}
)
public class DefaultStateMechanic implements ITargetedEntitySkill {
private final MythicLineConfig config;
private final PlaceholderString modelId;
private final PlaceholderString type;
private ModelState stateType;
public DefaultStateMechanic(MythicLineConfig mlc) {
this.config = mlc;
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.type = mlc.getPlaceholderString(new String[]{"t", "type"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String type = MythicUtils.getOrNull(this.type, meta, target);
if (type == null) {
return SkillResult.INVALID_CONFIG;
} else {
this.stateType = ModelState.get(type);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.configureModel(activeModel, meta, target));
return SkillResult.SUCCESS;
}
}
}
private void configureModel(ActiveModel activeModel, SkillMetadata meta, AbstractEntity target) {
AnimationHandler animationHandler = activeModel.getAnimationHandler();
AnimationHandler.DefaultProperty property = animationHandler.getDefaultProperty(this.stateType);
PlaceholderString statePlaceholder = this.config.getPlaceholderString(new String[]{"s", "state"}, property.getAnimation(), new String[0]);
PlaceholderInt lerpInPlaceholder = this.config.getPlaceholderInteger(new String[]{"li", "lerpin"}, (int)(property.getLerpIn() * 20.0), new String[0]);
PlaceholderInt lerpOutPlaceholder = this.config.getPlaceholderInteger(new String[]{"lo", "lerpout"}, (int)(property.getLerpOut() * 20.0), new String[0]);
PlaceholderDouble speedPlaceholder = this.config.getPlaceholderDouble(new String[]{"sp", "speed"}, property.getSpeed(), new String[0]);
PlaceholderBoolean mergePlaceholder = this.config.getPlaceholderBoolean(new String[]{"mg", "merge"}, property.isMerge());
Pair<String, String> statePair = MiscUtils.getAnimationRef(statePlaceholder.get(meta, target));
PlaceholderString srcId = this.config
.getPlaceholderString(new String[]{"src", "sid", "srcmodel", "srcmodelid"}, (String)statePair.first(), new String[0]);
String state = MiscUtils.createAnimationRef(MythicUtils.getOrNull(srcId, meta, target), (String)statePair.second());
double lerpIn = lerpInPlaceholder.get(meta, target) * 0.05;
double lerpOut = lerpOutPlaceholder.get(meta, target) * 0.05;
double speed = speedPlaceholder.get(meta, target);
boolean merge = mergePlaceholder.get(meta, target);
animationHandler.setDefaultProperty(new AnimationHandler.DefaultProperty(this.stateType, state, lerpIn, lerpOut, speed, merge));
if (animationHandler instanceof IPriorityHandler priorityHandler && priorityHandler.isPlayingAnimation(property.getAnimation())) {
priorityHandler.stopAnimation(property.getAnimation());
priorityHandler.playState(this.stateType);
} else if (animationHandler instanceof IStateMachineHandler stateMachineHandler) {
stateMachineHandler.refreshState(property);
}
}
}
@@ -0,0 +1,50 @@
package com.ticxo.modelengine.core21.mythic.mechanics.model;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
@MythicMechanic(
name = "lockmodelhead",
aliases = {"lockhead"}
)
public class LockHeadMechanic implements ITargetedEntitySkill {
private final MythicLineConfig config;
private final PlaceholderString modelId;
public LockHeadMechanic(MythicLineConfig mlc) {
this.config = mlc;
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
MythicUtils.executeOptModelId(model, modelId, this::lock);
return SkillResult.SUCCESS;
}
}
private void lock(ActiveModel activeModel) {
boolean lockPitch = this.config.getBoolean(new String[]{"lp", "lpitch", "lockpitch"}, activeModel.isLockPitch());
boolean lockYaw = this.config.getBoolean(new String[]{"ly", "lyaw", "lockyaw"}, activeModel.isLockYaw());
activeModel.setLockPitch(lockPitch);
activeModel.setLockYaw(lockYaw);
}
}
@@ -0,0 +1,69 @@
package com.ticxo.modelengine.core21.mythic.mechanics.model;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderBoolean;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
@MythicMechanic(
name = "lockmodel",
aliases = {"lockrotation"}
)
public class LockModelRotationMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderBoolean lock;
public LockModelRotationMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.lock = mlc.getPlaceholderBoolean(new String[]{"l", "lock"}, true);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
boolean lock = this.lock.get(meta, target);
if (modelId != null) {
MythicUtils.executeOptModelId(model, modelId, activeModel -> activeModel.setModelRotationLocked(lock));
} else {
model.setModelRotationLocked(lock);
}
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
boolean lock = this.lock.get(meta);
if (modelId != null) {
MythicUtils.executeOptModelId(model, modelId, activeModel -> activeModel.setModelRotationLocked(lock));
} else {
model.setModelRotationLocked(lock);
}
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,116 @@
package com.ticxo.modelengine.core21.mythic.mechanics.model;
import com.ticxo.modelengine.api.animation.BlueprintAnimation;
import com.ticxo.modelengine.api.animation.handler.AnimationHandler;
import com.ticxo.modelengine.api.animation.handler.IStateMachineHandler;
import com.ticxo.modelengine.api.animation.property.IAnimationProperty;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.utils.math.Easing;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
@MythicMechanic(
name = "modifystate",
aliases = {"modifyanimation", "modstate"}
)
public class ModifyStateMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final MythicLineConfig mlc;
private final PlaceholderString modelId;
private final PlaceholderString state;
private final PlaceholderInt priority;
public ModifyStateMechanic(MythicLineConfig mlc) {
this.mlc = mlc;
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.state = mlc.getPlaceholderString(new String[]{"s", "state"}, null, new String[0]);
this.priority = mlc.getPlaceholderInteger(new String[]{"p", "pr", "priority"}, 1, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
String state = MythicUtils.getOrNullLowercase(this.state, meta, target);
model.getModel(modelId).ifPresentOrElse(activeModel -> this.configureAnimation(state, activeModel, meta, target), () -> {
for (ActiveModel activeModel : model.getModels().values()) {
this.configureAnimation(state, activeModel, meta, target);
}
});
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
String state = MythicUtils.getOrNullLowercase(this.state, meta);
model.getModel(modelId).ifPresentOrElse(activeModel -> this.configureAnimation(state, activeModel, meta, null), () -> {
for (ActiveModel activeModel : model.getModels().values()) {
this.configureAnimation(state, activeModel, meta, null);
}
});
return SkillResult.SUCCESS;
}
}
private void configureAnimation(String state, ActiveModel activeModel, SkillMetadata meta, AbstractEntity target) {
AnimationHandler handler = activeModel.getAnimationHandler();
IAnimationProperty property;
if (handler instanceof IStateMachineHandler stateMachineHandler) {
int priority = this.priority.get(meta, target);
property = stateMachineHandler.getAnimation(priority, state);
} else {
property = handler.getAnimation(state);
}
if (property != null) {
PlaceholderDouble speedPlaceholder = this.mlc.getPlaceholderDouble(new String[]{"sp", "speed"}, property.getSpeed(), new String[0]);
PlaceholderInt lerpInPlaceholder = this.mlc.getPlaceholderInteger(new String[]{"li", "lerpin"}, (int)(property.getLerpIn() * 20.0), new String[0]);
PlaceholderInt lerpOutPlaceholder = this.mlc.getPlaceholderInteger(new String[]{"lo", "lerpout"}, (int)(property.getLerpOut() * 20.0), new String[0]);
BlueprintAnimation.LoopMode loopMode = property.getForceLoopMode();
PlaceholderString loopModePlaceholder = this.mlc
.getPlaceholderString(new String[]{"l", "loop"}, loopMode == null ? null : loopMode.name(), new String[0]);
loopMode = BlueprintAnimation.LoopMode.getOrNull(MythicUtils.getOrNull(loopModePlaceholder, meta, target));
BlueprintAnimation.OverrideMode override = property.getForceOverride();
PlaceholderString overridePlaceholder = this.mlc
.getPlaceholderString(new String[]{"ov", "override"}, override == null ? null : override.name(), new String[0]);
override = BlueprintAnimation.OverrideMode.getOrNull(MythicUtils.getOrNull(overridePlaceholder, meta, target));
Easing curveIn = property.getLerpCurveIn();
PlaceholderString curveInPlaceholder = this.mlc.getPlaceholderString(new String[]{"lci", "lerpcurvein"}, curveIn.name(), new String[0]);
curveIn = Easing.get(MythicUtils.getOrNull(curveInPlaceholder, meta, target));
Easing curveOut = property.getLerpCurveOut();
PlaceholderString curveOutPlaceholder = this.mlc.getPlaceholderString(new String[]{"lco", "lerpcurveout"}, curveOut.name(), new String[0]);
curveOut = Easing.get(MythicUtils.getOrNull(curveOutPlaceholder, meta, target));
property.setSpeed(speedPlaceholder.get(meta, target));
property.setLerpIn(lerpInPlaceholder.get(meta, target) * 0.05);
property.setLerpOut(lerpOutPlaceholder.get(meta, target) * 0.05);
property.setForceLoopMode(loopMode);
property.setForceOverride(override);
property.setLerpCurveIn(curveIn);
property.setLerpCurveOut(curveOut);
}
}
}
@@ -0,0 +1,147 @@
package com.ticxo.modelengine.core21.mythic.mechanics.model;
import com.ticxo.modelengine.api.generator.blueprint.BlueprintBone;
import com.ticxo.modelengine.api.generator.blueprint.ModelBlueprint;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
@MythicMechanic(
name = "remapmodel",
aliases = {"remap"}
)
public class RemapModelMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString newModelId;
private final PlaceholderString map;
public RemapModelMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.newModelId = mlc.getPlaceholderString(new String[]{"n", "nid", "newmodel", "newmodelid"}, null, new String[0]);
this.map = mlc.getPlaceholderString(new String[]{"map"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
ActiveModel activeModel = MythicUtils.getActiveModelOrNull(model, modelId);
if (activeModel == null) {
return SkillResult.INVALID_CONFIG;
} else {
String newModelId = MythicUtils.getOrNullLowercase(this.newModelId, meta, target);
ModelBlueprint blueprint = MythicUtils.getBlueprintOrNull(newModelId);
if (blueprint == null) {
return SkillResult.INVALID_CONFIG;
} else {
if (this.map != null) {
String mapId = MythicUtils.getOrNullLowercase(this.map, meta, target);
ModelBlueprint mapBlueprint = MythicUtils.getBlueprintOrNull(mapId);
if (mapBlueprint == null) {
return SkillResult.INVALID_CONFIG;
}
for (String bone : mapBlueprint.getFlatMap().keySet()) {
BlueprintBone blueprintBone = blueprint.getFlatMap().get(bone);
if (blueprintBone != null && blueprintBone.isRenderer()) {
activeModel.getBone(bone).ifPresent(replaced -> {
if (replaced.isRenderer()) {
replaced.setModel(blueprintBone);
}
});
}
}
} else {
for (String bonex : blueprint.getFlatMap().size() < activeModel.getBones().size()
? blueprint.getFlatMap().keySet()
: activeModel.getBones().keySet()) {
BlueprintBone blueprintBone = blueprint.getFlatMap().get(bonex);
if (blueprintBone != null && blueprintBone.isRenderer()) {
activeModel.getBone(bonex).ifPresent(replaced -> {
if (replaced.isRenderer()) {
replaced.setModelScale(blueprintBone.getScale());
replaced.setModel(blueprintBone);
}
});
}
}
}
return null;
}
}
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
ActiveModel activeModel = MythicUtils.getActiveModelOrNull(model, modelId);
if (activeModel == null) {
return SkillResult.INVALID_CONFIG;
} else {
String newModelId = MythicUtils.getOrNullLowercase(this.newModelId, meta);
ModelBlueprint blueprint = MythicUtils.getBlueprintOrNull(newModelId);
if (blueprint == null) {
return SkillResult.INVALID_CONFIG;
} else {
if (this.map != null) {
String mapId = MythicUtils.getOrNullLowercase(this.map, meta);
ModelBlueprint mapBlueprint = MythicUtils.getBlueprintOrNull(mapId);
if (mapBlueprint == null) {
return SkillResult.INVALID_CONFIG;
}
for (String bone : mapBlueprint.getFlatMap().keySet()) {
BlueprintBone blueprintBone = blueprint.getFlatMap().get(bone);
if (blueprintBone != null && blueprintBone.isRenderer()) {
activeModel.getBone(bone).ifPresent(replaced -> {
if (replaced.isRenderer()) {
replaced.setModel(blueprintBone);
}
});
}
}
} else {
for (String bonex : blueprint.getFlatMap().size() < activeModel.getBones().size()
? blueprint.getFlatMap().keySet()
: activeModel.getBones().keySet()) {
BlueprintBone blueprintBone = blueprint.getFlatMap().get(bonex);
if (blueprintBone != null && blueprintBone.isRenderer()) {
activeModel.getBone(bonex).ifPresent(replaced -> {
if (replaced.isRenderer()) {
replaced.setModelScale(blueprintBone.getScale());
replaced.setModel(blueprintBone);
}
});
}
}
}
return null;
}
}
}
}
}
@@ -0,0 +1,46 @@
package com.ticxo.modelengine.core21.mythic.mechanics.model;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
@MythicMechanic(
name = "rendererinit",
aliases = {"renderinit"}
)
public class RendererInitMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
public RendererInitMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
ActiveModel activeModel = MythicUtils.getActiveModelOrNull(model, modelId);
if (activeModel == null) {
return SkillResult.CONDITION_FAILED;
} else {
activeModel.initializeRenderer();
return SkillResult.SUCCESS;
}
}
}
}
@@ -0,0 +1,59 @@
package com.ticxo.modelengine.core21.mythic.mechanics.model;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.animation.rootmotion.RootMotionHandler;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderBoolean;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
@MythicMechanic(
name = "rootmotion",
aliases = {}
)
public class RootMotionMechanic implements ITargetedEntitySkill {
private final PlaceholderDouble weight;
private final PlaceholderDouble baseWeight;
private final PlaceholderBoolean override;
public RootMotionMechanic(MythicLineConfig mlc) {
this.weight = mlc.getPlaceholderDouble(new String[]{"w", "weight"}, "-1", new String[0]);
this.baseWeight = mlc.getPlaceholderDouble(new String[]{"bw", "baseweight"}, "-1", new String[0]);
this.override = mlc.getPlaceholderBoolean(new String[]{"ov", "override"}, null);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
RootMotionHandler handler = model.getRootMotionHandler();
double weight = this.weight == null ? -1.0 : this.weight.get(meta, target);
double baseWeight = this.baseWeight == null ? -1.0 : this.baseWeight.get(meta, target);
Boolean override = this.override == null ? null : this.override.get(meta, target);
if (weight >= 0.0) {
handler.setWeight(weight);
}
if (baseWeight >= 0.0) {
handler.setBaseWeight(baseWeight);
}
if (override != null) {
handler.setOverride(override);
}
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,73 @@
package com.ticxo.modelengine.core21.mythic.mechanics.model;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
@MythicMechanic(
name = "scale",
aliases = {}
)
public class ScaleMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderDouble scale;
private final boolean isHitbox;
public ScaleMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.scale = mlc.getPlaceholderDouble(new String[]{"s", "scale"}, "1", new String[0]);
this.isHitbox = mlc.getBoolean(new String[]{"h", "hitbox"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
double scale = this.scale.get(meta, target);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
MythicUtils.executeOptModelId(model, modelId, activeModel -> {
if (this.isHitbox) {
activeModel.setHitboxScale(scale);
} else {
activeModel.setScale(scale);
}
});
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
double scale = this.scale.get(meta);
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
MythicUtils.executeOptModelId(model, modelId, activeModel -> {
if (this.isHitbox) {
activeModel.setHitboxScale(scale);
} else {
activeModel.setScale(scale);
}
});
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,201 @@
package com.ticxo.modelengine.core21.mythic.mechanics.model;
import com.ticxo.modelengine.api.animation.BlueprintAnimation;
import com.ticxo.modelengine.api.animation.handler.AnimationHandler;
import com.ticxo.modelengine.api.animation.handler.IPriorityHandler;
import com.ticxo.modelengine.api.animation.handler.IStateMachineHandler;
import com.ticxo.modelengine.api.animation.property.IAnimationProperty;
import com.ticxo.modelengine.api.generator.blueprint.ModelBlueprint;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.utils.math.Easing;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderBoolean;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
@MythicMechanic(
name = "state",
aliases = {"animation"}
)
public class StateMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString srcId;
private final PlaceholderString state;
private final PlaceholderString forceLoopMode;
private final PlaceholderString forceOverride;
private final PlaceholderString lerpCurveIn;
private final PlaceholderString lerpCurveOut;
private final boolean remove;
private final boolean ignoreLerp;
private final boolean force;
private final PlaceholderInt lerpIn;
private final PlaceholderInt lerpOut;
private final PlaceholderInt priority;
private final PlaceholderDouble speed;
private final PlaceholderBoolean skipLastFrame;
private final PlaceholderBoolean merge;
private final PlaceholderBoolean emptyZero;
public StateMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.srcId = mlc.getPlaceholderString(new String[]{"src", "sid", "srcmodel", "srcmodelid"}, null, new String[0]);
this.state = mlc.getPlaceholderString(new String[]{"s", "state"}, null, new String[0]);
this.remove = mlc.getBoolean(new String[]{"r", "remove"}, false);
this.speed = mlc.getPlaceholderDouble(new String[]{"sp", "speed"}, "1", new String[0]);
this.lerpIn = mlc.getPlaceholderInteger(new String[]{"li", "lerpin"}, 0, new String[0]);
this.lerpOut = mlc.getPlaceholderInteger(new String[]{"lo", "lerpout"}, 0, new String[0]);
this.lerpCurveIn = mlc.getPlaceholderString(new String[]{"lci", "lerpcurvein"}, null, new String[0]);
this.lerpCurveOut = mlc.getPlaceholderString(new String[]{"lco", "lerpcurveout"}, null, new String[0]);
this.ignoreLerp = mlc.getBoolean(new String[]{"i", "ignorelerp"}, false);
this.force = mlc.getBoolean(new String[]{"f", "force"}, true);
this.priority = mlc.getPlaceholderInteger(new String[]{"p", "pr", "priority"}, 1, new String[0]);
this.forceLoopMode = mlc.getPlaceholderString(new String[]{"l", "loop"}, null, new String[0]);
this.forceOverride = mlc.getPlaceholderString(new String[]{"ov", "override"}, null, new String[0]);
this.skipLastFrame = mlc.getPlaceholderBoolean(new String[]{"skip", "skiplastframe"}, null);
this.merge = mlc.getPlaceholderBoolean(new String[]{"mg", "merge"}, false);
this.emptyZero = mlc.getPlaceholderBoolean(new String[]{"ez", "zero"}, null);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
return this.remove ? this.removeAnimation(meta, target) : this.addAnimation(meta, target);
}
public SkillResult cast(SkillMetadata meta) {
return this.remove ? this.removeAnimation(meta, null) : this.addAnimation(meta, null);
}
private SkillResult removeAnimation(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target == null ? null : target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String state = MythicUtils.getOrNullLowercase(this.state, meta, target);
if (state == null) {
return SkillResult.INVALID_CONFIG;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
String srcId = Optional.ofNullable(MythicUtils.getOrNullLowercase(this.srcId, meta, target)).orElse(modelId);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.removeAnimation(activeModel, srcId, state, meta, target));
return SkillResult.SUCCESS;
}
}
}
private void removeAnimation(ActiveModel activeModel, String srcId, String state, SkillMetadata meta, AbstractEntity target) {
ModelBlueprint srcBlueprint = Optional.ofNullable(MythicUtils.getBlueprintOrNull(srcId)).orElse(activeModel.getBlueprint());
AnimationHandler handler = activeModel.getAnimationHandler();
if (handler instanceof IStateMachineHandler stateMachineHandler) {
int priority = this.priority.get(meta, target);
if (this.ignoreLerp) {
stateMachineHandler.forceStopAnimation(priority, srcBlueprint, state);
} else {
stateMachineHandler.stopAnimation(priority, srcBlueprint, state);
}
} else if (handler instanceof IPriorityHandler priorityHandler) {
if (this.ignoreLerp) {
priorityHandler.forceStopAnimation(srcBlueprint, state);
} else {
priorityHandler.stopAnimation(srcBlueprint, state);
}
} else if (this.ignoreLerp) {
handler.forceStopAnimation(state);
} else {
handler.stopAnimation(state);
}
}
private SkillResult addAnimation(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target == null ? null : target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String state = MythicUtils.getOrNullLowercase(this.state, meta, target);
if (state == null) {
return SkillResult.INVALID_CONFIG;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
String srcId = Optional.ofNullable(MythicUtils.getOrNullLowercase(this.srcId, meta, target)).orElse(modelId);
MythicUtils.executeOptModelId(model, modelId, activeModel -> this.addAnimation(activeModel, srcId, state, meta, target));
return SkillResult.SUCCESS;
}
}
}
private void addAnimation(ActiveModel activeModel, String srcId, String state, SkillMetadata meta, AbstractEntity target) {
ModelBlueprint srcBlueprint = Optional.ofNullable(MythicUtils.getBlueprintOrNull(srcId)).orElse(activeModel.getBlueprint());
int lerpIn = this.lerpIn.get(meta, target);
int lerpOut = this.lerpOut.get(meta, target);
double speed = this.speed.get(meta, target);
BlueprintAnimation.LoopMode loopMode = BlueprintAnimation.LoopMode.getOrNull(MythicUtils.getOrNull(this.forceLoopMode, meta, target));
BlueprintAnimation.OverrideMode override = BlueprintAnimation.OverrideMode.getOrNull(MythicUtils.getOrNull(this.forceOverride, meta, target));
Boolean skip = this.skipLastFrame != null ? this.skipLastFrame.get(meta, target) : null;
boolean merge = this.merge != null && this.merge.get(meta, target);
Boolean emptyZero = this.emptyZero != null ? this.emptyZero.get(meta, target) : null;
Easing curveIn = Easing.getOrNull(MythicUtils.getOrNull(this.lerpCurveIn, meta, target));
Easing curveOut = Easing.getOrNull(MythicUtils.getOrNull(this.lerpCurveOut, meta, target));
AnimationHandler handler = activeModel.getAnimationHandler();
if (handler instanceof IStateMachineHandler stateMachineHandler) {
int priority = this.priority.get(meta, target);
IAnimationProperty property = stateMachineHandler.playAnimation(priority, srcBlueprint, state, lerpIn * 0.05, lerpOut * 0.05, speed, this.force);
this.configProperty(loopMode, override, skip, merge, emptyZero, curveIn, curveOut, property);
} else if (handler instanceof IPriorityHandler priorityHandler) {
IAnimationProperty property = priorityHandler.playAnimation(srcBlueprint, state, lerpIn * 0.05, lerpOut * 0.05, speed, this.force);
this.configProperty(loopMode, override, skip, merge, emptyZero, curveIn, curveOut, property);
} else {
IAnimationProperty property = handler.playAnimation(state, lerpIn * 0.05, lerpOut * 0.05, speed, this.force);
this.configProperty(loopMode, override, skip, merge, emptyZero, curveIn, curveOut, property);
}
}
private void configProperty(
BlueprintAnimation.LoopMode loopMode,
BlueprintAnimation.OverrideMode override,
Boolean skip,
boolean merge,
Boolean emptyZero,
Easing curveIn,
Easing curveOut,
IAnimationProperty property
) {
if (property != null) {
property.setMergeLerp(merge);
if (emptyZero != null) {
property.setEmptyZero(emptyZero);
}
property.setForceLoopMode(loopMode);
if (this.forceOverride != null) {
property.setForceOverride(override);
}
if (skip != null) {
property.setSkipLastFrame(skip);
}
if (curveIn != null) {
property.setLerpCurveIn(curveIn);
}
if (curveOut != null) {
property.setLerpCurveOut(curveOut);
}
}
}
}
@@ -0,0 +1,160 @@
package com.ticxo.modelengine.core21.mythic.mechanics.model;
import com.ticxo.modelengine.api.animation.handler.AnimationHandler;
import com.ticxo.modelengine.api.animation.handler.IStateMachineHandler;
import com.ticxo.modelengine.api.animation.property.IAnimationProperty;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.utils.math.Easing;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
@MythicMechanic(
name = "statetoggle",
aliases = {"togglestate"}
)
public class StateToggleMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString state;
private final PlaceholderString lerpCurveIn;
private final PlaceholderString lerpCurveOut;
private final boolean ignoreLerp;
private final boolean force;
private final PlaceholderInt lerpIn;
private final PlaceholderInt lerpOut;
private final PlaceholderInt priority;
private final PlaceholderDouble speed;
public StateToggleMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.state = mlc.getPlaceholderString(new String[]{"s", "state"}, null, new String[0]);
this.speed = mlc.getPlaceholderDouble(new String[]{"sp", "speed"}, "1", new String[0]);
this.lerpIn = mlc.getPlaceholderInteger(new String[]{"li", "lerpin"}, 0, new String[0]);
this.lerpOut = mlc.getPlaceholderInteger(new String[]{"lo", "lerpout"}, 0, new String[0]);
this.lerpCurveIn = mlc.getPlaceholderString(new String[]{"lci", "lerpcurvein"}, null, new String[0]);
this.lerpCurveOut = mlc.getPlaceholderString(new String[]{"lco", "lerpcurveout"}, null, new String[0]);
this.ignoreLerp = mlc.getBoolean(new String[]{"i", "ignorelerp"}, false);
this.force = mlc.getBoolean(new String[]{"f", "force"}, true);
this.priority = mlc.getPlaceholderInteger(new String[]{"p", "pr", "priority"}, 1, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String state = MythicUtils.getOrNullLowercase(this.state, meta, target);
if (state == null) {
return SkillResult.INVALID_CONFIG;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
MythicUtils.executeOptModelId(model, modelId, activeModel -> {
AnimationHandler handler = activeModel.getAnimationHandler();
if (handler instanceof IStateMachineHandler stateMachineHandler) {
if (stateMachineHandler.isPlayingAnimation(state)) {
this.removeAnimation(stateMachineHandler, state, meta, target);
} else {
this.addAnimation(stateMachineHandler, state, meta, target);
}
} else if (handler.isPlayingAnimation(state)) {
this.removeAnimation(handler, state);
} else {
this.addAnimation(handler, state, meta, target);
}
});
return SkillResult.SUCCESS;
}
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String state = MythicUtils.getOrNullLowercase(this.state, meta);
if (state == null) {
return SkillResult.INVALID_CONFIG;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
MythicUtils.executeOptModelId(model, modelId, activeModel -> {
AnimationHandler handler = activeModel.getAnimationHandler();
if (handler instanceof IStateMachineHandler stateMachineHandler) {
if (stateMachineHandler.isPlayingAnimation(state)) {
this.removeAnimation(stateMachineHandler, state, meta, null);
} else {
this.addAnimation(stateMachineHandler, state, meta, null);
}
} else if (handler.isPlayingAnimation(state)) {
this.removeAnimation(handler, state);
} else {
this.addAnimation(handler, state, meta, null);
}
});
return SkillResult.SUCCESS;
}
}
}
private void removeAnimation(AnimationHandler handler, String state) {
if (this.ignoreLerp) {
handler.forceStopAnimation(state);
} else {
handler.stopAnimation(state);
}
}
private void removeAnimation(IStateMachineHandler handler, String state, SkillMetadata meta, AbstractEntity target) {
int priority = this.priority.get(meta, target);
if (this.ignoreLerp) {
handler.forceStopAnimation(priority, state);
} else {
handler.stopAnimation(priority, state);
}
}
private void addAnimation(AnimationHandler handler, String state, SkillMetadata meta, AbstractEntity target) {
int lerpIn = this.lerpIn.get(meta, target);
int lerpOut = this.lerpOut.get(meta, target);
double speed = this.speed.get(meta, target);
this.configProperty(handler.playAnimation(state, lerpIn * 0.05, lerpOut * 0.05, speed, this.force), meta, target);
}
private void addAnimation(IStateMachineHandler handler, String state, SkillMetadata meta, AbstractEntity target) {
int lerpIn = this.lerpIn.get(meta, target);
int lerpOut = this.lerpOut.get(meta, target);
double speed = this.speed.get(meta, target);
int priority = this.priority.get(meta, target);
this.configProperty(handler.playAnimation(priority, state, lerpIn * 0.05, lerpOut * 0.05, speed, this.force), meta, target);
}
private void configProperty(IAnimationProperty property, SkillMetadata meta, AbstractEntity target) {
if (property != null) {
Easing curveIn = Easing.getOrNull(MythicUtils.getOrNull(this.lerpCurveIn, meta, target));
if (curveIn != null) {
property.setLerpCurveIn(curveIn);
}
Easing curveOut = Easing.getOrNull(MythicUtils.getOrNull(this.lerpCurveOut, meta, target));
if (curveOut != null) {
property.setLerpCurveOut(curveOut);
}
}
}
}
@@ -0,0 +1,109 @@
package com.ticxo.modelengine.core21.mythic.mechanics.model;
import com.ticxo.modelengine.api.generator.blueprint.BlueprintBone;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
@MythicMechanic(
name = "submodel",
aliases = {}
)
public class SubModelMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString parentId;
private final PlaceholderString childId;
private final PlaceholderString prefix;
private final boolean remove;
public SubModelMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.parentId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, null, new String[0]);
this.childId = mlc.getPlaceholderString(new String[]{"sp", "spid", "subpart", "subpartid"}, null, new String[0]);
this.prefix = mlc.getPlaceholderString(new String[]{"pfx", "prefix"}, "", new String[0]);
this.remove = mlc.getBoolean(new String[]{"r", "remove"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, target.getUniqueId());
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
ActiveModel activeModel = MythicUtils.getActiveModelOrNull(model, modelId);
if (activeModel == null) {
return SkillResult.CONDITION_FAILED;
} else {
String childId = MythicUtils.getOrNullLowercase(this.childId, meta, target);
if (childId == null) {
return SkillResult.INVALID_CONFIG;
} else {
if (this.remove) {
activeModel.getBone(childId).ifPresent(ModelBone::destroy);
} else {
String parentId = MythicUtils.getOrNullLowercase(this.parentId, meta, target);
String prefix = MythicUtils.getOrNullLowercase(this.prefix, meta, target);
BlueprintBone childBone = activeModel.getBlueprint().getFlatMap().get(childId);
if (childBone == null) {
return SkillResult.INVALID_CONFIG;
}
activeModel.forceGenerateBone(parentId, prefix, childBone);
}
return SkillResult.SUCCESS;
}
}
}
}
public SkillResult cast(SkillMetadata meta) {
Optional<ModeledEntity> maybeModel = MythicUtils.findSkillableModel(meta, null);
if (maybeModel.isEmpty()) {
return SkillResult.CONDITION_FAILED;
} else {
ModeledEntity model = maybeModel.get();
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
ActiveModel activeModel = MythicUtils.getActiveModelOrNull(model, modelId);
if (activeModel == null) {
return SkillResult.CONDITION_FAILED;
} else {
String childId = MythicUtils.getOrNullLowercase(this.childId, meta);
if (childId == null) {
return SkillResult.INVALID_CONFIG;
} else {
if (this.remove) {
activeModel.getBone(childId).ifPresent(ModelBone::destroy);
} else {
String parentId = MythicUtils.getOrNullLowercase(this.parentId, meta);
String prefix = MythicUtils.getOrNullLowercase(this.prefix, meta);
BlueprintBone childBone = activeModel.getBlueprint().getFlatMap().get(childId);
if (childBone == null) {
return SkillResult.INVALID_CONFIG;
}
activeModel.forceGenerateBone(parentId, prefix, childBone);
}
return SkillResult.SUCCESS;
}
}
}
}
}
@@ -0,0 +1,75 @@
package com.ticxo.modelengine.core21.mythic.mechanics.model;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
@MythicMechanic(
name = "swapentity",
aliases = {}
)
public class SwapEntityMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final boolean hitbox;
private final boolean invisible;
private final PlaceholderDouble stepHeight;
private final PlaceholderInt viewRadius;
public SwapEntityMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.hitbox = mlc.getBoolean(new String[]{"h", "hitbox"}, true);
this.invisible = mlc.getBoolean(new String[]{"i", "invis", "invisible"}, true);
this.stepHeight = mlc.getPlaceholderDouble(new String[]{"s", "step"}, "0.5", new String[0]);
this.viewRadius = mlc.getPlaceholderInteger(new String[]{"rad", "radius"}, 0, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
AbstractEntity caster = meta.getCaster().getEntity();
ModeledEntity casterModel = ModelEngineAPI.getModeledEntity(caster.getUniqueId());
if (casterModel == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
if (modelId == null) {
return SkillResult.INVALID_CONFIG;
} else if (!casterModel.getModels().containsKey(modelId)) {
return SkillResult.INVALID_CONFIG;
} else {
ModeledEntity targetModel = ModelEngineAPI.getOrCreateModeledEntity(target.getBukkitEntity());
if (targetModel.getModel(modelId).isPresent()) {
return SkillResult.CONDITION_FAILED;
} else {
double stepHeight = this.stepHeight.get(meta, target);
int viewRadius = this.viewRadius.get(meta, target);
Optional<ActiveModel> maybeModel = casterModel.removeModel(modelId);
maybeModel.ifPresent(activeModel -> {
targetModel.setBaseEntityVisible(!this.invisible);
targetModel.getBase().setMaxStepHeight(stepHeight);
if (viewRadius > 0) {
targetModel.getBase().setRenderRadius(viewRadius);
}
targetModel.addModel(activeModel, this.hitbox).ifPresent(ActiveModel::destroy);
});
return SkillResult.SUCCESS;
}
}
}
}
}
@@ -0,0 +1,67 @@
package com.ticxo.modelengine.core21.mythic.mechanics.mounting;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.ServerInfo;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.manager.MountManager;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
@MythicMechanic(
name = "dismountallmodel",
aliases = {"dismountall"}
)
public class DismountAllMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final PlaceholderString pBone;
public DismountAllMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.pBone = mlc.getPlaceholderString(new String[]{"p", "pbone", "seat"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
if (ServerInfo.scheduleOnRegion(target.getBukkitEntity(), () -> this.castAtEntity(meta, target))) {
return SkillResult.SUCCESS;
} else {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
if (modelId == null) {
return SkillResult.INVALID_CONFIG;
} else {
this.dismountLogic(meta, target, modelId);
return SkillResult.SUCCESS;
}
}
}
}
private void dismountLogic(SkillMetadata meta, AbstractEntity target, String modelId) {
ModelEngineAPI.getModeledEntity(target.getUniqueId())
.getModel(modelId)
.ifPresent(activeModel -> activeModel.getMountManager().ifPresent(mountManager -> {
String parts = MythicUtils.getOrNullLowercase(this.pBone, meta, target);
if (parts != null) {
for (String seat : parts.split(",")) {
((MountManager)mountManager).dismountPassengers(seat);
}
} else {
((MountManager)mountManager).dismountAll();
}
}));
}
}
@@ -0,0 +1,86 @@
package com.ticxo.modelengine.core21.mythic.mechanics.mounting;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.ServerInfo;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.manager.MountData;
import com.ticxo.modelengine.api.model.bone.manager.MountManager;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.Optional;
import org.bukkit.entity.Entity;
@MythicMechanic(
name = "dismountmodel",
aliases = {}
)
public class DismountModelMechanic implements ITargetedEntitySkill {
private final boolean driver;
private PlaceholderString modelId;
private PlaceholderString pBone;
public DismountModelMechanic(MythicLineConfig mlc) {
this.driver = mlc.getBoolean(new String[]{"d", "drive", "driver"}, true);
if (!this.driver) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.pBone = mlc.getPlaceholderString(new String[]{"p", "pbone", "seat"}, null, new String[0]);
}
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
if (ServerInfo.scheduleOnRegion(target.getBukkitEntity(), () -> this.castAtEntity(meta, target))) {
return SkillResult.SUCCESS;
} else {
ModeledEntity model = ModelEngineAPI.getModeledEntity(meta.getCaster().getEntity().getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else if (this.driver) {
((MountManager)((MountData)model.getMountData()).getMainMountManager()).dismountDriver();
return SkillResult.SUCCESS;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
model.getModel(modelId).ifPresent(activeModel -> activeModel.getMountManager().ifPresent(mountManager -> {
Entity entity = target.getBukkitEntity();
String part = MythicUtils.getOrNullLowercase(this.pBone, meta, target);
if (part == null) {
((MountManager)mountManager).dismountRider(entity);
} else {
String[] seats = part.split(",");
Optional maybeMount = ((MountManager)mountManager).getMount(entity);
maybeMount.ifPresent(mount -> {
if (this.contains(((com.ticxo.modelengine.api.model.bone.behavior.BoneBehavior)mount).getBone().getUniqueBoneId(), seats)) {
((MountManager)mountManager).dismountRider(entity);
}
});
}
}));
return SkillResult.SUCCESS;
}
}
}
public boolean getTargetsCreatives() {
return true;
}
private boolean contains(String seat, String... seats) {
for (String s : seats) {
if (seat.equals(s)) {
return true;
}
}
return false;
}
}
@@ -0,0 +1,179 @@
package com.ticxo.modelengine.core21.mythic.mechanics.mounting;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.ServerInfo;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.behavior.GlobalBehaviorData;
import com.ticxo.modelengine.api.model.bone.manager.BehaviorManager;
import com.ticxo.modelengine.api.model.bone.manager.MountData;
import com.ticxo.modelengine.api.model.bone.manager.MountManager;
import com.ticxo.modelengine.api.mount.controller.MountControllerSupplier;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.packs.Pack;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.Skill;
import io.lumine.mythic.api.skills.SkillHolder;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.bukkit.events.MythicMechanicLoadEvent;
import io.lumine.mythic.core.skills.SkillExecutor;
import java.io.File;
import java.util.List;
import java.util.Optional;
@MythicMechanic(
name = "mountmodel",
aliases = {}
)
public class MountModelMechanic implements ITargetedEntitySkill, SkillHolder {
private final boolean isDriver;
private final boolean force;
private final boolean autoDismount;
private final boolean canDamageMount;
private final boolean canInteractMount;
private final PlaceholderString mode;
private final PlaceholderString modelId;
private Skill controllerSkill;
private PlaceholderString pbone;
public MountModelMechanic(MythicMechanicLoadEvent event) {
File file = event.getContainer().getFile();
SkillExecutor manager = event.getContainer().getManager();
MythicLineConfig mlc = event.getConfig();
this.isDriver = mlc.getBoolean(new String[]{"d", "drive", "driver"}, true);
this.force = mlc.getBoolean(new String[]{"f", "force"}, false);
this.autoDismount = mlc.getBoolean(new String[]{"ad", "autodismount"}, false);
this.canDamageMount = mlc.getBoolean(new String[]{"dmg", "damagemount"}, false);
this.canInteractMount = mlc.getBoolean(new String[]{"int", "interactmount"}, false);
this.mode = mlc.getPlaceholderString(new String[]{"m", "mode"}, "walking", new String[0]);
this.modelId = mlc.getPlaceholderString(new String[]{"mid", "model", "modelid"}, null, new String[0]);
if (!this.isDriver) {
this.pbone = mlc.getPlaceholderString(new String[]{"p", "pbone", "seat"}, null, new String[0]);
}
manager.queueSecondPass(() -> manager.getSkill(file, this, this.mode.serialize()).ifPresent(skill -> {
this.controllerSkill = skill;
if (this.controllerSkill.isInlineSkill()) {
this.controllerSkill.addParent(this);
}
}));
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
if (ServerInfo.scheduleOnRegion(target.getBukkitEntity(), () -> this.castAtEntity(meta, target))) {
return SkillResult.SUCCESS;
} else {
AbstractEntity caster = meta.getCaster().getEntity();
ModeledEntity model = ModelEngineAPI.getModeledEntity(caster.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String controllerId = MythicUtils.getOrNullLowercase(this.mode, meta, target);
MountControllerSupplier controllerType = this.controllerSkill != null
? MythicUtils.createControllerSupplier(this.controllerSkill, meta)
: ModelEngineAPI.getMountControllerTypeRegistry().get(controllerId);
if (this.isDriver) {
GlobalBehaviorData mountData = model.getMountData();
BehaviorManager mountManager = ((MountData)mountData).getMainMountManager();
if (mountManager == null) {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
Optional<ActiveModel> maybeModel = model.getModel(modelId);
if (maybeModel.isPresent()) {
Optional maybeManager = maybeModel.get().getMountManager();
if (maybeManager.isPresent()) {
mountManager = (BehaviorManager)maybeManager.get();
}
}
}
if (mountManager == null) {
return SkillResult.CONDITION_FAILED;
}
if (!((MountManager)mountManager).canDrive()) {
return SkillResult.CONDITION_FAILED;
}
if (!this.force && ((MountManager)mountManager).isControlled()) {
return SkillResult.CONDITION_FAILED;
}
if (this.tryDismountOld(target)) {
((MountManager)mountManager).dismountDriver();
((MountManager)mountManager).mountDriver(target.getBukkitEntity(), controllerType, mountController -> {
mountController.setCanDamageMount(this.canDamageMount);
mountController.setCanInteractMount(this.canInteractMount);
});
}
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
String pbone = MythicUtils.getOrNullLowercase(this.pbone, meta, target);
if (modelId == null || pbone == null) {
return SkillResult.INVALID_CONFIG;
}
List<String> seats = List.of(pbone.split(","));
model.getModel(modelId).ifPresent(activeModel -> activeModel.getMountManager().ifPresent(mountManagerx -> {
if (((MountManager)mountManagerx).canRide()) {
if (this.tryDismountOld(target)) {
if (this.force) {
((MountManager)mountManagerx).mountLeastOccupied(target.getBukkitEntity(), seats, controllerType, mountController -> {
mountController.setCanDamageMount(this.canDamageMount);
mountController.setCanInteractMount(this.canInteractMount);
});
} else {
((MountManager)mountManagerx).mountAvailable(target.getBukkitEntity(), seats, controllerType, mountController -> {
mountController.setCanDamageMount(this.canDamageMount);
mountController.setCanInteractMount(this.canInteractMount);
});
}
}
}
}));
}
return SkillResult.SUCCESS;
}
}
}
private boolean tryDismountOld(AbstractEntity target) {
ActiveModel model = ModelEngineAPI.getMountPairManager().getMountedPair(target.getUniqueId());
if (model == null) {
return true;
} else if (this.autoDismount) {
Optional maybeManager = model.getMountManager();
if (maybeManager.isEmpty()) {
return false;
} else {
BehaviorManager mountManager = (BehaviorManager)maybeManager.get();
((MountManager)mountManager).dismountRider(target.getBukkitEntity());
return true;
}
} else {
return false;
}
}
public boolean getTargetsCreatives() {
return true;
}
public String getInternalName() {
return "Unknown/mountModel";
}
public Pack getPack() {
return null;
}
}
@@ -0,0 +1,105 @@
package com.ticxo.modelengine.core21.mythic.mechanics.nametag;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes;
import com.ticxo.modelengine.api.model.bone.type.NameTag;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.adapters.AbstractVector;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.api.skills.placeholders.PlaceholderVector;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.entity.Display.Billboard;
import org.bukkit.entity.TextDisplay.TextAlignment;
@MythicMechanic(
name = "setmodeltag",
aliases = {}
)
public class SetNametagMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final PlaceholderString tag;
private final boolean visible;
private final Integer backgroundColor;
private final boolean useDefaultBackgroundColor;
private final TextAlignment alignment;
private final Billboard billboard;
private final PlaceholderVector scale;
private final boolean seeThrough;
private final byte textOpacity;
private final boolean shadow;
private final int lineWidth;
public SetNametagMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"b", "bone", "p", "pid", "part", "partid"}, null, new String[0]);
this.tag = mlc.getPlaceholderString(new String[]{"t", "tag"}, null, new String[0]);
this.visible = mlc.getBoolean(new String[]{"v", "visible"}, true);
this.backgroundColor = mlc.getInteger(new String[]{"background", "backgroundcolor"}, 0);
this.useDefaultBackgroundColor = mlc.getBoolean(new String[]{"usedefaultbackground", "defaultbackground", "db"}, true);
this.alignment = (TextAlignment)mlc.getEnum(new String[]{"align", "alignment"}, TextAlignment.class, TextAlignment.CENTER);
this.billboard = (Billboard)mlc.getEnum(new String[]{"billboard"}, Billboard.class, Billboard.CENTER);
this.scale = mlc.getPlaceholderVector(new String[]{"scale"}, "1,1,1");
this.seeThrough = mlc.getBoolean(new String[]{"seethrough"}, true);
this.textOpacity = (byte)mlc.getInteger(new String[]{"opacity", "textopacity"}, -1);
this.shadow = mlc.getBoolean(new String[]{"shadow"}, false);
this.lineWidth = mlc.getInteger(new String[]{"linewidth"}, 200);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
model.getModel(modelId)
.ifPresent(
activeModel -> {
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
activeModel.getBone(partId)
.flatMap(modelBone -> modelBone.getBoneBehavior(BoneBehaviorTypes.NAMETAG))
.ifPresent(
nameTag -> {
((NameTag)nameTag)
.setComponentSupplier(
this.tag == null
? null
: () -> {
String raw = this.tag.get(meta, target);
return (Component)(raw.indexOf(167) >= 0
? LegacyComponentSerializer.legacySection().deserialize(raw)
: MiniMessage.miniMessage().deserialize(raw));
}
);
((NameTag)nameTag).setVisible(this.visible);
((NameTag)nameTag).setBackgroundColor(this.backgroundColor);
((NameTag)nameTag).setUseDefaultBackgroundColor(this.useDefaultBackgroundColor);
((NameTag)nameTag).setAlignment(this.alignment);
((NameTag)nameTag).setBillboard(this.billboard);
((NameTag)nameTag).setScale(((AbstractVector)this.scale.get()).toVector3f());
((NameTag)nameTag).setSeeThrough(this.seeThrough);
((NameTag)nameTag).setTextOpacity(this.textOpacity);
((NameTag)nameTag).setShadow(this.shadow);
((NameTag)nameTag).setLineWidth(this.lineWidth);
}
);
}
);
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,54 @@
package com.ticxo.modelengine.core21.mythic.mechanics.nametag;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.BoneBehaviorTypes;
import com.ticxo.modelengine.api.model.bone.type.NameTag;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
@MythicMechanic(
name = "setmodeltagvisible",
aliases = {}
)
public class SetNametagVisibilityMechanic implements ITargetedEntitySkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final boolean visible;
public SetNametagVisibilityMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"b", "bone", "p", "pid", "part", "partid"}, null, new String[0]);
this.visible = mlc.getBoolean(new String[]{"v", "visible"}, true);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
ModeledEntity model = ModelEngineAPI.getModeledEntity(target.getUniqueId());
if (model == null) {
return SkillResult.CONDITION_FAILED;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
model.getModel(modelId)
.ifPresent(
activeModel -> {
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
activeModel.getBone(partId)
.flatMap(modelBone -> modelBone.getBoneBehavior(BoneBehaviorTypes.NAMETAG))
.ifPresent(nameTag -> ((NameTag)nameTag).setVisible(this.visible));
}
);
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,56 @@
package com.ticxo.modelengine.core21.mythic.mechanics.vfx;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.vfx.VFX;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import java.util.UUID;
@MythicMechanic(
name = "vfxbrightness",
aliases = {"vfxlight"}
)
public class VFXBrightnessMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderInt blockLight;
private final PlaceholderInt skyLight;
public VFXBrightnessMechanic(MythicLineConfig mlc) {
this.blockLight = mlc.getPlaceholderInteger(new String[]{"block", "b"}, -1, new String[0]);
this.skyLight = mlc.getPlaceholderInteger(new String[]{"sky", "s"}, -1, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
VFX vfx = ModelEngineAPI.getVFX(target.getBukkitEntity());
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.setBlockLight(this.blockLight.get(meta, target));
vfx.setSkyLight(this.skyLight.get(meta, target));
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
UUID uuid = MythicUtils.getVFXUniqueId(meta);
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(uuid);
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.setBlockLight(this.blockLight.get(meta));
vfx.setSkyLight(this.skyLight.get(meta));
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,66 @@
package com.ticxo.modelengine.core21.mythic.mechanics.vfx;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.vfx.VFX;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.UUID;
@MythicMechanic(
name = "vfxchangemodel",
aliases = {}
)
public class VFXChangeModelMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
public VFXChangeModelMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, null, new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
if (modelId != null && partId != null) {
VFX vfx = ModelEngineAPI.getVFX(target.getBukkitEntity());
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.useModel(modelId, partId);
return SkillResult.SUCCESS;
}
} else {
return SkillResult.INVALID_CONFIG;
}
}
public SkillResult cast(SkillMetadata meta) {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
String partId = MythicUtils.getOrNullLowercase(this.partId, meta);
if (modelId != null && partId != null) {
UUID uuid = MythicUtils.getVFXUniqueId(meta);
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(uuid);
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.useModel(modelId, partId);
return SkillResult.SUCCESS;
}
} else {
return SkillResult.INVALID_CONFIG;
}
}
}
@@ -0,0 +1,51 @@
package com.ticxo.modelengine.core21.mythic.mechanics.vfx;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.vfx.VFX;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import java.util.UUID;
@MythicMechanic(
name = "vfxenchant",
aliases = {}
)
public class VFXEnchantMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final boolean enchant;
public VFXEnchantMechanic(MythicLineConfig mlc) {
this.enchant = mlc.getBoolean(new String[]{"e", "en", "enchant"}, true);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
VFX vfx = ModelEngineAPI.getVFX(target.getBukkitEntity());
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.setEnchanted(this.enchant);
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
UUID uuid = MythicUtils.getVFXUniqueId(meta);
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(uuid);
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.setEnchanted(this.enchant);
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,128 @@
package com.ticxo.modelengine.core21.mythic.mechanics.vfx;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.ServerInfo;
import com.ticxo.modelengine.api.nms.entity.wrapper.BodyRotationController;
import com.ticxo.modelengine.api.vfx.VFX;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.compatibility.ProjectileEntity;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.core.skills.projectiles.ProjectileBulletableTracker;
import java.util.UUID;
import org.bukkit.Color;
@MythicMechanic(
name = "vfx",
aliases = {}
)
public class VFXMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final boolean remove;
private final PlaceholderInt radius;
private final PlaceholderString color;
private final boolean enchant;
private final boolean visible;
private final boolean baseVisible;
public VFXMechanic(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, null, new String[0]);
this.remove = mlc.getBoolean(new String[]{"r", "remove"}, false);
this.radius = mlc.getPlaceholderInteger(new String[]{"rad", "radius"}, 0, new String[0]);
this.color = mlc.getPlaceholderString(new String[]{"c", "color"}, "FFFFFF", new String[0]);
this.enchant = mlc.getBoolean(new String[]{"en", "enchant"}, false);
this.visible = mlc.getBoolean(new String[]{"v", "visible"}, true);
this.baseVisible = mlc.getBoolean(new String[]{"bv", "bvisible"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
if (ServerInfo.scheduleOnRegion(target.getBukkitEntity(), () -> this.castAtEntity(meta, target))) {
return SkillResult.SUCCESS;
} else if (this.remove) {
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(target.getUniqueId());
if (vfx == null) {
return SkillResult.CONDITION_FAILED;
} else {
vfx.markRemoved();
return SkillResult.SUCCESS;
}
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta, target);
String partId = MythicUtils.getOrNullLowercase(this.partId, meta, target);
if (modelId != null && partId != null) {
int radius = this.radius.get(meta, target);
Color color = MythicUtils.getColor(MythicUtils.getOrNull(this.color, meta, target));
ModelEngineAPI.createVFX(target.getBukkitEntity(), vfx -> {
BodyRotationController brc = vfx.getBase().getBodyRotationController();
brc.setYBodyRot(brc.getYHeadRot());
vfx.useModel(modelId, partId);
if (radius > 0) {
vfx.getBase().setRenderRadius(radius);
}
vfx.setColor(color);
vfx.setEnchanted(this.enchant);
vfx.setVisible(this.visible);
vfx.setBaseEntityVisible(this.baseVisible);
});
return SkillResult.SUCCESS;
} else {
return SkillResult.INVALID_CONFIG;
}
}
}
public SkillResult cast(SkillMetadata meta) {
if (meta.getCallingEvent() instanceof ProjectileBulletableTracker projectileTracker) {
if (this.remove) {
UUID uuid = MythicUtils.getVFXUniqueId(meta);
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(uuid);
if (vfx == null) {
return SkillResult.CONDITION_FAILED;
} else {
vfx.markRemoved();
return SkillResult.SUCCESS;
}
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, meta);
String partId = MythicUtils.getOrNullLowercase(this.partId, meta);
if (modelId != null && partId != null) {
int radius = this.radius.get(meta);
Color color = MythicUtils.getColor(MythicUtils.getOrNull(this.color, meta));
MythicUtils.castProjectileEntity(projectileTracker).ifPresent(tracker -> ModelEngineAPI.createVFX(new ProjectileEntity(tracker), vfx -> {
BodyRotationController brc = vfx.getBase().getBodyRotationController();
brc.setYBodyRot(brc.getYHeadRot());
vfx.useModel(modelId, partId);
if (radius > 0) {
vfx.getBase().setRenderRadius(radius);
}
vfx.setColor(color);
vfx.setEnchanted(this.enchant);
vfx.setVisible(this.visible);
vfx.setBaseEntityVisible(this.baseVisible);
}));
return SkillResult.SUCCESS;
} else {
return SkillResult.INVALID_CONFIG;
}
}
} else {
return SkillResult.INVALID_TARGET;
}
}
}
@@ -0,0 +1,45 @@
package com.ticxo.modelengine.core21.mythic.mechanics.vfx;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.vfx.VFX;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import java.util.UUID;
import org.joml.Vector3f;
@MythicMechanic(
name = "vfxposreset",
aliases = {}
)
public class VFXResetPositionMechanic implements ITargetedEntitySkill, INoTargetSkill {
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
VFX vfx = ModelEngineAPI.getVFX(target.getBukkitEntity());
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.setPosition(new Vector3f());
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
UUID uuid = MythicUtils.getVFXUniqueId(meta);
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(uuid);
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.setPosition(new Vector3f());
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,45 @@
package com.ticxo.modelengine.core21.mythic.mechanics.vfx;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.vfx.VFX;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import java.util.UUID;
import org.joml.Vector3f;
@MythicMechanic(
name = "vfxrotreset",
aliases = {}
)
public class VFXResetRotationMechanic implements ITargetedEntitySkill, INoTargetSkill {
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
VFX vfx = ModelEngineAPI.getVFX(target.getBukkitEntity());
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.setRotation(new Vector3f());
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
UUID uuid = MythicUtils.getVFXUniqueId(meta);
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(uuid);
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.setRotation(new Vector3f());
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,45 @@
package com.ticxo.modelengine.core21.mythic.mechanics.vfx;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.vfx.VFX;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import java.util.UUID;
import org.joml.Vector3f;
@MythicMechanic(
name = "vfxscalereset",
aliases = {"vfxsclreset", "vfxscareset"}
)
public class VFXResetScaleMechanic implements ITargetedEntitySkill, INoTargetSkill {
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
VFX vfx = ModelEngineAPI.getVFX(target.getBukkitEntity());
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.setScale(new Vector3f(1.0F));
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
UUID uuid = MythicUtils.getVFXUniqueId(meta);
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(uuid);
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.setScale(new Vector3f(1.0F));
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,87 @@
package com.ticxo.modelengine.core21.mythic.mechanics.vfx;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.utils.logger.TLogger;
import com.ticxo.modelengine.api.vfx.VFX;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import java.util.UUID;
import org.joml.Vector3f;
@MythicMechanic(
name = "vfxpos",
aliases = {}
)
public class VFXSetPositionMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final boolean relative;
private PlaceholderDouble x;
private PlaceholderDouble y;
private PlaceholderDouble z;
public VFXSetPositionMechanic(MythicLineConfig mlc) {
String coords = mlc.getString(new String[]{"p", "pos", "position"}, null, new String[0]);
if (coords != null) {
String[] split = coords.split(",");
try {
this.x = PlaceholderDouble.of(split[0]);
this.y = PlaceholderDouble.of(split[1]);
this.z = PlaceholderDouble.of(split[2]);
} catch (Exception var5) {
TLogger.error("The 'position' attribute must be in the format p=x,y,z.");
this.x = PlaceholderDouble.of("0");
this.y = PlaceholderDouble.of("0");
this.z = PlaceholderDouble.of("0");
}
} else {
this.x = mlc.getPlaceholderDouble("x", "0");
this.y = mlc.getPlaceholderDouble("y", "0");
this.z = mlc.getPlaceholderDouble("z", "0");
}
this.relative = mlc.getBoolean(new String[]{"r", "rel", "relative"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
VFX vfx = ModelEngineAPI.getVFX(target.getBukkitEntity());
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
if (this.relative) {
vfx.getPosition().add((float)this.x.get(meta, target), (float)this.y.get(meta, target), (float)this.z.get(meta, target));
} else {
vfx.setPosition(new Vector3f((float)this.x.get(meta, target), (float)this.y.get(meta, target), (float)this.z.get(meta, target)));
}
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
UUID uuid = MythicUtils.getVFXUniqueId(meta);
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(uuid);
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
if (this.relative) {
vfx.getPosition().add((float)this.x.get(meta), (float)this.y.get(meta), (float)this.z.get(meta));
} else {
vfx.setPosition(new Vector3f((float)this.x.get(meta), (float)this.y.get(meta), (float)this.z.get(meta)));
}
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,131 @@
package com.ticxo.modelengine.core21.mythic.mechanics.vfx;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.utils.logger.TLogger;
import com.ticxo.modelengine.api.utils.math.TMath;
import com.ticxo.modelengine.api.vfx.VFX;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import java.util.UUID;
import org.joml.Quaternionf;
import org.joml.Vector3f;
@MythicMechanic(
name = "vfxrot",
aliases = {}
)
public class VFXSetRotationMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final boolean relative;
private final boolean newOrigin;
private PlaceholderDouble x;
private PlaceholderDouble y;
private PlaceholderDouble z;
public VFXSetRotationMechanic(MythicLineConfig mlc) {
String coords = mlc.getString(new String[]{"r", "rot", "rotation"}, null, new String[0]);
if (coords != null) {
String[] split = coords.split(",");
try {
this.x = PlaceholderDouble.of(split[0]);
this.y = PlaceholderDouble.of(split[1]);
this.z = PlaceholderDouble.of(split[2]);
} catch (Exception var5) {
TLogger.error("The 'rotation' attribute must be in the format r=x,y,z.");
this.x = PlaceholderDouble.of("0");
this.y = PlaceholderDouble.of("0");
this.z = PlaceholderDouble.of("0");
}
} else {
this.x = mlc.getPlaceholderDouble("x", "0");
this.y = mlc.getPlaceholderDouble("y", "0");
this.z = mlc.getPlaceholderDouble("z", "0");
}
this.relative = mlc.getBoolean(new String[]{"rel", "relative"}, false);
this.newOrigin = mlc.getBoolean(new String[]{"neworigin", "origin", "o"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
VFX vfx = ModelEngineAPI.getVFX(target.getBukkitEntity());
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
if (this.relative) {
Vector3f r = vfx.getRotation();
Quaternionf original = new Quaternionf().rotationZYX(r.z, r.y, r.x);
Quaternionf delta = new Quaternionf()
.rotationZYX(
(float)this.z.get(meta, target) * (float) (Math.PI / 180.0),
(float)this.y.get(meta, target) * (float) (Math.PI / 180.0),
(float)this.x.get(meta, target) * (float) (Math.PI / 180.0)
);
if (this.newOrigin) {
original.mul(delta);
TMath.getEulerAnglesZYX(original, r);
} else {
delta.mul(original);
TMath.getEulerAnglesZYX(delta, r);
}
} else {
vfx.setRotation(
new Vector3f(
(float)this.x.get(meta, target) * (float) (Math.PI / 180.0),
(float)this.y.get(meta, target) * (float) (Math.PI / 180.0),
(float)this.z.get(meta, target) * (float) (Math.PI / 180.0)
)
);
}
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
UUID uuid = MythicUtils.getVFXUniqueId(meta);
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(uuid);
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
if (this.relative) {
Vector3f r = vfx.getRotation();
Quaternionf original = new Quaternionf().rotationZYX(r.z, r.y, r.x);
Quaternionf delta = new Quaternionf()
.rotationZYX(
(float)this.z.get(meta) * (float) (Math.PI / 180.0),
(float)this.y.get(meta) * (float) (Math.PI / 180.0),
(float)this.x.get(meta) * (float) (Math.PI / 180.0)
);
if (this.newOrigin) {
original.mul(delta);
TMath.getEulerAnglesZYX(original, r);
} else {
delta.mul(original);
TMath.getEulerAnglesZYX(delta, r);
}
} else {
vfx.setRotation(
new Vector3f(
(float)this.x.get(meta) * (float) (Math.PI / 180.0),
(float)this.y.get(meta) * (float) (Math.PI / 180.0),
(float)this.z.get(meta) * (float) (Math.PI / 180.0)
)
);
}
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,87 @@
package com.ticxo.modelengine.core21.mythic.mechanics.vfx;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.utils.logger.TLogger;
import com.ticxo.modelengine.api.vfx.VFX;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import java.util.UUID;
import org.joml.Vector3f;
@MythicMechanic(
name = "vfxscale",
aliases = {"vfxscl", "vfxsca"}
)
public class VFXSetScaleMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final boolean relative;
private PlaceholderDouble x;
private PlaceholderDouble y;
private PlaceholderDouble z;
public VFXSetScaleMechanic(MythicLineConfig mlc) {
String coords = mlc.getString(new String[]{"s", "sca", "scl", "scale"}, null, new String[0]);
if (coords != null) {
String[] split = coords.split(",");
try {
this.x = PlaceholderDouble.of(split[0]);
this.y = PlaceholderDouble.of(split[1]);
this.z = PlaceholderDouble.of(split[2]);
} catch (Exception var5) {
TLogger.error("The 'scale' attribute must be in the format s=x,y,z.");
this.x = PlaceholderDouble.of("0");
this.y = PlaceholderDouble.of("0");
this.z = PlaceholderDouble.of("0");
}
} else {
this.x = mlc.getPlaceholderDouble("x", "0");
this.y = mlc.getPlaceholderDouble("y", "0");
this.z = mlc.getPlaceholderDouble("z", "0");
}
this.relative = mlc.getBoolean(new String[]{"r", "rel", "relative"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
VFX vfx = ModelEngineAPI.getVFX(target.getBukkitEntity());
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
if (this.relative) {
vfx.getScale().add((float)this.x.get(meta, target), (float)this.y.get(meta, target), (float)this.z.get(meta, target));
} else {
vfx.setScale(new Vector3f((float)this.x.get(meta, target), (float)this.y.get(meta, target), (float)this.z.get(meta, target)));
}
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
UUID uuid = MythicUtils.getVFXUniqueId(meta);
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(uuid);
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
if (this.relative) {
vfx.getScale().add((float)this.x.get(meta), (float)this.y.get(meta), (float)this.z.get(meta));
} else {
vfx.setScale(new Vector3f((float)this.x.get(meta), (float)this.y.get(meta), (float)this.z.get(meta)));
}
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,51 @@
package com.ticxo.modelengine.core21.mythic.mechanics.vfx;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.vfx.VFX;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import java.util.UUID;
@MythicMechanic(
name = "vfxsetvis",
aliases = {}
)
public class VFXSetVisibilityMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final boolean vis;
public VFXSetVisibilityMechanic(MythicLineConfig mlc) {
this.vis = mlc.getBoolean(new String[]{"v", "visible"}, false);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
VFX vfx = ModelEngineAPI.getVFX(target.getBukkitEntity());
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.setVisible(this.vis);
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
UUID uuid = MythicUtils.getVFXUniqueId(meta);
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(uuid);
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
vfx.setVisible(this.vis);
return SkillResult.SUCCESS;
}
}
}
@@ -0,0 +1,129 @@
package com.ticxo.modelengine.core21.mythic.mechanics.vfx;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.entity.BukkitEntity;
import com.ticxo.modelengine.api.utils.scheduling.PlatformScheduler;
import com.ticxo.modelengine.api.utils.scheduling.PlatformTask;
import com.ticxo.modelengine.api.vfx.VFX;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicMechanic;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.INoTargetSkill;
import io.lumine.mythic.api.skills.ITargetedEntitySkill;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.SkillResult;
import io.lumine.mythic.api.skills.ThreadSafetyLevel;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import java.util.UUID;
import org.bukkit.Color;
@MythicMechanic(
name = "vfxtint",
aliases = {"vfxcolor"}
)
public class VFXTintMechanic implements ITargetedEntitySkill, INoTargetSkill {
private final PlaceholderInt duration;
private final PlaceholderString colorA;
private final PlaceholderString colorB;
public VFXTintMechanic(MythicLineConfig mlc) {
this.duration = mlc.getPlaceholderInteger(new String[]{"duration", "d"}, 0, new String[0]);
this.colorA = mlc.getPlaceholderString(new String[]{"c", "color", "ca", "colora"}, "FFFFFF", new String[0]);
this.colorB = mlc.getPlaceholderString(new String[]{"cb", "colorb"}, "FFFFFF", new String[0]);
}
public ThreadSafetyLevel getThreadSafetyLevel() {
return ThreadSafetyLevel.SYNC_ONLY;
}
public SkillResult castAtEntity(SkillMetadata meta, AbstractEntity target) {
VFX vfx = ModelEngineAPI.getVFX(target.getBukkitEntity());
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
int duration = this.duration.get(meta, target);
Color colorA = MythicUtils.getColor(MythicUtils.getOrNull(this.colorA, meta, target));
if (duration <= 0) {
vfx.setColor(colorA);
} else {
Color colorB = MythicUtils.getColor(MythicUtils.getOrNull(this.colorB, meta, target));
new VFXTintMechanic.Animator(vfx, duration, colorA, colorB);
}
return SkillResult.SUCCESS;
}
}
public SkillResult cast(SkillMetadata meta) {
UUID uuid = MythicUtils.getVFXUniqueId(meta);
VFX vfx = ModelEngineAPI.getAPI().getVFXUpdater().getVFX(uuid);
if (vfx == null) {
return SkillResult.INVALID_TARGET;
} else {
int duration = this.duration.get(meta);
Color colorA = MythicUtils.getColor(MythicUtils.getOrNull(this.colorA, meta));
if (duration <= 0) {
vfx.setColor(colorA);
} else {
Color colorB = MythicUtils.getColor(MythicUtils.getOrNull(this.colorB, meta));
new VFXTintMechanic.Animator(vfx, duration, colorA, colorB);
}
return SkillResult.SUCCESS;
}
}
private static class Animator implements Runnable {
private final VFX target;
private final double duration;
private final VFXTintMechanic.FloatColor colorA;
private final VFXTintMechanic.FloatColor colorB;
private final PlatformTask task;
private double iteration;
public Animator(VFX entity, int duration, Color colorA, Color colorB) {
this.duration = duration;
PlatformScheduler scheduler = ModelEngineAPI.getAPI().getScheduler();
if (entity.getBase() instanceof BukkitEntity bukkitEntity) {
this.task = scheduler.scheduleRepeating(ModelEngineAPI.getAPI(), bukkitEntity.getOriginal(), this, 0L, 1L);
} else {
this.task = scheduler.scheduleRepeating(ModelEngineAPI.getAPI(), this, 0L, 1L);
}
this.colorA = new VFXTintMechanic.FloatColor(colorA);
this.colorB = new VFXTintMechanic.FloatColor(colorB);
this.target = entity;
}
@Override
public void run() {
if (this.iteration > this.duration) {
this.task.cancel();
} else {
this.target.setColor(this.lerpColor(this.iteration / this.duration));
this.iteration++;
}
}
private Color lerpColor(double ratio) {
int r = (int)(Math.sqrt((1.0 - ratio) * this.colorA.r + ratio * this.colorB.r) * 255.0);
int g = (int)(Math.sqrt((1.0 - ratio) * this.colorA.g + ratio * this.colorB.g) * 255.0);
int b = (int)(Math.sqrt((1.0 - ratio) * this.colorA.b + ratio * this.colorB.b) * 255.0);
return Color.fromRGB(r, g, b);
}
}
private static class FloatColor {
protected final float r;
protected final float g;
protected final float b;
public FloatColor(Color color) {
this.r = color.getRed() * color.getRed() / 65025.0F;
this.g = color.getGreen() * color.getGreen() / 65025.0F;
this.b = color.getBlue() * color.getBlue() / 65025.0F;
}
}
}
@@ -0,0 +1,31 @@
package com.ticxo.modelengine.core21.mythic.placeholders;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.nms.entity.wrapper.BodyRotationController;
import io.lumine.mythic.api.skills.SkillCaster;
import io.lumine.mythic.core.skills.placeholders.PlaceholderContext;
import io.lumine.mythic.core.skills.placeholders.types.GenericPlaceholder;
import io.lumine.mythic.core.skills.placeholders.types.GenericPlaceholder.GenericPlaceholderArguments;
import io.lumine.mythic.core.skills.placeholders.types.GenericPlaceholderTypes.StringPlaceholder;
import io.lumine.mythic.core.utils.annotations.MythicPlaceholder;
@MythicPlaceholder(
placeholder = "caster.model.yaw"
)
public class CasterModelRotationPlaceholder extends GenericPlaceholder<String> implements StringPlaceholder {
public CasterModelRotationPlaceholder(GenericPlaceholderArguments arguments) {
super(arguments);
}
public String applyWithMetaKeywords(PlaceholderContext placeholderContext) {
SkillCaster caster = placeholderContext.meta().getCaster();
ModeledEntity model = ModelEngineAPI.getModeledEntity(caster.getEntity().getUniqueId());
if (model == null) {
return "[No Model]";
} else {
BodyRotationController controller = model.getBase().getBodyRotationController();
return String.valueOf(controller.getYBodyRot());
}
}
}
@@ -0,0 +1,37 @@
package com.ticxo.modelengine.core21.mythic.targeters;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.manager.BehaviorManager;
import com.ticxo.modelengine.api.model.bone.manager.MountData;
import com.ticxo.modelengine.api.model.bone.manager.MountManager;
import com.ticxo.modelengine.core21.mythic.utils.MythicTargeter;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.skills.SkillCaster;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.targeters.IEntityTargeter;
import io.lumine.mythic.bukkit.BukkitAdapter;
import java.util.Collection;
import java.util.HashSet;
@MythicTargeter(
name = "modeldriver",
aliases = {}
)
public class ModelDriverTargeter implements IEntityTargeter {
public Collection<AbstractEntity> getEntities(SkillMetadata skillMetadata) {
HashSet<AbstractEntity> targets = new HashSet<>();
SkillCaster caster = skillMetadata.getCaster();
ModeledEntity model = ModelEngineAPI.getModeledEntity(caster.getEntity().getUniqueId());
if (model == null) {
return targets;
} else {
BehaviorManager main = ((MountData)model.getMountData()).getMainMountManager();
if (((MountManager)main).isControlled()) {
targets.add(BukkitAdapter.adapt(((MountManager)main).getDriver()));
}
return targets;
}
}
}
@@ -0,0 +1,102 @@
package com.ticxo.modelengine.core21.mythic.targeters;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.ModelBone;
import com.ticxo.modelengine.api.utils.OffsetMode;
import com.ticxo.modelengine.api.utils.logger.TLogger;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicTargeter;
import io.lumine.mythic.api.adapters.AbstractLocation;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.SkillCaster;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.api.skills.targeters.ILocationTargeter;
import io.lumine.mythic.bukkit.BukkitAdapter;
import java.util.Collection;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map.Entry;
import org.joml.Vector3f;
@MythicTargeter(
name = "modelpart",
aliases = {}
)
public class ModelPartTargeter implements ILocationTargeter {
private final PlaceholderString modelId;
private final PlaceholderString partId;
private final PlaceholderString offset;
private final boolean exactMatch;
private final boolean scale;
private PlaceholderDouble x;
private PlaceholderDouble y;
private PlaceholderDouble z;
public ModelPartTargeter(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.partId = mlc.getPlaceholderString(new String[]{"p", "pid", "part", "partid"}, null, new String[0]);
this.offset = mlc.getPlaceholderString(new String[]{"o", "off", "offset"}, "LOCAL", new String[0]);
String coords = mlc.getString(new String[]{"location", "loc", "l", "coordinates", "c"}, null, new String[0]);
if (coords != null) {
String[] split = coords.split(",");
try {
this.x = PlaceholderDouble.of(split[0]);
this.y = PlaceholderDouble.of(split[1]);
this.z = PlaceholderDouble.of(split[2]);
} catch (Exception var5) {
TLogger.error("The 'coordinates' attribute must be in the format c=x,y,z.");
this.x = PlaceholderDouble.of("0");
this.y = PlaceholderDouble.of("0");
this.z = PlaceholderDouble.of("0");
}
} else {
this.x = mlc.getPlaceholderDouble("x", "0");
this.y = mlc.getPlaceholderDouble("y", "0");
this.z = mlc.getPlaceholderDouble("z", "0");
}
this.exactMatch = mlc.getBoolean(new String[]{"em", "exact", "match", "exactmatch"}, true);
this.scale = mlc.getBoolean(new String[]{"s", "sc", "scale"}, true);
}
public Collection<AbstractLocation> getLocations(SkillMetadata skillMetadata) {
HashSet<AbstractLocation> targets = new HashSet<>();
SkillCaster caster = skillMetadata.getCaster();
ModeledEntity model = ModelEngineAPI.getModeledEntity(caster.getEntity().getUniqueId());
if (model == null) {
return targets;
} else {
String modelId = MythicUtils.getOrNullLowercase(this.modelId, skillMetadata);
OffsetMode offsetMode = OffsetMode.get(this.offset.get(skillMetadata).toUpperCase(Locale.ENGLISH));
Vector3f offset = new Vector3f().set(this.x.get(skillMetadata), this.y.get(skillMetadata), this.z.get(skillMetadata));
model.getModel(modelId).ifPresentOrElse(activeModel -> {
String partId = MythicUtils.getOrNullLowercase(this.partId, skillMetadata);
if (this.exactMatch) {
activeModel.getBone(partId).ifPresent(modelBone -> targets.add(BukkitAdapter.adapt(modelBone.getLocation(offsetMode, offset, this.scale))));
} else {
for (Entry<String, ModelBone> entry : activeModel.getBones().entrySet()) {
if (entry.getKey().contains(partId)) {
targets.add(BukkitAdapter.adapt(entry.getValue().getLocation(offsetMode, offset, this.scale)));
}
}
}
}, () -> model.getModels().values().forEach(activeModel -> {
String partId = MythicUtils.getOrNullLowercase(this.partId, skillMetadata);
if (this.exactMatch) {
activeModel.getBone(partId).ifPresent(modelBone -> targets.add(BukkitAdapter.adapt(modelBone.getLocation(offsetMode, offset, this.scale))));
} else {
for (Entry<String, ModelBone> entry : activeModel.getBones().entrySet()) {
if (entry.getKey().contains(partId)) {
targets.add(BukkitAdapter.adapt(entry.getValue().getLocation(offsetMode, offset, this.scale)));
}
}
}
}));
return targets;
}
}
}
@@ -0,0 +1,72 @@
package com.ticxo.modelengine.core21.mythic.targeters;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.manager.MountManager;
import com.ticxo.modelengine.api.model.bone.type.Mount;
import com.ticxo.modelengine.core21.mythic.MythicUtils;
import com.ticxo.modelengine.core21.mythic.utils.MythicTargeter;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.SkillCaster;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.api.skills.targeters.IEntityTargeter;
import io.lumine.mythic.bukkit.BukkitAdapter;
import java.util.Collection;
import java.util.HashSet;
import org.bukkit.entity.Entity;
@MythicTargeter(
name = "modelpassengers",
aliases = {}
)
public class ModelPassengersTargeter implements IEntityTargeter {
private final PlaceholderString modelId;
private final PlaceholderString pbone;
public ModelPassengersTargeter(MythicLineConfig mlc) {
this.modelId = mlc.getPlaceholderString(new String[]{"m", "mid", "model", "modelid"}, null, new String[0]);
this.pbone = mlc.getPlaceholderString(new String[]{"p", "pbone", "seat"}, null, new String[0]);
}
public Collection<AbstractEntity> getEntities(SkillMetadata skillMetadata) {
HashSet<AbstractEntity> targets = new HashSet<>();
SkillCaster caster = skillMetadata.getCaster();
ModeledEntity model = ModelEngineAPI.getModeledEntity(caster.getEntity().getUniqueId());
if (model == null) {
return targets;
} else {
String parts = MythicUtils.getOrNullLowercase(this.pbone, skillMetadata);
if (parts == null) {
return targets;
} else {
String[] seats = parts.split(",");
String modelId = MythicUtils.getOrNullLowercase(this.modelId, skillMetadata);
model.getModel(modelId).ifPresentOrElse(activeModel -> activeModel.getMountManager().ifPresent(mountManager -> {
for (String seat : seats) {
((MountManager)mountManager).getSeat(seat).ifPresent(mount -> {
for (Entity passenger : ((Mount)mount).getPassengers()) {
targets.add(BukkitAdapter.adapt(passenger));
}
});
}
}), () -> {
for (ActiveModel activeModel : model.getModels().values()) {
activeModel.getMountManager().ifPresent(mountManager -> {
for (String seat : seats) {
((MountManager)mountManager).getSeat(seat).ifPresent(mount -> {
for (Entity passenger : ((Mount)mount).getPassengers()) {
targets.add(BukkitAdapter.adapt(passenger));
}
});
}
});
}
});
return targets;
}
}
}
}
@@ -0,0 +1,34 @@
package com.ticxo.modelengine.core21.mythic.targeters;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.entity.BaseEntity;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.core21.mythic.utils.MythicTargeter;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.skills.SkillCaster;
import io.lumine.mythic.api.skills.SkillMetadata;
import io.lumine.mythic.api.skills.targeters.IEntityTargeter;
import io.lumine.mythic.bukkit.BukkitAdapter;
import java.util.Collection;
import java.util.HashSet;
import org.bukkit.entity.Entity;
@MythicTargeter(
name = "mountedmodel",
aliases = {}
)
public class MountedModelTargeter implements IEntityTargeter {
public Collection<AbstractEntity> getEntities(SkillMetadata skillMetadata) {
HashSet<AbstractEntity> targets = new HashSet<>();
SkillCaster caster = skillMetadata.getCaster();
ActiveModel model = ModelEngineAPI.getMountPairManager().getMountedPair(caster.getEntity().getUniqueId());
if (model != null) {
BaseEntity<?> base = model.getModeledEntity().getBase();
if (base.getOriginal() instanceof Entity entity) {
targets.add(BukkitAdapter.adapt(entity));
}
}
return targets;
}
}
@@ -0,0 +1,233 @@
package com.ticxo.modelengine.core21.mythic.utils;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.ticxo.modelengine.api.ModelEngineAPI;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.ISkillMechanic;
import io.lumine.mythic.api.skills.conditions.ISkillCondition;
import io.lumine.mythic.api.skills.targeters.ISkillTargeter;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.bukkit.events.MythicConditionLoadEvent;
import io.lumine.mythic.bukkit.events.MythicMechanicLoadEvent;
import io.lumine.mythic.bukkit.events.MythicReloadedEvent;
import io.lumine.mythic.bukkit.events.MythicTargeterLoadEvent;
import io.lumine.mythic.bukkit.utils.Schedulers;
import io.lumine.mythic.core.logging.MythicLogger;
import io.lumine.mythic.core.skills.placeholders.Placeholder;
import io.lumine.mythic.core.utils.annotations.AnnotationUtil;
import io.lumine.mythic.core.utils.annotations.MythicPlaceholder;
import java.lang.reflect.Constructor;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class ModelEngineComponentRegistry implements Listener {
private final Map<String, Constructor<? extends ISkillMechanic>> mechanics = Maps.newConcurrentMap();
private final Map<String, Constructor<? extends ISkillCondition>> conditions = Maps.newConcurrentMap();
private final Map<String, Constructor<? extends ISkillTargeter>> targeters = Maps.newConcurrentMap();
private final Map<String, Class<? extends Placeholder>> placeholders = Maps.newConcurrentMap();
public ModelEngineComponentRegistry(JavaPlugin plugin, String packagePath) {
this(plugin, Lists.newArrayList(new String[]{packagePath}));
}
public ModelEngineComponentRegistry(JavaPlugin plugin, Collection<String> packages) {
for (String packagePath : packages) {
for (Class<?> clazz : AnnotationUtil.getAnnotatedClasses(plugin, packagePath, MythicMechanic.class)) {
try {
MythicMechanic annotation = clazz.getAnnotation(MythicMechanic.class);
String namespace = annotation.namespace();
String name = annotation.name();
String[] aliases = annotation.aliases();
if (ISkillMechanic.class.isAssignableFrom(clazz)) {
Constructor<ISkillMechanic> constructor;
try {
constructor = (Constructor<ISkillMechanic>)clazz.getConstructor(MythicLineConfig.class);
} catch (NoSuchMethodException var20) {
try {
constructor = (Constructor<ISkillMechanic>)clazz.getConstructor(MythicMechanicLoadEvent.class);
} catch (NoSuchMethodException var19) {
constructor = (Constructor<ISkillMechanic>)clazz.getConstructor();
}
}
this.mechanics.put(name.toUpperCase(), constructor);
this.mechanics.put(namespace.toUpperCase() + ":" + name.toUpperCase(), constructor);
for (String alias : aliases) {
this.mechanics.put(alias.toUpperCase(), constructor);
this.mechanics.put(namespace.toUpperCase() + ":" + alias.toUpperCase(), constructor);
}
}
} catch (Throwable var24) {
MythicLogger.error("Failed to register custom mechanic {0}", new Object[]{clazz.getCanonicalName()});
var24.printStackTrace();
}
}
for (Class<?> clazz : AnnotationUtil.getAnnotatedClasses(plugin, packagePath, MythicCondition.class)) {
try {
MythicCondition annotation = clazz.getAnnotation(MythicCondition.class);
String namespace = annotation.namespace();
String name = annotation.name();
String[] aliases = annotation.aliases();
if (ISkillCondition.class.isAssignableFrom(clazz)) {
Constructor<ISkillCondition> constructor;
try {
constructor = (Constructor<ISkillCondition>)clazz.getConstructor(ModelEngineAPI.class, MythicConditionLoadEvent.class);
} catch (NoSuchMethodException var23) {
try {
constructor = (Constructor<ISkillCondition>)clazz.getConstructor(MythicLineConfig.class);
} catch (NoSuchMethodException var22) {
constructor = (Constructor<ISkillCondition>)clazz.getConstructor();
}
}
this.conditions.put(name.toUpperCase(), constructor);
this.conditions.put(namespace.toUpperCase() + ":" + name.toUpperCase(), constructor);
for (String alias : aliases) {
this.conditions.put(alias.toUpperCase(), constructor);
this.conditions.put(namespace.toUpperCase() + ":" + alias.toUpperCase(), constructor);
}
}
} catch (Throwable var25) {
MythicLogger.error("Failed to register custom condition {0}", new Object[]{clazz.getCanonicalName()});
var25.printStackTrace();
}
}
for (Class<?> clazz : AnnotationUtil.getAnnotatedClasses(plugin, packagePath, MythicTargeter.class)) {
try {
MythicTargeter annotation = clazz.getAnnotation(MythicTargeter.class);
String namespace = annotation.namespace();
String name = annotation.name();
String[] aliases = annotation.aliases();
if (ISkillTargeter.class.isAssignableFrom(clazz)) {
Constructor<ISkillTargeter> constructor;
try {
constructor = (Constructor<ISkillTargeter>)clazz.getConstructor(MythicLineConfig.class);
} catch (NoSuchMethodException var21) {
constructor = (Constructor<ISkillTargeter>)clazz.getConstructor();
}
this.targeters.put(name.toUpperCase(), constructor);
this.targeters.put(namespace.toUpperCase() + ":" + name.toUpperCase(), constructor);
for (String alias : aliases) {
this.targeters.put(alias.toUpperCase(), constructor);
this.targeters.put(namespace.toUpperCase() + ":" + alias.toUpperCase(), constructor);
}
}
} catch (Throwable var26) {
MythicLogger.error("Failed to register custom targeter {0}", new Object[]{clazz.getCanonicalName()});
var26.printStackTrace();
}
}
for (Class<?> clazz : AnnotationUtil.getAnnotatedClasses(plugin, packagePath, MythicPlaceholder.class)) {
try {
MythicPlaceholder anno = clazz.getAnnotation(MythicPlaceholder.class);
String name = anno.placeholder();
String[] aliases = anno.aliases();
if (Placeholder.class.isAssignableFrom(clazz)) {
this.placeholders.put(name, (Class<? extends Placeholder>)clazz);
for (String alias : aliases) {
this.placeholders.put(alias, (Class<? extends Placeholder>)clazz);
}
}
} catch (Exception var27) {
MythicLogger.error("Failed to load placeholder {0}", new Object[]{clazz.getCanonicalName()});
}
}
}
Schedulers.sync().runLater(() -> this.injectPlaceholders(), 20L);
}
@EventHandler
public void onMythicMechanicLoad(MythicMechanicLoadEvent event) {
String name = event.getMechanicName().toUpperCase();
if (this.mechanics.containsKey(name)) {
Constructor<? extends ISkillMechanic> constructor = this.mechanics.get(name);
try {
if (constructor.getParameterCount() == 1) {
if (constructor.getParameterTypes()[0] == MythicLineConfig.class) {
event.register(constructor.newInstance(event.getConfig()));
} else {
event.register(constructor.newInstance(event));
}
} else {
event.register(constructor.newInstance());
}
} catch (Exception var5) {
MythicLogger.error("Failed to construct mechanic {0}", new Object[]{name});
var5.printStackTrace();
}
}
}
@EventHandler
public void onMythicConditionLoad(MythicConditionLoadEvent event) {
String name = event.getConditionName().toUpperCase();
if (this.conditions.containsKey(name)) {
Constructor<? extends ISkillCondition> constructor = this.conditions.get(name);
try {
if (constructor.getParameterCount() == 2) {
event.register(constructor.newInstance(ModelEngineAPI.getAPI(), event));
} else if (constructor.getParameterCount() == 1) {
event.register(constructor.newInstance(event.getConfig()));
} else {
event.register(constructor.newInstance());
}
} catch (Exception var5) {
MythicLogger.error("Failed to construct condition {0}", new Object[]{name});
var5.printStackTrace();
}
}
}
@EventHandler
public void onMythicTargeterLoad(MythicTargeterLoadEvent event) {
String name = event.getTargeterName().toUpperCase();
if (this.targeters.containsKey(name)) {
Constructor<? extends ISkillTargeter> constructor = this.targeters.get(name);
try {
if (constructor.getParameterCount() == 1) {
event.register(constructor.newInstance(event.getConfig()));
} else {
event.register(constructor.newInstance());
}
} catch (Exception var5) {
MythicLogger.error("Failed to construct targeter {0}", new Object[]{name});
var5.printStackTrace();
}
}
}
@EventHandler
public void onMythicReloaded(MythicReloadedEvent event) {
this.injectPlaceholders();
}
private void injectPlaceholders() {
for (Entry<String, Class<? extends Placeholder>> entry : this.placeholders.entrySet()) {
String name = entry.getKey();
Class<Placeholder> clazz = (Class<Placeholder>)entry.getValue();
try {
MythicBukkit.inst().getPlaceholderManager().register(clazz);
} catch (Exception var6) {
MythicBukkit.inst().getPlaceholderManager().register(name, clazz);
}
}
}
}
@@ -0,0 +1,21 @@
package com.ticxo.modelengine.core21.mythic.utils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface MythicCondition {
String name() default "";
String[] aliases() default {};
String author() default "";
String description() default "";
String version() default "4.0";
boolean premium() default false;
String namespace() default "meg";
}
@@ -0,0 +1,21 @@
package com.ticxo.modelengine.core21.mythic.utils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface MythicMechanic {
String name() default "";
String[] aliases() default {};
String author() default "";
String description() default "";
String version() default "4.0";
boolean premium() default false;
String namespace() default "meg";
}
@@ -0,0 +1,21 @@
package com.ticxo.modelengine.core21.mythic.utils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface MythicTargeter {
String name() default "";
String[] aliases() default {};
String author() default "";
String description() default "";
String version() default "4.0";
boolean premium() default false;
String namespace() default "meg";
}