当前位置: 首页>>代码示例>>Java>>正文


Java Block.setTypeId方法代码示例

本文整理汇总了Java中org.bukkit.block.Block.setTypeId方法的典型用法代码示例。如果您正苦于以下问题:Java Block.setTypeId方法的具体用法?Java Block.setTypeId怎么用?Java Block.setTypeId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.block.Block的用法示例。


在下文中一共展示了Block.setTypeId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: update

import org.bukkit.block.Block; //导入方法依赖的package包/类
public boolean update(boolean force, boolean applyPhysics) {
    Block block = getBlock();

    if (block.getType() != getType()) {
        if (force) {
            block.setTypeId(getTypeId(), applyPhysics);
        } else {
            return false;
        }
    }

    block.setData(getRawData(), applyPhysics);
    world.getHandle().markBlockForUpdate(x, y, z);
    // Cauldron start - restore TE data from snapshot
    if (nbt != null)
    {
        TileEntity te = world.getHandle().getTileEntity(x, y, z);
        if (te != null)
        {
            te.readFromNBT(nbt);
        }
    }
    // Cauldron end

    return true;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:27,代码来源:CraftBlockState.java

示例2: setBlock

import org.bukkit.block.Block; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void setBlock(int id, Block block) {		
	// if(y < 0 || y > 127 || id < 0 || id > 255){
	if (id < 0 || id > 255) {
		// + " x=" + x + " y=" + y + " z=" + z);
		System.out.println("Invalid block type ID. Begin panic.");
		return;
	}
	
	if(block.getTypeId() == id) {
		NavyCraft.instance.DebugMessage("Tried to change a " + id + " to itself.", 5);
		return;
	}
	
	NavyCraft.instance.DebugMessage("Attempting to set block at " + block.getX() + ", "
			 + block.getY() + ", " + block.getZ() + " to " + id, 5);
	
	if (block.setTypeId(id) == false) {
		if(craft.world.getBlockAt(block.getLocation()).setTypeId(id) == false)
			System.out.println("Could not set block of type " + block.getTypeId() + 
					" to type " + id + ". I tried to fix it, but I couldn't.");
		else
			System.out.println("I hope to whatever God you believe in that this fix worked.");
	}
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:26,代码来源:CraftRotator.java

示例3: onBlockFromTo

import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onBlockFromTo(final BlockFromToEvent event) {
	if (!event.isCancelled()) {
		final Block block = event.getToBlock();

		if ((block.getTypeId() == 75) || (block.getTypeId() == 76) || (block.getTypeId() == 65) || (block.getTypeId() == 69) || (block.getTypeId() == 77) || (block.getTypeId() == 70) || (block.getTypeId() == 72) || (block.getTypeId() == 68) || (block.getTypeId() == 63) || (block.getTypeId() == 143) || (block.getTypeId() == 55)) {
			if (Craft.getCraft(block.getX(), block.getY(), block.getZ()) != null) {
				// event.setCancelled(true);
				block.setTypeId(8);
			}
		}
	}
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:14,代码来源:NavyCraft_BlockListener.java

示例4: setBlock

import org.bukkit.block.Block; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void setBlock(int id, Block block) {
	// if(y < 0 || y > 127 || id < 0 || id > 255){
	if ((id < 0) || (id > 255)) {
		// + " x=" + x + " y=" + y + " z=" + z);
		System.out.println("Invalid block type ID. Begin panic.");
		return;
	}



	if (block.getTypeId() == id) {
		NavyCraft.instance.DebugMessage("Tried to change a " + id + " to itself.", 5);
		return;
	}

	NavyCraft.instance.DebugMessage("Attempting to set block at " + block.getX() + ", " + block.getY() + ", " + block.getZ() + " to " + id, 5);


	try {
		if (block.setTypeId(id) == false) {
			if (craft.world.getBlockAt(block.getLocation()).setTypeId(id) == false) {
				System.out.println("Could not set block of type " + block.getTypeId() + " to type " + id + ". I tried to fix it, but I couldn't.");
			} else {
				System.out.println("I hope to whatever God you believe in that this fix worked.");
			}
		}
	} catch (ClassCastException cce) {
		System.out.println("Routine cast exception.");
	}


}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:34,代码来源:CraftMover.java

示例5: checkSink

import org.bukkit.block.Block; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public boolean checkSink() {
	int blockId;
	Block newBlock;

	int solidCount = 0;
	for (int x = 0; x < craft.sizeX; x++) {
		for (int z = 0; z < craft.sizeZ; z++) {
			newBlock = craft.world.getBlockAt(craft.minX + x, craft.minY - 1, craft.minZ + z);
			blockId = newBlock.getTypeId();
			if ((blockId != 0) && !((blockId >= 8) && (blockId <= 11))) {
				solidCount++;
			}

		}
	}

	if ((solidCount / ((float) craft.sizeX * (float) craft.sizeZ)) >= 0.6f) {
		Block contactBlock = craft.world.getBlockAt(craft.minX + (craft.sizeX / 2), craft.minY, craft.minZ + (craft.sizeZ / 2));
		contactBlock.setTypeId(5);
		////////////////////////// ******************?////////////////
		contactBlock.getWorld().createExplosion(contactBlock.getLocation(), 8);

		return false;
	} else {
		return true;
	}
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:29,代码来源:CraftMover.java

示例6: paste

import org.bukkit.block.Block; //导入方法依赖的package包/类
/**
 * Paste this block at blockLoc
 * @param nms
 * @param blockLoc
 */
//@SuppressWarnings("deprecation")
@SuppressWarnings("deprecation")
public void paste(NMSAbstraction nms, Location blockLoc, boolean usePhysics, Biome biome) {
    // Only paste air if it is below the sea level and in the overworld
    Block block = new Location(blockLoc.getWorld(), x, y, z).add(blockLoc).getBlock();
    block.setBiome(biome);
    block.getChunk().load();
    nms.setBlockSuperFast(block, typeId, data, usePhysics);
    if (signText != null) {
        if (block.getTypeId() != typeId) {
            block.setTypeId(typeId);
        }
        // Sign
        Sign sign = (Sign) block.getState();
        int index = 0;
        for (String line : signText) {
            sign.setLine(index++, line);
        }
        sign.update();
    } else if (banner != null) {
        banner.set(block);
    } else if (spawnerBlockType != null) {
        if (block.getTypeId() != typeId) {
            block.setTypeId(typeId);
        }
        CreatureSpawner cs = (CreatureSpawner)block.getState();
        cs.setSpawnedType(spawnerBlockType);
    } else if (!chestContents.isEmpty()) {
        if (block.getTypeId() != typeId) {
            block.setTypeId(typeId);
        }
        // Check if this is a double chest
        Chest chestBlock = (Chest) block.getState();
        InventoryHolder iH = chestBlock.getInventory().getHolder();
        if (iH instanceof DoubleChest) {
            //Bukkit.getLogger().info("DEBUG: double chest");
            DoubleChest doubleChest = (DoubleChest) iH;
            for (ItemStack chestItem: chestContents.values()) {
                doubleChest.getInventory().addItem(chestItem);
            }
        } else {
            // Single chest
            for (Entry<Byte, ItemStack> en : chestContents.entrySet()) {
                chestBlock.getInventory().setItem(en.getKey(), en.getValue());
            }
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:54,代码来源:IslandBlock.java


注:本文中的org.bukkit.block.Block.setTypeId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。