/** * Instantiate a pumpkin facing in a particular direction. * * @param direction the direction the pumkin's face is facing */ public Pumpkin(BlockFace direction) { this(); setFacingDirection(direction); }
public BlockFace getFacing() { byte data = getData(); switch (data) { case 0x0: return BlockFace.NORTH; case 0x1: return BlockFace.EAST; case 0x2: return BlockFace.SOUTH; case 0x3: default: return BlockFace.EAST; } }
public boolean isLit() { return getItemType() == Material.JACK_O_LANTERN; }
public void setFacingDirection(BlockFace face) { byte data; switch (face) { case NORTH: data = 0x0; break; case EAST: data = 0x1; break; case SOUTH: data = 0x2; break; case WEST: default: data = 0x3; } setData(data); }
@Override public void populate(World world, Random random, Chunk source) { if (random.nextInt(32) == 0) { int sourceX = (source.getX() << 4) + random.nextInt(16); int sourceZ = (source.getZ() << 4) + random.nextInt(16); int sourceY = random.nextInt(world.getHighestBlockYAt(sourceX, sourceZ) << 1); for (int i = 0; i < 64; i++) { int x = sourceX + random.nextInt(8) - random.nextInt(8); int z = sourceZ + random.nextInt(8) - random.nextInt(8); int y = sourceY + random.nextInt(4) - random.nextInt(4); if (world.getBlockAt(x, y, z).getType() == Material.AIR && world.getBlockAt(x, y - 1, z).getType() == Material.GRASS) { BlockState state = world.getBlockAt(x, y, z).getState(); state.setType(Material.PUMPKIN); // random facing state.setData(new Pumpkin(FACES[random.nextInt(FACES.length)])); state.update(true); } } } } }
public boolean isLit() { return getItemType() == Material.JACK_O_LANTERN; }
public void setFacingDirection(BlockFace face) { byte data; switch (face) { case NORTH: data = 0x0; break; case EAST: data = 0x1; break; case SOUTH: data = 0x2; break; case WEST: default: data = 0x3; } setData(data); }
targetBlockState.setType(fruitType); if (fruitType == Material.PUMPKIN) { targetBlockState.setData(new Pumpkin(face.getOppositeFace()));
@Override public void placeBlock(GlowPlayer player, GlowBlockState state, BlockFace face, ItemStack holding, Vector clickedLoc) { super.placeBlock(player, state, face, holding, clickedLoc); MaterialData data = state.getData(); if (data instanceof Pumpkin) { ((Pumpkin) data).setFacingDirection(player.getCardinalFacing()); state.setData(data); } else { warnMaterialData(Pumpkin.class, data); } } }
public BlockFace getFacing() { byte data = getData(); switch (data) { case 0x0: return BlockFace.NORTH; case 0x1: return BlockFace.EAST; case 0x2: return BlockFace.SOUTH; case 0x3: default: return BlockFace.EAST; } }
/** * Instantiate a pumpkin facing in a particular direction. * * @param direction the direction the pumkin's face is facing */ public Pumpkin(BlockFace direction) { this(); setFacingDirection(direction); }