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


Java SpawnReason类代码示例

本文整理汇总了Java中org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason的典型用法代码示例。如果您正苦于以下问题:Java SpawnReason类的具体用法?Java SpawnReason怎么用?Java SpawnReason使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SpawnReason类属于org.bukkit.event.entity.CreatureSpawnEvent包,在下文中一共展示了SpawnReason类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: spawnEntity

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
public Entity spawnEntity(Location loc, EntityType entityType) {
    // Cauldron start - handle custom entity spawns from plugins
    if (EntityRegistry.entityClassMap.get(entityType.getName()) != null)
    {
        net.minecraft.entity.Entity entity = null;
        entity = getEntity(EntityRegistry.entityClassMap.get(entityType.getName()), world);
        if (entity != null)
        {
            entity.setLocationAndAngles(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
            world.addEntity(entity, SpawnReason.CUSTOM);
            return entity.getBukkitEntity();
        }
    }
    // Cauldron end
    return spawn(loc, entityType.getEntityClass());
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:17,代码来源:CraftWorld.java

示例2: spawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
public void spawn(Location location) {
    final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCanceled()) {
        NMSRegistry.accessWorldGuardSpawn(location);
        this.rabbit.spawn(location);
        final net.minecraft.server.v1_8_R1.World mcWorld = ((org.bukkit.craftbukkit.v1_8_R1.CraftWorld) location.getWorld()).getHandle();
        this.setPosition(location.getX(), location.getY(), location.getZ());
        mcWorld.addEntity(this, SpawnReason.CUSTOM);
        final net.minecraft.server.v1_8_R1.NBTTagCompound compound = new net.minecraft.server.v1_8_R1.NBTTagCompound();
        compound.setBoolean("invulnerable", true);
        compound.setBoolean("Invisible", true);
        compound.setBoolean("PersistenceRequired", true);
        compound.setBoolean("ShowArms", true);
        compound.setBoolean("NoBasePlate", true);
        this.a(compound);
        ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878));
        ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0));
        ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField());
        NMSRegistry.rollbackWorldGuardSpawn(location);
        ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true);
        ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName());
        ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false);
        ((LivingEntity) this.rabbit.getEntity()).setRemoveWhenFarAway(false);
        this.health = ConfigPet.getInstance().getCombat_health();
        if (this.petMeta == null)
            return;
        PetBlockHelper.setItemConsideringAge(this);
    }
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:31,代码来源:CustomGroundArmorstand.java

示例3: spawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
@Override
public void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final net.minecraft.server.v1_8_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.a(compound);
    this.slime = new CustomRabbit(location.getWorld(), true, this);
    this.slime.spawn(location);
    this.getSpigotEntity().setHeadPose(new EulerAngle(0, 0, 0));
    this.getSpigotEntity().setBodyPose(new EulerAngle(0, 0, 2778));
    this.getSpigotEntity().setRightArmPose(new EulerAngle(2778, 0, 0));
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:20,代码来源:CustomArmorstand.java

示例4: spawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
@Override
public void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.a(compound);
    this.slime = new CustomRabbit(location.getWorld(), true, this);
    this.slime.spawn(location);
    this.getSpigotEntity().setHeadPose(new EulerAngle(0, 0, 0));
    this.getSpigotEntity().setBodyPose(new EulerAngle(0, 0, 2778));
    this.getSpigotEntity().setRightArmPose(new EulerAngle(2778, 0, 0));
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:20,代码来源:CustomArmorstand.java

示例5: spawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
@Override
public void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final net.minecraft.server.v1_8_R3.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.a(compound);
    this.slime = new CustomRabbit(location.getWorld(), this);
    this.slime.spawn(location);
    this.getSpigotEntity().setHeadPose(new EulerAngle(0, 0, 0));
    this.getSpigotEntity().setBodyPose(new EulerAngle(0, 0, 2778));
    this.getSpigotEntity().setRightArmPose(new EulerAngle(2778, 0, 0));
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:20,代码来源:CustomArmorstand.java

示例6: spawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
@Override
public void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final net.minecraft.server.v1_8_R2.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.a(compound);
    this.slime = new CustomRabbit(location.getWorld(), true, this);
    this.slime.spawn(location);
    this.getSpigotEntity().setHeadPose(new EulerAngle(0, 0, 0));
    this.getSpigotEntity().setBodyPose(new EulerAngle(0, 0, 2778));
    this.getSpigotEntity().setRightArmPose(new EulerAngle(2778, 0, 0));
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:20,代码来源:CustomArmorstand.java

示例7: onSpawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
 if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySpawnerEggs") == true) {
  if (event.getSpawnReason() == SpawnReason.SPAWNER_EGG) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
 }
 if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySpawners") == true) {
  if (event.getSpawnReason() == SpawnReason.SPAWNER) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
 }
 if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySummonCommand") == true) {
  if (event.getSpawnReason() == SpawnReason.DEFAULT) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
  if (event.getSpawnReason() == SpawnReason.CUSTOM) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
 }
}
 
开发者ID:AnonymousDr,项目名称:ADR,代码行数:22,代码来源:mobs.java

示例8: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent event)
{
    LivingEntity entity = event.getEntity();
    if(!this.isMonster(entity)) return;
    
    SpawnReason reason = event.getSpawnReason();
    if(reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG)
    {
        entity.setMetadata(this.ALLOW_TARGET_TAG, new FixedMetadataValue(GPFlags.instance, new Boolean(true)));
        return;
    }
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getLocation(), null);
    if(flag == null) return;
    
    event.setCancelled(true);
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:19,代码来源:FlagDef_NoMonsterSpawns.java

示例9: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event)
{
    if(!(event.getEntity() instanceof LivingEntity)) return;
    
    if(event.getLocation() == null) return;
    
    EntityType type = event.getEntityType();
    if(type == EntityType.PLAYER) return;
    if(type == EntityType.ARMOR_STAND) return;
    
    SpawnReason reason = event.getSpawnReason();
    if(reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG) return;
    
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getLocation(), null);
    if(flag == null) return;
    
    event.setCancelled(true);
}
 
开发者ID:BigScary,项目名称:GriefPreventionFlags,代码行数:21,代码来源:FlagDef_NoMobSpawns.java

示例10: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getSpawnReason() != SpawnReason.NATURAL) { //TODO: Should check for Custom instead of checking against natural?
        return;
    }

    EntityType type = event.getEntityType();
    World world = event.getLocation().getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.MORE_SPAWNING) && worldConfig.getStringList(Config.FEATURE_MORE_SPAWNING_MOBS).contains(type.getName().toUpperCase())) {
        for (int i = 0; i < Math.max(worldConfig.getInt(Config.FEATURE_MORE_SPAWNING_MULTIPLIER), 1); ++i) {
            for (BloodMoonEntityType bloodMoonEntity : BloodMoonEntityType.values()) {
                if (type == bloodMoonEntity.getEntityType()) {
                    bloodMoonEntity.spawnEntity(event.getLocation().add((random.nextDouble() * 3) - 1.5, (random.nextDouble() * 3) - 1.5, (random.nextDouble() * 3) - 1.5));
                    return;
                }
            }
        }
    }
}
 
开发者ID:Samistine,项目名称:BloodMoon,代码行数:22,代码来源:MoreSpawningListener.java

示例11: onEntitySpawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event)
{
	//these rules apply only to creative worlds
	if(!GriefPrevention.instance.creativeRulesApply(event.getLocation())) return;
	
	//chicken eggs and breeding could potentially make a mess in the wilderness, once griefers get involved
	SpawnReason reason = event.getSpawnReason();
	if(reason != SpawnReason.SPAWNER_EGG && reason != SpawnReason.BUILD_IRONGOLEM && reason != SpawnReason.BUILD_SNOWMAN)
	{
		event.setCancelled(true);
		return;
	}

	//otherwise, just apply the limit on total entities per claim (and no spawning in the wilderness!)
	Claim claim = this.dataStore.getClaimAt(event.getLocation(), false, null);
	if(claim == null || claim.allowMoreEntities() != null)
	{
		event.setCancelled(true);
		return;
	}
}
 
开发者ID:john01dav,项目名称:GriefPreventionPlus,代码行数:23,代码来源:EntityEventHandler.java

示例12: spawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
public static Entity spawn(Location loc, ICustomMob iCustom, String name) {
	CraftWorld world = (CraftWorld) loc.getWorld();
	World mcWorld = world.getHandle();
	MobBaseZombie zombie = new MobBaseZombie(mcWorld, iCustom);
	
	if (name != null) {
		zombie.setCustomName(name);
		zombie.setCustomNameVisible(true);
	}
	iCustom.setEntity(zombie);
	
	zombie.setPosition(loc.getX(), loc.getY(), loc.getZ());
	mcWorld.addEntity(zombie, SpawnReason.CUSTOM);
	
	return zombie;
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:17,代码来源:MobBaseZombie.java

示例13: onCreatureSpawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event)
{
    Entity entity = event.getEntity();

    Location location = event.getLocation();
    Point pos = new Point(location.getBlockX(), location.getBlockZ());

    ZoneWorld world = plugin.getWorld(entity.getWorld());
    Zone zone = world.findZone(pos);

    if (zone == null || zone.hasHostiles()) {
        return;
    }

    if (!allowedMobs.contains(event.getEntityType()) &&
        event.getSpawnReason() == SpawnReason.NATURAL) {

        event.setCancelled(true);
    }
}
 
开发者ID:EmilHernvall,项目名称:tregmine,代码行数:22,代码来源:ZoneEntityListener.java

示例14: onEnderDragonSpawn

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
/**
 * - Prevents natural spawn of EnderDragon
 * - Prevents too many Dragons in the End world
 * - Handle custom health and take care of this new Dragon
 *
 * @param event a CreatureSpawnEvent
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEnderDragonSpawn(final CreatureSpawnEvent event) {
    if (event.getEntityType() == EntityType.ENDER_DRAGON) {
        final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(event.getLocation().getWorld().getName()));
        if (handler != null) {
            if (handler.getNumberOfAliveEnderDragons() >= handler.getConfig().getRespawnNumber()) {
                event.setCancelled(true);
            } else {
                if (event.getSpawnReason() != SpawnReason.CUSTOM && event.getSpawnReason() != SpawnReason.SPAWNER_EGG) {
                    event.setCancelled(true);
                } else {
                    if (!handler.getDragons().containsKey(event.getEntity().getUniqueId())) {
                        handler.getDragons().put(event.getEntity().getUniqueId(), new HashMap<String, Double>());
                        event.getEntity().setMaxHealth(handler.getConfig().getEdHealth());
                        event.getEntity().setHealth(event.getEntity().getMaxHealth());
                    }
                    handler.getLoadedDragons().add(event.getEntity().getUniqueId());
                }
            }
        }
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:30,代码来源:EnderDragonListener.java

示例15: spawnFallingBlock

import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; //导入依赖的package包/类
public FallingBlock spawnFallingBlock(Location location, org.bukkit.Material material, byte data) throws IllegalArgumentException {
    Validate.notNull(location, "Location cannot be null");
    Validate.notNull(material, "Material cannot be null");
    Validate.isTrue(material.isBlock(), "Material must be a block");

    double x = location.getBlockX() + 0.5;
    double y = location.getBlockY() + 0.5;
    double z = location.getBlockZ() + 0.5;

    net.minecraft.entity.item.EntityFallingBlock entity = new net.minecraft.entity.item.EntityFallingBlock(world, x, y, z, net.minecraft.block.Block.getBlockById(material.getId()), data);
    entity.field_145812_b = 1; // ticksLived

    world.addEntity(entity, SpawnReason.CUSTOM);
    return (FallingBlock) entity.getBukkitEntity();
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:16,代码来源:CraftWorld.java


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