Search in sources :

Example 1 with EntityHorse

use of net.minecraft.entity.passive.EntityHorse in project ArsMagica2 by Mithion.

the class AMEventHandler method onLivingDrops.

@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event) {
    if (EntityUtilities.isSummon(event.entityLiving) && !(event.entityLiving instanceof EntityHorse)) {
        event.setCanceled(true);
    }
    if (event.source == DamageSources.darkNexus) {
        event.setCanceled(true);
    }
    if (!event.entityLiving.worldObj.isRemote && event.entityLiving instanceof EntityPig && event.entityLiving.getRNG().nextDouble() < 0.3f) {
        EntityItem animalFat = new EntityItem(event.entityLiving.worldObj);
        ItemStack stack = new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_ANIMALFAT);
        animalFat.setPosition(event.entity.posX, event.entity.posY, event.entity.posZ);
        animalFat.setEntityItemStack(stack);
        event.drops.add(animalFat);
    }
}
Also used : EntityHorse(net.minecraft.entity.passive.EntityHorse) EntityPig(net.minecraft.entity.passive.EntityPig) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 2 with EntityHorse

use of net.minecraft.entity.passive.EntityHorse in project ArsMagica2 by Mithion.

the class Summon method summonCreature.

public EntityLiving summonCreature(ItemStack stack, EntityLivingBase caster, EntityLivingBase target, World world, double x, double y, double z) {
    Class clazz = getSummonType(stack);
    EntityLiving entity = null;
    try {
        entity = (EntityLiving) clazz.getConstructor(World.class).newInstance(world);
    } catch (Throwable t) {
        t.printStackTrace();
        return null;
    }
    if (entity == null) {
        return null;
    }
    if (entity instanceof EntitySkeleton) {
        ((EntitySkeleton) entity).setSkeletonType(0);
        ((EntitySkeleton) entity).setCurrentItemOrArmor(0, new ItemStack(Items.bow));
    } else if (entity instanceof EntityHorse && caster instanceof EntityPlayer) {
        ((EntityHorse) entity).setTamedBy(((EntityPlayer) caster));
    }
    entity.setPosition(x, y, z);
    world.spawnEntityInWorld(entity);
    if (caster instanceof EntityPlayer) {
        EntityUtilities.makeSummon_PlayerFaction((EntityCreature) entity, (EntityPlayer) caster, false);
    } else {
        EntityUtilities.makeSummon_MonsterFaction((EntityCreature) entity, false);
    }
    EntityUtilities.setOwner(entity, caster);
    int duration = SpellUtils.instance.getModifiedInt_Mul(4800, stack, caster, target, world, 0, SpellModifiers.DURATION);
    EntityUtilities.setSummonDuration(entity, duration);
    SpellHelper.instance.applyStageToEntity(stack, caster, world, entity, 0, false);
    return entity;
}
Also used : EntityHorse(net.minecraft.entity.passive.EntityHorse) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) EntityPlayer(net.minecraft.entity.player.EntityPlayer) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Example 3 with EntityHorse

use of net.minecraft.entity.passive.EntityHorse in project Railcraft by Railcraft.

the class EntityAIHalloweenKnights method updateTask.

/**
     * Updates the task
     */
@Override
public void updateTask() {
    executed = true;
    DifficultyInstance difficultyinstance = horse.worldObj.getDifficultyForLocation(new BlockPos(horse));
    horse.setType(HorseType.SKELETON);
    horse.setHorseTamed(true);
    horse.setGrowingAge(0);
    horse.worldObj.addWeatherEffect(new EntityLightningBolt(horse.worldObj, horse.posX, horse.posY, horse.posZ, true));
    EntitySkeleton entityskeleton = createSkeleton(difficultyinstance, horse);
    entityskeleton.startRiding(horse);
    for (int i = 0; i < 3; ++i) {
        EntityHorse entityhorse = createHorse(difficultyinstance);
        EntitySkeleton skeleton = createSkeleton(difficultyinstance, entityhorse);
        skeleton.startRiding(entityhorse);
        entityhorse.addVelocity(horse.getRNG().nextGaussian() * 0.5D, 0.0D, horse.getRNG().nextGaussian() * 0.5D);
    }
}
Also used : EntityHorse(net.minecraft.entity.passive.EntityHorse) DifficultyInstance(net.minecraft.world.DifficultyInstance) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) BlockPos(net.minecraft.util.math.BlockPos) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt)

Example 4 with EntityHorse

use of net.minecraft.entity.passive.EntityHorse in project MinecraftForge by MinecraftForge.

the class BiomeSpawnableListTest method testAddAndRemoveSpawn.

@Test
public void testAddAndRemoveSpawn() throws Exception {
    final Class<EntityHorse> entityClass = EntityHorse.class;
    final int weightedProb = 1;
    final int minGroupCount = 1;
    final int maxGroupCount = 20;
    final Biome biome = Biomes.PLAINS;
    // Test 1: We can add a spawn for the non-vanilla EnumCreatureType
    EntityRegistry.addSpawn(entityClass, weightedProb, minGroupCount, maxGroupCount, creatureTypeHorse, biome);
    final boolean containsEntryAfterAdd = spawnableListContainsEntry(entityClass, weightedProb, minGroupCount, maxGroupCount, creatureTypeHorse, biome);
    assertTrue("The SpawnListEntry wasn't added", containsEntryAfterAdd);
    // Test 2: We can remove a spawn for the non-vanilla EnumCreatureType
    EntityRegistry.removeSpawn(entityClass, creatureTypeHorse, biome);
    final boolean containsEntryAfterRemove = spawnableListContainsEntry(entityClass, weightedProb, minGroupCount, maxGroupCount, creatureTypeHorse, biome);
    assertFalse("The SpawnListEntry wasn't removed", containsEntryAfterRemove);
}
Also used : EntityHorse(net.minecraft.entity.passive.EntityHorse) Biome(net.minecraft.world.biome.Biome) Test(org.junit.Test)

Example 5 with EntityHorse

use of net.minecraft.entity.passive.EntityHorse in project Pearcel-Mod by MiningMark48.

the class BlockSummoner method onBlockActivated.

public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
    Random rand = new Random();
    int spawnRand = rand.nextInt(5) + 1;
    int negRand = rand.nextInt(2) + 1;
    int x = pos.getX();
    int y = pos.getY();
    int z = pos.getZ();
    if (negRand == 1) {
        spawnRand = -spawnRand;
    }
    EntitySheep sheep = new EntitySheep(world);
    sheep.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityEnderman enderman = new EntityEnderman(world);
    enderman.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityBlaze blaze = new EntityBlaze(world);
    blaze.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityGhast ghast = new EntityGhast(world);
    ghast.setPosition(x + spawnRand, y + 5, z + spawnRand);
    EntitySkeleton skeleton = new EntitySkeleton(world);
    skeleton.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityCreeper creeper = new EntityCreeper(world);
    creeper.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityEnderCrystal endcrystal = new EntityEnderCrystal(world);
    endcrystal.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityHorse horse = new EntityHorse(world);
    horse.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityIronGolem iron_golem = new EntityIronGolem(world);
    iron_golem.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityVillager villager = new EntityVillager(world);
    villager.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityDragon dragon = new EntityDragon(world);
    dragon.setPosition(x + spawnRand, y + 2, z + spawnRand);
    EntityWither wither = new EntityWither(world);
    wither.setPosition(x + spawnRand, y + 2, z + spawnRand);
    if (player.getHeldItem(EnumHand.MAIN_HAND) != null) {
        if (!player.isSneaking() && player.getHeldItem(EnumHand.MAIN_HAND).getItem() == ModItems.sap) {
            if (!world.isRemote) {
                //Missing Block
                if (world.getBlockState(pos.up()).getBlock() == Blocks.AIR) {
                    player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.missingBlock")));
                    if (world.isRemote) {
                        world.spawnEntity(new EntityLightningBolt(world, player.posX, player.posY, player.posZ, true));
                    }
                } else //Dragon
                if (isCorrectSetup(pos, world, Blocks.DRAGON_EGG, Blocks.DIAMOND_BLOCK)) {
                    if (player.dimension == 1) {
                        setTainted(pos, world);
                        world.spawnEntity(dragon);
                        player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.dragon") + " " + Translate.toLocal("summoner.summoned")));
                    } else {
                        player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.wrongDimension")));
                    }
                } else //Wither
                if (isCorrectSetup(pos, world, Blocks.SKULL, Blocks.DIAMOND_BLOCK)) {
                    setTainted(pos, world);
                    world.spawnEntity(wither);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.wither") + " " + Translate.toLocal("summoner.summoned")));
                } else //Sheep
                if (isCorrectSetup(pos, world, Blocks.WOOL, Blocks.WOOL)) {
                    setTainted(pos, world);
                    world.spawnEntity(sheep);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.sheep") + " " + Translate.toLocal("summoner.summoned")));
                } else //Enderman
                if (isCorrectSetup(pos, world, Blocks.END_STONE, Blocks.END_STONE)) {
                    setTainted(pos, world);
                    world.spawnEntity(enderman);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.enderman") + " " + Translate.toLocal("summoner.summoned")));
                } else //Blaze
                if (isCorrectSetup(pos, world, Blocks.GRAVEL, Blocks.NETHERRACK)) {
                    setTainted(pos, world);
                    world.spawnEntity(blaze);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.blaze") + " " + Translate.toLocal("summoner.summoned")));
                } else //Ghast
                if (isCorrectSetup(pos, world, Blocks.COBBLESTONE, Blocks.SOUL_SAND)) {
                    setTainted(pos, world);
                    world.spawnEntity(ghast);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.ghast") + " " + Translate.toLocal("summoner.summoned")));
                } else //Skeleton
                if (isCorrectSetup(pos, world, Blocks.PLANKS, Blocks.SAND)) {
                    setTainted(pos, world);
                    world.spawnEntity(skeleton);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.skeleton") + " " + Translate.toLocal("summoner.summoned")));
                } else //Creeper
                if (isCorrectSetup(pos, world, Blocks.TNT, Blocks.TNT)) {
                    setTainted(pos, world);
                    world.spawnEntity(creeper);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.creeper") + " " + Translate.toLocal("summoner.summoned")));
                } else //Horse
                if (isCorrectSetup(pos, world, Blocks.HAY_BLOCK, Blocks.HAY_BLOCK)) {
                    setTainted(pos, world);
                    world.spawnEntity(horse);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.horse") + " " + Translate.toLocal("summoner.summoned")));
                } else //Iron Golem
                if (isCorrectSetup(pos, world, Blocks.IRON_BLOCK, Blocks.IRON_BLOCK)) {
                    setTainted(pos, world);
                    world.spawnEntity(iron_golem);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.iron_golem") + " " + Translate.toLocal("summoner.summoned")));
                } else //Villager
                if (isCorrectSetup(pos, world, Blocks.EMERALD_BLOCK, Blocks.SKULL)) {
                    setTainted(pos, world);
                    world.spawnEntity(villager);
                    player.sendMessage(new TextComponentString(TextFormatting.GOLD + Translate.toLocal("summoner.mob_summon.villager") + " " + Translate.toLocal("summoner.summoned")));
                } else {
                    if (!world.isRemote) {
                        setTainted(pos, world);
                        player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.incorrectBlock")));
                    }
                    if (world.isRemote) {
                        world.spawnEntity(new EntityLightningBolt(world, player.posX, player.posY, player.posZ, true));
                    }
                }
            }
            player.playSound(ModSoundEvents.BLOCK_SUMMONER_LAUGH, 5.0F, 1.0F);
            world.spawnParticle(EnumParticleTypes.EXPLOSION_HUGE, x, y, z, 1.0D, 0.0D, 0.0D);
            if (!player.isCreative()) {
                player.getHeldItem(EnumHand.MAIN_HAND).damageItem(1, player);
                player.attackEntityFrom(DamageSource.outOfWorld, 10.0F);
            }
        } else {
            if (!world.isRemote) {
                player.sendMessage(new TextComponentString(TextFormatting.DARK_RED + Translate.toLocal("summoner.error.incorrectItem")));
            }
        }
    }
    return true;
}
Also used : EntityDragon(net.minecraft.entity.boss.EntityDragon) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) EntityLightningBolt(net.minecraft.entity.effect.EntityLightningBolt) TextComponentString(net.minecraft.util.text.TextComponentString) EntityHorse(net.minecraft.entity.passive.EntityHorse) Random(java.util.Random) EntityVillager(net.minecraft.entity.passive.EntityVillager) EntitySheep(net.minecraft.entity.passive.EntitySheep) EntityWither(net.minecraft.entity.boss.EntityWither)

Aggregations

EntityHorse (net.minecraft.entity.passive.EntityHorse)6 EntityLightningBolt (net.minecraft.entity.effect.EntityLightningBolt)2 EntitySkeleton (net.minecraft.entity.monster.EntitySkeleton)2 ItemStack (net.minecraft.item.ItemStack)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 Random (java.util.Random)1 EntityDragon (net.minecraft.entity.boss.EntityDragon)1 EntityWither (net.minecraft.entity.boss.EntityWither)1 EntityEnderCrystal (net.minecraft.entity.item.EntityEnderCrystal)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPig (net.minecraft.entity.passive.EntityPig)1 EntitySheep (net.minecraft.entity.passive.EntitySheep)1 EntityVillager (net.minecraft.entity.passive.EntityVillager)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 BlockPos (net.minecraft.util.math.BlockPos)1 TextComponentString (net.minecraft.util.text.TextComponentString)1 DifficultyInstance (net.minecraft.world.DifficultyInstance)1 World (net.minecraft.world.World)1 Biome (net.minecraft.world.biome.Biome)1 Test (org.junit.Test)1