本文整理汇总了Java中com.sk89q.worldedit.blocks.BaseBlock.getType方法的典型用法代码示例。如果您正苦于以下问题:Java BaseBlock.getType方法的具体用法?Java BaseBlock.getType怎么用?Java BaseBlock.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.worldedit.blocks.BaseBlock
的用法示例。
在下文中一共展示了BaseBlock.getType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: actPrimary
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
World world = (World) clicked.getExtent();
final Vector pos = clicked.toVector();
EditSession editSession = session.createEditSession(player);
BaseBlock block = editSession.getBlock(pos);
int initialType = block.getType();
if (initialType == BlockID.AIR || (initialType == BlockID.BEDROCK && !player.canDestroyBedrock())) {
editSession.flushQueue();
return true;
}
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);
final int radius = (int) range;
final BlockReplace replace = new BlockReplace(editSession, (editSession.nullBlock));
editSession.setMask((Mask) null);
RecursiveVisitor visitor = new RecursiveVisitor(new IdMask(editSession), replace, radius, editSession);
visitor.visit(pos);
Operations.completeBlindly(visitor);
editSession.flushQueue();
session.remember(editSession);
return true;
}
示例3: fillIteration
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public void fillIteration(int brushSize, int brushSizeSquared, int fillFaces, FaweClipboard current, FaweClipboard target) {
int[] frequency = null;
for (int x = -brushSize; x <= brushSize; x++) {
int x2 = x * x;
for (int z = -brushSize; z <= brushSize; z++) {
int x2y2 = x2 + z * z;
for (int y = -brushSize; y <= brushSize; y++) {
int cube = x2y2 + y * y;
target.setBlock(x, y, z, current.getBlock(x, y, z));
if (cube >= brushSizeSquared) {
continue;
}
BaseBlock state = current.getBlock(x, y, z);
if (!FaweCache.isLiquidOrGas(state.getId())) {
continue;
}
int total = 0;
int highest = 1;
BaseBlock highestState = state;
if (frequency == null) {
frequency = new int[4096];
} else {
Arrays.fill(frequency, 0);
}
for (Vector offs : FACES_TO_CHECK) {
BaseBlock next = current.getBlock(x + offs.getBlockX(), y + offs.getBlockY(), z + offs.getBlockZ());
if (FaweCache.isLiquidOrGas(next.getId())) {
continue;
}
total++;
int count = ++frequency[next.getType()];
if (count >= highest) {
highest = count;
highestState = next;
}
}
if (total >= fillFaces) {
target.setBlock(x, y, z, highestState);
}
}
}
}
}
示例4: erosionIteration
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
public void erosionIteration(int brushSize, int brushSizeSquared, int erodeFaces, FaweClipboard current, FaweClipboard target) {
int[] frequency = null;
for (int x = -brushSize; x <= brushSize; x++) {
int x2 = x * x;
for (int z = -brushSize; z <= brushSize; z++) {
int x2y2 = x2 + z * z;
for (int y = -brushSize; y <= brushSize; y++) {
int cube = x2y2 + y * y;
target.setBlock(x, y, z, current.getBlock(x, y, z));
if (cube >= brushSizeSquared) {
continue;
}
BaseBlock state = current.getBlock(x, y, z);
if (FaweCache.isLiquidOrGas(state.getId())) {
continue;
}
int total = 0;
int highest = 1;
int highestState = state.getType();
if (frequency == null) {
frequency = new int[4096];
} else {
Arrays.fill(frequency, 0);
}
for (Vector offs : FACES_TO_CHECK) {
BaseBlock next = current.getBlock(x + offs.getBlockX(), y + offs.getBlockY(), z + offs.getBlockZ());
if (!FaweCache.isLiquidOrGas(next.getId())) {
continue;
}
total++;
int count = ++frequency[next.getType()];
if (count > highest) {
highest = count;
highestState = next.getType();
}
}
if (total >= erodeFaces) {
target.setBlock(x, y, z, FaweCache.CACHE_BLOCK[highestState << 4]);
}
}
}
}
}
示例5: setBlock
import com.sk89q.worldedit.blocks.BaseBlock; //导入方法依赖的package包/类
@Override
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
switch (block.getType()) {
case 54:
case 130:
case 142:
case 27:
case 137:
case 52:
case 154:
case 84:
case 25:
case 144:
case 138:
case 176:
case 177:
case 63:
case 68:
case 323:
case 117:
case 116:
case 28:
case 66:
case 157:
case 61:
case 62:
case 140:
case 146:
case 149:
case 150:
case 158:
case 23:
case 123:
case 124:
case 29:
case 33:
case 151:
case 178: {
if (BSblocked) {
return false;
}
BScount++;
if (BScount > Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES) {
BSblocked = true;
PlotSquared.log("&cPlotSquared detected unsafe WorldEdit: " + (location.getBlockX()) + "," + (location.getBlockZ()));
}
}
}
if (WEManager.maskContains(mask, location.getBlockX(), location.getBlockZ())) {
return super.setBlock(location, block);
}
return false;
}