本文整理汇总了Java中org.bukkit.block.Block.setTypeIdAndData方法的典型用法代码示例。如果您正苦于以下问题:Java Block.setTypeIdAndData方法的具体用法?Java Block.setTypeIdAndData怎么用?Java Block.setTypeIdAndData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.block.Block
的用法示例。
在下文中一共展示了Block.setTypeIdAndData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: countUnsupportedNeighbors
import org.bukkit.block.Block; //导入方法依赖的package包/类
/**
* Return the number of unsupported blocks connected to any blocks neighboring the given location.
* An air block is placed there temporarily if it is not already air. The search may bail out early
* when the count is >= the given limit, though this cannot be guaranteed.
*/
public int countUnsupportedNeighbors(Block block, int limit) {
BlockState state = null;
if(block.getType() != Material.AIR) {
state = block.getState();
block.setTypeIdAndData(0, (byte) 0, false);
}
int count = countUnsupportedNeighbors(encodePos(block), limit);
if(state != null) {
block.setTypeIdAndData(state.getTypeId(), state.getRawData(), false);
}
return count;
}
示例2: placeBlock
import org.bukkit.block.Block; //导入方法依赖的package包/类
/**
* "simulate" a block place when you click on the side of a duct
*/
public static boolean placeBlock(Player p, Block b, Block placedAgainst, int id, byte data, EquipmentSlot es) {
if (!DuctUtils.canBuild(p, b, placedAgainst, es)) {
return false;
}
// check if there is already a duct at this position
Map<BlockLoc, Duct> ductMap = TransportPipes.instance.getDuctMap(b.getWorld());
if (ductMap != null) {
if (ductMap.containsKey(BlockLoc.convertBlockLoc(b.getLocation()))) {
return false;
}
}
if (!(b.getType() == Material.AIR || b.isLiquid())) {
return false;
}
b.setTypeIdAndData(id, data, true);
if (TransportPipes.instance.containerBlockUtils.isIdContainerBlock(id)) {
TransportPipes.instance.containerBlockUtils.updateDuctNeighborBlockSync(b, true);
}
return true;
}
示例3: onPlayerInteractCrops
import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteractCrops(PlayerInteractEvent event) {
if (event.getAction() == Action.PHYSICAL) {
Block b = event.getClickedBlock();
if (b.getType() == Material.SOIL) {
event.setCancelled(true);
b.setTypeIdAndData(b.getType().getId(), b.getData(), true);
}
if (b.getType() == Material.CROPS) {
event.setCancelled(true);
b.setTypeIdAndData(b.getType().getId(), b.getData(), true);
}
}
}
示例4: replaceBlocks
import org.bukkit.block.Block; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void replaceBlocks(MaterialData newMaterial) {
// Calling this method causes all non-destroyed blocks to be replaced, and the material
// list to be replaced with one containing only the new block. If called on a multi-stage
// destroyable, i.e. one which is affected by block replacement rules, it effectively ceases
// to be multi-stage. Even if there are block replacement rules for the new block, the
// replacements will not be in the material list, and so those blocks will be considered
// destroyed the first time they are mined. This can have some strange effects on the health
// of the destroyable: individual block health can only decrease, while the total health
// percentage can only increase.
double oldCompletion = getCompletion();
for (Block block : this.getBlockRegion().getBlocks(match.getWorld())) {
BlockState oldState = block.getState();
int oldHealth = this.getBlockHealth(oldState);
if (oldHealth > 0) {
block.setTypeIdAndData(newMaterial.getItemTypeId(), newMaterial.getData(), true);
}
}
// Update the materials list on switch
this.materialPatterns.clear();
this.materials.clear();
addMaterials(new MaterialPattern(newMaterial));
// If there is a block health map, get rid of it, since there is now only one material in the list
this.blockMaterialHealth = null;
this.recalculateHealth();
if(oldCompletion != getCompletion()) {
match.callEvent(new DestroyableHealthChangeEvent(match, this, null));
}
}
示例5: replaceBlocks
import org.bukkit.block.Block; //导入方法依赖的package包/类
@Override
@SuppressWarnings("deprecation")
public void replaceBlocks(MaterialData newMaterial) {
for(Block block : this.getCasingRegion().getBlocks(match.getWorld())) {
if(this.isObjectiveMaterial(block)) {
block.setTypeIdAndData(newMaterial.getItemTypeId(), newMaterial.getData(), true);
}
}
this.material = newMaterial;
}
示例6: setBlockSuperFast
import org.bukkit.block.Block; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
b.setTypeIdAndData(blockId, data, applyPhysics);
}
示例7: setFlowerPotBlock
import org.bukkit.block.Block; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void setFlowerPotBlock(Block block, ItemStack itemStack) {
block.setTypeIdAndData(itemStack.getTypeId(), itemStack.getData().getData(), false);
}
示例8: doBlockDrops
import org.bukkit.block.Block; //导入方法依赖的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);
}
}