當前位置: 首頁>>代碼示例>>Java>>正文


Java Block.setTypeIdAndData方法代碼示例

本文整理匯總了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;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:21,代碼來源:FallingBlocksMatchModule.java

示例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;
}
 
開發者ID:RoboTricker,項目名稱:Transport-Pipes,代碼行數:28,代碼來源:HitboxUtils.java

示例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);
        }
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:15,代碼來源:EnvironmentManager.java

示例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));
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:37,代碼來源:Destroyable.java

示例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;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:11,代碼來源:Core.java

示例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);
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:6,代碼來源:NMSHandler.java

示例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);

}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:7,代碼來源:NMSHandler.java

示例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);

    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:77,代碼來源:BlockDropsMatchModule.java


注:本文中的org.bukkit.block.Block.setTypeIdAndData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。