Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-08 04:20:06 +01:00
Fixed //fill and //rotate
Dieser Commit ist enthalten in:
Ursprung
2239d14a01
Commit
65420af09e
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -32,6 +34,8 @@ import com.sk89q.worldedit.world.block.BlockState;
|
|||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -39,8 +43,6 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -238,6 +240,45 @@ public class BukkitAdapter {
|
|||||||
return Material.getMaterial(blockType.getId().replace("minecraft:", "").toUpperCase());
|
return Material.getMaterial(blockType.getId().replace("minecraft:", "").toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a WorldEdit GameMode from a Bukkit one.
|
||||||
|
*
|
||||||
|
* @param gameMode Bukkit GameMode
|
||||||
|
* @return WorldEdit GameMode
|
||||||
|
*/
|
||||||
|
public static GameMode adapt(org.bukkit.GameMode gameMode) {
|
||||||
|
checkNotNull(gameMode);
|
||||||
|
return GameModes.get(gameMode.name().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a Material to a BlockType
|
||||||
|
*
|
||||||
|
* @param material The material
|
||||||
|
* @return The blocktype
|
||||||
|
*/
|
||||||
|
public static BlockType asBlockType(Material material) {
|
||||||
|
checkNotNull(material);
|
||||||
|
if (!material.isBlock()) {
|
||||||
|
throw new IllegalArgumentException(material.getKey().toString() + " is not a block!");
|
||||||
|
}
|
||||||
|
return BlockTypes.get(material.getKey().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a Material to a ItemType
|
||||||
|
*
|
||||||
|
* @param material The material
|
||||||
|
* @return The itemtype
|
||||||
|
*/
|
||||||
|
public static ItemType asItemType(Material material) {
|
||||||
|
checkNotNull(material);
|
||||||
|
if (!material.isItem()) {
|
||||||
|
throw new IllegalArgumentException(material.getKey().toString() + " is not an item!");
|
||||||
|
}
|
||||||
|
return ItemTypes.get(material.getKey().toString());
|
||||||
|
}
|
||||||
|
|
||||||
private static Map<String, BlockState> blockStateCache = new HashMap<>();
|
private static Map<String, BlockState> blockStateCache = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,7 @@ public class BlockVector extends Vector {
|
|||||||
* @param position the other position
|
* @param position the other position
|
||||||
*/
|
*/
|
||||||
public BlockVector(Vector position) {
|
public BlockVector(Vector position) {
|
||||||
super(position);
|
this(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +59,7 @@ public class BlockVector extends Vector {
|
|||||||
* @param z the Z coordinate
|
* @param z the Z coordinate
|
||||||
*/
|
*/
|
||||||
public BlockVector(float x, float y, float z) {
|
public BlockVector(float x, float y, float z) {
|
||||||
super(x, y, z);
|
this((int) x, (int) y, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -70,7 +70,7 @@ public class BlockVector extends Vector {
|
|||||||
* @param z the Z coordinate
|
* @param z the Z coordinate
|
||||||
*/
|
*/
|
||||||
public BlockVector(double x, double y, double z) {
|
public BlockVector(double x, double y, double z) {
|
||||||
super(x, y, z);
|
this((int) x, (int) y, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +36,7 @@ public class BlockVector2D extends Vector2D {
|
|||||||
* @param position the position to copy
|
* @param position the position to copy
|
||||||
*/
|
*/
|
||||||
public BlockVector2D(Vector2D position) {
|
public BlockVector2D(Vector2D position) {
|
||||||
super(position);
|
this(position.getBlockX(), position.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +56,7 @@ public class BlockVector2D extends Vector2D {
|
|||||||
* @param z the Z coordinate
|
* @param z the Z coordinate
|
||||||
*/
|
*/
|
||||||
public BlockVector2D(float x, float z) {
|
public BlockVector2D(float x, float z) {
|
||||||
super(x, z);
|
this((int) x, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +66,7 @@ public class BlockVector2D extends Vector2D {
|
|||||||
* @param z the Z coordinate
|
* @param z the Z coordinate
|
||||||
*/
|
*/
|
||||||
public BlockVector2D(double x, double z) {
|
public BlockVector2D(double x, double z) {
|
||||||
super(x, z);
|
this((int) x, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,10 +19,18 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||||
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
@ -43,10 +51,6 @@ import com.sk89q.worldedit.session.ClipboardHolder;
|
|||||||
import com.sk89q.worldedit.util.command.binding.Switch;
|
import com.sk89q.worldedit.util.command.binding.Switch;
|
||||||
import com.sk89q.worldedit.util.command.parametric.Optional;
|
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clipboard commands.
|
* Clipboard commands.
|
||||||
*/
|
*/
|
||||||
|
@ -104,12 +104,7 @@ public class UtilityCommands {
|
|||||||
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1;
|
int depth = args.argsLength() > 2 ? Math.max(1, args.getInteger(2)) : 1;
|
||||||
|
|
||||||
Vector pos = session.getPlacementPosition(player);
|
Vector pos = session.getPlacementPosition(player);
|
||||||
int affected;
|
int affected = editSession.fillXZ(pos, pattern, radius, depth, false);
|
||||||
if (pattern instanceof BlockPattern) {
|
|
||||||
affected = editSession.fillXZ(pos, ((BlockPattern) pattern).getBlock(), radius, depth, false);
|
|
||||||
} else {
|
|
||||||
affected = editSession.fillXZ(pos, pattern, radius, depth, false);
|
|
||||||
}
|
|
||||||
player.print(affected + " block(s) have been created.");
|
player.print(affected + " block(s) have been created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,8 +74,7 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
|
|||||||
* @return the same block
|
* @return the same block
|
||||||
*/
|
*/
|
||||||
private <T extends BlockStateHolder> T transformBlock(T block, boolean reverse) {
|
private <T extends BlockStateHolder> T transformBlock(T block, boolean reverse) {
|
||||||
transform(block, reverse ? transform.inverse() : transform);
|
return transform(block, reverse ? transform.inverse() : transform);
|
||||||
return block;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -126,11 +125,11 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
|
|||||||
|
|
||||||
for (Property property : block.getBlockType().getProperties()) {
|
for (Property property : block.getBlockType().getProperties()) {
|
||||||
if (property instanceof DirectionalProperty) {
|
if (property instanceof DirectionalProperty) {
|
||||||
Vector value = (Vector) block.getState(property);
|
Direction value = (Direction) block.getState(property);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
Vector newValue = getNewStateValue((DirectionalProperty) property, transform, value);
|
Vector newValue = getNewStateValue((DirectionalProperty) property, transform, value.toVector());
|
||||||
if (newValue != null) {
|
if (newValue != null) {
|
||||||
changedBlock.with(property, newValue);
|
changedBlock = (T) changedBlock.with(property, Direction.findClosest(newValue, Direction.Flag.ALL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.session;
|
package com.sk89q.worldedit.session;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||||
@ -29,9 +29,6 @@ import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
|||||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.math.transform.Transform;
|
import com.sk89q.worldedit.math.transform.Transform;
|
||||||
import com.sk89q.worldedit.world.registry.Registries;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds an operation to paste the contents of a clipboard.
|
* Builds an operation to paste the contents of a clipboard.
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren