本文整理汇总了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());
}
}
示例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;
}
}
示例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);
}
示例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();
}
}
示例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());
}
示例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());
}
示例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;
}
}
示例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);
}
}
}
}
}
示例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;
}
示例10: isSafe
import org.bukkit.Material; //导入方法依赖的package包/类
public static boolean isSafe(Material material) {
return !(material == Material.CACTUS || material.isTransparent()) && material.isSolid();
}
示例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;
}
示例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();
}