當前位置: 首頁>>代碼示例>>Java>>正文


Java FallingBlock類代碼示例

本文整理匯總了Java中org.bukkit.entity.FallingBlock的典型用法代碼示例。如果您正苦於以下問題:Java FallingBlock類的具體用法?Java FallingBlock怎麽用?Java FallingBlock使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FallingBlock類屬於org.bukkit.entity包,在下文中一共展示了FallingBlock類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: clear

import org.bukkit.entity.FallingBlock; //導入依賴的package包/類
public void clear(@Nonnull World world) {
    // clear information about blocks in that world
    Iterator<Map.Entry<Block, OfflinePlayer>> blockIt = this.placedAnvils.entrySet().iterator();
    while(blockIt.hasNext()) {
        Block block = blockIt.next().getKey();
        if(block.getWorld().equals(world)) {
            blockIt.remove();
        }
    }

    // clear information about entitys in that world
    Iterator<Map.Entry<FallingBlock, OfflinePlayer>> entityIt = this.ownedAnvils.entrySet().iterator();
    while(entityIt.hasNext()) {
        Entity tnt = entityIt.next().getKey();
        if(tnt.getWorld().equals(world)) {
            entityIt.remove();
        }
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:20,代碼來源:SimpleAnvilTracker.java

示例2: resolve

import org.bukkit.entity.FallingBlock; //導入依賴的package包/類
public DamageInfo resolve(LivingEntity entity, Lifetime lifetime, EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;

        if(event.getDamager() instanceof FallingBlock) {
            FallingBlock anvil = (FallingBlock) event.getDamager();
            OfflinePlayer offlineOwner = this.anvilTracker.getOwner(anvil);
            Player onlineOwner = null;

            if(offlineOwner != null) onlineOwner = offlineOwner.getPlayer();

            return new AnvilDamageInfo(anvil, onlineOwner, offlineOwner);
        }
    }

    return null;
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:18,代碼來源:AnvilDamageResolver.java

示例3: 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++;
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:20,代碼來源:BombardmentGame.java

示例4: 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});
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:27,代碼來源:TrampolinioGame.java

示例5: onEntityChangeBlock

import org.bukkit.entity.FallingBlock; //導入依賴的package包/類
@EventHandler(priority=EventPriority.LOWEST)
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
	if (e.getEntity() instanceof FallingBlock) {
		if (Variables.blocks.contains(e.getEntity().getUniqueId())) {
			e.setCancelled(true);
			e.getEntity().remove();
		}
	}
	else if (e.getEntity() instanceof Wither) {
		SlimefunItem item = BlockStorage.check(e.getBlock());
		if (item != null) {
			if (item.getName().equals("WITHER_PROOF_OBSIDIAN")) e.setCancelled(true);
			if (item.getName().equals("WITHER_PROOF_GLASS")) e.setCancelled(true);
		}
	}
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:17,代碼來源:ItemListener.java

示例6: fall

import org.bukkit.entity.FallingBlock; //導入依賴的package包/類
@SuppressWarnings("deprecation")
private void fall(long pos, @Nullable ParticipantState breaker) {
    // Block must be removed BEFORE spawning the FallingBlock, or it will not appear on the client
    // https://bugs.mojang.com/browse/MC-72248
    Block block = blockAt(this.getMatch().getWorld(), pos);
    BlockState oldState = block.getState();
    block.setType(Material.AIR, false);
    FallingBlock fallingBlock = oldState.spawnFallingBlock();

    BlockFallEvent event = new BlockFallEvent(block, fallingBlock);
    getMatch().callEvent(breaker == null ? new BlockTransformEvent(event, block, Material.AIR)
                                         : new ParticipantBlockTransformEvent(event, block, Material.AIR, breaker));

    if(event.isCancelled()) {
        fallingBlock.remove();
        oldState.update(true, false); // Restore the old block if the fall is cancelled
    } else {
        // This is already air, but physics have not been applied yet, so do that now
        block.simulateChangeForNeighbors(oldState.getMaterialData(), new MaterialData(Material.AIR));
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:22,代碼來源:FallingBlocksMatchModule.java

示例7: 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 );
    }
}
 
開發者ID:PickAxis,項目名稱:MinePlace,代碼行數:24,代碼來源:PaintBlocksTask.java

示例8: compare

import org.bukkit.entity.FallingBlock; //導入依賴的package包/類
@Override
public Relation compare(final DamageCause dc, final EntityData e) {
	switch (dc) {
		case ENTITY_ATTACK:
			return Relation.get(e.isSupertypeOf(EntityData.fromClass(Entity.class)));
		case PROJECTILE:
			return Relation.get(e.isSupertypeOf(EntityData.fromClass(Projectile.class)));
		case WITHER:
			return Relation.get(e.isSupertypeOf(EntityData.fromClass(Wither.class)));
		case FALLING_BLOCK:
			return Relation.get(e.isSupertypeOf(EntityData.fromClass(FallingBlock.class)));
			//$CASES-OMITTED$
		default:
			return Relation.NOT_EQUAL;
	}
}
 
開發者ID:nfell2009,項目名稱:Skript,代碼行數:17,代碼來源:DefaultComparators.java

示例9: 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);
        }
    }
}
 
開發者ID:ModernDayPlayer,項目名稱:SurvivalGamesX,代碼行數:18,代碼來源:BlockListener.java

示例10: onEntityChangeBlock

import org.bukkit.entity.FallingBlock; //導入依賴的package包/類
@EventHandler(priority=EventPriority.LOWEST)
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
	if (e.getEntity() instanceof FallingBlock) {
		if (Variables.blocks.contains(e.getEntity().getUniqueId())) {
			e.setCancelled(true);
			e.getEntity().remove();
		}
	}
	else if (e.getEntity() instanceof Wither) {
		SlimefunItem item = BlockStorage.check(e.getBlock());
		if (item != null) {
			if (item.getID().equals("WITHER_PROOF_OBSIDIAN")) e.setCancelled(true);
			if (item.getID().equals("WITHER_PROOF_GLASS")) e.setCancelled(true);
		}
	}
}
 
開發者ID:TheBusyBiscuit,項目名稱:Slimefun4,代碼行數:17,代碼來源:ItemListener.java

示例11: spawnCrate

import org.bukkit.entity.FallingBlock; //導入依賴的package包/類
@Override
@SuppressWarnings("deprecation")
public Crate spawnCrate(CratePlayer p, Crate crate, Location loc) {
	if(p.hasCrate()) {
		return crate;
	}
	if(canFall(loc)) {
		if(getConfiguration().isCrateMessagesEnabled()) {
			if(crate.getType() == CrateType.RARE) {
				Bukkit.broadcastMessage(getConfiguration().getRareCrateDropMessage().replaceAll("%p", p.getPlayer().getName()).replaceAll("%crate", crate.getCrateName()));
			} else if(crate.getType() == CrateType.NORMAL) {
				Bukkit.broadcastMessage(getConfiguration().getNormalCrateDropMessage().replaceAll("%p", p.getPlayer().getName()).replaceAll("%crate", crate.getCrateName()));
			}
		}

			FallingBlock fall = p.getPlayer().getWorld().spawnFallingBlock(loc.add(0, 1, 0), Material.CHEST, (byte)0);
			fall.setMetadata("crate_serie", new FixedMetadataValue(this, crate.getCrateName()));
			fall.setMetadata("crate_owner", new FixedMetadataValue(this, p.getPlayer().getName()));
			getCrateOwners().add(p.getPlayer().getName());
	}
	return crate;
}
 
開發者ID:xize,項目名稱:manco2,代碼行數:23,代碼來源:ManCo.java

示例12: 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);
		}
	}
}
 
開發者ID:Taiterio,項目名稱:ce,代碼行數:19,代碼來源:Molotov.java

示例13: randBlock

import org.bukkit.entity.FallingBlock; //導入依賴的package包/類
private static FallingBlock randBlock(Location l){

		Location ground = new Location(l.getWorld(), l.getX(), l.getY() - 1, l.getZ());
		Material block = ground.getBlock().getType();

		Random rand = new Random();
		int item = rand.nextInt(4);
		Material stack = null;
		Byte b = null; 

		if (item == 0){
			stack = Material.WOOL;
			b = 5;
		}else if (item == 1){
			stack = Material.WOOL;
			b = 14;
		}else if (item == 2){
			stack = block;
			b = 0;
		}else if (item == 3){
			stack = block;
			b = 0;
		}
		return(l.getWorld().spawnFallingBlock(l, stack, b));
	}
 
開發者ID:EmilHernvall,項目名稱:tregmine,代碼行數:26,代碼來源:GrinchListener.java

示例14: run

import org.bukkit.entity.FallingBlock; //導入依賴的package包/類
@Override
public void run() {
	for (FallingBlock fb : plugin.anvils.keySet()) {
		for (Entity en : fb.getWorld().getEntities()) {
			if (!(en instanceof LivingEntity)) {
				continue;
			}
			if (Util.inRegionOf(fb.getLocation(), en.getLocation(), 1)) {
				((LivingEntity) en).damage(3.0f);
			}
		}
		
		plugin.anvils.put(fb, plugin.anvils.get(fb) - 1);
		if (plugin.anvils.get(fb) < 0) {
			plugin.anvils.remove(fb);
		}
	}
}
 
開發者ID:SugarCaney,項目名稱:DirtyArrows,代碼行數:19,代碼來源:Iron.java

示例15: onBlockChange

import org.bukkit.entity.FallingBlock; //導入依賴的package包/類
@EventHandler
public void onBlockChange(EntityChangeBlockEvent e) {
	if (e.getEntity() instanceof FallingBlock) {
		if (plugin.anvils.containsKey(e.getEntity())) {
			for (Entity ent : e.getEntity().getWorld().getEntities()) {
				if (ent instanceof LivingEntity) {
					LivingEntity len = (LivingEntity) ent;
					if (Util.inRegionOf(len.getLocation(), e.getEntity().getLocation(), 3)) {
						if (len instanceof Player) {
							((Player) len).playSound(e.getEntity().getLocation(), Sound.ANVIL_LAND, 1, 1);
						}
						len.damage(10.0f);
					}
				}
			}
		}
		plugin.anvils.remove(e.getEntity());
	}
}
 
開發者ID:SugarCaney,項目名稱:DirtyArrows,代碼行數:20,代碼來源:Iron.java


注:本文中的org.bukkit.entity.FallingBlock類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。