本文整理匯總了Java中org.bukkit.entity.FallingBlock.setDropItem方法的典型用法代碼示例。如果您正苦於以下問題:Java FallingBlock.setDropItem方法的具體用法?Java FallingBlock.setDropItem怎麽用?Java FallingBlock.setDropItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.entity.FallingBlock
的用法示例。
在下文中一共展示了FallingBlock.setDropItem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fireCannon
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
private void fireCannon(Location cannon, Location target) {
FallingBlock entity = cannon.getWorld().spawnFallingBlock(cannon, new MaterialData(Material.COAL_BLOCK));
this.playParticles(entity.getLocation());
entity.setGravity(true);
entity.setDropItem(false);
entity.setHurtEntities(false);
entity.setInvulnerable(true);
this.moveToward(entity, target, 2D);
new BukkitRunnable() {
public void run() {
if(entity.isDead()) {
this.cancel();
} else {
entity.setTicksLived(1);
}
}
}.runTaskTimer(this.getAPI().getPlugin(), 0, 20L);
totalCannonShots++;
}
示例2: spawnPoint
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
private void spawnPoint() {
final Location spawnLocation = spawnLocations.get(new Random().nextInt(spawnLocations.size()));
for(Map.Entry<Location, Object[]> entry : this.currentLocations.entrySet()) {
if(spawnLocation.distance(entry.getKey()) >= 1D) continue;
return;
}
PointType pointType = PointType.fetch();
FallingBlock entity = spawnLocation.getWorld().spawnFallingBlock(spawnLocation, pointType.getMaterialData());
entity.setGravity(false);
entity.setDropItem(false);
entity.setHurtEntities(false);
entity.setInvulnerable(true);
entity.setCustomName(pointType.getTranslation());
entity.setCustomNameVisible(true);
new BukkitRunnable() {
public void run() {
if(entity.isDead()) {
this.cancel();
} else {
entity.setTicksLived(1);
entity.teleport(spawnLocation);
}
}
}.runTaskTimer(this.getAPI().getPlugin(), 0, 20L);
this.currentLocations.put(spawnLocation, new Object[]{pointType, entity});
}
示例3: placeBlock
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@SuppressWarnings( value = "deprecation" )
private void placeBlock( int seq, int data )
{
int x = seq % 1000;
int z = seq / 1000;
Block block = this.getWorld().getBlockAt( x, this.getHeight(), z );
if( block.getType() != Material.WOOL )
{
block.setType( Material.WOOL );
}
byte woolColor = PlaceColor.getColorById( data ).getWoolColor();
if( block.getData() != woolColor )
{
block.setData( woolColor );
FallingBlock fb = this.getWorld().spawnFallingBlock( new Location( this.getWorld(), x, this.getFallingBlockHeight(), z ), Material.WOOL, woolColor );
fb.setDropItem( false );
fb.setHurtEntities( false );
}
}
示例4: fragBallExplode
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@EventHandler
public void fragBallExplode(EntityExplodeEvent e) {
e.setCancelled(true);
for(Block block : e.blockList()) {
if(block.getRelative(BlockFace.UP).getType() == Material.AIR && block.getType().isSolid()) {
FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0, 1, 0), block.getType(), block.getData());
double x = (block.getLocation().getX() - e.getLocation().getX()) / 3,
y = 1,
z = (block.getLocation().getZ() - e.getLocation().getZ()) / 3;
fallingBlock.setVelocity(new Vector(x, y, z).normalize());
fallingBlock.setMetadata("explode", new FixedMetadataValue(plugin, false));
fallingBlock.setDropItem(false);
e.setYield(0F);
}
}
}
示例5: effect
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void effect(Event e, ItemStack item, final int level) {
if(e instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
Entity target = event.getEntity();
World world = target.getWorld();
world.playEffect(target.getLocation(), Effect.POTION_BREAK, 10);
double boundaries = 0.1*level;
for(double x = boundaries; x >= -boundaries; x-=0.1)
for(double z = boundaries; z >= -boundaries; z-=0.1) {
FallingBlock b = world.spawnFallingBlock(target.getLocation(), Material.FIRE.getId(), (byte) 0x0);
b.setVelocity(new Vector(x, 0.1, z));
b.setDropItem(false);
}
}
}
示例6: onEntityExplode
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled=true)
public void onEntityExplode(EntityExplodeEvent event) {
if (event.getEntity() instanceof TNTPrimed &&
bombSites.containsKey((TNTPrimed) event.getEntity())) {
for (Block b : event.blockList()) {
if (Math.random() < 0.4) {
FallingBlock block = event.getEntity().getWorld().spawnFallingBlock(b.getLocation().add(0, 1, 0), b.getType(), b.getData());
Location bLoc = b.getLocation();
Location tLoc = event.getEntity().getLocation();
double power = 0.15;
double x = (bLoc.getX() - tLoc.getX()) * power + Math.random() - 0.5;
double z = (bLoc.getZ() - tLoc.getZ()) * power + Math.random() - 0.5;
double y = 0.8;
block.setVelocity(new Vector(x, y, z));
block.setDropItem(false);
}
b.setType(Material.AIR);
}
}
}
示例7: bounceBlock
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
public void bounceBlock(BlockState b) {
if(b == null) return;
if(fallingBlocks.size() > 1500) {
return;
}
for(Material mat : allowedMaterials()) {
if(b.getType() == mat) {
FallingBlock fb = b.getWorld().spawnFallingBlock(b.getLocation(), b.getData().getItemType(), b.getData().getData());
float x = (float) -1 + (float) (Math.random() * ((1 - -1) + 1));
float y = 2;//(float) -5 + (float)(Math.random() * ((5 - -5) + 1));
float z = (float) -0.3 + (float)(Math.random() * ((0.3 - -0.3) + 1));
fb.setDropItem(false);
fb.setVelocity(new Vector(x, y, z));
fallingBlocks.add(fb);
fb.setMetadata("xe:explosion", new FixedMetadataValue(pl, ""));
}
}
}
示例8: onExplode
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@EventHandler
@SuppressWarnings("deprecation")
public void onExplode(EntityExplodeEvent event) {
for (final Block block : event.blockList()) {
if(!ArenaUtils.isProtected(block.getLocation())){
return;
}
Random r = new Random();
FallingBlock fb = block.getWorld().spawnFallingBlock(block.getLocation(), block.getType(), block.getData());
fb.setVelocity(new Vector(0, r.nextInt(3), 0));
fb.setDropItem(false);
}
}
示例9: run
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@Override
public void run()
{
int distance = 5;
Block block = null;
while (distance > 0) {
block = player.getDelegate().getTargetBlock((Set<Material>) null, distance);
if (block.getType().equals(Material.AIR)) {
break;
}
distance--;
}
if (currentBlock != null) {
currentBlock.remove();
currentBlock = null;
}
FallingBlock gravityBlock =
player.getWorld().spawnFallingBlock(block.getLocation(),
material,
data);
gravityBlock.setDropItem(false);
gravityBlock.setFallDistance(0f);
gravityBlock.setVelocity(new Vector(0, 0.1, 0));
dstLocation = gravityBlock.getLocation();
currentBlock = gravityBlock;
}
示例10: throwAnvil
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
private void throwAnvil(World world, Location playerLoc, Location hookLoc) {
double d5 = playerLoc.getX() - hookLoc.getX();
double d6 = playerLoc.getY() - hookLoc.getY();
double d7 = playerLoc.getZ() - hookLoc.getZ();
double d8 = (double) Math.sqrt(d5 * d5 + d6 * d6 + d7 * d7);
double d9 = 0.03D;
FallingBlock anvil = world.spawnFallingBlock(hookLoc, Material.ANVIL, (byte) 8);
anvil.setVelocity(new Vector(d5 * d9, d6 * d9 + (double) Math.sqrt(d8) * 0.32D, d7 * d9));
anvil.setDropItem(true);
enableFallingBlockDamage(anvil);
}
示例11: doStep
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@Override
public void doStep(final Altar altar) {
final Location locBlock = altar.getCenterLocation().toBukkitLocation().add(this.block.getRelativeLocation());
locBlock.getBlock().setType(Material.AIR);
locBlock.getWorld().playEffect(locBlock, Effect.MOBSPAWNER_FLAMES, (byte)4);
locBlock.getWorld().playSound(locBlock, Sound.IRONGOLEM_THROW, 1.0f, 1.0f);
final Location locSpawn = locBlock.clone().add(0, this.fromHeight, 0);
if (locSpawn.getY() >= locSpawn.getWorld().getMaxHeight()) {
locSpawn.setY(locSpawn.getWorld().getMaxHeight() - 1);
}
final FallingBlock fb = locSpawn.getWorld().spawnFallingBlock(locSpawn, this.block.getBlockMaterial(), this.block.getBlockData());
fb.setDropItem(false);
fb.setVelocity(this.initialVelocity);
}
示例12: doBlockDrops
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
/**
* This is not an event handler. It is called explicitly by BlockTransformListener
* after all event handlers have been called.
*/
@SuppressWarnings("deprecation")
public void doBlockDrops(final BlockTransformEvent event) {
if(!causesDrops(event.getCause())) {
return;
}
final BlockDrops drops = event.getDrops();
if(drops != null) {
event.setCancelled(true);
final BlockState oldState = event.getOldState();
final BlockState newState = event.getNewState();
final Block block = event.getOldState().getBlock();
final int newTypeId = newState.getTypeId();
final byte newData = newState.getRawData();
block.setTypeIdAndData(newTypeId, newData, true);
boolean explosion = false;
MatchPlayer player = ParticipantBlockTransformEvent.getParticipant(event);
if(event.getCause() instanceof EntityExplodeEvent) {
EntityExplodeEvent explodeEvent = (EntityExplodeEvent) event.getCause();
explosion = true;
if(drops.fallChance != null &&
oldState.getType().isBlock() &&
oldState.getType() != Material.AIR &&
this.getMatch().getRandom().nextFloat() < drops.fallChance) {
FallingBlock fallingBlock = event.getOldState().spawnFallingBlock();
fallingBlock.setDropItem(false);
if(drops.landChance != null && this.getMatch().getRandom().nextFloat() >= drops.landChance) {
this.fallingBlocksThatWillNotLand.add(fallingBlock);
}
Vector v = fallingBlock.getLocation().subtract(explodeEvent.getLocation()).toVector();
double distance = v.length();
v.normalize().multiply(BASE_FALL_SPEED * drops.fallSpeed / Math.max(1d, distance));
// A very simple deflection model. Check for a solid
// neighbor block and "bounce" the velocity off of it.
Block west = block.getRelative(BlockFace.WEST);
Block east = block.getRelative(BlockFace.EAST);
Block down = block.getRelative(BlockFace.DOWN);
Block up = block.getRelative(BlockFace.UP);
Block north = block.getRelative(BlockFace.NORTH);
Block south = block.getRelative(BlockFace.SOUTH);
if((v.getX() < 0 && west != null && Materials.isColliding(west.getType())) ||
v.getX() > 0 && east != null && Materials.isColliding(east.getType())) {
v.setX(-v.getX());
}
if((v.getY() < 0 && down != null && Materials.isColliding(down.getType())) ||
v.getY() > 0 && up != null && Materials.isColliding(up.getType())) {
v.setY(-v.getY());
}
if((v.getZ() < 0 && north != null && Materials.isColliding(north.getType())) ||
v.getZ() > 0 && south != null && Materials.isColliding(south.getType())) {
v.setZ(-v.getZ());
}
fallingBlock.setVelocity(v);
}
}
dropObjects(drops, player, newState.getLocation(), 1d, explosion);
}
}
示例13: effect
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public boolean effect(Event event, final Player player) {
PlayerInteractEvent e = (PlayerInteractEvent) event;
e.setCancelled(true);
if(player.getItemInHand().getDurability() >= 64) {
if(IsReloadable) {
addLock(player);
player.getWorld().playEffect(player.getLocation(), Effect.CLICK1, 2);
player.sendMessage(ChatColor.RED + "Reloading...");
new BukkitRunnable() {
@Override
public void run() {
if(player.getItemInHand().getDurability() == 0) {
removeLock(player);
player.getWorld().playEffect(player.getLocation(), Effect.CLICK2, 2);
this.cancel();
} else {
player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() - 1));
}
}
}.runTaskTimer(main, 0l, 2l);
} else {
player.getItemInHand().setType(Material.AIR);
}
} else {
final List<Location> list = getLinePlayer(player, FireBlocksPerBurst);
for(final Location l: list) {
if(l.getBlock().getType().equals(Material.AIR))
l.getBlock().setType(Material.FIRE);
l.getWorld().playEffect(l, Effect.SMOKE, 20);
final FallingBlock fire = l.getWorld().spawnFallingBlock(l, Material.FIRE.getId(), (byte) 0);
fire.setDropItem(false);
fire.setVelocity(player.getLocation().getDirection());
new BukkitRunnable() {
@Override
public void run() {
if(fire.isDead()) {
list.add(fire.getLocation());
this.cancel();
} else {
if(!Tools.checkWorldGuard(fire.getLocation(), player, "BUILD", true) || fire.getLocation().getBlock().getType().equals(Material.WATER) || fire.getLocation().getBlock().getType().equals(Material.STATIONARY_WATER)) {
fire.getWorld().playEffect(fire.getLocation(), Effect.EXTINGUISH, 60);
fire.remove();
this.cancel();
}
for(Entity ent:fire.getNearbyEntities(0, 0, 0)) {
if(ent != player) {
ent.setFireTicks(BurnDuration);
}
}
}
}
}.runTaskTimer(main, 0l, 1l);
}
new BukkitRunnable() {
@Override
public void run() {
for(Location ls:list) {
if(ls.getBlock().getType().equals(Material.FIRE)) {
ls.getWorld().playEffect(ls, Effect.EXTINGUISH, 60);
ls.getBlock().setType(Material.AIR);
}
}
}
}.runTaskLater(main, 200l);
player.getWorld().playEffect(player.getLocation(), Effect.BLAZE_SHOOT, 30);
if(!player.getGameMode().equals(GameMode.CREATIVE)) {
player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() + 1));
}
}
return true;
}
示例14: effect
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@Override
public void effect(Event e, ItemStack item, final int level) {
final EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
Player damager = (Player) event.getDamager();
new BukkitRunnable() {
@Override
public void run() {
event.getEntity().setVelocity(new Vector(0, 1 + (level / 4), 0));
}
}.runTaskLater(getPlugin(), 1l);
Location loc = damager.getLocation();
loc.setY(damager.getLocation().getY() - 1);
List<Location> list = Tools.getCone(loc);
this.generateCooldown(damager, cooldown);
damager.getWorld().playEffect(damager.getLocation(), Effect.ZOMBIE_DESTROY_DOOR, 10);
for (final Location l : list) {
final org.bukkit.block.Block block = l.getBlock();
Material blockMat = block.getType();
if (!ForbiddenMaterials.contains(blockMat) && checkSurrounding(block)) {
if (!Tools.checkWorldGuard(l, damager, "PVP", false))
return;
final Material mat = blockMat;
final byte matData = block.getData();
final FallingBlock b = l.getWorld().spawnFallingBlock(l, mat, block.getData());
b.setDropItem(false);
b.setVelocity(new Vector(0, (0.5 + 0.1 * (list.indexOf(l))) + (level / 4), 0));
block.setType(Material.AIR);
new BukkitRunnable() {
Location finLoc = l;
@Override
public void run() {
if (!b.isDead()) {
finLoc = b.getLocation();
} else {
//if(finLoc.getBlock().getLocation() != l)
finLoc.getBlock().setType(Material.AIR);
block.setType(mat);
block.setData(matData);
this.cancel();
}
}
}.runTaskTimer(main, 0l, 5l);
}
}
}
示例15: onBlockBreak
import org.bukkit.entity.FallingBlock; //導入方法依賴的package包/類
@Override
public void onBlockBreak(BlockBreakEvent event, PlayerDetails details) {
Block root = event.getBlock();
if (isLog(root.getType())) {
// Initialize some variables:
World world = event.getPlayer().getWorld();
Location location = root.getLocation();
Random random = new Random();
Vector vel = event.getPlayer().getLocation().toVector().subtract(location.toVector()).normalize().setY(0).multiply(0.2);
// Find the blocks
Set<Block> blocks = getTreeBlocks(root);
if (blocks.size() > 0) {
world.playSound(location, Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 0.5f, 1);
}
double durability = blocks.size()*0.25;
// Bring 'em down.
for (Block block : blocks) {
Material mat = block.getType();
if (mat == Material.LOG && random.nextFloat() < 0.1f) {
world.playSound(block.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 0.6f, 1);
block.breakNaturally();
durability += 1;
} else if (mat == Material.LEAVES && random.nextFloat() < 0.4f) {
world.playSound(block.getLocation(), Sound.BLOCK_GRASS_BREAK, 0.5f, 1);
block.breakNaturally();
durability += 1;
} else {
FallingBlock fallingBlock = world.spawnFallingBlock(block.getLocation(), block.getType(), block.getData());
fallingBlock.setVelocity(vel.multiply(random.nextFloat()*0.2 + 0.9));
if (block.getType() == Material.LEAVES) {
fallingBlock.setDropItem(false);
}
block.setType(Material.AIR);
}
}
// Apply durability.
if (event.getPlayer().getGameMode() != GameMode.CREATIVE) {
ItemStack item = details.getItem();
item.setDurability((short) (item.getDurability() + durability));
}
}
}