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


Java Entity.setMetadata方法代码示例

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


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

示例1: spawnEntity

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public static void spawnEntity(String player, int challenge, String str, int amount) {
	EntityType entity = EntityType.valueOf(str);
	Location loc1 = plugin.getChallengesFile().getFirstLocation(challenge);
	Location loc2 = plugin.getChallengesFile().getSecondLocation(challenge);
	Location spawnLoc = loc1;
	for(int i = 0; i < amount; i++) {
		spawnLoc.setX(getRandom(loc1.getBlockX(), loc2.getBlockX()));
		spawnLoc.setY(getRandom(loc1.getBlockY(), loc2.getBlockY()));
		spawnLoc.setZ(getRandom(loc1.getBlockZ(), loc2.getBlockZ()));
		Entity e = loc1.getWorld().spawnEntity(spawnLoc, entity);
		e.setMetadata("challenge", new FixedMetadataValue(plugin, String.valueOf(challenge) + ", " + player));
	}
}
 
开发者ID:benNek,项目名称:AsgardAscension,代码行数:14,代码来源:Convert.java

示例2: changeBowProjectile

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void changeBowProjectile(EntityShootBowEvent event) {
    Plugin plugin = this.getMatch().getPlugin();
    Entity newProjectile;

    if(this.projectile == Arrow.class && event.getProjectile() instanceof Arrow) {
        // Don't change the projectile if it's an Arrow and the custom entity type is also Arrow
        newProjectile = event.getProjectile();
    } else {
        // Replace the projectile
        World world = event.getEntity().getWorld();
        Projectile oldEntity = (Projectile) event.getProjectile();

        if(Projectile.class.isAssignableFrom(projectile)) {
            // Ender Pearls need to be soawned this way, otherwise they will hit the shooter sometimes
            newProjectile = event.getEntity().launchProjectile(projectile.asSubclass(Projectile.class), oldEntity.getVelocity());
        } else {
            newProjectile = world.spawn(oldEntity.getLocation(), projectile);
            newProjectile.setVelocity(oldEntity.getVelocity());
        }

        event.setProjectile(newProjectile);

        // Copy some things from the old projectile
        newProjectile.setFallDistance(oldEntity.getFallDistance());
        newProjectile.setFireTicks(oldEntity.getFireTicks());

        if(newProjectile instanceof Projectile) {
            ((Projectile) newProjectile).setShooter(oldEntity.getShooter());
            ((Projectile) newProjectile).setBounce(oldEntity.doesBounce());
        }

        // Save some special properties of Arrows
        if(oldEntity instanceof Arrow) {
            Arrow arrow = (Arrow) oldEntity;
            newProjectile.setMetadata("critical", new FixedMetadataValue(plugin, arrow.isCritical()));
            newProjectile.setMetadata("knockback", new FixedMetadataValue(plugin, arrow.getKnockbackStrength()));
            newProjectile.setMetadata("damage", new FixedMetadataValue(plugin, arrow.getDamage()));
        }
    }

    // Tag the projectile as custom
    newProjectile.setMetadata("customProjectile", new FixedMetadataValue(plugin, true));

    getMatch().callEvent(new EntityLaunchEvent(newProjectile, event.getEntity()));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:47,代码来源:ModifyBowProjectileMatchModule.java


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