use of com.denizenscript.denizencore.objects.core.MapTag in project Denizen-For-Bukkit by DenizenScript.
the class CuboidBlockSet method pasteEntities.
public void pasteEntities(LocationTag relative) {
if (entities == null) {
return;
}
for (MapTag data : entities.filter(MapTag.class, CoreUtilities.noDebugContext)) {
try {
LocationTag offset = data.getObject("offset").asType(LocationTag.class, CoreUtilities.noDebugContext);
int rotation = data.getObject("rotation").asElement().asInt();
EntityTag entity = data.getObject("entity").asType(EntityTag.class, CoreUtilities.noDebugContext);
if (entity == null || offset == null) {
continue;
}
entity = entity.duplicate();
offset = offset.clone();
if (rotation != 0) {
ArrayList<Mechanism> mechs = new ArrayList<>(entity.getWaitingMechanisms().size());
for (Mechanism mech : entity.getWaitingMechanisms()) {
if (mech.getName().equals("rotation")) {
String rotationName = mech.getValue().asString();
BlockFace face = BlockFace.valueOf(rotationName.toUpperCase());
for (int i = 0; i < rotation; i += 90) {
face = rotateFaceOne(face);
}
// Compensate for hanging locations being very stupid
offset.add(face.getDirection().multiply(0.1));
mechs.add(new Mechanism("rotation", new ElementTag(face.name()), CoreUtilities.noDebugContext));
} else {
mechs.add(new Mechanism(mech.getName(), mech.value, CoreUtilities.noDebugContext));
}
}
entity.mechanisms = mechs;
} else {
for (Mechanism mechanism : entity.mechanisms) {
mechanism.context = CoreUtilities.noDebugContext;
}
}
Location spawnLoc = relative.clone().add(offset);
spawnLoc.setYaw(offset.getYaw() - rotation);
spawnLoc.setPitch(offset.getPitch());
entity.spawnAt(spawnLoc);
} catch (Exception ex) {
Debug.echoError(ex);
}
}
}
Aggregations