Java 类org.bukkit.event.entity.SlimeSplitEvent 实例源码

项目:SwornCritters    文件:EntityListener.java   
@EventHandler
public void onSlimeSplit(SlimeSplitEvent event)
{
    Slime slime = event.getEntity();
    if (plugin.getLegendaryEntityId() != null && plugin.getLegendaryEntityId().equals(slime.getUniqueId()))
    {
        event.setCount(0);

        Player killer = slime.getKiller();
        if (killer != null)
        {
            Material mat = MaterialUtil.getMaterial(plugin.getConfig().getString("slimeDropsType"));
            slime.getWorld().dropItem(slime.getLocation(), new ItemStack(mat, plugin.getConfig().getInt("slimeDropsAmount")));
            killer.sendMessage(ChatColor.GREEN + "You have killed a legendary monster!");
        }

        slime.remove();
        plugin.removeLegendary();
    }
}
项目:CraftBukkit    文件:EntitySlime.java   
public void die() {
    int i = this.getSize();

    if (!this.world.isStatic && i > 1 && this.getHealth() <= 0.0F) {
        int j = 2 + this.random.nextInt(3);

        // CraftBukkit start
        SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), j);
        this.world.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled() && event.getCount() > 0) {
            j = event.getCount();
        } else {
            super.die();
            return;
        }
        // CraftBukkit end

        for (int k = 0; k < j; ++k) {
            float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F;
            float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F;
            EntitySlime entityslime = this.bQ();

            entityslime.setSize(i / 2);
            entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F);
            this.world.addEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
        }
    }

    super.die();
}
项目:Almura-Server    文件:EntitySlime.java   
public void die() {
    int i = this.getSize();

    if (!this.world.isStatic && i > 1 && this.getHealth() <= 0.0F) {
        int j = 2 + this.random.nextInt(3);

        // CraftBukkit start
        SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), j);
        this.world.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled() && event.getCount() > 0) {
            j = event.getCount();
        } else {
            super.die();
            return;
        }
        // CraftBukkit end

        for (int k = 0; k < j; ++k) {
            float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F;
            float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F;
            EntitySlime entityslime = this.bK();

            entityslime.setSize(i / 2);
            entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F);
            this.world.addEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
        }
    }

    super.die();
}
项目:Tweakkit-Server    文件:EntitySlime.java   
public void die() {
    int i = this.getSize();

    if (!this.world.isStatic && i > 1 && this.getHealth() <= 0.0F) {
        int j = 2 + this.random.nextInt(3);

        // CraftBukkit start
        SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), j);
        this.world.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled() && event.getCount() > 0) {
            j = event.getCount();
        } else {
            super.die();
            return;
        }
        // CraftBukkit end

        for (int k = 0; k < j; ++k) {
            float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F;
            float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F;
            EntitySlime entityslime = this.bQ();

            entityslime.setSize(i / 2);
            entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F);
            this.world.addEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
        }
    }

    super.die();
}
项目:Cauldron    文件:EntitySlime.java   
public void setDead()
{
    int i = this.getSlimeSize();

    if (!this.worldObj.isRemote && i > 1 && this.getHealth() <= 0.0F)
    {
        int j = 2 + this.rand.nextInt(3);
        // CraftBukkit start
        SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), j);
        this.worldObj.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled() && event.getCount() > 0)
        {
            j = event.getCount();
        }
        else
        {
            super.setDead();
            return;
        }

        // CraftBukkit end

        for (int k = 0; k < j; ++k)
        {
            float f = ((float)(k % 2) - 0.5F) * (float)i / 4.0F;
            float f1 = ((float)(k / 2) - 0.5F) * (float)i / 4.0F;
            EntitySlime entityslime = this.createInstance();
            entityslime.setSlimeSize(i / 2);
            entityslime.setLocationAndAngles(this.posX + (double)f, this.posY + 0.5D, this.posZ + (double)f1, this.rand.nextFloat() * 360.0F, 0.0F);
            this.worldObj.addEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
        }
    }

    super.setDead();
}
项目:SpigotSource    文件:EntitySlime.java   
public void die() {
    int i = this.getSize();

    if (!this.world.isClientSide && i > 1 && this.getHealth() <= 0.0F) {
        int j = 2 + this.random.nextInt(3);

        // CraftBukkit start
        SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), j);
        this.world.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled() && event.getCount() > 0) {
            j = event.getCount();
        } else {
            super.die();
            return;
        }
        // CraftBukkit end

        for (int k = 0; k < j; ++k) {
            float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F;
            float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F;
            EntitySlime entityslime = this.cU();

            if (this.hasCustomName()) {
                entityslime.setCustomName(this.getCustomName());
            }

            if (this.isPersistent()) {
                entityslime.cM();
            }

            entityslime.setSize(i / 2);
            entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F);
            this.world.addEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
        }
    }

    super.die();
}
项目:Craft-city    文件:EntitySlime.java   
public void die() {
    int i = this.getSize();

    if (!this.world.isStatic && i > 1 && this.getHealth() <= 0) {
        int j = 2 + this.random.nextInt(3);

        // CraftBukkit start
        SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), j);
        this.world.getServer().getPluginManager().callEvent(event);

        if (!event.isCancelled() && event.getCount() > 0) {
            j = event.getCount();
        } else {
            super.die();
            return;
        }
        // CraftBukkit end

        for (int k = 0; k < j; ++k) {
            float f = ((float) (k % 2) - 0.5F) * (float) i / 4.0F;
            float f1 = ((float) (k / 2) - 0.5F) * (float) i / 4.0F;
            EntitySlime entityslime = this.i();

            entityslime.setSize(i / 2);
            entityslime.setPositionRotation(this.locX + (double) f, this.locY + 0.5D, this.locZ + (double) f1, this.random.nextFloat() * 360.0F, 0.0F);
            this.world.addEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
        }
    }

    super.die();
}
项目:ZentrelaRPG    文件:EnvironmentManager.java   
@EventHandler
public void onSlimeSplit(SlimeSplitEvent event) {
    event.setCancelled(true);
}
项目:ProjectAres    文件:OwnedMobTracker.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSlimeSplit(SlimeSplitEvent event) {
    if(event.getCount() > 0 && resolveEntity(event.getEntity()) != null) {
        splitter = new WeakReference<>(event.getEntity());
    }
}