mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-07-25 22:04:42 +02:00
Fix pasting of blueprints from clipboard. Always pasted at y=0
This commit is contained in:
parent
cf0b2ccdd5
commit
a3f8d2998f
|
@ -34,7 +34,7 @@ public class AdminBlueprintOriginCommand extends CompositeCommand {
|
|||
// Get the block player is looking at
|
||||
Block b = user.getPlayer().getLineOfSight(null, 20).stream().filter(x -> !x.getType().equals(Material.AIR)).findFirst().orElse(null);
|
||||
if (b != null) {
|
||||
clipboard.setOrigin(b.getLocation());
|
||||
clipboard.setOrigin(b.getLocation().toVector());
|
||||
user.getPlayer().sendBlockChange(b.getLocation(), Material.REDSTONE_BLOCK.createBlockData());
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(),
|
||||
() -> user.getPlayer().sendBlockChange(b.getLocation(), b.getBlockData()), 20L);
|
||||
|
|
|
@ -53,7 +53,7 @@ public class BlueprintClipboard {
|
|||
private @Nullable Blueprint blueprint;
|
||||
private @Nullable Location pos1;
|
||||
private @Nullable Location pos2;
|
||||
private @Nullable Location origin;
|
||||
private @Nullable Vector origin;
|
||||
private BukkitTask copyTask;
|
||||
private int count;
|
||||
private boolean copying;
|
||||
|
@ -85,12 +85,13 @@ public class BlueprintClipboard {
|
|||
user.sendMessage("commands.admin.blueprint.mid-copy");
|
||||
return false;
|
||||
}
|
||||
origin = origin == null ? user.getLocation() : origin;
|
||||
if (pos1 == null || pos2 == null) {
|
||||
user.sendMessage("commands.admin.blueprint.need-pos1-pos2");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (origin == null) {
|
||||
setOrigin(user.getLocation().toVector());
|
||||
}
|
||||
user.sendMessage("commands.admin.blueprint.copying");
|
||||
|
||||
// World
|
||||
|
@ -166,15 +167,15 @@ public class BlueprintClipboard {
|
|||
return r;
|
||||
}
|
||||
|
||||
private boolean copyBlock(Location l, Location copyOrigin, boolean copyAir, Collection<LivingEntity> entities) {
|
||||
private boolean copyBlock(Location l, @Nullable Vector origin2, boolean copyAir, Collection<LivingEntity> entities) {
|
||||
Block block = l.getBlock();
|
||||
if (!copyAir && block.getType().equals(Material.AIR) && entities.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
// Create position
|
||||
int x = l.getBlockX() - copyOrigin.getBlockX();
|
||||
int y = l.getBlockY() - copyOrigin.getBlockY();
|
||||
int z = l.getBlockZ() - copyOrigin.getBlockZ();
|
||||
int x = l.getBlockX() - origin2.getBlockX();
|
||||
int y = l.getBlockY() - origin2.getBlockY();
|
||||
int z = l.getBlockZ() - origin2.getBlockZ();
|
||||
Vector pos = new Vector(x, y, z);
|
||||
|
||||
// Set entities
|
||||
|
@ -279,7 +280,7 @@ public class BlueprintClipboard {
|
|||
* @return the origin
|
||||
*/
|
||||
@Nullable
|
||||
public Location getOrigin() {
|
||||
public Vector getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
/**
|
||||
|
@ -304,7 +305,7 @@ public class BlueprintClipboard {
|
|||
/**
|
||||
* @param origin the origin to set
|
||||
*/
|
||||
public void setOrigin(@Nullable Location origin) {
|
||||
public void setOrigin(@Nullable Vector origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,9 +80,7 @@ public class BlueprintPaster {
|
|||
this.plugin = plugin;
|
||||
this.clipboard = clipboard;
|
||||
// Calculate location for pasting
|
||||
Vector offset = clipboard.getOrigin() != null ? clipboard.getOrigin().toVector() : new Vector(0, 0, 0);
|
||||
Location loc = location.toVector().subtract(offset).toLocation(location.getWorld());
|
||||
paste(location.getWorld(), null, loc, clipboard.getBlueprint(), task);
|
||||
paste(location.getWorld(), null, location, clipboard.getBlueprint(), task);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user