use of com.denizenscript.denizen.objects.EntityTag in project Denizen-For-Bukkit by DenizenScript.
the class EntityAddToWorldScriptEvent method onPreCreatureSpawn.
@EventHandler
public void onPreCreatureSpawn(EntityAddToWorldEvent event) {
this.entity = new EntityTag(event.getEntity());
this.location = new LocationTag(event.getEntity().getLocation());
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.EntityTag in project Denizen-For-Bukkit by DenizenScript.
the class EntityKnocksbackEntityScriptEvent method onEntityKnockbackEntity.
@EventHandler
public void onEntityKnockbackEntity(EntityKnockbackByEntityEvent event) {
entity = new EntityTag(event.getEntity());
hitBy = new EntityTag(event.getHitBy());
held = hitBy.getItemInHand();
this.event = event;
fire(event);
}
use of com.denizenscript.denizen.objects.EntityTag in project Denizen-For-Bukkit by DenizenScript.
the class EntityPathfindScriptEvent method onEntityPathfind.
@EventHandler
public void onEntityPathfind(EntityPathfindEvent event) {
this.event = event;
this.entity = new EntityTag(event.getEntity());
Entity target = event.getTargetEntity();
this.target = target != null ? new EntityTag(target) : null;
fire(event);
}
use of com.denizenscript.denizen.objects.EntityTag in project Denizen-For-Bukkit by DenizenScript.
the class AttachCommand method execute.
@Override
public void execute(final ScriptEntry scriptEntry) {
LocationTag offset = scriptEntry.getObjectTag("offset");
List<EntityTag> entities = (List<EntityTag>) scriptEntry.getObject("entities");
EntityTag target = scriptEntry.getObjectTag("to");
List<PlayerTag> forPlayers = (List<PlayerTag>) scriptEntry.getObject("for");
ElementTag cancel = scriptEntry.getElement("cancel");
ElementTag relative = scriptEntry.getElement("relative");
ElementTag sync_server = scriptEntry.getElement("sync_server");
ElementTag no_rotate = scriptEntry.getElement("no_rotate");
ElementTag no_pitch = scriptEntry.getElement("no_pitch");
ElementTag yaw_offset = scriptEntry.getElement("yaw_offset");
ElementTag pitch_offset = scriptEntry.getElement("pitch_offset");
boolean shouldCancel = cancel.asBoolean();
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), db("entities", entities), shouldCancel ? cancel : target, relative, offset, yaw_offset, pitch_offset, sync_server, no_rotate, no_pitch, db("for", forPlayers));
}
BiConsumer<EntityTag, UUID> procPlayer = (entity, player) -> {
if (shouldCancel) {
EntityAttachmentHelper.removeAttachment(entity.getUUID(), player);
} else {
EntityAttachmentHelper.AttachmentData attachment = new EntityAttachmentHelper.AttachmentData();
attachment.attached = entity;
attachment.to = target;
attachment.positionalOffset = offset == null ? null : offset.clone();
attachment.offsetRelative = relative.asBoolean();
attachment.yawAngleOffset = yaw_offset.asFloat();
attachment.pitchAngleOffset = pitch_offset.asFloat();
attachment.syncServer = sync_server.asBoolean();
attachment.forPlayer = player;
attachment.noRotate = no_rotate.asBoolean();
attachment.noPitch = no_pitch.asBoolean();
EntityAttachmentHelper.registerAttachment(attachment);
}
};
for (EntityTag entity : entities) {
if (!entity.isSpawned() && !entity.isFake && !shouldCancel) {
Debug.echoError("Cannot attach entity '" + entity + "': entity is not spawned.");
continue;
}
if (forPlayers == null) {
procPlayer.accept(entity, null);
} else {
for (PlayerTag player : forPlayers) {
procPlayer.accept(entity, player.getUUID());
}
}
}
}
use of com.denizenscript.denizen.objects.EntityTag in project Denizen-For-Bukkit by DenizenScript.
the class BurnCommand method execute.
@Override
public void execute(final ScriptEntry scriptEntry) {
List<EntityTag> entities = (List<EntityTag>) scriptEntry.getObject("entities");
DurationTag duration = scriptEntry.getObjectTag("duration");
if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), duration, db("entities", entities));
}
for (EntityTag entity : entities) {
if (entity.isSpawned()) {
entity.getBukkitEntity().setFireTicks(duration.getTicksAsInt());
}
}
}
Aggregations