@Override public BaseBlock toBaseBlock(CompoundTag compoundTag) { if (compoundTag == null) { return this.blockState.toBaseBlock(); } else if (compoundTag == this.nbtData) { return this; } else { return new BaseBlock(this.blockState, compoundTag); } }
@Override public BaseBlock apply(BlockVector3 pos) { BaseBlock block = buffer.get(pos); if (block != null) { return block; } else { return BlockTypes.AIR.getDefaultState().toBaseBlock(); } }
@Override public BaseBlock toBaseBlock(CompoundTag compoundTag) { if (compoundTag == null) { return toBaseBlock(); } return new BaseBlock(this, compoundTag); }
@Override public BaseBlock getFullBlock(BlockVector3 position) { return getBlock(position).toBaseBlock(); }
@Override public BaseBlock getFullBlock(BlockVector3 position) { return getBlock(position).toBaseBlock(); }
@Override public BaseBlock getBlock(BlockVector3 position) throws DataException { int id = getBlockID(position); int data = getBlockData(position); BlockState state = LegacyMapper.getInstance().getBlockFromLegacy(id, data); if (state == null) { WorldEdit.logger.warning("Unknown legacy block " + id + ":" + data + " found when loading legacy anvil chunk."); return BlockTypes.AIR.getDefaultState().toBaseBlock(); } CompoundTag tileEntity = getBlockTileEntity(position); if (tileEntity != null) { return state.toBaseBlock(tileEntity); } return state.toBaseBlock(); }
@Override public <V> BaseBlock with(Property<V> property, V value) { return this.blockState.with(property, value).toBaseBlock(getNbtData()); }
@Override public BaseBlock getBlock(BlockVector3 position) throws DataException { int x = position.getX() - rootX * 16; int y = position.getY(); int z = position.getZ() - rootZ * 16; int section = y >> 4; int yIndex = y & 0x0F; if (section < 0 || section >= blocks.length) { throw new DataException("Chunk does not contain position " + position); } BlockState[] sectionBlocks = blocks[section]; BlockState state = sectionBlocks != null ? sectionBlocks[(yIndex << 8) | (z << 4) | x] : BlockTypes.AIR.getDefaultState(); CompoundTag tileEntity = getBlockTileEntity(position); if (tileEntity != null) { return state.toBaseBlock(tileEntity); } return state.toBaseBlock(); }
@Override public BaseBlock getBlock(BlockVector3 position) throws DataException { if(position.getY() >= 128) return BlockTypes.VOID_AIR.getDefaultState().toBaseBlock(); int id, dataVal; if (state == null) { WorldEdit.logger.warning("Unknown legacy block " + id + ":" + dataVal + " found when loading legacy anvil chunk."); return BlockTypes.AIR.getDefaultState().toBaseBlock(); return state.toBaseBlock(tileEntity); return state.toBaseBlock();
@Override public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException { ItemStack itemStack = handSide == HandSide.MAIN_HAND ? player.getInventory().getItemInMainHand() : player.getInventory().getItemInOffHand(); return BukkitAdapter.asBlockState(itemStack).toBaseBlock(); }
@Override public BaseBlock getFullBlock(BlockVector3 position) { BlockPos pos = new BlockPos(position.getBlockX(), position.getBlockY(), position.getBlockZ()); TileEntity tile = getWorld().getTileEntity(pos); if (tile != null) { return getBlock(position).toBaseBlock(NBTConverter.fromNative(TileEntityUtils.copyNbtData(tile))); } else { return getBlock(position).toBaseBlock(); } }
@Override public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException { final ItemType typeId = getItemInHand(handSide).getType(); if (typeId.hasBlockType()) { return typeId.getBlockType().getDefaultState().toBaseBlock(); } else { throw new NotABlockException(); } }
@Override public BaseBlock getFullBlock(BlockVector3 position) { BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter(); if (adapter != null) { return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position)); } else { return getBlock(position).toBaseBlock(); } }
@Override public BaseBlock getFullBlock(BlockVector3 position) { if (region.contains(position)) { BlockVector3 v = position.subtract(region.getMinimumPoint()); BaseBlock block = blocks[v.getBlockX()][v.getBlockY()][v.getBlockZ()]; if (block != null) { return block; } } return BlockTypes.AIR.getDefaultState().toBaseBlock(); }
structureTag.put("id", new StringTag(BlockTypes.STRUCTURE_BLOCK.getId())); return BlockTypes.STRUCTURE_BLOCK.getDefaultState().toBaseBlock(new CompoundTag(structureTag));
return state.toBaseBlock();
values.remove("Id"); values.remove("Pos"); clipboard.setBlock(clipboard.getMinimumPoint().add(pt), state.toBaseBlock(new CompoundTag(values))); } else { clipboard.setBlock(clipboard.getMinimumPoint().add(pt), state);
@Override protected BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial) { final Vector3 current = Vector3.at(x, y, z); environment.setCurrentBlock(current); final Vector3 scaled = current.subtract(zero).divide(unit); try { if (expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ(), defaultMaterial.getBlockType().getLegacyId(), 0) <= 0) { // TODO data return null; } return LegacyMapper.getInstance().getBlockFromLegacy((int) typeVariable.getValue(), (int) dataVariable.getValue()).toBaseBlock(); } catch (Exception e) { log.log(Level.WARNING, "Failed to create shape", e); return null; } } };
if (state != null) { if (tileEntitiesMap.containsKey(pt)) { clipboard.setBlock(region.getMinimumPoint().add(pt), state.toBaseBlock(new CompoundTag(tileEntitiesMap.get(pt)))); } else { clipboard.setBlock(region.getMinimumPoint().add(pt), state);