3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +01:00

Expose a way of switching between ItemType and BlockType for ItemBlocks.

Dieser Commit ist enthalten in:
Matthew Miller 2018-07-01 23:20:07 +10:00
Ursprung b06937d1c8
Commit 93b225ca3c
17 geänderte Dateien mit 110 neuen und 1243 gelöschten Zeilen

Datei anzeigen

@ -69,7 +69,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
ItemStack itemStack = handSide == HandSide.MAIN_HAND
? player.getInventory().getItemInMainHand()
: player.getInventory().getItemInOffHand();
return BukkitUtil.toBlock(getWorld(), itemStack);
return BukkitUtil.toBlock(itemStack);
}
@Override

Datei anzeigen

@ -24,19 +24,17 @@ import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.ItemID;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.blocks.type.ItemType;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.util.Location;
import org.bukkit.DyeColor;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Dye;
import java.util.List;
@ -123,29 +121,17 @@ public final class BukkitUtil {
return ((BukkitWorld) world).getWorld();
}
public static BaseBlock toBlock(com.sk89q.worldedit.world.World world, ItemStack itemStack) throws WorldEditException {
final int typeId = itemStack.getTypeId();
switch (typeId) {
case ItemID.INK_SACK:
final Dye materialData = (Dye) itemStack.getData();
if (materialData.getColor() == DyeColor.BROWN) {
return new BaseBlock(BlockTypes.COCOA);
}
break;
default:
final BaseBlock baseBlock = BlockType.getBlockForItem(typeId, itemStack.getDurability());
if (baseBlock != null) {
return baseBlock;
}
break;
public static BaseBlock toBlock(ItemStack itemStack) throws WorldEditException {
ItemType itemType = LegacyMapper.getInstance().getItemFromLegacy(itemStack.getTypeId(), itemStack.getData().getData());
if (itemType.hasBlockType()) {
return new BaseBlock(itemType.getBlockType().getDefaultState());
} else {
return new BaseBlock(BlockTypes.AIR.getDefaultState());
}
return new BaseBlock(typeId, -1);
}
public static BaseItemStack toBaseItemStack(ItemStack itemStack) {
return new BaseItemStack(itemStack.getTypeId(), itemStack.getDurability());
ItemType itemType = LegacyMapper.getInstance().getItemFromLegacy(itemStack.getTypeId(), itemStack.getData().getData());
return new BaseItemStack(itemType, itemStack.getAmount());
}
}

Datei anzeigen

@ -443,7 +443,7 @@ public class EditSession implements Extent {
Vector pt = new Vector(x, y, z);
BlockState block = getBlock(pt);
int[] datas = LegacyMapper.getInstance().getLegacyFromBlock(block);
if (naturalOnly ? BlockType.isNaturalTerrainBlock(datas[0], datas[1]) : !BlockType.canPassThrough(datas[0], datas[1])) {
if (naturalOnly ? BlockType.isNaturalTerrainBlock(datas[0], datas[1]) : block.getBlockType().getMaterial().isMovementBlocker()) {
return y;
}
}
@ -1583,7 +1583,6 @@ public class EditSession implements Extent {
for (int y = world.getMaxY(); y >= 1; --y) {
final Vector pt = new Vector(x, y, z);
final BlockState block = getBlock(pt);
final com.sk89q.worldedit.blocks.type.BlockType id = block.getBlockType();
if (block.getBlockType() == BlockTypes.DIRT ||
(!onlyNormalDirt && block.getBlockType() == BlockTypes.COARSE_DIRT)) {
@ -1593,7 +1592,7 @@ public class EditSession implements Extent {
break;
} else if (block.getBlockType() == BlockTypes.WATER || block.getBlockType() == BlockTypes.LAVA) {
break;
} else if (!BlockType.canPassThrough(id.getLegacyId())) {
} else if (block.getBlockType().getMaterial().isMovementBlocker()) {
break;
}
}
@ -2116,8 +2115,7 @@ public class EditSession implements Extent {
while (!queue.isEmpty()) {
final BlockVector current = queue.removeFirst();
final BlockState block = getBlock(current);
int[] datas = LegacyMapper.getInstance().getLegacyFromBlock(block);
if (!BlockType.canPassThrough(datas[0], datas[1])) {
if (block.getBlockType().getMaterial().isMovementBlocker()) {
continue;
}

Datei anzeigen

@ -555,7 +555,7 @@ public class LocalSession {
* @throws InvalidToolBindException if the item can't be bound to that item
*/
public void setTool(ItemType item, @Nullable Tool tool) throws InvalidToolBindException {
if (false /*TODO item > 0 && item < 255*/) {
if (item.hasBlockType()) {
throw new InvalidToolBindException(item, "Blocks can't be used");
} else if (item == ItemTypes.getItemType(config.wandItem)) {
throw new InvalidToolBindException(item, "Already used for the wand");

Datei anzeigen

@ -25,7 +25,7 @@ import static com.sk89q.worldedit.event.platform.Interaction.OPEN;
import com.sk89q.worldedit.CuboidClipboard.FlipDirection;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.type.BlockType;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.platform.BlockInteractEvent;
import com.sk89q.worldedit.event.platform.InputType;
@ -488,7 +488,7 @@ public class WorldEdit {
int i = 0;
for (Integer id : missingBlocks.keySet()) {
BlockType type = BlockType.fromID(id);
BlockType type = LegacyMapper.getInstance().getBlockFromLegacy(id).getBlockType();
str.append(type != null
? type.getName() + " (" + id + ")"

Datei anzeigen

@ -127,7 +127,6 @@ public final class BlockID {
public static final int REDSTONE_REPEATER_ON = 94; // POWERED_REPEATER
@Deprecated
public static final int LOCKED_CHEST = 95;
public static final int STAINED_GLASS = 95;
public static final int TRAP_DOOR = 96; // TRAPDOOR
public static final int SILVERFISH_BLOCK = 97; // MONSTER_EGG
public static final int STONE_BRICK = 98; // STONEBRICK
@ -154,7 +153,6 @@ public final class BlockID {
public static final int END_PORTAL = 119;
public static final int END_PORTAL_FRAME = 120;
public static final int END_STONE = 121;
public static final int DRAGON_EGG = 122;
public static final int REDSTONE_LAMP_OFF = 123; // REDSTONE_LAMP
public static final int REDSTONE_LAMP_ON = 124; // LIT_REDSTONE_LAMP
public static final int DOUBLE_WOODEN_STEP = 125; // DOUBLE_WOODEN_SLAB
@ -170,7 +168,6 @@ public final class BlockID {
public static final int BIRCH_WOOD_STAIRS = 135; // BRUCE_STAIRS
public static final int JUNGLE_WOOD_STAIRS = 136; // JUNGLE_STAIRS
public static final int COMMAND_BLOCK = 137;
public static final int BEACON = 138;
public static final int COBBLESTONE_WALL = 139;
public static final int FLOWER_POT = 140;
public static final int CARROTS = 141;
@ -197,11 +194,8 @@ public final class BlockID {
public static final int LOG2 = 162;
public static final int ACACIA_STAIRS = 163;
public static final int DARK_OAK_STAIRS = 164;
public static final int SLIME = 165;
public static final int BARRIER = 166;
public static final int IRON_TRAP_DOOR = 167;
public static final int PRISMARINE = 168;
public static final int SEA_LANTERN = 169;
public static final int HAY_BLOCK = 170;
public static final int CARPET = 171;
public static final int HARDENED_CLAY = 172;
@ -211,9 +205,7 @@ public final class BlockID {
public static final int STANDING_BANNER = 176;
public static final int WALL_BANNER = 177;
public static final int DAYLIGHT_SENSOR_INVERTED = 178;
public static final int RED_SANDSTONE = 179;
public static final int RED_SANDSTONE_STAIRS = 180;
public static final int DOUBLE_STEP2 = 181;
public static final int STEP2 = 182;
public static final int SPRUCE_FENCE_GATE = 183;
public static final int BIRCH_FENCE_GATE = 184;
@ -233,59 +225,9 @@ public final class BlockID {
public static final int END_ROD = 198;
public static final int CHORUS_PLANT = 199;
public static final int CHORUS_FLOWER = 200;
public static final int PURPUR_BLOCK = 201;
public static final int PURPUR_PILLAR = 202;
public static final int PURPUR_STAIRS = 203;
public static final int PURPUR_DOUBLE_SLAB = 204;
public static final int PURPUR_SLAB = 205;
public static final int END_BRICKS = 206;
public static final int BEETROOTS = 207;
public static final int GRASS_PATH = 208;
public static final int END_GATEWAY = 209;
public static final int REPEATING_COMMAND_BLOCK = 210;
public static final int CHAIN_COMMAND_BLOCK = 211;
public static final int FROSTED_ICE = 212;
public static final int MAGMA_BLOCK = 213;
public static final int NETHER_WART_BLOCK = 214;
public static final int RED_NETHER_BRICK = 215;
public static final int BONE_BLOCK = 216;
public static final int STRUCTURE_VOID = 217;
public static final int OBSERVER = 218;
public static final int SHULKER_BOX_WHITE = 219;
public static final int SHULKER_BOX_ORANGE = 220;
public static final int SHULKER_BOX_MAGENTA = 221;
public static final int SHULKER_BOX_LIGHT_BLUE = 222;
public static final int SHULKER_BOX_YELLOW = 223;
public static final int SHULKER_BOX_LIME = 224;
public static final int SHULKER_BOX_PINK = 225;
public static final int SHULKER_BOX_GRAY = 226;
public static final int SHULKER_BOX_LIGHT_GRAY = 227;
public static final int SHULKER_BOX_CYAN = 228;
public static final int SHULKER_BOX_PURPLE = 229;
public static final int SHULKER_BOX_BLUE = 230;
public static final int SHULKER_BOX_BROWN = 231;
public static final int SHULKER_BOX_GREEN = 232;
public static final int SHULKER_BOX_RED = 233;
public static final int SHULKER_BOX_BLACK = 234;
public static final int TERRACOTTA_WHITE = 235;
public static final int TERRACOTTA_ORANGE = 236;
public static final int TERRACOTTA_MAGENTA = 237;
public static final int TERRACOTTA_LIGHT_BLUE = 238;
public static final int TERRACOTTA_YELLOW = 239;
public static final int TERRACOTTA_LIME = 240;
public static final int TERRACOTTA_PINK = 241;
public static final int TERRACOTTA_GRAY = 242;
public static final int TERRACOTTA_LIGHT_GRAY = 243;
public static final int TERRACOTTA_CYAN = 244;
public static final int TERRACOTTA_PURPLE = 245;
public static final int TERRACOTTA_BLUE = 246;
public static final int TERRACOTTA_BROWN = 247;
public static final int TERRACOTTA_GREEN = 248;
public static final int TERRACOTTA_RED = 249;
public static final int TERRACOTTA_BLACK = 250;
public static final int CONCRETE = 251;
public static final int CONCRETE_POWDER = 252;
public static final int STRUCTURE_BLOCK = 255;
private BlockID() {
}

Datei anzeigen

@ -27,218 +27,35 @@ package com.sk89q.worldedit.blocks;
@Deprecated
public final class ItemID {
public static final int IRON_SHOVEL = 256;
public static final int IRON_PICK = 257;
public static final int IRON_AXE = 258;
public static final int FLINT_AND_TINDER = 259;
public static final int RED_APPLE = 260;
public static final int BOW = 261;
public static final int ARROW = 262;
public static final int COAL = 263;
public static final int DIAMOND = 264;
public static final int IRON_BAR = 265;
public static final int GOLD_BAR = 266;
public static final int IRON_SWORD = 267;
public static final int WOOD_SWORD = 268;
public static final int WOOD_SHOVEL = 269;
public static final int WOOD_PICKAXE = 270;
public static final int WOOD_AXE = 271;
public static final int STONE_SWORD = 272;
public static final int STONE_SHOVEL = 273;
public static final int STONE_PICKAXE = 274;
public static final int STONE_AXE = 275;
public static final int DIAMOND_SWORD = 276;
public static final int DIAMOND_SHOVEL = 277;
public static final int DIAMOND_PICKAXE = 278;
public static final int DIAMOND_AXE = 279;
public static final int STICK = 280;
public static final int BOWL = 281;
public static final int MUSHROOM_SOUP = 282;
public static final int GOLD_SWORD = 283;
public static final int GOLD_SHOVEL = 284;
public static final int GOLD_PICKAXE = 285;
public static final int GOLD_AXE = 286;
public static final int STRING = 287;
public static final int FEATHER = 288;
public static final int SULPHUR = 289;
public static final int WOOD_HOE = 290;
public static final int STONE_HOE = 291;
public static final int IRON_HOE = 292;
public static final int DIAMOND_HOE = 293;
public static final int GOLD_HOE = 294;
public static final int SEEDS = 295;
public static final int WHEAT = 296;
public static final int BREAD = 297;
public static final int LEATHER_HELMET = 298;
public static final int LEATHER_CHEST = 299;
public static final int LEATHER_PANTS = 300;
public static final int LEATHER_BOOTS = 301;
public static final int CHAINMAIL_HELMET = 302;
public static final int CHAINMAIL_CHEST = 303;
public static final int CHAINMAIL_PANTS = 304;
public static final int CHAINMAIL_BOOTS = 305;
public static final int IRON_HELMET = 306;
public static final int IRON_CHEST = 307;
public static final int IRON_PANTS = 308;
public static final int IRON_BOOTS = 309;
public static final int DIAMOND_HELMET = 310;
public static final int DIAMOND_CHEST = 311;
public static final int DIAMOND_PANTS = 312;
public static final int DIAMOND_BOOTS = 313;
public static final int GOLD_HELMET = 314;
public static final int GOLD_CHEST = 315;
public static final int GOLD_PANTS = 316;
public static final int GOLD_BOOTS = 317;
public static final int FLINT = 318;
public static final int RAW_PORKCHOP = 319;
public static final int COOKED_PORKCHOP = 320;
public static final int PAINTING = 321;
public static final int GOLD_APPLE = 322;
public static final int SIGN = 323;
public static final int WOODEN_DOOR_ITEM = 324;
public static final int BUCKET = 325;
public static final int WATER_BUCKET = 326;
public static final int LAVA_BUCKET = 327;
public static final int MINECART = 328;
public static final int SADDLE = 329;
public static final int IRON_DOOR_ITEM = 330;
public static final int REDSTONE_DUST = 331;
public static final int SNOWBALL = 332;
public static final int WOOD_BOAT = 333;
public static final int LEATHER = 334;
public static final int MILK_BUCKET = 335;
public static final int BRICK_BAR = 336;
public static final int CLAY_BALL = 337;
public static final int SUGAR_CANE_ITEM = 338;
public static final int PAPER = 339;
public static final int BOOK = 340;
public static final int SLIME_BALL = 341;
public static final int STORAGE_MINECART = 342;
public static final int POWERED_MINECART = 343;
public static final int EGG = 344;
public static final int COMPASS = 345;
public static final int FISHING_ROD = 346;
public static final int WATCH = 347;
public static final int LIGHTSTONE_DUST = 348;
public static final int RAW_FISH = 349;
public static final int COOKED_FISH = 350;
public static final int INK_SACK = 351;
public static final int BONE = 352;
public static final int SUGAR = 353;
public static final int CAKE_ITEM = 354;
public static final int BED_ITEM = 355;
public static final int REDSTONE_REPEATER = 356;
public static final int COOKIE = 357;
public static final int MAP = 358;
public static final int SHEARS = 359;
public static final int MELON = 360;
public static final int PUMPKIN_SEEDS = 361;
public static final int MELON_SEEDS = 362;
public static final int RAW_BEEF = 363;
public static final int COOKED_BEEF = 364;
public static final int RAW_CHICKEN = 365;
public static final int COOKED_CHICKEN = 366;
public static final int ROTTEN_FLESH = 367;
public static final int ENDER_PEARL = 368;
public static final int BLAZE_ROD = 369;
public static final int GHAST_TEAR = 370;
public static final int GOLD_NUGGET = 371;
public static final int NETHER_WART_SEED = 372;
public static final int POTION = 373;
public static final int GLASS_BOTTLE = 374;
public static final int SPIDER_EYE = 375;
public static final int FERMENTED_SPIDER_EYE = 376;
public static final int BLAZE_POWDER = 377;
public static final int MAGMA_CREAM = 378;
public static final int BREWING_STAND = 379;
public static final int CAULDRON = 380;
public static final int EYE_OF_ENDER = 381;
public static final int GLISTERING_MELON = 382;
public static final int SPAWN_EGG = 383;
public static final int BOTTLE_O_ENCHANTING = 384;
public static final int FIRE_CHARGE = 385;
public static final int BOOK_AND_QUILL = 386;
public static final int WRITTEN_BOOK = 387;
public static final int EMERALD = 388;
public static final int ITEM_FRAME = 389;
public static final int FLOWER_POT = 390;
public static final int CARROT = 391;
public static final int POTATO = 392;
public static final int BAKED_POTATO = 393;
public static final int POISONOUS_POTATO = 394;
public static final int BLANK_MAP = 395;
public static final int GOLDEN_CARROT = 396;
public static final int HEAD = 397;
public static final int CARROT_ON_A_STICK = 398;
public static final int NETHER_STAR = 399;
public static final int PUMPKIN_PIE = 400;
public static final int FIREWORK_ROCKET = 401;
public static final int FIREWORK_STAR = 402;
public static final int ENCHANTED_BOOK = 403;
public static final int COMPARATOR = 404;
public static final int NETHER_BRICK = 405;
public static final int NETHER_QUARTZ = 406;
public static final int TNT_MINECART = 407;
public static final int HOPPER_MINECART = 408;
public static final int PRISMARINE_SHARD = 409;
public static final int PRISMARINE_CRYSTALS = 410;
public static final int RABBIT = 411;
public static final int COOKED_RABBIT = 412;
public static final int RABBIT_STEW = 413;
public static final int RABBIT_FOOT = 414;
public static final int RABBIT_HIDE = 415;
public static final int ARMOR_STAND = 416;
public static final int HORSE_ARMOR_IRON = 417;
public static final int HORSE_ARMOR_GOLD = 418;
public static final int HORSE_ARMOR_DIAMOND = 419;
public static final int LEAD = 420;
public static final int NAME_TAG = 421;
public static final int COMMAND_BLOCK_MINECART = 422;
public static final int MUTTON = 423;
public static final int COOKED_MUTTON = 424;
public static final int BANNER = 425;
public static final int END_CRYSTAL = 426;
public static final int SPRUCE_DOOR = 427;
public static final int BIRCH_DOOR = 428;
public static final int JUNGLE_DOOR = 429;
public static final int ACACIA_DOOR = 430;
public static final int DARK_OAK_DOOR = 431;
public static final int CHORUS_FRUIT = 432;
public static final int CHORUS_FRUIT_POPPED = 433;
public static final int BEETROOT = 434;
public static final int BEETROOT_SEEDS = 435;
public static final int BEETROOT_SOUP = 436;
public static final int DRAGON_BREATH = 437;
public static final int SPLASH_POTION = 438;
public static final int SPECTRAL_ARROW = 439;
public static final int TIPPED_ARROW = 440;
public static final int LINGERING_POTION = 441;
public static final int SHIELD = 442;
public static final int ELYTRA = 443;
public static final int SPRUCE_BOAT = 444;
public static final int BIRCH_BOAT = 445;
public static final int JUNGLE_BOAT = 446;
public static final int ACACIA_BOAT = 447;
public static final int DARK_OAK_BOAT = 448;
public static final int TOTEM_OF_UNDYING = 449;
public static final int SHULKER_SHELL = 450;
public static final int IRON_NUGGET = 452;
public static final int KNOWLEDGE_BOOK = 453;
@Deprecated public static final int GOLD_RECORD = 2256; // deprecated, but leave it there
@Deprecated public static final int GREEN_RECORD = 2257; // deprecated, but leave it there
public static final int DISC_13 = 2256;
public static final int DISC_CAT = 2257;
public static final int DISC_BLOCKS = 2258;
public static final int DISC_CHIRP = 2259;
public static final int DISC_FAR = 2260;
public static final int DISC_MALL = 2261;
public static final int DISC_MELLOHI = 2262;
public static final int DISC_STAL = 2263;
public static final int DISC_STRAD = 2264;
public static final int DISC_WARD = 2265;
public static final int DISC_11 = 2266;
public static final int DISC_WAIT = 2267;
private ItemID() {
}

Datei anzeigen

@ -19,11 +19,16 @@
package com.sk89q.worldedit.blocks.type;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.world.registry.BundledBlockData;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.util.function.Function;
import javax.annotation.Nullable;
public class BlockType {
private String id;
@ -77,6 +82,34 @@ public class BlockType {
return this.defaultState;
}
/**
* Gets whether this block type has an item representation.
*
* @return If it has an item
*/
public boolean hasItemType() {
return getItemType() != null;
}
/**
* Gets the item representation of this block type, if it exists.
*
* @return The item representation
*/
@Nullable
public ItemType getItemType() {
return ItemTypes.getItemType(this.id);
}
/**
* Get the material for this BlockType.
*
* @return The material
*/
public BlockMaterial getMaterial() {
return WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(this.id);
}
/**
* Gets the legacy ID. Needed for legacy reasons.
*
@ -94,11 +127,6 @@ public class BlockType {
}
}
@Deprecated
public com.sk89q.worldedit.blocks.BlockType getLegacyType() {
return com.sk89q.worldedit.blocks.BlockType.fromID(getLegacyId());
}
@Override
public int hashCode() {
return this.id.hashCode();

Datei anzeigen

@ -22,6 +22,8 @@ package com.sk89q.worldedit.blocks.type;
import com.sk89q.worldedit.world.registry.BundledItemData;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import javax.annotation.Nullable;
public class ItemType {
private String id;
@ -52,6 +54,26 @@ public class ItemType {
}
}
/**
* Gets whether this item type has a block representation.
*
* @return If it has a block
*/
public boolean hasBlockType() {
return getBlockType() != null;
}
/**
* Gets the block representation of this item type, if it exists.
*
* @return The block representation
*/
@Nullable
public BlockType getBlockType() {
return BlockTypes.getBlockType(this.id);
}
/**
* Gets the legacy ID. Needed for legacy reasons.
*

Datei anzeigen

@ -192,13 +192,13 @@ public class GeneralCommands {
break;
}
// TODO if (blocksOnly && searchType.getID() > 255) {
// continue;
// }
//
// if (itemsOnly && searchType.getID() <= 255) {
// continue;
// }
if (blocksOnly && !searchType.hasBlockType()) {
continue;
}
if (itemsOnly && searchType.hasBlockType()) {
continue;
}
for (String alias : Sets.newHashSet(searchType.getId(), searchType.getName())) {
if (alias.contains(query)) {

Datei anzeigen

@ -102,7 +102,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
byte free = 0;
while (y <= world.getMinimumPoint().getBlockY() + 2) {
if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
++free;
} else {
free = 0;
@ -132,7 +132,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
while (y >= 0) {
final Vector pos = new Vector(x, y, z);
final BlockState id = world.getBlock(pos);
if (!BlockType.canPassThrough(id.getBlockType().getLegacyId())) {
if (id.getBlockType().getMaterial().isMovementBlocker()) {
setPosition(new Vector(x + 0.5, y + BlockType.centralTopLimit(id), z + 0.5));
return;
}
@ -158,7 +158,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
byte spots = 0;
while (y <= world.getMaximumPoint().getY() + 2) {
if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
++free;
} else {
free = 0;
@ -198,7 +198,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
byte free = 0;
while (y >= 1) {
if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
if (!world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
++free;
} else {
free = 0;
@ -253,7 +253,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
while (y <= world.getMaximumPoint().getY()) {
// Found a ceiling!
if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
if (world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
int platformY = Math.max(initialY, y - 3 - clearance);
floatAt(x, platformY + 1, z, alwaysGlass);
return true;
@ -281,7 +281,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
final Extent world = getLocation().getExtent();
while (y <= world.getMaximumPoint().getY() + 2) {
if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
if (world.getBlock(new Vector(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
break; // Hit something
} else if (y > maxY + 1) {
break;
@ -364,7 +364,11 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException {
final ItemType typeId = getItemInHand(handSide).getType();
return new BaseBlock(typeId.getLegacyId());
if (typeId.hasBlockType()) {
return new BaseBlock(typeId.getBlockType());
} else {
return new BaseBlock(BlockTypes.AIR);
}
}
/**
@ -384,7 +388,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
boolean inFree = false;
while ((block = hitBlox.getNextBlock()) != null) {
boolean free = BlockType.canPassThrough(world.getBlock(block.toVector()));
boolean free = !world.getBlock(block.toVector()).getBlockType().getMaterial().isMovementBlocker();
if (firstBlock) {
firstBlock = false;

Datei anzeigen

@ -20,7 +20,6 @@
package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.Blocks;
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
import com.sk89q.worldedit.extent.Extent;

Datei anzeigen

@ -19,10 +19,9 @@
package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.type.BlockState;
import com.sk89q.worldedit.extent.Extent;
import javax.annotation.Nullable;
@ -35,8 +34,8 @@ public class SolidBlockMask extends AbstractExtentMask {
@Override
public boolean test(Vector vector) {
Extent extent = getExtent();
BaseBlock lazyBlock = extent.getLazyBlock(vector);
return !BlockType.canPassThrough(lazyBlock.getBlockType().getLegacyId(), lazyBlock.getData());
BlockState block = extent.getBlock(vector);
return block.getBlockType().getMaterial().isMovementBlocker();
}
@Nullable

Datei anzeigen

@ -136,7 +136,7 @@ public class TargetBlock {
* @return Block
*/
public Location getSolidTargetBlock() {
while (getNextBlock() != null && BlockType.canPassThrough(world.getBlock(getCurrentBlock().toVector()))) ;
while (getNextBlock() != null && !world.getBlock(getCurrentBlock().toVector()).getBlockType().getMaterial().isMovementBlocker()) ;
return getCurrentBlock();
}

Datei anzeigen

@ -19,15 +19,15 @@
package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.blocks.type.BlockState;
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
import com.sk89q.worldedit.world.registry.state.State;
import javax.annotation.Nullable;
import java.util.Map;
import javax.annotation.Nullable;
/**
* Provides information on blocks and provides methods to create them.
*/
@ -45,11 +45,11 @@ public interface BlockRegistry {
/**
* Get the material for the given block.
*
* @param block the block
* @param id the block
* @return the material, or null if the material information is not known
*/
@Nullable
BlockMaterial getMaterial(BaseBlock block);
BlockMaterial getMaterial(String id);
/**
* Get an unmodifiable map of states for this block.

Datei anzeigen

@ -19,16 +19,16 @@
package com.sk89q.worldedit.world.registry;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockMaterial;
import com.sk89q.worldedit.blocks.type.BlockState;
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
import com.sk89q.worldedit.blocks.type.BlockTypes;
import com.sk89q.worldedit.world.registry.state.State;
import javax.annotation.Nullable;
import java.util.Map;
import javax.annotation.Nullable;
/**
* A block registry that uses {@link BundledBlockData} to serve information
* about blocks.
@ -43,8 +43,8 @@ public class BundledBlockRegistry implements BlockRegistry {
@Nullable
@Override
public BlockMaterial getMaterial(BaseBlock block) {
return BundledBlockData.getInstance().getMaterialById(block.getBlockType().getId());
public BlockMaterial getMaterial(String id) {
return BundledBlockData.getInstance().getMaterialById(id);
}
@Nullable