當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。