Models duplicating without Multiverse Core?
Hello,
I'm using Model Engine R3.+ API to show custom models and for some reason apparently the models were being duplicated when someone left the server and re-entered. I tried to do deep debugging in my code that dealt with this and I couldn't find any reason for the model to stay there and when I asked the customer to add Multiverse Core to see if this happened when he changed worlds the problem no longer happened and so it seems that for some reason the Multiverse Core made it work.
I don't know if this is a bug on your side and after talking to another developer who also implemented Model Engine with this, he told me that he also had this problem (even though he couldn't tell me what the reason was)
So I would like to know if you have received any reports about this or if you have any idea what it could be.
This is the current code I'm using: ` final Location loc = this.crate.getLocation().clone();
loc.setX(loc.getBlockX() + .5);
loc.setY(loc.getBlockY());
loc.setZ(loc.getBlockZ() + .5);
final ModelBlueprint blueprint = ModelEngineAPI.getBlueprint(this.modelId);
if (blueprint == null) {
initWaitingHologram("§cInvalid blueprint \"" + this.modelId + "\"");
return;
}
this.activeModel = ModelEngineAPI.createActiveModel(blueprint);
if (this.activeModel == null) {
initWaitingHologram("§cFailed to load model \"" + this.modelId + "\"");
return;
}
if (this.viewer == null) {
final FakeArmorStandEntity entity =
Utilities.getNMSFactory().createFakeArmorStand(this.crate.getPlugin(), loc);
entity.setInvisible(true);
entity.setMarker(true);
entity.setPositionAndRotation(loc);
entity.addToWorld(this.crate.getWorld(), SpawnReason.CUSTOM);
this.bukkitEntity = (LivingEntity) entity.getBukkitEntity();
this.modeledEntity = ModelEngineAPI.createModeledEntity(this.bukkitEntity);
if (this.modeledEntity == null) {
initWaitingHologram("§cFailed to create npc modelled entity");
return;
}
} else {
final Dummy dummy = ModelEngineAPI.createDummy();
dummy.setLocation(loc);
dummy.setYBodyRot(loc.getYaw());
dummy.setYHeadRot(loc.getYaw());
dummy.setXHeadRot(loc.getPitch());
this.modeledEntity = ModelEngineAPI.createModeledEntity(dummy);
if (this.modeledEntity == null) {
initWaitingHologram("§cFailed to create npc modelled entity");
return;
}
}
this.modeledEntity.getRangeManager().setRenderDistance(
this.crate.getPlugin().getConfiguration().getCratesEffectsDespawnRange());
this.modeledEntity.addModel(this.activeModel, false);
if (this.viewer != null) {
Bukkit.getScheduler().runTaskLater(this.crate.getPlugin(), () -> {
this.modeledEntity.getRangeManager().forceSpawn(this.viewer);
}, 2);
} else {
if (this.crate.getHologram().isSpawned()) {
this.crate.getHologram().teleport(this.crate.getHologramLocation());
}
}`