mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Get rid of the string equality and convert a few more ID uses over.
This commit is contained in:
@ -21,7 +21,8 @@ package com.sk89q.worldedit.command.tool;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
@ -32,7 +33,7 @@ import com.sk89q.worldedit.world.World;
|
||||
*/
|
||||
public class AreaPickaxe implements BlockTool {
|
||||
|
||||
private static final BaseBlock air = new BaseBlock(0);
|
||||
private static final BaseBlock air = new BaseBlock(BlockTypes.AIR);
|
||||
private int range;
|
||||
|
||||
public AreaPickaxe(int range) {
|
||||
@ -49,13 +50,13 @@ public class AreaPickaxe implements BlockTool {
|
||||
int ox = clicked.getBlockX();
|
||||
int oy = clicked.getBlockY();
|
||||
int oz = clicked.getBlockZ();
|
||||
int initialType = ((World) clicked.getExtent()).getBlockType(clicked.toVector());
|
||||
BlockType initialType = ((World) clicked.getExtent()).getBlock(clicked.toVector()).getType();
|
||||
|
||||
if (initialType == 0) {
|
||||
if (initialType == BlockTypes.AIR) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
|
||||
if (initialType == BlockTypes.BEDROCK && !player.canDestroyBedrock()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -67,11 +68,11 @@ public class AreaPickaxe implements BlockTool {
|
||||
for (int y = oy - range; y <= oy + range; ++y) {
|
||||
for (int z = oz - range; z <= oz + range; ++z) {
|
||||
Vector pos = new Vector(x, y, z);
|
||||
if (editSession.getBlockType(pos) != initialType) {
|
||||
if (editSession.getBlock(pos).getType() != initialType) {
|
||||
continue;
|
||||
}
|
||||
|
||||
((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toVector().distanceSq(pos));
|
||||
((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType.getLegacyId(), clicked.toVector().distanceSq(pos));
|
||||
|
||||
editSession.setBlock(pos, air);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.command.tool;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
@ -37,7 +38,7 @@ import java.util.Set;
|
||||
* to anything else)
|
||||
*/
|
||||
public class FloatingTreeRemover implements BlockTool {
|
||||
private static final BaseBlock AIR = new BaseBlock(BlockID.AIR);
|
||||
private static final BaseBlock AIR = new BaseBlock(BlockTypes.AIR);
|
||||
private int rangeSq;
|
||||
|
||||
public FloatingTreeRemover() {
|
||||
|
@ -56,7 +56,7 @@ public class QueryTool implements BlockTool {
|
||||
|
||||
World world = (World) clicked.getExtent();
|
||||
EditSession editSession = session.createEditSession(player);
|
||||
BaseBlock block = (editSession).rawGetBlock(clicked.toVector());
|
||||
BaseBlock block = editSession.getBlock(clicked.toVector());
|
||||
BlockType type = BlockType.fromID(block.getType().getLegacyId());
|
||||
|
||||
player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
|
||||
@ -71,13 +71,9 @@ public class QueryTool implements BlockTool {
|
||||
} else if (block instanceof NoteBlock) {
|
||||
player.printRaw("\u00A7e" + "Note block: "
|
||||
+ ((NoteBlock) block).getNote());
|
||||
} else if (block.getType().getId().equals(BlockTypes.WOOL)) {
|
||||
// Should never be null
|
||||
player.printRaw("\u00A7e" + "Color: "
|
||||
+ ClothColor.fromID(block.getData()).getName());
|
||||
}
|
||||
|
||||
Map<String, ? extends State> states = BundledBlockData.getInstance().getStatesById(block.getId());
|
||||
Map<String, ? extends State> states = BundledBlockData.getInstance().getStatesById(block.getType().getId());
|
||||
if (states == null || states.isEmpty()) return true;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("States: ");
|
||||
|
@ -22,6 +22,8 @@ package com.sk89q.worldedit.command.tool;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
@ -36,7 +38,7 @@ import java.util.Set;
|
||||
*/
|
||||
public class RecursivePickaxe implements BlockTool {
|
||||
|
||||
private static final BaseBlock air = new BaseBlock(0);
|
||||
private static final BaseBlock air = new BaseBlock(BlockTypes.AIR);
|
||||
private double range;
|
||||
|
||||
public RecursivePickaxe(double range) {
|
||||
@ -52,13 +54,13 @@ public class RecursivePickaxe implements BlockTool {
|
||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||
World world = (World) clicked.getExtent();
|
||||
|
||||
int initialType = world.getBlockType(clicked.toVector());
|
||||
BlockType initialType = world.getBlock(clicked.toVector()).getType();
|
||||
|
||||
if (initialType == BlockID.AIR) {
|
||||
if (initialType == BlockTypes.AIR) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
|
||||
if (initialType == BlockTypes.BEDROCK && !player.canDestroyBedrock()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -79,7 +81,7 @@ public class RecursivePickaxe implements BlockTool {
|
||||
}
|
||||
|
||||
private static void recurse(Platform server, EditSession editSession, World world, BlockVector pos,
|
||||
Vector origin, double size, int initialType, Set<BlockVector> visited) throws MaxChangedBlocksException {
|
||||
Vector origin, double size, BlockType initialType, Set<BlockVector> visited) throws MaxChangedBlocksException {
|
||||
|
||||
final double distanceSq = origin.distanceSq(pos);
|
||||
if (distanceSq > size*size || visited.contains(pos)) {
|
||||
@ -88,11 +90,11 @@ public class RecursivePickaxe implements BlockTool {
|
||||
|
||||
visited.add(pos);
|
||||
|
||||
if (editSession.getBlock(pos).getType().getLegacyId() != initialType) {
|
||||
if (editSession.getBlock(pos).getType() != initialType) {
|
||||
return;
|
||||
}
|
||||
|
||||
world.queueBlockBreakEffect(server, pos, initialType, distanceSq);
|
||||
world.queueBlockBreakEffect(server, pos, initialType.getLegacyId(), distanceSq);
|
||||
|
||||
editSession.setBlock(pos, air);
|
||||
|
||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
@ -39,7 +40,7 @@ public class CylinderBrush implements Brush {
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
editSession.makeCylinder(position, Patterns.wrap(pattern), size, size, height, true);
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class GravityBrush implements Brush {
|
||||
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
final BaseBlock air = new BaseBlock(BlockID.AIR, 0);
|
||||
final BaseBlock air = new BaseBlock(BlockTypes.AIR);
|
||||
final double startY = fullHeight ? editSession.getWorld().getMaxY() : position.getBlockY() + size;
|
||||
for (double x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
|
||||
for (double z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
|
||||
@ -56,7 +56,7 @@ public class GravityBrush implements Brush {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
Collections.reverse(blockTypes);
|
||||
for (int i = 0; i < blockTypes.size();) {
|
||||
if (editSession.getBlock(pt).getType().getId().equals(BlockTypes.AIR)) {
|
||||
if (editSession.getBlock(pt).isAir()) {
|
||||
editSession.setBlock(pt, blockTypes.get(i++));
|
||||
}
|
||||
pt = pt.add(0, 1, 0);
|
||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
@ -39,7 +40,7 @@ public class HollowCylinderBrush implements Brush {
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
editSession.makeCylinder(position, Patterns.wrap(pattern), size, size, height, false);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
@ -33,7 +34,7 @@ public class HollowSphereBrush implements Brush {
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
editSession.makeSphere(position, Patterns.wrap(pattern), size, size, size, false);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.function.pattern.Patterns;
|
||||
@ -33,7 +34,7 @@ public class SphereBrush implements Brush {
|
||||
@Override
|
||||
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
|
||||
if (pattern == null) {
|
||||
pattern = new BlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
||||
pattern = new BlockPattern(new BaseBlock(BlockTypes.COBBLESTONE));
|
||||
}
|
||||
editSession.makeSphere(position, Patterns.wrap(pattern), size, size, size, true);
|
||||
}
|
||||
|
Reference in New Issue
Block a user