本文整理匯總了Java中org.bukkit.block.BlockState.getTypeId方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockState.getTypeId方法的具體用法?Java BlockState.getTypeId怎麽用?Java BlockState.getTypeId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.block.BlockState
的用法示例。
在下文中一共展示了BlockState.getTypeId方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTypeId
import org.bukkit.block.BlockState; //導入方法依賴的package包/類
public int getTypeId(int x, int y, int z) {
for (BlockState state : blocks) {
if (state.getX() == x && state.getY() == y && state.getZ() == z) {
return state.getTypeId();
}
}
return world.getBlockTypeIdAt(x, y, z);
}
示例2: handleBlockState
import org.bukkit.block.BlockState; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Nonnull
private static String handleBlockState(BlockState blockState) {
return "[" + blockState.getData() + ", " +
"id=" + blockState.getTypeId() + ", " +
"light=" + blockState.getLightLevel() + ", " +
blockState.getLocation() + "]";
}
示例3: doBlockDrops
import org.bukkit.block.BlockState; //導入方法依賴的package包/類
/**
* This is not an event handler. It is called explicitly by BlockTransformListener
* after all event handlers have been called.
*/
@SuppressWarnings("deprecation")
public void doBlockDrops(final BlockTransformEvent event) {
if(!causesDrops(event.getCause())) {
return;
}
final BlockDrops drops = event.getDrops();
if(drops != null) {
event.setCancelled(true);
final BlockState oldState = event.getOldState();
final BlockState newState = event.getNewState();
final Block block = event.getOldState().getBlock();
final int newTypeId = newState.getTypeId();
final byte newData = newState.getRawData();
block.setTypeIdAndData(newTypeId, newData, true);
boolean explosion = false;
MatchPlayer player = ParticipantBlockTransformEvent.getParticipant(event);
if(event.getCause() instanceof EntityExplodeEvent) {
EntityExplodeEvent explodeEvent = (EntityExplodeEvent) event.getCause();
explosion = true;
if(drops.fallChance != null &&
oldState.getType().isBlock() &&
oldState.getType() != Material.AIR &&
this.getMatch().getRandom().nextFloat() < drops.fallChance) {
FallingBlock fallingBlock = event.getOldState().spawnFallingBlock();
fallingBlock.setDropItem(false);
if(drops.landChance != null && this.getMatch().getRandom().nextFloat() >= drops.landChance) {
this.fallingBlocksThatWillNotLand.add(fallingBlock);
}
Vector v = fallingBlock.getLocation().subtract(explodeEvent.getLocation()).toVector();
double distance = v.length();
v.normalize().multiply(BASE_FALL_SPEED * drops.fallSpeed / Math.max(1d, distance));
// A very simple deflection model. Check for a solid
// neighbor block and "bounce" the velocity off of it.
Block west = block.getRelative(BlockFace.WEST);
Block east = block.getRelative(BlockFace.EAST);
Block down = block.getRelative(BlockFace.DOWN);
Block up = block.getRelative(BlockFace.UP);
Block north = block.getRelative(BlockFace.NORTH);
Block south = block.getRelative(BlockFace.SOUTH);
if((v.getX() < 0 && west != null && Materials.isColliding(west.getType())) ||
v.getX() > 0 && east != null && Materials.isColliding(east.getType())) {
v.setX(-v.getX());
}
if((v.getY() < 0 && down != null && Materials.isColliding(down.getType())) ||
v.getY() > 0 && up != null && Materials.isColliding(up.getType())) {
v.setY(-v.getY());
}
if((v.getZ() < 0 && north != null && Materials.isColliding(north.getType())) ||
v.getZ() > 0 && south != null && Materials.isColliding(south.getType())) {
v.setZ(-v.getZ());
}
fallingBlock.setVelocity(v);
}
}
dropObjects(drops, player, newState.getLocation(), 1d, explosion);
}
}