Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-24 18:10:08 +01:00
Ursprung
c0f2557f15
Commit
096a9e4f9f
@ -35,6 +35,7 @@ import com.sk89q.worldedit.math.transform.Transform;
|
|||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.util.Direction.Flag;
|
import com.sk89q.worldedit.util.Direction.Flag;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies entities provided to the function to the provided destination
|
* Copies entities provided to the function to the provided destination
|
||||||
@ -91,9 +92,18 @@ public class ExtentEntityCopy implements EntityFunction {
|
|||||||
if (state != null) {
|
if (state != null) {
|
||||||
Location newLocation;
|
Location newLocation;
|
||||||
Location location = entity.getLocation();
|
Location location = entity.getLocation();
|
||||||
|
// If the entity has stored the location in the NBT data, we use that location
|
||||||
|
CompoundTag tag = state.getNbtData();
|
||||||
|
boolean hasTilePosition = tag != null && tag.containsKey("TileX") && tag.containsKey("TileY") && tag.containsKey("TileZ");
|
||||||
|
if (hasTilePosition) {
|
||||||
|
location = location.setPosition(Vector3.at(tag.asInt("TileX"), tag.asInt("TileY"), tag.asInt("TileZ")).add(0.5, 0.5, 0.5));
|
||||||
|
}
|
||||||
|
|
||||||
Vector3 pivot = from.round().add(0.5, 0.5, 0.5);
|
Vector3 pivot = from.round().add(0.5, 0.5, 0.5);
|
||||||
Vector3 newPosition = transform.apply(location.toVector().subtract(pivot));
|
Vector3 newPosition = transform.apply(location.toVector().subtract(pivot));
|
||||||
|
if (hasTilePosition) {
|
||||||
|
newPosition = newPosition.subtract(0.5, 0.5, 0.5);
|
||||||
|
}
|
||||||
Vector3 newDirection;
|
Vector3 newDirection;
|
||||||
|
|
||||||
newDirection = transform.isIdentity() ?
|
newDirection = transform.isIdentity() ?
|
||||||
@ -142,14 +152,15 @@ public class ExtentEntityCopy implements EntityFunction {
|
|||||||
.putInt("TileZ", newTilePosition.getBlockZ());
|
.putInt("TileZ", newTilePosition.getBlockZ());
|
||||||
|
|
||||||
if (hasFacing) {
|
if (hasFacing) {
|
||||||
Direction direction = MCDirections.fromHanging(tag.asInt("Facing"));
|
boolean isPainting = state.getType() == EntityTypes.PAINTING; // Paintings have different facing values
|
||||||
|
Direction direction = isPainting ? MCDirections.fromHorizontalHanging(tag.asInt("Facing")) : MCDirections.fromHanging(tag.asInt("Facing"));
|
||||||
|
|
||||||
if (direction != null) {
|
if (direction != null) {
|
||||||
Vector3 vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
Vector3 vector = transform.apply(direction.toVector()).subtract(transform.apply(Vector3.ZERO)).normalize();
|
||||||
Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL);
|
Direction newDirection = Direction.findClosest(vector, Flag.CARDINAL);
|
||||||
|
|
||||||
if (newDirection != null) {
|
if (newDirection != null) {
|
||||||
builder.putByte("Facing", (byte) MCDirections.toHanging(newDirection));
|
builder.putByte("Facing", (byte) (isPainting ? MCDirections.toHorizontalHanging(newDirection) : MCDirections.toHanging(newDirection)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -160,5 +171,4 @@ public class ExtentEntityCopy implements EntityFunction {
|
|||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,10 @@ public final class MCDirections {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Direction fromPre13Hanging(int i) {
|
public static Direction fromPre13Hanging(int i) {
|
||||||
|
return fromHorizontalHanging(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Direction fromHorizontalHanging(int i) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0:
|
case 0:
|
||||||
return Direction.SOUTH;
|
return Direction.SOUTH;
|
||||||
@ -82,6 +86,21 @@ public final class MCDirections {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int toHorizontalHanging(Direction direction) {
|
||||||
|
switch (direction) {
|
||||||
|
case SOUTH:
|
||||||
|
return 0;
|
||||||
|
case WEST:
|
||||||
|
return 1;
|
||||||
|
case NORTH:
|
||||||
|
return 2;
|
||||||
|
case EAST:
|
||||||
|
return 3;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int fromLegacyHanging(byte i) {
|
public static int fromLegacyHanging(byte i) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: return 2;
|
case 0: return 2;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren