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


Java Block.getTypeId方法代码示例

本文整理汇总了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;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:26,代码来源:CraftLivingEntity.java

示例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());
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:22,代码来源:CraftBlockState.java

示例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);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:25,代码来源:BlockImage.java

示例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);
				}
			}
		}
		
	}
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:25,代码来源:NavyCraft_BlockListener.java

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

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

示例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();
}
 
开发者ID:Recraft,项目名称:Recreator,代码行数:41,代码来源:ItemDrawKnife.java

示例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);
			}
		}
	}
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:14,代码来源:NavyCraft_BlockListener.java

示例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;
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:13,代码来源:Cuboid.java

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


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

示例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;
	}
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:29,代码来源:CraftMover.java

示例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;
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:15,代码来源:Cuboid.java

示例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();
              }
          }
      }
  }
 
开发者ID:thekeenant,项目名称:mczone,代码行数:41,代码来源:GameEvents.java

示例13: getTypeId

import org.bukkit.block.Block; //导入方法依赖的package包/类
public static int getTypeId(Block block) {
    return block.getTypeId();
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:4,代码来源:DeprecatedMethods.java

示例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());
            }
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:54,代码来源:IslandBlock.java

示例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;
					}
				}
			}
		}
	}
}
 
开发者ID:Maximuspayne,项目名称:NavyCraft2-Lite,代码行数:46,代码来源:NavyCraft_BlockListener.java


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