Search in sources :

Example 1 with SkeletonEntity

use of net.minecraft.entity.monster.SkeletonEntity in project Mekanism by mekanism.

the class MekanismTools method onLivingSpecialSpawn.

private void onLivingSpecialSpawn(LivingSpawnEvent.SpecialSpawn event) {
    LivingEntity entity = event.getEntityLiving();
    if (entity instanceof ZombieEntity || entity instanceof SkeletonEntity || entity instanceof PiglinEntity) {
        // Don't bother calculating random numbers unless the instanceof checks pass
        Random random = event.getWorld().getRandom();
        double chance = random.nextDouble();
        if (chance < MekanismToolsConfig.tools.armorSpawnRate.get()) {
            // We can only spawn refined glowstone armor on piglins
            int armorType = entity instanceof PiglinEntity ? 0 : random.nextInt(6);
            if (armorType == 0) {
                setEntityArmorWithChance(random, entity, ToolsItems.REFINED_GLOWSTONE_SWORD, ToolsItems.REFINED_GLOWSTONE_HELMET, ToolsItems.REFINED_GLOWSTONE_CHESTPLATE, ToolsItems.REFINED_GLOWSTONE_LEGGINGS, ToolsItems.REFINED_GLOWSTONE_BOOTS, MekanismToolsConfig.tools.refinedGlowstoneSpawnRate);
            } else if (armorType == 1) {
                setEntityArmorWithChance(random, entity, ToolsItems.LAPIS_LAZULI_SWORD, ToolsItems.LAPIS_LAZULI_HELMET, ToolsItems.LAPIS_LAZULI_CHESTPLATE, ToolsItems.LAPIS_LAZULI_LEGGINGS, ToolsItems.LAPIS_LAZULI_BOOTS, MekanismToolsConfig.tools.lapisLazuliSpawnRate);
            } else if (armorType == 2) {
                setEntityArmorWithChance(random, entity, ToolsItems.REFINED_OBSIDIAN_SWORD, ToolsItems.REFINED_OBSIDIAN_HELMET, ToolsItems.REFINED_OBSIDIAN_CHESTPLATE, ToolsItems.REFINED_OBSIDIAN_LEGGINGS, ToolsItems.REFINED_OBSIDIAN_BOOTS, MekanismToolsConfig.tools.refinedObsidianSpawnRate);
            } else if (armorType == 3) {
                setEntityArmorWithChance(random, entity, ToolsItems.STEEL_SWORD, ToolsItems.STEEL_HELMET, ToolsItems.STEEL_CHESTPLATE, ToolsItems.STEEL_LEGGINGS, ToolsItems.STEEL_BOOTS, MekanismToolsConfig.tools.steelSpawnRate);
            } else if (armorType == 4) {
                setEntityArmorWithChance(random, entity, ToolsItems.BRONZE_SWORD, ToolsItems.BRONZE_HELMET, ToolsItems.BRONZE_CHESTPLATE, ToolsItems.BRONZE_LEGGINGS, ToolsItems.BRONZE_BOOTS, MekanismToolsConfig.tools.bronzeSpawnRate);
            } else {
                // armorType == 5
                setEntityArmorWithChance(random, entity, ToolsItems.OSMIUM_SWORD, ToolsItems.OSMIUM_HELMET, ToolsItems.OSMIUM_CHESTPLATE, ToolsItems.OSMIUM_LEGGINGS, ToolsItems.OSMIUM_BOOTS, MekanismToolsConfig.tools.osmiumSpawnRate);
            }
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ZombieEntity(net.minecraft.entity.monster.ZombieEntity) Random(java.util.Random) SkeletonEntity(net.minecraft.entity.monster.SkeletonEntity) PiglinEntity(net.minecraft.entity.monster.piglin.PiglinEntity)

Example 2 with SkeletonEntity

use of net.minecraft.entity.monster.SkeletonEntity in project xercamods by ercanserteli.

the class ItemGoldenCupcake method onItemUseFinish.

@Override
public ItemStack onItemUseFinish(ItemStack stack, World worldIn, LivingEntity player) {
    player.addPotionEffect(new EffectInstance(Effects.REGENERATION, 300, 1));
    player.addPotionEffect(new EffectInstance(Effects.WEAKNESS, 200, 0));
    if (!worldIn.isRemote) {
        int n = worldIn.rand.nextInt(5);
        switch(n) {
            case 0:
                ((ServerWorld) worldIn).addLightningBolt(new LightningBoltEntity(worldIn, player.posX, player.posY, player.posZ, true));
                worldIn.createExplosion(null, player.posX, player.posY, player.posZ, 1.1F, false, Explosion.Mode.BREAK);
                EntityConfettiBall entityball = new EntityConfettiBall(worldIn, player);
                entityball.shoot(player, 270, player.rotationYaw + 90, 0.0F, 1.0F, 1.0F);
                worldIn.addEntity(entityball);
                for (int i = 0; i < 8; i++) {
                    entityball = new EntityConfettiBall(worldIn, player);
                    entityball.shoot(player, 300, 45 * i, 0.0F, 1.0F, 1.0F);
                    worldIn.addEntity(entityball);
                }
                float multiplier = 0.5f;
                float motionX = worldIn.rand.nextFloat() - 0.5f;
                float motionY = worldIn.rand.nextFloat() - 0.5f;
                float motionZ = worldIn.rand.nextFloat() - 0.5f;
                ItemEntity newCupcake = new ItemEntity(worldIn, player.posX + motionX, player.posY + 1 + motionY, player.posZ + motionZ, new ItemStack(Items.ITEM_GOLDEN_CUPCAKE, 2));
                newCupcake.setMotion(motionX * multiplier, motionY * multiplier, motionZ * multiplier);
                worldIn.addEntity(newCupcake);
                break;
            case 1:
            case 2:
                worldIn.playSound(null, player.posX, player.posY + 3, player.posZ, SoundEvents.YAHOO, SoundCategory.PLAYERS, 1.0f, worldIn.rand.nextFloat() * 0.2F + 0.9F);
                player.addVelocity(0, 2, 0);
                player.velocityChanged = true;
                player.addPotionEffect(new EffectInstance(Effects.JUMP_BOOST, 1200, 6));
                break;
            case 3:
            case 4:
                worldIn.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.SCARY, SoundCategory.PLAYERS, 1.0f, worldIn.rand.nextFloat() * 0.2F + 0.8F);
                player.addPotionEffect(new EffectInstance(Effects.BLINDNESS, 200, 1));
                ItemStack head = new ItemStack(net.minecraft.item.Items.PLAYER_HEAD, 1);
                head.getOrCreateTag().put("SkullOwner", new StringNBT("MHF_Herobrine"));
                Item[] instruments = { Items.ITEM_GAVEL, Items.ITEM_RAW_SAUSAGE, Items.ITEM_STONE_WARHAMMER, Items.ITEM_PROSECUTOR_BADGE };
                int i = worldIn.rand.nextInt(4);
                Entity e1 = new SkeletonEntity(EntityType.SKELETON, worldIn);
                e1.setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(instruments[i]));
                e1.setItemStackToSlot(EquipmentSlotType.HEAD, head);
                e1.setLocationAndAngles(player.posX + (double) worldIn.rand.nextInt(3), player.posY + (double) worldIn.rand.nextInt(5), player.posZ + (double) worldIn.rand.nextInt(3), worldIn.rand.nextFloat() * 360.0F, 0.0F);
                ItemStack playerHead = new ItemStack(net.minecraft.item.Items.PLAYER_HEAD, 1);
                playerHead.getOrCreateTag().put("SkullOwner", new StringNBT(player.getName().getString()));
                Entity e2 = new ZombieEntity(worldIn);
                e2.setItemStackToSlot(EquipmentSlotType.MAINHAND, new ItemStack(Items.ITEM_KNIFE));
                e2.setItemStackToSlot(EquipmentSlotType.OFFHAND, new ItemStack(Items.ITEM_KNIFE));
                e2.setItemStackToSlot(EquipmentSlotType.HEAD, playerHead);
                e2.setLocationAndAngles(player.posX + (double) worldIn.rand.nextInt(3), player.posY + (double) worldIn.rand.nextInt(5), player.posZ + (double) worldIn.rand.nextInt(3), worldIn.rand.nextFloat() * 360.0F, 0.0F);
                worldIn.addEntity(e1);
                worldIn.addEntity(e2);
                break;
        }
    }
    return super.onItemUseFinish(stack, worldIn, player);
}
Also used : Entity(net.minecraft.entity.Entity) LightningBoltEntity(net.minecraft.entity.effect.LightningBoltEntity) LivingEntity(net.minecraft.entity.LivingEntity) ZombieEntity(net.minecraft.entity.monster.ZombieEntity) SkeletonEntity(net.minecraft.entity.monster.SkeletonEntity) ItemEntity(net.minecraft.entity.item.ItemEntity) ZombieEntity(net.minecraft.entity.monster.ZombieEntity) ItemEntity(net.minecraft.entity.item.ItemEntity) LightningBoltEntity(net.minecraft.entity.effect.LightningBoltEntity) StringNBT(net.minecraft.nbt.StringNBT) ServerWorld(net.minecraft.world.server.ServerWorld) Item(net.minecraft.item.Item) EntityConfettiBall(xerca.xercamod.common.entity.EntityConfettiBall) ItemStack(net.minecraft.item.ItemStack) SkeletonEntity(net.minecraft.entity.monster.SkeletonEntity) EffectInstance(net.minecraft.potion.EffectInstance)

Aggregations

LivingEntity (net.minecraft.entity.LivingEntity)2 SkeletonEntity (net.minecraft.entity.monster.SkeletonEntity)2 ZombieEntity (net.minecraft.entity.monster.ZombieEntity)2 Random (java.util.Random)1 Entity (net.minecraft.entity.Entity)1 LightningBoltEntity (net.minecraft.entity.effect.LightningBoltEntity)1 ItemEntity (net.minecraft.entity.item.ItemEntity)1 PiglinEntity (net.minecraft.entity.monster.piglin.PiglinEntity)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 StringNBT (net.minecraft.nbt.StringNBT)1 EffectInstance (net.minecraft.potion.EffectInstance)1 ServerWorld (net.minecraft.world.server.ServerWorld)1 EntityConfettiBall (xerca.xercamod.common.entity.EntityConfettiBall)1