本文整理汇总了Java中com.sk89q.worldedit.blocks.BaseBlock.getId方法的典型用法代码示例。如果您正苦于以下问题:Java BaseBlock.getId方法的具体用法?Java BaseBlock.getId怎么用?Java BaseBlock.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.worldedit.blocks.BaseBlock
的用法示例。
在下文中一共展示了BaseBlock.getId方法的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;
}
示例2: 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();
}
示例3: 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);
}
}
示例4: 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);
}
示例5: 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);
}
示例6: setBlock
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public boolean setBlock(int index, BaseBlock block) {
int id = block.getId();
setId(index, id);
setData(index, block.getData());
if (id >= 256) {
setAdd(index, (id >> 8));
}
CompoundTag tile = block.getNbtData();
if (tile != null) {
setTile(index, tile);
}
return true;
}
示例7: setBlock
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public boolean setBlock(int index, BaseBlock block) {
int id = block.getId();
setId(index, id);
if (id >= 256) {
setAdd(index, (id >> 8));
}
setData(index, block.getData());
CompoundTag tile = block.getNbtData();
if (tile != null) {
setTile(index, tile);
}
return true;
}
示例8: isSuitableBlock
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
protected boolean isSuitableBlock(BaseBlock material, BaseBlock materialAbove) {
switch (material.getId()) {
case 0:
case 8:
case 9:
case 10:
case 11:
case 7:
return false;
default:
return true;
}
}
示例9: 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);
}
示例10: sphereBrush
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Command(
aliases = {"sphere", "s"},
usage = "<pattern> [radius=2]",
flags = "h",
desc = "Creates a sphere",
help =
"Creates a sphere.\n" +
"The -h flag creates hollow spheres instead.",
min = 1,
max = 2
)
@CommandPermissions("worldedit.brush.sphere")
public BrushSettings sphereBrush(Player player, EditSession editSession, LocalSession session, Pattern fill, @Optional("2") double radius, @Switch('h') boolean hollow, CommandContext context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
Brush brush;
if (hollow) {
brush = new HollowSphereBrush();
} else {
brush = new SphereBrush();
}
if (fill instanceof BaseBlock) {
BaseBlock block = (BaseBlock) fill;
switch (block.getId()) {
case BlockID.SAND:
case BlockID.GRAVEL:
BBC.BRUSH_TRY_OTHER.send(player);
break;
}
}
return get(context)
.setBrush(brush)
.setSize(radius)
.setFill(fill);
}
示例11: applyBlock
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public void applyBlock(int x, int y, int z, BaseBlock block, MutableLong ignore) {
if (matchFrom.apply(block)) {
BaseBlock newBlock = to.apply(x, y, z);
int currentId = block.getId();
if (FaweCache.hasNBT(currentId)) {
block.setNbtData(null);
}
block.setId(newBlock.getId());
block.setData(newBlock.getData());
}
}
示例12: ascendLevel
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public boolean ascendLevel() {
final WorldVector pos = getBlockIn();
final int x = pos.getBlockX();
int y = Math.max(0, pos.getBlockY());
final int z = pos.getBlockZ();
final World world = pos.getWorld();
byte free = 0;
byte spots = 0;
while (y <= world.getMaxY() + 2) {
if (BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
++free;
} else {
free = 0;
}
if (free == 2) {
++spots;
if (spots == 2) {
final Vector platform = new Vector(x, y - 2, z);
final BaseBlock block = world.getBlock(platform);
final int type = block.getId();
// Don't get put in lava!
if (type == BlockID.LAVA || type == BlockID.STATIONARY_LAVA) {
return false;
}
setPosition(platform.add(0.5, BlockType.centralTopLimit(block), 0.5));
return true;
}
}
++y;
}
return false;
}
示例13: 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;
}
示例14: fall
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public int fall(final Region region, boolean fullHeight, final BaseBlock replace) {
FlatRegion flat = asFlatRegion(region);
final int startPerformY = region.getMinimumPoint().getBlockY();
final int startCheckY = fullHeight ? 0 : startPerformY;
final int endY = region.getMaximumPoint().getBlockY();
RegionVisitor visitor = new RegionVisitor(flat, new RegionFunction() {
@Override
public boolean apply(Vector pos) throws WorldEditException {
int x = pos.getBlockX();
int z = pos.getBlockZ();
int freeSpot = startCheckY;
for (int y = startCheckY; y <= endY; y++) {
if (y < startPerformY) {
if (getLazyBlock(x, y, z).getId() != 0) {
freeSpot = y + 1;
}
continue;
}
BaseBlock block = getLazyBlock(x, y, z);
if (block.getId() != 0) {
if (freeSpot != y) {
setBlock(x, freeSpot, z, block);
setBlock(x, y, z, replace);
}
freeSpot++;
}
}
return true;
}
}, this);
Operations.completeBlindly(visitor);
return this.changes;
}
示例15: 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;
}