Java Code Examples for net.minecraft.entity.monster.EntityZombie.setPosition()

The following are Jave code examples for showing how to use setPosition() of the net.minecraft.entity.monster.EntityZombie class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Bewitchment   File: FortuneMeetZombie.java   View Source Code Vote up 6 votes
@Override
public boolean apply(EntityPlayer player) {
	for (int i = 0; i < 10; i++) {
		BlockPos pos = new BlockPos(player.posX + player.getRNG().nextGaussian() * 4, player.posY, player.posZ + player.getRNG().nextGaussian() * 4);
		EntityZombie zombie = new EntityZombie(player.world);
		if (player.world.isAirBlock(pos) && player.world.isAirBlock(pos.up()) && player.world.getBlockState(pos.down()).canEntitySpawn(zombie)) {
			zombie.setPosition(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
			zombie.onInitialSpawn(player.world.getDifficultyForLocation(pos), null);
			player.world.spawnEntity(zombie);
			if (player.getRNG().nextBoolean() && player.getRNG().nextBoolean())
				zombie.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 900, 1));
			if (player.getRNG().nextBoolean() && player.getRNG().nextBoolean())
				zombie.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, 900, 1));
			if (player.getRNG().nextBoolean() && player.getRNG().nextBoolean())
				zombie.addPotionEffect(new PotionEffect(MobEffects.SPEED, 900, 1));
			if (player.getRNG().nextBoolean() && player.getRNG().nextBoolean())
				zombie.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 900, 1));
			return true;
		}
	}
	return false;
}
 
Example 2
Project: Halloween   File: EntityZombieHands.java   View Source Code Vote up 6 votes
private EntityZombie unearthMe()
{
	EntityZombie zombie = (this.getZombieType() == ZombieType.NORMAL ? new EntityZombie(this.world) : new EntityHusk(this.world));
	zombie.renderYawOffset = this.renderYawOffset;
	zombie.prevRotationPitch = zombie.rotationPitch = this.rotationPitch;
	zombie.prevRotationYaw = zombie.rotationYaw = this.rotationYaw;
	zombie.setPosition(this.posX, this.posY, this.posZ);
	zombie.setHealth(this.getHealth());
	zombie.setFire((Integer)ReflectionUtils.getFieldValue(entityFire, this));
	zombie.setAttackTarget(this.getAttackTarget());

	this.springEffect();
	this.setDead();

	this.world.spawnEntity(zombie);
	return zombie;
}
 
Example 3
Project: Rival-Rebels-Mod   File: EntityB2Spirit.java   View Source Code Vote up 6 votes
@Override
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
	super.attackEntityFrom(par1DamageSource, par2);
	if (!this.isDead && !this.worldObj.isRemote)
	{
		this.health -= par2;
		if (this.health <= 0)
		{
			this.setDead();
			this.worldObj.createExplosion((Entity) null, this.posX, this.posY, this.posZ, 6.0F, true);
			worldObj.spawnEntityInWorld(new EntityB2Frag(worldObj, this, 0));
			worldObj.spawnEntityInWorld(new EntityB2Frag(worldObj, this, 1));
			EntityZombie pz = new EntityZombie(worldObj);
			pz.setPosition(posX, posY, posZ);
			worldObj.spawnEntityInWorld(pz);
			RivalRebelsSoundPlayer.playSound(this, 0, 0, 30, 1);
		}
	}
	
	return true;
}
 
Example 4
Project: runesofwizardry-classics   File: InscriptionForesight.java   View Source Code Vote up 5 votes
@Override
public void onWornTick(World world, EntityPlayer player, ItemStack stack) {
	int damage = stack.getItemDamage();
	if(damage<DustRegistry.getInscriptionFromStack(stack).getMaxDurability()){
		if(world.getTotalWorldTime()%(2*Refs.TPS)==0&&!player.capabilities.isCreativeMode){
			stack.setItemDamage(damage+1);
		}
	}else{
		return;
	}
	if(world.isRemote){
		int skysub=world.calculateSkylightSubtracted(1.0f);
		int rad = Config.foresightRadius;
		EntityZombie dummy = new EntityZombie(world);
		for(int i=-rad;i<rad;i++){
			for(int j=-rad;j<rad;j++){
				for(int k=-rad;k<rad;k++){
					BlockPos pos = player.getPosition().add(i, j, k);
					dummy.setPosition(pos.getX(),pos.getY(),pos.getZ());
					boolean test2 = dummy.getCanSpawnHere()&&!world.isAirBlock(pos)&&world.isAirBlock(pos.up());
					if(test2&& Math.random() < 0.2){
						int blockLight = world.getLightFor(EnumSkyBlock.BLOCK, pos.up());
						int skyLight = world.getLightFor(EnumSkyBlock.SKY, pos.up())-skysub;
						//RunesofWizardry_Classics.log().info(blockLight+" "+skyLight);
						if(blockLight<8){
							if(skyLight<8){//can spawn now
								world.spawnParticle(EnumParticleTypes.SPELL, false, pos.getX()+0.5, pos.getY()+1, pos.getZ()+0.5, 0d, 0d, 0d);
							}else{//can spawn at night
								world.spawnParticle(EnumParticleTypes.SPELL_MOB, false, pos.getX()+0.5, pos.getY()+1, pos.getZ()+0.5, 0d, 0d, 0d);
							}
						}
					}
				}
			}
		}
	}

}
 
Example 5
Project: Herdcraft   File: HerdCraft.java   View Source Code Vote up 5 votes
private void spawnZombieHordeOn(EntityZombie target, World targetWorld)
{
	int numToSpawn = 0;
	if (ZOMBIE_HORDE_MAX - ZOMBIE_HORDE_MIN + 1 > 0)
	{
		numToSpawn = ZOMBIE_HORDE_MIN + rand.nextInt(ZOMBIE_HORDE_MAX - ZOMBIE_HORDE_MIN + 1);
	}

	for(int i = 0; i < numToSpawn; i++)
	{
		EntityZombie curr = new EntityZombie(targetWorld);
		curr.setPosition(target.posX, target.posY, target.posZ);
		targetWorld.spawnEntityInWorld(curr);
	}
}
 
Example 6
Project: witchery   File: EntityWitchProjectile.java   View Source Code Vote up 4 votes
private void impactLove(MovingObjectPosition mop, boolean enhanced) {
   double RADIUS = enhanced?5.0D:4.0D;
   AxisAlignedBB axisalignedbb = super.boundingBox.expand(RADIUS, 2.0D, RADIUS);
   List list1 = super.worldObj.getEntitiesWithinAABB(EntityLiving.class, axisalignedbb);
   if(list1 != null && !list1.isEmpty() && !super.worldObj.isRemote) {
      EntityLivingBase entityThrower = this.getThrower();
      EntityPlayer thrower = entityThrower != null && entityThrower instanceof EntityPlayer?(EntityPlayer)entityThrower:null;
      Iterator iterator = list1.iterator();
      ArrayList villagers = new ArrayList();
      ArrayList zombies = new ArrayList();

      while(iterator.hasNext()) {
         EntityLiving limit = (EntityLiving)iterator.next();
         double zombie = limit.getDistanceSq(super.posX, super.posY, super.posZ);
         if(zombie < RADIUS * RADIUS) {
            double baby = 1.0D - Math.sqrt(zombie) / RADIUS;
            if(limit == mop.entityHit) {
               baby = 1.0D;
            }

            int j = (int)(baby * 400.0D + 0.5D);
            if(limit instanceof EntityAnimal) {
               EntityAnimal zombie1 = (EntityAnimal)limit;
               if(zombie1.getGrowingAge() >= 0) {
                  zombie1.setGrowingAge(0);
                  zombie1.func_146082_f((EntityPlayer)null);
               }
            } else if(limit instanceof EntityVillager) {
               EntityVillager var26 = (EntityVillager)limit;
               if(var26.getGrowingAge() >= 0) {
                  villagers.add(var26);
               }
            } else if(limit instanceof EntityZombie) {
               EntityZombie var25 = (EntityZombie)limit;
               if(!var25.isChild() && thrower != null) {
                  NBTTagCompound nbt = var25.getEntityData();
                  if(PotionEnslaved.isMobEnslavedBy(var25, thrower)) {
                     zombies.add(var25);
                  }
               }
            }
         }
      }

      int var20 = 10;

      while(villagers.size() > 1 && var20-- > 0) {
         EntityVillager var22 = (EntityVillager)villagers.get(0);
         EntityVillager mate = (EntityVillager)villagers.get(1);
         var22.setPosition(mate.posX, mate.posY, mate.posZ);
         ParticleEffect.HEART.send(SoundEffect.NONE, mate, 1.0D, 2.0D, 8);
         this.giveBirth(var22, mate);
         villagers.remove(0);
         villagers.remove(0);
      }

      var20 = 10;

      while(zombies.size() > 1 && var20-- > 0) {
         EntityZombie var21 = (EntityZombie)zombies.get(0);
         EntityZombie var23 = (EntityZombie)zombies.get(1);
         var21.setPosition(var23.posX, var23.posY, var23.posZ);
         ParticleEffect.HEART.send(SoundEffect.NONE, var23, 1.0D, 2.0D, 8);
         var21.setVillager(true);
         var23.setVillager(true);
         EntityZombie var24 = new EntityZombie(super.worldObj);
         var24.setLocationAndAngles(var23.posX, var23.posY, var23.posZ, 0.0F, 0.0F);
         var24.setChild(true);
         super.worldObj.spawnEntityInWorld(var24);
         zombies.remove(0);
         zombies.remove(0);
      }
   }

}
 
Example 7
Project: pnc-repressurized   File: PneumaticCraftUtils.java   View Source Code Vote up 2 votes
/**
 * A little hack needed here; in 1.8 players were a subclass of EntityLiving and could be used as entities for
 * pathfinding purposes.  But now they extend EntityLivingBase, and pathfinder methods only work for subclasses of
 * EntityLiving.  So create a temporary living entity at the player's location and pathfind from that.
 *
 * @param player the player to mimic
 * @return a dummy player-sized living entity
 */
public static EntityLiving createDummyEntity(EntityPlayer player) {
    EntityZombie zombie = new EntityZombie(player.world);
    zombie.setPosition(player.posX, player.posY, player.posZ);
    return zombie;
}