本文整理匯總了Java中org.bukkit.block.Block.getTypeId方法的典型用法代碼示例。如果您正苦於以下問題:Java Block.getTypeId方法的具體用法?Java Block.getTypeId怎麽用?Java Block.getTypeId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.block.Block
的用法示例。
在下文中一共展示了Block.getTypeId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLineOfSight
import org.bukkit.block.Block; //導入方法依賴的package包/類
private List<Block> getLineOfSight(HashSet<Byte> transparent, int maxDistance, int maxLength) {
if (maxDistance > 120) {
maxDistance = 120;
}
ArrayList<Block> blocks = new ArrayList<Block>();
Iterator<Block> itr = new BlockIterator(this, maxDistance);
while (itr.hasNext()) {
Block block = itr.next();
blocks.add(block);
if (maxLength != 0 && blocks.size() > maxLength) {
blocks.remove(0);
}
byte id = (byte)block.getTypeId();
if (transparent == null) {
if (id != 0) {
break;
}
} else {
if (!transparent.contains(id)) {
break;
}
}
}
return blocks;
}
示例2: CraftBlockState
import org.bukkit.block.Block; //導入方法依賴的package包/類
public CraftBlockState(final Block block) {
this.world = (CraftWorld) block.getWorld();
this.x = block.getX();
this.y = block.getY();
this.z = block.getZ();
this.type = block.getTypeId();
this.light = block.getLightLevel();
this.chunk = (CraftChunk) block.getChunk();
this.flag = 3;
// Cauldron start - save TE data
TileEntity te = world.getHandle().getTileEntity(x, y, z);
if (te != null)
{
nbt = new NBTTagCompound();
te.writeToNBT(nbt);
}
else nbt = null;
// Cauldron end
createData(block.getData());
}
示例3: save
import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
* Set every block in this image to its current state in the world
*/
@SuppressWarnings("deprecation")
public void save() {
if(this.blockCounts != null) {
this.blockCounts.clear();
}
int offset = 0;
for(Vec3 v : this.bounds.blockRegion().mutableIterable()) {
Block block = this.world.getBlockAt(v.coarseX(),
v.coarseY(),
v.coarseZ());
this.blockIds[offset] = (short) block.getTypeId();
this.blockData[offset] = block.getData();
++offset;
if(this.blockCounts != null) {
MaterialData md = block.getState().getData();
this.blockCounts.put(md, this.blockCounts.get(md) + 1);
}
}
}
示例4: onBlockPhysics
import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPhysics(final BlockPhysicsEvent event) {
if (!event.isCancelled()) {
final Block block = event.getBlock();
if (Craft_Hyperspace.hyperspaceBlocks.contains(block)) {
event.setCancelled(true);
}
if ((block.getTypeId() == 63) || (block.getTypeId() == 68) || (block.getTypeId() == 50) || (block.getTypeId() == 75) || (block.getTypeId() == 76) || (block.getTypeId() == 65) || (block.getTypeId() == 64) || (block.getTypeId() == 71) || (block.getTypeId() == 70) || (block.getTypeId() == 72) || (block.getTypeId() == 143)) {
Craft c = Craft.getCraft(block.getX(), block.getY(), block.getZ());
if (c != null) {
// if not iron door being controlled by circuit...
if ((event.getChangedTypeId() != 0) && !(((block.getTypeId() == 71) || (block.getTypeId() == 64)) && ((event.getChangedTypeId() == 69) || (event.getChangedTypeId() == 77) || (event.getChangedTypeId() == 55) || (event.getChangedTypeId() == 70) || (event.getChangedTypeId() == 72) || (block.getTypeId() == 143) || (block.getTypeId() == 75) || (block.getTypeId() == 76) || (block.getTypeId() == 50)))) {
event.setCancelled(true);
}
}
}
}
}
示例5: reloadWeapons
import org.bukkit.block.Block; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void reloadWeapons(Player p) {
for (DataBlock dataBlock : craft.dataBlocks) {
Block theBlock = getWorldBlock(dataBlock.x, dataBlock.y, dataBlock.z);
if (theBlock.getTypeId() == 23) {
for (OneCannon onec : AimCannon.getCannons()) {
if (onec.isThisCannon(theBlock.getLocation(), false)) {
onec.reload(p);
}
}
}
}
}
示例6: fillData
import org.bukkit.block.Block; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public static byte fillData(Block block) {
byte data = block.getData();
int id = block.getTypeId();
if (id == 17) {
switch (data) {
case 0:
case 4:
case 8:
return 12;
case 1:
case 5:
case 9:
return 13;
case 2:
case 6:
case 10:
return 14;
case 3:
case 7:
case 11:
return 15;
}
}
if (id == 162) {
switch (data) {
case 0:
case 4:
case 8:
return 12;
case 1:
case 5:
case 9:
return 13;
}
}
throw new UnsupportedOperationException();
}
示例7: 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);
}
}
}
}
示例8: containsOnly
import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
* Check if the Cuboid contains only blocks of the given type
*
* @param blockId - The block ID to check for
* @return true if this Cuboid contains only blocks of the given type
*/
public boolean containsOnly(int blockId) {
for (Block b : this) {
if (b.getTypeId() != blockId) return false;
}
return true;
}
示例9: 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.");
}
}
示例10: 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;
}
}
示例11: containsOnly
import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
* Check if the Cuboid contains only blocks of the given type
*
* @param blockId - The block ID to check for
* @return true if this Cuboid contains only blocks of the given type
*/
@SuppressWarnings("deprecation")
public boolean containsOnly(int blockId) {
for (Block b : this) {
if (b.getTypeId() != blockId)
return false;
}
return true;
}
示例12: onPlayerMove
import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) {
Player p = event.getPlayer();
Location to = event.getTo();
Location from = event.getFrom();
World world = to.getWorld();
if (to.clone().add(0, -1, 0).getBlock().getType() != Material.REDSTONE_LAMP_ON)
return;
if (from.clone().add(0, -1, 0).getBlock().getType() == Material.REDSTONE_LAMP_ON)
return;
for (Block block : getPortalNear(world, to.getBlockX(), to.getBlockY(), to.getBlockZ())) {
for (BlockFace bf : BlockFace.values()) {
Block relative = block.getRelative(bf);
if (relative.getTypeId() == SIGN) {
// Specific server
Sign sign = (Sign) relative.getState();
Portal portal = null;
for (Portal po : Portal.getList()) {
if (WorldUtil.sameBlock(po.getSign().getBlock(), sign.getBlock())) {
portal = po;
break;
}
}
if (portal == null)
return;
if (portal.getCurrent().getStatus() == Status.CLOSED)
Chat.player(p, "&cThat server is currently unavailable!");
else
portal.getCurrent().connect(event.getPlayer());
portal.updateSign();
}
}
}
}
示例13: getTypeId
import org.bukkit.block.Block; //導入方法依賴的package包/類
public static int getTypeId(Block block) {
return block.getTypeId();
}
示例14: 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());
}
}
}
}
示例15: onBlockBreak
import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event) {
Player p = event.getPlayer();
if ( PermissionInterface.CheckEnabledWorld(p.getLocation())) {
Block checkBlock;
checkBlock = event.getBlock();
int craftBlockId = checkBlock.getTypeId();
Craft checkCraft = Craft.getCraft(checkBlock.getX(), checkBlock.getY(), checkBlock.getZ());
if (checkCraft != null) {
if ((craftBlockId == 46) && (p.getGameMode() != GameMode.CREATIVE)) {
p.sendMessage(ChatColor.RED + "Can't break vehicle TNT.");
event.setCancelled(true);
return;
} else if ((craftBlockId == 75) || (craftBlockId == 76) || (craftBlockId == 65) || (craftBlockId == 68) || (craftBlockId == 63) || (craftBlockId == 69) || (craftBlockId == 77) || (craftBlockId == 70) || (craftBlockId == 72) || (craftBlockId == 55) || (craftBlockId == 143) || (craftBlockId == 64) || (craftBlockId == 71)) {
int arrayX = checkBlock.getX() - checkCraft.minX;
int arrayY = checkBlock.getY() - checkCraft.minY;
int arrayZ = checkBlock.getZ() - checkCraft.minZ;
checkCraft.matrix[arrayX][arrayY][arrayZ] = -1;
if (((craftBlockId == 64) && (checkBlock.getRelative(BlockFace.UP).getTypeId() == 64)) || ((craftBlockId == 71) && (checkBlock.getRelative(BlockFace.UP).getTypeId() == 71))) {
checkBlock.getRelative(BlockFace.UP).setTypeId(0);
checkCraft.matrix[arrayX][arrayY + 1][arrayZ] = -1;
}
if (((craftBlockId == 64) && (checkBlock.getRelative(BlockFace.DOWN).getTypeId() == 64)) || ((craftBlockId == 71) && (checkBlock.getRelative(BlockFace.DOWN).getTypeId() == 71))) {
checkBlock.getRelative(BlockFace.DOWN).setTypeId(0);
checkCraft.matrix[arrayX][arrayY - 1][arrayZ] = -1;
}
for (DataBlock complexBlock : checkCraft.complexBlocks) {
if (complexBlock.locationMatches(arrayX, arrayY, arrayZ)) {
checkCraft.complexBlocks.remove(complexBlock);
break;
}
}
for (DataBlock dataBlock : checkCraft.dataBlocks) {
if (dataBlock.locationMatches(arrayX, arrayY, arrayZ)) {
checkCraft.dataBlocks.remove(dataBlock);
break;
}
}
}
}
}
}