Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-09 13:00:05 +01:00
Write yaw/pitch in degrees rather than in radians with schematic files.
Dieser Commit ist enthalten in:
Ursprung
e2082ee8a4
Commit
7243b2a05d
@ -40,6 +40,7 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.world.registry.WorldData;
|
||||
import com.sk89q.worldedit.world.storage.NBTConversions;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
@ -230,12 +231,11 @@ public class SchematicReader implements ClipboardReader {
|
||||
for (Tag tag : entityTags) {
|
||||
if (tag instanceof CompoundTag) {
|
||||
CompoundTag compound = (CompoundTag) tag;
|
||||
StringTag idTag = getTag(compound, StringTag.class, "id");
|
||||
Vector position = getVector(getTag(compound, ListTag.class, "Pos"));
|
||||
String id = compound.getString("id");
|
||||
Location location = NBTConversions.toLocation(clipboard, compound.getListTag("Pos"), compound.getListTag("Rotation"));
|
||||
|
||||
if (idTag != null & position != null) {
|
||||
Location location = readRotation(getTag(compound, ListTag.class, "Rotation"), new Location(clipboard, position));
|
||||
BaseEntity state = new BaseEntity(idTag.getValue(), compound);
|
||||
if (!id.isEmpty()) {
|
||||
BaseEntity state = new BaseEntity(id, compound);
|
||||
clipboard.createEntity(location, state);
|
||||
}
|
||||
}
|
||||
@ -246,37 +246,6 @@ public class SchematicReader implements ClipboardReader {
|
||||
return clipboard;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Vector getVector(@Nullable ListTag tag) {
|
||||
if (tag != null) {
|
||||
List<Tag> tags = tag.getValue();
|
||||
|
||||
if (tags.size() == 3 && tags.get(0) instanceof DoubleTag) {
|
||||
double x = ((DoubleTag) tags.get(0)).getValue();
|
||||
double y = ((DoubleTag) tags.get(1)).getValue();
|
||||
double z = ((DoubleTag) tags.get(2)).getValue();
|
||||
return new Vector(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Location readRotation(@Nullable ListTag tag, Location location) {
|
||||
if (tag != null) {
|
||||
List<Tag> tags = tag.getValue();
|
||||
|
||||
if (tags.size() == 2 && tags.get(0) instanceof FloatTag) {
|
||||
float yaw = ((FloatTag) tags.get(0)).getValue();
|
||||
float pitch = ((FloatTag) tags.get(1)).getValue();
|
||||
location = location.setDirection(yaw, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
private static <T extends Tag> T requireTag(Map<String, Tag> items, String key, Class<T> expected) throws IOException {
|
||||
if (!items.containsKey(key)) {
|
||||
throw new IOException("Schematic file is missing a \"" + key + "\" tag");
|
||||
|
@ -206,8 +206,8 @@ public class SchematicWriter implements ClipboardWriter {
|
||||
|
||||
private Tag writeRotation(Location location, String name) {
|
||||
List<FloatTag> list = new ArrayList<FloatTag>();
|
||||
list.add(new FloatTag("", location.getYaw()));
|
||||
list.add(new FloatTag("", location.getPitch()));
|
||||
list.add(new FloatTag("", (float) Math.toDegrees(location.getYaw())));
|
||||
list.add(new FloatTag("", (float) Math.toDegrees(location.getPitch())));
|
||||
return new ListTag(name, FloatTag.class, list);
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren