当前位置: 首页>>代码示例>>Java>>正文


Java BaseBlock.getData方法代码示例

本文整理汇总了Java中com.sk89q.worldedit.blocks.BaseBlock.getData方法的典型用法代码示例。如果您正苦于以下问题:Java BaseBlock.getData方法的具体用法?Java BaseBlock.getData怎么用?Java BaseBlock.getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sk89q.worldedit.blocks.BaseBlock的用法示例。


在下文中一共展示了BaseBlock.getData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setBlock

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) {
    try {
        int index = (HEADER_SIZE) + (getIndex(x, y, z) << 1);
        final int id = block.getId();
        final int data = block.getData();
        int combined = (id << 4) + data;
        mbb.putChar(index, (char) combined);
        CompoundTag tile = block.getNbtData();
        if (tile != null) {
            setTile(x, y, z, tile);
        }
        return true;
    } catch (Exception e) {
        MainUtil.handleError(e);
    }
    return false;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:19,代码来源:DiskOptimizedClipboard.java

示例2: applyBlock

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public void applyBlock(int x, int y, int z, BaseBlock block, MutableLong ignore) {
    int id = block.getId();
    int data = FaweCache.hasData(id) ? block.getData() : 0;
    int combined = FaweCache.getCombined(id, data);
    Pattern p = map[combined];
    if (p != null) {
        BaseBlock newBlock = p.apply(x, y, z);
        int currentId = block.getId();
        if (FaweCache.hasNBT(currentId)) {
            block.setNbtData(null);
        }
        block.setId(newBlock.getId());
        block.setData(newBlock.getData());
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:17,代码来源:MappedReplacePatternFilter.java

示例3: getName

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public String getName(BaseBlock block) {
    BlockEntry entry = legacyMap[block.getId()];
    if (entry != null) {
        String name = entry.id;
        if (block.getData() == 0) return name;
        StringBuilder append = new StringBuilder();
        Map<String, FaweState> states = entry.states;
        FaweState variants = states.get("variant");
        if (variants == null) variants = states.get("color");
        if (variants == null && !states.isEmpty()) variants = states.entrySet().iterator().next().getValue();
        if (variants != null) {
            for (Map.Entry<String, FaweStateValue> variant : variants.valueMap().entrySet()) {
                FaweStateValue state = variant.getValue();
                if (state.isSet(block)) {
                    append.append(append.length() == 0 ? ":" : "|");
                    append.append(variant.getKey());
                }
            }
        }
        if (append.length() == 0) return name + ":" + block.getData();
        return name + append;
    }
    if (block.getData() == 0) return Integer.toString(block.getId());
    return block.getId() + ":" + block.getData();
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:26,代码来源:BundledBlockData.java

示例4: setTool

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public void setTool(BaseBlock item, @Nullable Tool tool, Player player) throws InvalidToolBindException {
    int id = item.getId();
    int data = item.getData();
    if (id > 0 && id < 255) {
        throw new InvalidToolBindException(id, "Blocks can't be used");
    } else if (id == config.wandItem) {
        throw new InvalidToolBindException(id, "Already used for the wand");
    } else if (id == config.navigationWand) {
        throw new InvalidToolBindException(id, "Already used for the navigation wand");
    }
    Tool previous;
    if (player != null && (tool instanceof BrushTool || tool == null) && item instanceof BrushHolder) {
        BrushHolder holder = (BrushHolder) item;
        previous = holder.setTool((BrushTool) tool);
        if (tool != null) ((BrushTool) tool).setHolder(holder);
    } else {
        previous = this.tools.put(FaweCache.getCombined(id, data), tool);
    }
    if (previous != null && player != null && previous instanceof BrushTool) {
        BrushTool brushTool = (BrushTool) previous;
        brushTool.clear(player);
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:24,代码来源:LocalSession.java

示例5: apply

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public BaseBlock apply(Vector position) {
    BaseBlock oldBlock = getExtent().getBlock(position);
    BaseBlock newBlock = pattern.apply(position);
    int oldData = oldBlock.getData();
    int newData = newBlock.getData() + oldData - (oldData & bitMask);
    return FaweCache.getBlock(newBlock.getId(), newData);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:9,代码来源:IdDataMaskPattern.java

示例6: add

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public void add(int x, int y, int z, int combinedFrom, BaseBlock to) {
    try {
        if (to.hasNbtData()) {
            CompoundTag nbt = to.getNbtData();
            MainUtil.setPosition(nbt, x, y, z);
            addTileCreate(nbt);
        }
        int combinedTo = (to.getId() << 4) + to.getData();
        add(x, y, z, combinedFrom, combinedTo);

    } catch (Exception e) {
        MainUtil.handleError(e);
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:15,代码来源:FaweChangeSet.java

示例7: setBlock

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public boolean setBlock(int x, int y, int z, BaseBlock block) throws WorldEditException {
    int combined = queue.getCombinedId4DataDebug(x, y, z, 0, session);
    int id = (combined >> 4);
    if (id == block.getId()) {
        if (!FaweCache.hasData(id)) {
            if (!block.hasNbtData()) {
                return false;
            }
        } else if (!block.hasNbtData()) {
            int data = combined & 0xF;
            if (data == block.getData()) {
                return false;
            }
        }
    }
    try {
        if (!FaweCache.hasNBT(id)) {
            if (block.canStoreNBTData()) {
                this.changeSet.add(x, y, z, combined, block);
            } else {
                this.changeSet.add(x, y, z, combined, (block.getId() << 4) + block.getData());
            }
        } else {
            try {
                CompoundTag tag = queue.getTileEntity(x, y, z);
                this.changeSet.add(x, y, z, new BaseBlock(id, combined & 0xF, tag), block);
            } catch (Throwable e) {
                e.printStackTrace();
                this.changeSet.add(x, y, z, combined, block);
            }
        }
    } catch (FaweException ignore) {
        return false;
    }
    return getExtent().setBlock(x, y, z, block);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:38,代码来源:HistoryExtent.java

示例8: add

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public void add(BaseBlock block) {
    blockIds[block.getId()] = true;
    if (block.getData() == -1) {
        for (int data = 0; data < 16; data++) {
            blocks[FaweCache.getCombined(block.getId(), data)] = true;
        }
    } else {
        blocks[FaweCache.getCombined(block)] = true;
    }
    computedLegacyList = null;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:12,代码来源:BlockMask.java

示例9: run

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public void run(int x, int y, int z, BaseBlock block) {
    if (this.x == x - 1 && this.y == y && this.z == z) {
        this.x++;
        index++;
    } else {
        index = yarea[this.y = y] + zwidth[this.z = z] + (this.x = x);
    }
    int id = block.getId();
    blocks[index] = (byte) id;
    if (FaweCache.hasData(id)) {
        blockData[index] = (byte) block.getData();
        if (id > 255) {
            if (addBlocks == null) { // Lazily create section
                addBlocks = new byte[((blocks.length + 1) >> 1)];
            }
            addBlocks[index >> 1] = (byte) (((index & 1) == 0) ? addBlocks[index >> 1] & 0xF0 | (id >> 8) & 0xF : addBlocks[index >> 1] & 0xF | ((id >> 8) & 0xF) << 4);
        }
    }
    CompoundTag rawTag = block.getNbtData();
    if (rawTag != null) {
        Map<String, Tag> values = ReflectionUtils.getMap(rawTag.getValue());
        values.put("id", new StringTag(block.getNbtId()));
        values.put("x", new IntTag(x));
        values.put("y", new IntTag(y));
        values.put("z", new IntTag(z));
        tileEntities.add(rawTag);
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:30,代码来源:SchematicWriter.java

示例10: getMaterialCached

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
private BaseBlock getMaterialCached(int x, int y, int z, Pattern pattern) {
    final int index = (y - cacheOffsetY) + (z - cacheOffsetZ) * cacheSizeY + (x - cacheOffsetX) * cacheSizeY * cacheSizeZ;

    final short cacheEntry = cache[index];
    switch (cacheEntry) {
        case 0:
            // unknown, fetch material
            final BaseBlock material = getMaterial(x, y, z, pattern.apply(new BlockVector(x, y, z)));
            if (material == null) {
                // outside
                cache[index] = -1;
                return null;
            }

            short newCacheEntry = (short) (material.getType() | ((material.getData() + 1) << 8));
            if (newCacheEntry == 0) {
                // type and data 0
                newCacheEntry = -2;
            }

            cache[index] = newCacheEntry;
            return material;

        case -1:
            // outside
            return null;

        case -2:
            // type and data 0
            return new BaseBlock(0, 0);
    }

    return new BaseBlock(cacheEntry & 255, ((cacheEntry >> 8) - 1) & 15);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:35,代码来源:ArbitraryShape.java

示例11: getBlockDistributionWithData

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
/**
 * Get the block distribution inside a clipboard with data values.
 *
 * @return a block distribution
 */
// TODO reduce code duplication
public List<Countable<BaseBlock>> getBlockDistributionWithData() {
    List<Countable<BaseBlock>> distribution = new ArrayList<Countable<BaseBlock>>();
    Map<BaseBlock, Countable<BaseBlock>> map = new HashMap<BaseBlock, Countable<BaseBlock>>();

    int maxX = getWidth();
    int maxY = getHeight();
    int maxZ = getLength();

    for (int x = 0; x < maxX; ++x) {
        for (int y = 0; y < maxY; ++y) {
            for (int z = 0; z < maxZ; ++z) {
                final BaseBlock block = getBlock(x, y, z);
                if (block == null) {
                    continue;
                }

                // Strip the block from metadata that is not part of our key
                final BaseBlock bareBlock = new BaseBlock(block.getId(), block.getData());

                if (map.containsKey(bareBlock)) {
                    map.get(bareBlock).increment();
                } else {
                    Countable<BaseBlock> c = new Countable<BaseBlock>(bareBlock, 1);
                    map.put(bareBlock, c);
                    distribution.add(c);
                }
            }
        }
    }

    Collections.sort(distribution);
    // Collections.reverse(distribution);

    return distribution;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:42,代码来源:CuboidClipboard.java

示例12: query

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Dynamic
public static double query(RValue x, RValue y, RValue z, RValue type, RValue data) throws EvaluationException {
    final double xp = x.getValue();
    final double yp = y.getValue();
    final double zp = z.getValue();

    final ExpressionEnvironment environment = Expression.getInstance().getEnvironment();

    // Read values from world
    BaseBlock block = environment.getBlock(xp, yp, zp);
    int typeId = block.getId();
    int dataValue = block.getData();

    return queryInternal(type, data, typeId, dataValue);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:16,代码来源:Functions.java

示例13: queryAbs

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Dynamic
public static double queryAbs(RValue x, RValue y, RValue z, RValue type, RValue data) throws EvaluationException {
    final double xp = x.getValue();
    final double yp = y.getValue();
    final double zp = z.getValue();

    final ExpressionEnvironment environment = Expression.getInstance().getEnvironment();

    // Read values from world
    BaseBlock block = environment.getBlockAbs(xp, yp, zp);
    int typeId = block.getId();
    int dataValue = block.getData();

    return queryInternal(type, data, typeId, dataValue);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:16,代码来源:Functions.java

示例14: queryRel

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Dynamic
public static double queryRel(RValue x, RValue y, RValue z, RValue type, RValue data) throws EvaluationException {
    final double xp = x.getValue();
    final double yp = y.getValue();
    final double zp = z.getValue();

    final ExpressionEnvironment environment = Expression.getInstance().getEnvironment();

    // Read values from world
    BaseBlock block = environment.getBlockRel(xp, yp, zp);
    int typeId = block.getId();
    int dataValue = block.getData();

    return queryInternal(type, data, typeId, dataValue);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:16,代码来源:Functions.java

示例15: remapItem

import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public BaseItem remapItem(String name, int damage) {
    if (name.isEmpty()) return new BaseItem(0);
    if (from == RemapPlatform.PC) {
        BundledBlockData.BlockEntry state = BundledBlockData.getInstance().findById(name);
        if (state != null) {
            BaseBlock remapped = remap(new BaseBlock(state.legacyId, damage));
            return new BaseItem(remapped.getId(), (short) remapped.getData());
        } else {
            try {
                name = name.replace("minecraft:", "");
                WikiScraper scraper = loadItemMapping();
                Map<String, Integer> mapFrom = scraper.scapeOrCache(WikiScraper.Wiki.valueOf("ITEM_MAPPINGS_" + from.name()));
                Map<String, Integer> mapTo = scraper.scapeOrCache(WikiScraper.Wiki.valueOf("ITEM_MAPPINGS_" + from.opposite().name()));
                scraper.expand(mapTo);
                switch (name) {
                    case "spruce_boat":  return new BaseItem(333, (short) 1);
                    case "birch_boat":  return new BaseItem(333, (short) 2);
                    case "jungle_boat":  return new BaseItem(333, (short) 3);
                    case "acacia_boat":  return new BaseItem(333, (short) 4);
                    case "dark_oak_boat": return new BaseItem(333, (short) 5);
                    case "water_bucket": return new BaseItem(325, (short) 8);
                    case "lava_bucket": return new BaseItem(325, (short) 10);
                    case "milk_bucket": return new BaseItem(325, (short) 1);
                    case "tipped_arrow":
                    case "spectral_arrow":
                        name = "arrow"; // Unsupported
                        break;
                    case "totem_of_undying":
                        name = "totem";
                        break;
                    case "furnace_minecart":
                        name = "minecart"; // Unsupported
                        break;
                }
                Integer itemId = mapTo.get(name);
                if (itemId == null) itemId = mapTo.get(name.replace("_", ""));
                if (itemId == null) itemId = mapFrom.get(name);
                if (itemId != null) return new BaseItem(itemId, (short) damage);
            } catch (IOException ignore) {
                ignore.printStackTrace();
            }
        }
    }
    return new BaseItem(0);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:46,代码来源:ClipboardRemapper.java


注:本文中的com.sk89q.worldedit.blocks.BaseBlock.getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。