Start work on the new BaseBlock/BlockState split

This commit is contained in:
Matthew Miller
2018-06-17 15:42:47 +10:00
parent aaaf2d5678
commit c43109bde5
20 changed files with 273 additions and 268 deletions

View File

@ -50,7 +50,7 @@ public class AreaPickaxe implements BlockTool {
int ox = clicked.getBlockX();
int oy = clicked.getBlockY();
int oz = clicked.getBlockZ();
BlockType initialType = ((World) clicked.getExtent()).getBlock(clicked.toVector()).getType();
BlockType initialType = clicked.getExtent().getBlock(clicked.toVector()).getType();
if (initialType == BlockTypes.AIR) {
return true;
@ -72,7 +72,7 @@ public class AreaPickaxe implements BlockTool {
continue;
}
((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType.getLegacyId(), clicked.toVector().distanceSq(pos));
((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType, clicked.toVector().distanceSq(pos));
editSession.setBlock(pos, air);
}

View File

@ -26,7 +26,6 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.world.World;
/**
* A mode that replaces one block.
@ -66,10 +65,9 @@ public class BlockReplacer implements DoubleActionBlockTool {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
World world = (World) clicked.getExtent();
EditSession editSession = session.createEditSession(player);
targetBlock = (editSession).getBlock(clicked.toVector());
BlockType type = BlockType.fromID(targetBlock.getType().getLegacyId());
BlockType type = targetBlock.getType().getLegacyType();
if (type != null) {
player.print("Replacer tool switched to: " + type.getName());

View File

@ -102,7 +102,7 @@ public class FloatingTreeRemover implements BlockTool {
return true;
}
Vector[] recurseDirections = {
private Vector[] recurseDirections = {
PlayerDirection.NORTH.vector(),
PlayerDirection.EAST.vector(),
PlayerDirection.SOUTH.vector(),

View File

@ -67,8 +67,8 @@ public class FloodFillTool implements BlockTool {
EditSession editSession = session.createEditSession(player);
try {
recurse(server, editSession, world, clicked.toVector().toBlockVector(),
clicked.toVector(), range, initialType.getLegacyId(), new HashSet<>());
recurse(editSession, clicked.toVector().toBlockVector(),
clicked.toVector(), range, initialType, new HashSet<>());
} catch (MaxChangedBlocksException e) {
player.printError("Max blocks change limit reached.");
} finally {
@ -78,7 +78,7 @@ public class FloodFillTool implements BlockTool {
return true;
}
private void recurse(Platform server, EditSession editSession, World world, BlockVector pos, Vector origin, int size, int initialType,
private void recurse(EditSession editSession, BlockVector pos, Vector origin, int size, BlockType initialType,
Set<BlockVector> visited) throws MaxChangedBlocksException {
if (origin.distance(pos) > size || visited.contains(pos)) {
@ -87,23 +87,23 @@ public class FloodFillTool implements BlockTool {
visited.add(pos);
if (editSession.getBlock(pos).getType().getLegacyId() == initialType) {
if (editSession.getBlock(pos).getType() == initialType) {
editSession.setBlock(pos, pattern.apply(pos));
} else {
return;
}
recurse(server, editSession, world, pos.add(1, 0, 0).toBlockVector(),
recurse(editSession, pos.add(1, 0, 0).toBlockVector(),
origin, size, initialType, visited);
recurse(server, editSession, world, pos.add(-1, 0, 0).toBlockVector(),
recurse(editSession, pos.add(-1, 0, 0).toBlockVector(),
origin, size, initialType, visited);
recurse(server, editSession, world, pos.add(0, 0, 1).toBlockVector(),
recurse(editSession, pos.add(0, 0, 1).toBlockVector(),
origin, size, initialType, visited);
recurse(server, editSession, world, pos.add(0, 0, -1).toBlockVector(),
recurse(editSession, pos.add(0, 0, -1).toBlockVector(),
origin, size, initialType, visited);
recurse(server, editSession, world, pos.add(0, 1, 0).toBlockVector(),
recurse(editSession, pos.add(0, 1, 0).toBlockVector(),
origin, size, initialType, visited);
recurse(server, editSession, world, pos.add(0, -1, 0).toBlockVector(),
recurse(editSession, pos.add(0, -1, 0).toBlockVector(),
origin, size, initialType, visited);
}

View File

@ -93,7 +93,7 @@ public class RecursivePickaxe implements BlockTool {
return;
}
world.queueBlockBreakEffect(server, pos, initialType.getLegacyId(), distanceSq);
world.queueBlockBreakEffect(server, pos, initialType, distanceSq);
editSession.setBlock(pos, air);

View File

@ -24,7 +24,7 @@ import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
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;
@ -44,8 +44,8 @@ public class SinglePickaxe implements BlockTool {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
World world = (World) clicked.getExtent();
final int blockType = world.getLazyBlock(clicked.toVector()).getId();
if (blockType == BlockID.BEDROCK
final BlockType blockType = world.getLazyBlock(clicked.toVector()).getType();
if (blockType == BlockTypes.BEDROCK
&& !player.canDestroyBedrock()) {
return true;
}
@ -61,7 +61,7 @@ public class SinglePickaxe implements BlockTool {
editSession.flushQueue();
}
world.playEffect(clicked.toVector(), 2001, blockType);
world.playEffect(clicked.toVector(), 2001, blockType.getLegacyId());
return true;
}