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


Java Material.isSolid方法代码示例

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


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

示例1: onPlayerMove

import org.bukkit.Material; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
	final Player player = event.getPlayer();

	final Material from = event.getFrom().getBlock().getRelative(BlockFace.DOWN).getType();

	final Behaviour behaviour = Profile.getProfile(player.getUniqueId()).getBehaviour();

	final long current = System.currentTimeMillis();

	if (player.isSprinting()) {
		behaviour.getMotion().setLastSprint(current);
	}
	if (player.isFlying()) {
		behaviour.getMotion().setLastFly(current);
	}

	if (from.isSolid() || behaviour.getMotion().getLastY() == -1.0 || !behaviour.getMotion().isDescending()) {
		behaviour.getMotion().setLastY(player.getLocation().getY());
	}

	if (!behaviour.isOnGround()) {
		behaviour.getMotion().setLastYDiff(event.getTo().getY() - event.getFrom().getY());
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:26,代码来源:BehaviourListeners.java

示例2: onRun

import org.bukkit.Material; //导入方法依赖的package包/类
@Override
public void onRun()
{
    // Prevents an excess of particles
    if (last != null && last.getX() == getEntity().getLocation().getX() && last.getZ() == getEntity().getLocation().getZ())
        return;
    last = getEntity().getLocation();

    Block block = this.getEntity().getLocation().add(0, -0.4, 0).getBlock();
    Material type = block.getType();

    // If the step should be displayed or not
    if (type.isBlock() && type.isSolid() && !type.isTransparent()) {
        Location loc = getEntity().getLocation();
        loc.setY(block.getY());
        loc = loc.add(0, 1 + Math.random() / 100, 0);
        Vector dir = VectorUtils.rotateAroundAxisY(getEntity().getLocation().getDirection().setY(0).normalize(), p ? 90 : -90).multiply(0.25);
        display(ParticleEffect.FOOTSTEP, loc.add(dir.getX(), 0, dir.getZ()), 7, 0);

        p = !p;
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:23,代码来源:StepEffect.java

示例3: blockBroken

import org.bukkit.Material; //导入方法依赖的package包/类
/**
 * Called when a block is broken in a way that could initiate a spleef fall
 */
public void blockBroken(Block block, Player breaker) {
    Material material = block.getType();
    if (!material.isSolid()) {
        return;
    }
    // Bukkit considers these "solid" for some reason
    switch(material) {
        case SIGN_POST:
        case WALL_SIGN:
        case WOOD_PLATE:
        case STONE_PLATE:
        case IRON_PLATE:
        case GOLD_PLATE:
            return;
    }

    final BrokenBlock brokenBlock = new BrokenBlock(block, breaker, this.timer.getTicks());
    final Location location = brokenBlock.block.getLocation();
    this.brokenBlocks.put(location, brokenBlock);

    this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () -> {
        // Only remove the BrokenBlock if it's the same one we added. It may have been replaced since then.
        if (SimpleGravityKillTracker.this.brokenBlocks.get(location) == brokenBlock) {
            SimpleGravityKillTracker.this.brokenBlocks.remove(location);
        }
    }, MAX_SPLEEF_TIME + 1);
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:31,代码来源:SimpleGravityKillTracker.java

示例4: isColliding

import org.bukkit.Material; //导入方法依赖的package包/类
/**
 * Is the given {@link Material} a block that collides with entities?
 *
 * Note that this is not always 100% correct. There are a few blocks for which
 * solidness depends on state, such as fence gates.
 */
public static boolean isColliding(Material material) {
    if(material == null) {
        return false;
    }

    switch(material) {
        // Missing from Bukkit
        case CARPET:
        case WATER_LILY:
            return true;

        // Incorrectly included by Bukkit
        case SIGN_POST:
        case WALL_SIGN:
        case WOOD_PLATE:
        case STONE_PLATE:
        case IRON_PLATE:
        case GOLD_PLATE:
        case STANDING_BANNER:
        case WALL_BANNER:
            return false;

        default:
            return material.isSolid();
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:33,代码来源:Materials.java

示例5: teleportSpotUp

import org.bukkit.Material; //导入方法依赖的package包/类
public Location teleportSpotUp(Location loc, int min, int max) {
    int k = min;
    while (k < max) {
    	Material m = new Location(loc.getWorld(), loc.getBlockX(), k - 1, loc.getBlockZ()).getBlock().getType();
        Material m1 = new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ()).getBlock().getType();
        Material m2 = new Location(loc.getWorld(), loc.getBlockX(), (k + 1), loc.getBlockZ()).getBlock().getType();
        if (m1.equals(Material.AIR) && m2.equals(Material.AIR) && m.isSolid() && !m.equals(Material.SIGN_POST) && !m.equals(Material.WALL_SIGN)) {
            return new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ());
        }
        ++k;
    }
    return new Location(loc.getWorld(), loc.getBlockX(), loc.getWorld().getHighestBlockYAt(loc.getBlockX(), loc.getBlockZ()), loc.getBlockZ());
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:14,代码来源:ElevatorListener.java

示例6: teleportSpotDown

import org.bukkit.Material; //导入方法依赖的package包/类
public Location teleportSpotDown(Location loc, int min, int max) {
    int k = min;
    while (k > max) {
    	Material m = new Location(loc.getWorld(), loc.getBlockX(), k - 1, loc.getBlockZ()).getBlock().getType();
        Material m1 = new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ()).getBlock().getType();
        Material m2 = new Location(loc.getWorld(), loc.getBlockX(), (k + 1), loc.getBlockZ()).getBlock().getType();
        if (m1.equals(Material.AIR) && m2.equals(Material.AIR) && m.isSolid() && !m.equals(Material.SIGN_POST) && !m.equals(Material.WALL_SIGN)) {
            return new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ());
        }
        --k;
    }
    return new Location(loc.getWorld(), loc.getBlockX(), loc.getWorld().getHighestBlockYAt(loc.getBlockX(), loc.getBlockZ()), loc.getBlockZ());
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:14,代码来源:ElevatorListener.java

示例7: generate

import org.bukkit.Material; //导入方法依赖的package包/类
public LinkedHashMap<Location, VisualBlockData> generate(Player player, Iterable<Location> locations, VisualType visualType, boolean canOverwrite) {
    synchronized (storedVisualises) {
        LinkedHashMap<Location, VisualBlockData> results = new LinkedHashMap<>();

        ArrayList<VisualBlockData> filled = visualType.blockFiller().bulkGenerate(player, locations);
        if (filled != null) {
            int count = 0;
            for (Location location : locations) {
                if (!canOverwrite && storedVisualises.contains(player.getUniqueId(), location)) {
                    continue;
                }

                Material previousType = location.getBlock().getType();
                if (previousType.isSolid() || previousType != Material.AIR) {
                    continue;
                }

                VisualBlockData visualBlockData = filled.get(count++);
                results.put(location, visualBlockData);
                player.sendBlockChange(location, visualBlockData.getBlockType(), visualBlockData.getData());
                storedVisualises.put(player.getUniqueId(), location, new VisualBlock(visualType, visualBlockData, location));
            }
        }

        return results;
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:28,代码来源:VisualiseHandler.java

示例8: onPlaceBlock

import org.bukkit.Material; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlaceBlock(BlockPlaceEvent e) {
	Block block = e.getBlock();

	Material blockMaterial = block.getType();
	int x = block.getX();
	int y = block.getY();
	int z = block.getZ();
	WorldChunk chunk = CropControl.getDAO().getChunk(block.getChunk());

	if (CropControl.getDAO().isTracked(block) == true) {
		// We've got a replacement
		CropControl.getPlugin().debug("Ghost object? Placement is overtop a tracked object at {0}, {1}, {2}", x, y, z);
		handleRemoval(block, chunk);
	}
	if (harvestableCrops.containsKey(blockMaterial)) {
		// we placed a block overtop an existing crop. Will be handled by a break event?
		/*Crop crop = chunk.getCrop(x, y, z);
		if (crop != null) {
			crop.setRemoved();
			CropControl.getPlugin().debug("Missed an event? Replacing a Crop at {0}, {1}, {2}", x, y, z);
			//return;
		}*/
		
		// We've placed a crop!
		Crop.create(chunk, x, y, z, blockMaterial.toString(), getBaseCropState(blockMaterial),
				e.getPlayer().getUniqueId(), System.currentTimeMillis(), harvestableCrops.get(blockMaterial));
	} else if (blockMaterial == Material.SAPLING) {
		// we placed a block overtop an existing sapling. TODO: Do I need to remove sapling here, or will there be a break event?
		/*Sapling sapling = chunk.getSapling(x, y, z);
		if (sapling != null) {
			sapling.setRemoved();
			CropControl.getPlugin().debug("Missed an event? Replacing a Sapling at {0}, {1}, {2}", x, y, z);
			//return;
		}*/
		// We've placed a sapling!
		Sapling.create(chunk, x, y, z, getSaplingType(block.getData()),
				e.getPlayer().getUniqueId(), System.currentTimeMillis(), false);
	} else if (blockMaterial == Material.CHORUS_FLOWER) {
		/*if (CropControl.getDAO().isTracked(block) == true) {
			CropControl.getPlugin().debug("Ghost object? Placement is overtop a tracked object at {0}, {1}, {2}", x, y, z);
			//return;
		}*/
		
		// TODO: Check if connected to an existing chorus tree.

		// First register the "tree"
		Tree chorusPlant = Tree.create(chunk, x, y, z, Material.CHORUS_PLANT.toString(),
				e.getPlayer().getUniqueId(), System.currentTimeMillis());

		// Then the component in the tree.
		TreeComponent.create(chorusPlant, chunk, x, y, z, Material.CHORUS_PLANT.toString(),
				e.getPlayer().getUniqueId(), false);
	} else if (blockMaterial.isSolid()){ // check for cactus.
		for (BlockFace face : CropControlEventHandler.directions) {
			Block adj = block.getRelative(face);
			if (Material.CACTUS.equals(adj.getType())) {
				Location loc = adj.getLocation();
				if (!pendingChecks.contains(loc)) {
					pendingChecks.add(loc);
					handleBreak(adj, BreakType.PLAYER, e.getPlayer().getUniqueId(), null);
				}		
			}
		}
	}
}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:67,代码来源:CropControlEventHandler.java

示例9: gunBulletHitGroundEvent

import org.bukkit.Material; //导入方法依赖的package包/类
/**
	 * It hit the ground maybe!
	 * 
	 * @param event the impact event, we ignore any that aren't just blockhits
	 */
	@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
	public void gunBulletHitGroundEvent(ProjectileHitEvent event) {
		if (!(event.getEntity() instanceof Projectile)) return;
		if (event.getHitBlock() == null) return;

		Projectile bullet = (Projectile) event.getEntity();
		
		StandardGun gun = bulletToGunMap.get(bullet.getName());
		if (gun == null) return; // not a bullet from a gun.
		
		Location begin = this.travelPaths.remove(bullet.getUniqueId());
		Bullet bulletType = this.inFlightBullets.remove(bullet.getUniqueId());
		
		if (begin == null || bulletType == null) {
			AddGun.getPlugin().debug("Warning: bullet {1} claiming to be {0} but untracked -- from unloaded chunk?", gun.getBulletTag(), bullet.getUniqueId());
			//bullet.remove();
			return;
		}
		
		if (!bullet.getType().equals(bulletType.getEntityType())) {
			AddGun.getPlugin().debug("Bullet {1} matching {0} but has different type?!", bulletType.getName(), bullet.getUniqueId());
			//bullet.remove();
			return;
		}

		Material block = event.getHitBlock().getType();
		if (!block.isSolid() && block.isTransparent()) {
			if (Material.LAVA.equals(block) || Material.STATIONARY_LAVA.equals(block)) {
				// lava, it dies.
			} else {
				// respawn it
				/*Location newBegin = event.getHitBlock().getLocation().clone();
				if (hit instanceof Damageable) {
					Damageable dhit = (Damageable) hit;
					newBegin.add(bullet.getVelocity().normalize().multiply(dhit.getWidth() * 2));
				} else {
					newBegin.add(bullet.getVelocity().normalize().multiply(1.42)); // diagonalize!
				}
				AddGun.getPlugin().debug(" Just Missed at location {0}, spawning continue at {1} with velocity {2}", 
						end, newBegin, bullet.getVelocity());
				
				Projectile continueBullet = gun.shoot(newBegin, bulletType, bullet.getShooter(), bullet.getVelocity(), true);
				
				gun.postMiss(whereEnd, hit, bullet, continueBullet, bulletType);
*/	
			}
		}
		
		Location end = event.getHitBlock().getLocation().clone().add(0.5, 0.5, 0.5);

		AddGun.getPlugin().debug("Warning: bullet {1} of {0} hit ground {2}", gun.getBulletTag(), bullet.getUniqueId(), end);
		
		//gun.flightPath(begin, end, bulletType, true);
		
		gun.postHit(new HitDigest(HitPart.MISS, end), null, bullet, bulletType );

		//bullet.remove();
		return;
	}
 
开发者ID:ProgrammerDan,项目名称:AddGun,代码行数:65,代码来源:Guns.java

示例10: isSafe

import org.bukkit.Material; //导入方法依赖的package包/类
public static boolean isSafe(Material material) {
    return !(material == Material.CACTUS || material.isTransparent()) && material.isSolid();
}
 
开发者ID:Project-Coalesce,项目名称:UHC,代码行数:4,代码来源:Blocks.java

示例11: isSolid

import org.bukkit.Material; //导入方法依赖的package包/类
/**
 * Is the given block considered solid for flight-checks?
 * @param bk
 * @return solid
 */
private static boolean isSolid(Block bk) {
    Material type = bk.getType();
    return type.isSolid() || type == Material.CHORUS_PLANT || type == Material.CHORUS_FLOWER;
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:10,代码来源:Flight.java

示例12: isSolid

import org.bukkit.Material; //导入方法依赖的package包/类
/**
 * Returns whether or not the given material has a collision box.
 * @param mat
 * @return solid
 */
public static boolean isSolid(Material mat) {
    return mat.isSolid() && mat.isOccluding();
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:9,代码来源:Utils.java


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