Further BaseBlock modernisation

This commit is contained in:
Matthew Miller
2018-06-18 17:53:33 +10:00
parent 811f1d4433
commit e99190225e
61 changed files with 344 additions and 787 deletions

View File

@ -34,6 +34,7 @@ import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.blocks.type.ItemTypes;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.input.ParserContext;
@ -277,7 +278,7 @@ public class SelectionCommands {
@CommandPermissions("worldedit.wand")
public void wand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
player.giveItem(ItemTypes.getItemType(we.getConfiguration().wandItem).getLegacyId(), 1);
player.giveItem(new BaseItemStack(ItemTypes.getItemType(we.getConfiguration().wandItem), 1));
player.print("Left click: select pos #1; Right click: select pos #2");
}
@ -677,12 +678,12 @@ public class SelectionCommands {
player.print("# total blocks: " + size);
for (Countable<BaseBlock> c : distributionData) {
String name = c.getID().getType().getName();
String name = c.getID().getBlockType().getName();
String str = String.format("%-7s (%.3f%%) %s #%s%s",
String.valueOf(c.getAmount()),
c.getAmount() / (double) size * 100,
name,
c.getID().getType().getId(),
c.getID().getBlockType().getId(),
c.getID().getStates());
player.print(str);
}

View File

@ -214,7 +214,7 @@ public class ToolCommands {
session.setTool(itemStack.getType(), new LongRangeBuildTool(primary, secondary));
player.print("Long-range building tool bound to " + itemStack.getType().getName() + ".");
player.print("Left-click set to " + secondary.getType().getName() + "; right-click set to "
+ primary.getType().getName() + ".");
player.print("Left-click set to " + secondary.getBlockType().getName() + "; right-click set to "
+ primary.getBlockType().getName() + ".");
}
}

View File

@ -32,6 +32,7 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.command.util.CreatureButcher;
import com.sk89q.worldedit.command.util.EntityRemover;
import com.sk89q.worldedit.entity.Entity;
@ -65,7 +66,6 @@ import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
import com.sk89q.worldedit.world.World;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@ -176,7 +176,7 @@ public class UtilityCommands {
double radius = Math.max(0, args.getDouble(0));
we.checkMaxRadius(radius);
int affected = editSession.fixLiquid(
session.getPlacementPosition(player), radius, 10, 11);
session.getPlacementPosition(player), radius, BlockTypes.FLOWING_LAVA, BlockTypes.LAVA);
player.print(affected + " block(s) have been changed.");
}
@ -194,7 +194,7 @@ public class UtilityCommands {
double radius = Math.max(0, args.getDouble(0));
we.checkMaxRadius(radius);
int affected = editSession.fixLiquid(
session.getPlacementPosition(player), radius, 8, 9);
session.getPlacementPosition(player), radius, BlockTypes.FLOWING_WATER, BlockTypes.WATER);
player.print(affected + " block(s) have been changed.");
}
@ -261,7 +261,7 @@ public class UtilityCommands {
int size = Math.max(1, args.getInteger(1, 50));
we.checkMaxRadius(size);
int affected = editSession.removeNear(session.getPlacementPosition(player), block.getType().getLegacyId(), size);
int affected = editSession.removeNear(session.getPlacementPosition(player), block.getBlockType().getLegacyId(), size);
player.print(affected + " block(s) have been removed.");
}

View File

@ -68,7 +68,7 @@ public class ItemUseParser extends SimpleCommand<Contextual<RegionFunction>> {
@Override
public String toString() {
return "application of the item " + item.getType() + ":" + item.getData();
return "application of the item " + item.getType() + ":" + item.getNbtData();
}
}

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 = clicked.getExtent().getBlock(clicked.toVector()).getType();
BlockType initialType = clicked.getExtent().getBlock(clicked.toVector()).getBlockType();
if (initialType == BlockTypes.AIR) {
return true;
@ -68,7 +68,7 @@ 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.getBlock(pos).getType() != initialType) {
if (editSession.getBlock(pos).getBlockType() != initialType) {
continue;
}

View File

@ -67,7 +67,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
EditSession editSession = session.createEditSession(player);
targetBlock = (editSession).getBlock(clicked.toVector());
BlockType type = targetBlock.getType().getLegacyType();
BlockType type = targetBlock.getBlockType().getLegacyType();
if (type != null) {
player.print("Replacer tool switched to: " + type.getName());

View File

@ -81,7 +81,7 @@ public class FloatingTreeRemover implements BlockTool {
}
for (Vector blockVector : blockSet) {
final int typeId = editSession.getBlock(blockVector).getType().getLegacyId();
final int typeId = editSession.getBlock(blockVector).getBlockType().getLegacyId();
switch (typeId) {
case BlockID.LOG:
case BlockID.LOG2:

View File

@ -54,7 +54,7 @@ public class FloodFillTool implements BlockTool {
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
World world = (World) clicked.getExtent();
BlockType initialType = world.getLazyBlock(clicked.toVector()).getType();
BlockType initialType = world.getLazyBlock(clicked.toVector()).getBlockType();
if (initialType == BlockTypes.AIR) {
return true;
@ -87,7 +87,7 @@ public class FloodFillTool implements BlockTool {
visited.add(pos);
if (editSession.getBlock(pos).getType() == initialType) {
if (editSession.getBlock(pos).getBlockType() == initialType) {
editSession.setBlock(pos, pattern.apply(pos));
} else {
return;

View File

@ -55,7 +55,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
if (pos == null) return false;
EditSession eS = session.createEditSession(player);
try {
if (secondary.getType() == BlockTypes.AIR) {
if (secondary.getBlockType() == BlockTypes.AIR) {
eS.setBlock(pos.toVector(), secondary);
} else {
eS.setBlock(pos.getDirection(), secondary);
@ -74,7 +74,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
if (pos == null) return false;
EditSession eS = session.createEditSession(player);
try {
if (primary.getType() == BlockTypes.AIR) {
if (primary.getBlockType() == BlockTypes.AIR) {
eS.setBlock(pos.toVector(), primary);
} else {
eS.setBlock(pos.getDirection(), primary);

View File

@ -48,8 +48,8 @@ public class QueryTool implements BlockTool {
BaseBlock block = editSession.getBlock(clicked.toVector());
player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
+ "#" + block.getType() + "\u00A77" + " ("
+ block.getType().getId() + ") "
+ "#" + block.getBlockType() + "\u00A77" + " ("
+ block.getBlockType().getId() + ") "
+ "\u00A7f"
+ "[" + block.getStates().toString() + "]" + " (" + world.getBlockLightLevel(clicked.toVector()) + "/" + world.getBlockLightLevel(clicked.toVector().add(0, 1, 0)) + ")");

View File

@ -53,7 +53,7 @@ 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();
BlockType initialType = world.getBlock(clicked.toVector()).getType();
BlockType initialType = world.getBlock(clicked.toVector()).getBlockType();
if (initialType == BlockTypes.AIR) {
return true;
@ -89,7 +89,7 @@ public class RecursivePickaxe implements BlockTool {
visited.add(pos);
if (editSession.getBlock(pos).getType() != initialType) {
if (editSession.getBlock(pos).getBlockType() != initialType) {
return;
}

View File

@ -44,7 +44,7 @@ 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 BlockType blockType = world.getLazyBlock(clicked.toVector()).getType();
final BlockType blockType = world.getLazyBlock(clicked.toVector()).getBlockType();
if (blockType == BlockTypes.BEDROCK
&& !player.canDestroyBedrock()) {
return true;