mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2026-01-04 15:41:45 +00:00
Fixed ModelEngine error
This commit is contained in:
@@ -47,7 +47,6 @@ public class HookManager {
|
||||
final OraxenHook oraxenHook = new OraxenHook();
|
||||
final ItemsAdderHook itemsAdderHook = new ItemsAdderHook();
|
||||
final CitizensHook citizensHook = new CitizensHook(this.plugin);
|
||||
final ModelEngineHook modelEngineHook = new ModelEngineHook();
|
||||
if (pluginManager.getPlugin("Oraxen") != null) {
|
||||
itemHookMap.put(oraxenHook.getIdentifier(), oraxenHook);
|
||||
}
|
||||
@@ -63,6 +62,7 @@ public class HookManager {
|
||||
this.citizensHook = null;
|
||||
}
|
||||
if (pluginManager.getPlugin("ModelEngine") != null) {
|
||||
final ModelEngineHook modelEngineHook = new ModelEngineHook();
|
||||
this.registerHook(modelEngineHook.getClass());
|
||||
this.modelEngineHook = modelEngineHook;
|
||||
} else {
|
||||
|
||||
@@ -3,26 +3,32 @@ package io.github.fisher2911.hmccosmetics.hook;
|
||||
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.base.BaseEntity;
|
||||
import io.github.fisher2911.hmccosmetics.HMCCosmetics;
|
||||
import org.bukkit.Bukkit;
|
||||
import io.github.fisher2911.hmccosmetics.hook.entity.BalloonEntity;
|
||||
import io.github.fisher2911.hmccosmetics.hook.entity.MEGEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ModelEngineHook implements Hook {
|
||||
|
||||
public ModelEngineHook() {
|
||||
}
|
||||
|
||||
private static final String ID = "model-engine";
|
||||
|
||||
public void spawnModel(final String id, final BaseEntity<?> entity) {
|
||||
if (ModelEngineAPI.getModeledEntity(entity.getUniqueId()) != null) return;
|
||||
public void spawnModel(final String id, final BalloonEntity entity) {
|
||||
this.spawnModel(id, new MEGEntity(entity));
|
||||
}
|
||||
|
||||
public void spawnModel(final String id, final MEGEntity entity) {
|
||||
if (ModelEngineAPI.getModeledEntity(entity.getUuid()) != null) return;
|
||||
final ActiveModel model = ModelEngineAPI.createActiveModel(id);
|
||||
ModeledEntity modeledEntity = ModelEngineAPI.api.getModelManager().createModeledEntity(entity);
|
||||
modeledEntity.addActiveModel(model);
|
||||
}
|
||||
|
||||
public void addPlayerToModel(final Player player, final String id, final BaseEntity<?> entity) {
|
||||
final ModeledEntity model = ModelEngineAPI.getModeledEntity(entity.getUniqueId());
|
||||
public void addPlayerToModel(final Player player, final String id, final BalloonEntity entity) {
|
||||
final ModeledEntity model = ModelEngineAPI.getModeledEntity(entity.getUuid());
|
||||
if (model == null) {
|
||||
this.spawnModel(id, entity);
|
||||
return;
|
||||
|
||||
@@ -1,258 +1,72 @@
|
||||
package io.github.fisher2911.hmccosmetics.hook.entity;
|
||||
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import com.ticxo.modelengine.api.model.base.BaseEntity;
|
||||
import com.ticxo.modelengine.api.model.base.EntityData;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BalloonEntity implements BaseEntity<BalloonEntity> {
|
||||
public class BalloonEntity {
|
||||
|
||||
private final UUID uuid;
|
||||
private final int entityId;
|
||||
private Vector velocity = new Vector(0, 0, 0);
|
||||
private EntityType entityType;
|
||||
private Vector velocity;
|
||||
private Location location;
|
||||
private boolean alive;
|
||||
|
||||
public BalloonEntity(final UUID uuid, final int entityId, final Vector velocity, final Location location, final boolean alive) {
|
||||
public BalloonEntity(final UUID uuid, final int entityId, final EntityType entityType, final Vector velocity, final Location location, final boolean alive) {
|
||||
this.uuid = uuid;
|
||||
this.entityId = entityId;
|
||||
this.entityType = entityType;
|
||||
this.velocity = velocity;
|
||||
this.location = location;
|
||||
this.alive = alive;
|
||||
}
|
||||
|
||||
public BalloonEntity(final UUID uuid, final int entityId) {
|
||||
public BalloonEntity(final UUID uuid, final int entityId, final EntityType entityType) {
|
||||
this.uuid = uuid;
|
||||
this.entityId = entityId;
|
||||
this.alive = true;
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
public void setEntityType(final EntityType entityType) {
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
public Vector getVelocity() {
|
||||
return velocity;
|
||||
}
|
||||
|
||||
public void setVelocity(final Vector velocity) {
|
||||
this.velocity = velocity;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(final Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public void setAlive(final boolean alive) {
|
||||
this.alive = alive;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return alive;
|
||||
}
|
||||
|
||||
public EntityData getEntityData() {
|
||||
return entityData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BalloonEntity getBase() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getVelocity() {
|
||||
return velocity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnGround() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return this.location.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Entity> getNearbyEntities(final double v, final double v1, final double v2) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEntityId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
this.alive = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCustomNameVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDead() {
|
||||
return !this.alive;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.PUFFERFISH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGravity() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGravity(final boolean flag) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealth() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxHealth() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(final String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMovementSpeed() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInOffHand() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLivingEntity() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPotionEffect(final PotionEffect potion) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePotionEffect(final PotionEffectType potion) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntitySize(final float width, final float height, final float eye) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendDespawnPacket(final ModeledEntity modeledEntity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSpawnPacket(final ModeledEntity modeledEntity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLastX() {
|
||||
return this.location.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLastY() {
|
||||
return this.location.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLastZ() {
|
||||
return this.location.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWantedX() {
|
||||
return this.location.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWantedY() {
|
||||
return this.location.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWantedZ() {
|
||||
return this.location.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveModelList(final Map<String, ActiveModel> models) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveModelInfo(final ModeledEntity model) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getModelList() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final EntityData entityData = new EntityData();
|
||||
|
||||
@Override
|
||||
public EntityData loadModelInfo() {
|
||||
return this.entityData;
|
||||
public void setAlive(final boolean alive) {
|
||||
this.alive = alive;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
package io.github.fisher2911.hmccosmetics.hook.entity;
|
||||
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import com.ticxo.modelengine.api.model.base.BaseEntity;
|
||||
import com.ticxo.modelengine.api.model.base.EntityData;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MEGEntity implements BaseEntity<MEGEntity> {
|
||||
|
||||
private final UUID uuid;
|
||||
private final int entityId;
|
||||
private Vector velocity = new Vector(0, 0, 0);
|
||||
private Location location;
|
||||
private boolean alive;
|
||||
|
||||
public MEGEntity(final BalloonEntity entity) {
|
||||
this.uuid = entity.getUuid();
|
||||
this.entityId = entity.getEntityId();
|
||||
this.velocity = entity.getVelocity();
|
||||
this.location = entity.getLocation();
|
||||
this.alive = entity.isAlive();
|
||||
}
|
||||
|
||||
protected MEGEntity(final UUID uuid, final int entityId, final Vector velocity, final Location location, final boolean alive) {
|
||||
this.uuid = uuid;
|
||||
this.entityId = entityId;
|
||||
this.velocity = velocity;
|
||||
this.location = location;
|
||||
this.alive = alive;
|
||||
}
|
||||
|
||||
protected MEGEntity(final UUID uuid, final int entityId) {
|
||||
this.uuid = uuid;
|
||||
this.entityId = entityId;
|
||||
this.alive = true;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setVelocity(final Vector velocity) {
|
||||
this.velocity = velocity;
|
||||
}
|
||||
|
||||
public void setLocation(final Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public void setAlive(final boolean alive) {
|
||||
this.alive = alive;
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
return alive;
|
||||
}
|
||||
|
||||
public EntityData getEntityData() {
|
||||
return entityData;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public MEGEntity getBase() {
|
||||
return this;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public Location getLocation() {
|
||||
return this.location;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public Vector getVelocity() {
|
||||
return velocity;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public boolean isOnGround() {
|
||||
return false;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public World getWorld() {
|
||||
return this.location.getWorld();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public List<Entity> getNearbyEntities(final double v, final double v1, final double v2) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public int getEntityId() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void remove() {
|
||||
this.alive = false;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public boolean isCustomNameVisible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public boolean isDead() {
|
||||
return !this.alive;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public UUID getUniqueId() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.PUFFERFISH;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public boolean isInvulnerable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public boolean hasGravity() {
|
||||
return false;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void setGravity(final boolean flag) {
|
||||
|
||||
}
|
||||
|
||||
//@Override
|
||||
public double getHealth() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public double getMaxHealth() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public String getCustomName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void setCustomName(final String s) {
|
||||
|
||||
}
|
||||
|
||||
//@Override
|
||||
public double getMovementSpeed() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public ItemStack getItemInMainHand() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public ItemStack getItemInOffHand() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public boolean isLivingEntity() {
|
||||
return false;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void addPotionEffect(final PotionEffect potion) {
|
||||
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void removePotionEffect(final PotionEffectType potion) {
|
||||
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void setEntitySize(final float width, final float height, final float eye) {
|
||||
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void sendDespawnPacket(final ModeledEntity modeledEntity) {
|
||||
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void sendSpawnPacket(final ModeledEntity modeledEntity) {
|
||||
|
||||
}
|
||||
|
||||
//@Override
|
||||
public double getLastX() {
|
||||
return this.location.getX();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public double getLastY() {
|
||||
return this.location.getY();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public double getLastZ() {
|
||||
return this.location.getZ();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public double getWantedX() {
|
||||
return this.location.getX();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public double getWantedY() {
|
||||
return this.location.getY();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public double getWantedZ() {
|
||||
return this.location.getZ();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void saveModelList(final Map<String, ActiveModel> models) {
|
||||
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void saveModelInfo(final ModeledEntity model) {
|
||||
|
||||
}
|
||||
|
||||
//@Override
|
||||
public List<String> getModelList() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final EntityData entityData = new EntityData();
|
||||
|
||||
//@Override
|
||||
public EntityData loadModelInfo() {
|
||||
return this.entityData;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,6 @@ import java.util.UUID;
|
||||
|
||||
public abstract class BaseUser<T> {
|
||||
|
||||
private final HMCCosmetics plugin;
|
||||
protected final T id;
|
||||
protected final EntityIds entityIds;
|
||||
protected final BalloonEntity balloon;
|
||||
@@ -47,8 +46,7 @@ public abstract class BaseUser<T> {
|
||||
this.id = id;
|
||||
this.entityIds = entityIds;
|
||||
this.playerArmor = playerArmor;
|
||||
this.plugin = HMCCosmetics.getPlugin(HMCCosmetics.class);
|
||||
this.balloon = new BalloonEntity(UUID.randomUUID(), -1);
|
||||
this.balloon = new BalloonEntity(UUID.randomUUID(), -1, EntityType.PUFFERFISH);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -99,7 +97,7 @@ public abstract class BaseUser<T> {
|
||||
protected void despawnBalloon() {
|
||||
final HookManager hookManager = HookManager.getInstance();
|
||||
if (!hookManager.isEnabled(ModelEngineHook.class)) return;
|
||||
hookManager.getModelEngineHook().remove(this.balloon.getUniqueId());
|
||||
hookManager.getModelEngineHook().remove(this.balloon.getUuid());
|
||||
PacketManager.sendPacketToOnline(PacketManager.getEntityDestroyPacket(this.getBalloonId()));
|
||||
this.viewingBalloon.clear();
|
||||
}
|
||||
@@ -107,7 +105,7 @@ public abstract class BaseUser<T> {
|
||||
protected void despawnBalloon(final Player other) {
|
||||
final HookManager hookManager = HookManager.getInstance();
|
||||
if (!hookManager.isEnabled(ModelEngineHook.class)) return;
|
||||
hookManager.getModelEngineHook().removePlayerFromModel(other, this.balloon.getUniqueId());
|
||||
hookManager.getModelEngineHook().removePlayerFromModel(other, this.balloon.getUuid());
|
||||
PacketManager.sendPacket(other, PacketManager.getEntityDestroyPacket(this.getBalloonId()));
|
||||
this.viewingBalloon.remove(other.getUniqueId());
|
||||
if (this.viewingBalloon.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user