Java Code Examples for net.minecraft.entity.monster.EntityZombie

The following examples show how to use net.minecraft.entity.monster.EntityZombie. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Sakura_mod   Source File: ModelCustomArmor.java    License: MIT License 6 votes vote down vote up
public void setRotationAnglesZombie(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
  super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
  
  boolean flag = ((entityIn instanceof EntityZombie)) && (((EntityZombie)entityIn).isArmsRaised());
  float f = MathHelper.sin(this.swingProgress * 3.1415927F);
  float f1 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F);
  this.bipedRightArm.rotateAngleZ = 0.0F;
  this.bipedLeftArm.rotateAngleZ = 0.0F;
  this.bipedRightArm.rotateAngleY = (-(0.1F - f * 0.6F));
  this.bipedLeftArm.rotateAngleY = (0.1F - f * 0.6F);
  float f2 = -3.1415927F / (flag ? 1.5F : 2.25F);
  this.bipedRightArm.rotateAngleX = f2;
  this.bipedLeftArm.rotateAngleX = f2;
  this.bipedRightArm.rotateAngleX += f * 1.2F - f1 * 0.4F;
  this.bipedLeftArm.rotateAngleX += f * 1.2F - f1 * 0.4F;
  this.bipedRightArm.rotateAngleZ += MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
  this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(ageInTicks * 0.09F) * 0.05F + 0.05F;
  this.bipedRightArm.rotateAngleX += MathHelper.sin(ageInTicks * 0.067F) * 0.05F;
  this.bipedLeftArm.rotateAngleX -= MathHelper.sin(ageInTicks * 0.067F) * 0.05F;
}
 
Example 2
Source Project: ToroQuest   Source File: ModelMage.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected void arms(float ageInTicks, Entity entityIn) {
	boolean armIsRaised = entityIn instanceof EntityZombie && ((EntityZombie) entityIn).isArmsRaised();
	float swingAngle = MathHelper.sin(swingProgress * (float) Math.PI);
	float f1 = MathHelper.sin((1.0F - (1.0F - swingProgress) * (1.0F - swingProgress)) * (float) Math.PI);

	/*
	 * z rotates arm inward and outward
	 * 
	 * y rotates the axis down the arm
	 */

	bipedRightArm.rotateAngleZ = 0.0F;
	bipedLeftArm.rotateAngleZ = 0.0F;
	staff.rotateAngleX = 0F;

	if (isStaffAttacking) {
		bipedRightArm.rotateAngleX += -1.2F;
		bipedLeftArm.rotateAngleX += -1.4F;
		staff.rotateAngleX = 1.1F;
	} else {
		bipedRightArm.rotateAngleX += -1.1F;
	}

}
 
Example 3
Source Project: Cyberware   Source File: CyberwareContent.java    License: MIT License 6 votes vote down vote up
public static void postInit()
{
	
	if (!CyberwareConfig.NO_ZOMBIES)
	{
		List<Biome> biomes = new ArrayList<Biome>();
		
		for (ResourceLocation key : Biome.REGISTRY.getKeys())
		{
			Biome biome = Biome.REGISTRY.getObject(key);
			for (SpawnListEntry entry : biome.getSpawnableList(EnumCreatureType.MONSTER))
			{
				if (entry.entityClass == EntityZombie.class)
				{
					biomes.add(biome);
				}
			}
		}
		EntityRegistry.addSpawn(EntityCyberZombie.class, CyberwareConfig.ZOMBIE_WEIGHT, CyberwareConfig.ZOMBIE_MIN_PACK, CyberwareConfig.ZOMBIE_MAX_PACK, EnumCreatureType.MONSTER, biomes.toArray(new Biome[0]));
	}

}
 
Example 4
Source Project: mocreaturesdev   Source File: MoCreatures.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static void ClearVanillaMobSpawns()
{
    for (int i = 0; i < BiomeGenBase.biomeList.length; i++)
    {
        if (BiomeGenBase.biomeList[i] != null)
        {
            EntityRegistry.removeSpawn(EntityCreeper.class, EnumCreatureType.monster, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntitySkeleton.class, EnumCreatureType.monster, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntityZombie.class, EnumCreatureType.monster, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntitySpider.class, EnumCreatureType.monster, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntityEnderman.class, EnumCreatureType.monster, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntityCaveSpider.class, EnumCreatureType.monster, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntitySlime.class, EnumCreatureType.monster, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntityGhast.class, EnumCreatureType.monster, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntityPigZombie.class, EnumCreatureType.monster, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntityMagmaCube.class, EnumCreatureType.monster, BiomeGenBase.biomeList[i]);
            EntityRegistry.removeSpawn(EntityOcelot.class, EnumCreatureType.monster, BiomeGenBase.biomeList[i]);
        }
    }
}
 
Example 5
@Override
public void setMobClass(MobType type, boolean clear) {
	
	EntityLiving oldMob = (EntityLiving)this.mob;
	EntityLiving newMob = (EntityLiving)MobType.getEntity(this.mob.world, type);

	newMob.copyLocationAndAnglesFrom(oldMob);
	
	this.mob = (Entity)newMob;
	
	if(newMob instanceof EntityZombie){
		((EntityZombie)newMob).setChild(((EntityZombie)oldMob).isChild());
	}
	
	for(EntityEquipmentSlot slot : EntityEquipmentSlot.values()){
		ItemStack toTrade = oldMob.getItemStackFromSlot(slot);
		newMob.setItemStackToSlot(slot, toTrade);
	}
	
	
	oldMob.world.removeEntity(oldMob);
	newMob.world.spawnEntity(newMob);
}
 
Example 6
Source Project: TofuCraftReload   Source File: EntityTofunian.java    License: MIT License 5 votes vote down vote up
public void updateEntityAI() {

        if (!this.isAleadyUpdate) {
            if (canGuard()) {
                this.tasks.addTask(1, new EntityAIAttackMelee(this, 0.65F, true));
                this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this, EntityTofuChinger.class, false));
                this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this, EntityZombie.class, false));
                this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this, AbstractIllager.class, false));
                this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this, EntityVex.class, false));
                this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this, EntityTofuGandlem.class, false));

                if (!this.isChild()) {
                    this.tasks.addTask(6, new EntityAIUseItemOnLeftHand<>(this, new ItemStack(ItemLoader.bugle), TofuSounds.TOFUBUGLE, (p_213736_1_) -> {
                        return WorldUtils.isMorning(this.world) && this.world.rand.nextInt(350) == 0;
                    }));
                }
            } else {
                this.tasks.addTask(1, new EntityAITofunianAvoidEntity<>(this, EntityTofuChinger.class, 8.0F, 0.6D, 0.6D));
                this.tasks.addTask(1, new EntityAITofunianAvoidEntity<>(this, EntityZombie.class, 8.0F, 0.6D, 0.6D));
                this.tasks.addTask(1, new EntityAITofunianAvoidEntity<>(this, AbstractIllager.class, 8.0F, 0.8D, 0.8D));
                this.tasks.addTask(1, new EntityAITofunianAvoidEntity<>(this, EntityVex.class, 8.0F, 0.6D, 0.6D));
                this.tasks.addTask(1, new EntityAITofunianAvoidEntity<>(this, EntityTofuGandlem.class, 8.0F, 0.8D, 0.8D));

                this.tasks.addTask(2, new EntityAIPanic(this, 0.75F));
            }


            if (canFarm() && !this.isChild()) {
                this.tasks.addTask(8, new EntityAIHarvestTofuFarmland(this, 0.6D));
            }

            if ((canFarm() || canFish()) && !this.isChild()) {
                this.tasks.addTask(8, new EntityAIMakingFood(this, 0.6D));
            }
            this.isAleadyUpdate = true;
        }
    }
 
Example 7
@SubscribeEvent
public static void onSpecialSpawn (SpecialSpawn event) {
	
	EntityLivingBase entity = event.getEntityLiving();
	if (Math.random() < (spawnChance * event.getWorld().getDifficulty().getId()) && (entity instanceof EntityZombie || entity instanceof EntitySkeleton)) {
		
		entity.setItemStackToSlot(EntityEquipmentSlot.LEGS, new ItemStack(tightPants));
	}
}
 
Example 8
@SuppressWarnings("deprecation")
@Override
public void onInit(FMLInitializationEvent event) {
	FMLLog.log.info("Chickenification is beginning...");
	//RenderingRegistry.registerEntityRenderingHandler(EntitySheep.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntityCow.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntityPig.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntitySquid.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntityZombie.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntitySpider.class, new RenderStupidChicken());
	RenderingRegistry.registerEntityRenderingHandler(EntitySkeleton.class, new RenderStupidChicken());
	FMLLog.log.info("Chickenificated all the bois!");
}
 
Example 9
@SubscribeEvent
public static void onEntitySpawn(LivingSpawnEvent.SpecialSpawn event) {
    EntityLivingBase entity = event.getEntityLiving();
    EnumDifficulty difficulty = entity.world.getDifficulty();
    if (difficulty == EnumDifficulty.HARD && entity.getRNG().nextFloat() <= 0.03f) {
        if (entity instanceof EntityZombie) {
            ItemStack itemStack = MetaItems.NANO_SABER.getInfiniteChargedStack();
            ToggleEnergyConsumerBehavior.setItemActive(itemStack, true);
            entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, itemStack);
            ((EntityZombie) entity).setDropChance(EntityEquipmentSlot.MAINHAND, 0.0f);
        }
    }
}
 
Example 10
/**
 * Returns whether the EntityAIBase should begin execution.
 */
@SuppressWarnings("unchecked")
public boolean shouldExecute() {
	if (this.targetChance > 0 && this.taskOwner.getRNG().nextInt(this.targetChance) != 0) {
		return false;
	} else if (this.targetClass != EntityPlayer.class && this.targetClass != EntityPlayerMP.class) {
		List<T> list = this.taskOwner.world.getEntitiesWithinAABB(this.targetClass, this.getTargetableArea(this.getTargetDistance()), this.targetEntitySelector);

		if (list.isEmpty()) {
			return false;
		} else {
			list.sort(this.sorter);
			this.targetEntity = list.get(0);
			return true;
		}
	} else {
		this.targetEntity = (T) this.taskOwner.world.getNearestAttackablePlayer(this.taskOwner.posX, this.taskOwner.posY + (double) this.taskOwner.getEyeHeight(), this.taskOwner.posZ, this.getTargetDistance(), this.getTargetDistance(), new Function<EntityPlayer, Double>() {
			@Nullable
			public Double apply(@Nullable EntityPlayer p_apply_1_) {
				ItemStack itemstack = p_apply_1_.getItemStackFromSlot(EntityEquipmentSlot.HEAD);

				if (itemstack.getItem() == Items.SKULL) {
					int i = itemstack.getItemDamage();
					boolean flag = EntityAINearestAttackableTargetFiltered.this.taskOwner instanceof EntitySkeleton && i == 0;
					boolean flag1 = EntityAINearestAttackableTargetFiltered.this.taskOwner instanceof EntityZombie && i == 2;
					boolean flag2 = EntityAINearestAttackableTargetFiltered.this.taskOwner instanceof EntityCreeper && i == 4;

					if (flag || flag1 || flag2) {
						return Double.valueOf(0.5D);
					}
				}

				return Double.valueOf(1.0D);
			}
		}, (Predicate<EntityPlayer>) this.targetEntitySelector);
		return this.targetEntity != null;
	}
}
 
Example 11
Source Project: Cyberware   Source File: RenderCyberZombie.java    License: MIT License 5 votes vote down vote up
public RenderCyberZombie(RenderManager renderManagerIn)
{
	super(renderManagerIn);
       List<LayerRenderer<EntityZombie>> defaultLayers = ReflectionHelper.getPrivateValue(RenderZombie.class, this, 10);
       defaultLayers.add(new LayerZombieHighlight(this));
       ReflectionHelper.setPrivateValue(RenderZombie.class, this, defaultLayers, 10);
}
 
Example 12
Source Project: Cyberware   Source File: RenderCyberZombie.java    License: MIT License 5 votes vote down vote up
@Override
protected ResourceLocation getEntityTexture(EntityZombie entity)
{
	EntityCyberZombie cz = (EntityCyberZombie) entity;
	if (cz.isBrute())
	{
		return ZOMBIE_BRUTE;
	}
	return ZOMBIE;
}
 
Example 13
Source Project: Cyberware   Source File: RenderCyberZombie.java    License: MIT License 5 votes vote down vote up
@Override
protected void preRenderCallback(EntityZombie zombie, float partialTickTime)
   {
	EntityCyberZombie cz = (EntityCyberZombie) zombie;
       if (cz.height == (1.95F * 1.2F))
       {
           GlStateManager.scale(1.2F, 1.2F, 1.2F);
       }
   }
 
Example 14
Source Project: Gadomancy   Source File: AuraEffects.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void doBlockEffect(ChunkCoordinates originTile, ChunkCoordinates selectedBlock, World world) {
    EntityLiving mob = world.rand.nextBoolean() ? new EntitySkeleton(world) : new EntityZombie(world);
    if(setAndCheckPosition(mob, selectedBlock, world, true) && world.difficultySetting != EnumDifficulty.PEACEFUL) {
        for(int i = 0; i < 5; i++) {
            mob.setCurrentItemOrArmor(i, null);
        }

        int timeout = 40;
        int totalCount = (world.rand.nextInt(3) == 0 ? 1 : 0) + 2;
        do {
            int slot = mob.getEquipmentInSlot(0) == null ? 0 : (mob.getEquipmentInSlot(4) == null ? 4 : (world.rand.nextInt(3)+1));
            if(mob.getEquipmentInSlot(slot) == null) {
                ItemStack[] items = ITEMS_SOUL[slot];
                ItemStack stack = items[world.rand.nextInt(items.length)];
                if(stack.getItem() != Items.bow || mob instanceof EntitySkeleton) {
                    totalCount--;
                    mob.setCurrentItemOrArmor(slot, stack);
                    mob.setEquipmentDropChance(slot, 0);
                }
            }
            timeout--;
        } while (totalCount > 0 && timeout > 0);

        if(timeout > 0) {
            mob.addPotionEffect(new PotionEffect(Potion.invisibility.getId(), MiscUtils.ticksForMinutes(60*24*365), 1, true));

            ChunkCoordinates pos = new ChunkCoordinates((int) mob.posX, (int) mob.posY, (int) mob.posZ);
            pos = iterateDown(pos, world);
            mob.setPosition(pos.posX + 0.5, pos.posY, pos.posZ + 0.5);
            world.spawnEntityInWorld(mob);
        }
    }
}
 
Example 15
Source Project: Et-Futurum   Source File: ServerEventHandler.java    License: The Unlicense 5 votes vote down vote up
@SubscribeEvent
public void livingUpdate(LivingUpdateEvent event) {
	ModEnchantments.onLivingUpdate(event.entityLiving);

	if (EtFuturum.enableVillagerZombies)
		if (!event.entityLiving.worldObj.isRemote && event.entityLiving.getClass() == EntityZombie.class) {
			EntityZombie zombie = (EntityZombie) event.entityLiving;
			if (zombie.isVillager()) {
				EntityZombieVillager villagerZombie = new EntityZombieVillager(zombie.worldObj);
				villagerZombie.copyLocationAndAnglesFrom(zombie);
				villagerZombie.onSpawnWithEgg(null);
				villagerZombie.worldObj.spawnEntityInWorld(villagerZombie);

				zombie.setDead();
			}
		}

	if (EtFuturum.enableShearableGolems)
		if (!event.entityLiving.worldObj.isRemote && event.entityLiving.getClass() == EntitySnowman.class) {
			EntityNewSnowGolem golen = new EntityNewSnowGolem(event.entityLiving.worldObj);
			golen.copyLocationAndAnglesFrom(event.entityLiving);
			golen.onSpawnWithEgg(null);
			golen.worldObj.spawnEntityInWorld(golen);

			event.entityLiving.setDead();
		}
}
 
Example 16
Source Project: Et-Futurum   Source File: ServerEventHandler.java    License: The Unlicense 5 votes vote down vote up
private int getHeadMetadata(EntityLivingBase entity) {
	if (entity.getClass() == EntityZombie.class)
		return 2;
	else if (entity.getClass() == EntitySkeleton.class && ((EntitySkeleton) entity).getSkeletonType() == 0)
		return 0;
	else if (entity.getClass() == EntityCreeper.class)
		return 4;

	return -1;
}
 
Example 17
@Override
public Object getMeta(EntityZombie target, Vec3 relativePos) {
	Map<String, Object> map = Maps.newHashMap();

	map.put("isVillagerZombie", target.isVillager());
	map.put("convertingToVillager", target.isConverting());

	return map;
}
 
Example 18
@SubscribeEvent
public void onSpawn(CheckSpawn event) {
	if (event.getResult() == Event.Result.ALLOW) {
		return;
	}
	if (event.getEntityLiving().isCreatureType(EnumCreatureType.MONSTER, false)) {
		Entity entity = event.getEntity();
		BlockPos spawn = entity.getEntityWorld().getSpawnPoint();
		// This is the code for the safe spawn zone
		if (GTConfig.general.preventMobSpawnsCloseToSpawn
				&& entity.getEntityWorld().provider.getDimensionType().equals(DimensionType.OVERWORLD)
				&& entity.getPosition().distanceSq(spawn.getX(), spawn.getY(), spawn.getZ()) <= 128 * 128) {
			event.setResult(Event.Result.DENY);
		}
		// this is code for zombies spawning with pickaxes
		if (GTConfig.general.caveZombiesSpawnWithPickaxe && entity instanceof EntityZombie && event.getY() <= 50.0F
				&& event.getWorld().rand.nextInt(2) == 0) {
			EntityZombie zombie = (EntityZombie) entity;
			ItemStack tool = getRandomPickaxe(event.getWorld().rand);
			int damage = event.getWorld().rand.nextInt(tool.getMaxDamage() + 1);
			tool.damageItem(GTHelperMath.clip(damage, 1, tool.getMaxDamage() - 1), zombie);
			zombie.setHeldItem(EnumHand.MAIN_HAND, tool);
		}
		// This is the code for the mob repellator
		for (int[] rep : mobReps) {
			World world = event.getEntity().getEntityWorld();
			if (rep[3] == world.provider.getDimension()) {
				TileEntity tile = world.getTileEntity(new BlockPos(rep[0], rep[1], rep[2]));
				if (tile instanceof GTTileMobRepeller) {
					int r = ((GTTileMobRepeller) tile).range;
					double dx = rep[0] + 0.5F - event.getEntity().posX;
					double dy = rep[1] + 0.5F - event.getEntity().posY;
					double dz = rep[2] + 0.5F - event.getEntity().posZ;
					if ((dx * dx + dz * dz + dy * dy) <= Math.pow(r, 2)) {
						event.setResult(Event.Result.DENY);
					}
				}
			}
		}
	}
}
 
Example 19
Source Project: Kettle   Source File: CraftZombie.java    License: GNU General Public License v3.0 4 votes vote down vote up
public CraftZombie(CraftServer server, EntityZombie entity) {
    super(server, entity);
}
 
Example 20
Source Project: Kettle   Source File: CraftZombie.java    License: GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityZombie getHandle() {
    return (EntityZombie) entity;
}
 
Example 21
public void onLivingUpdate()
{

    super.onLivingUpdate();

    if (isOnAir() && isFlyer() && rand.nextInt(5) == 0)
    {
        wingFlapCounter = 1;
    }
    
    if (rand.nextInt(200)==0)
    {
        moveTail();
    }
    
    if (!isOnAir() && (this.riddenByEntity == null) && rand.nextInt(250)==0)
    {
        stand();
    }
    
    if ((getType() == 38) && (rand.nextInt(50) == 0) && !MoCreatures.isServer())
    {
        LavaFX();
    }
    
    if ((getType() == 23) && (rand.nextInt(50) == 0) && !MoCreatures.isServer())
    {
        UndeadFX();
    }
    
    
    
    if (MoCreatures.isServer())
        
    {
        if (isFlyer() && rand.nextInt(500) == 0)
        {
            wingFlap();
        }
        
        if (this.worldObj.isDaytime())
        {
            float var1 = this.getBrightness(1.0F);

            if (var1 > 0.5F && this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)) && this.rand.nextFloat() * 30.0F < (var1 - 0.4F) * 2.0F)
            {
                this.setFire(8);
            }
        }
        
        if (!isOnAir() && (this.riddenByEntity == null) && rand.nextInt(300)==0)
        {
            setEating();
        }
        

        
        
        
        
        
        
        if (this.riddenByEntity == null)
        {
        List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(4D, 3D, 4D));
        for(int i = 0; i < list.size(); i++)
        {
            Entity entity = (Entity) list.get(i);
            if(!(entity instanceof EntityMob))
            {
                continue;
            }
            EntityMob entitymob = (EntityMob) entity;
            if(entitymob.ridingEntity == null && (entitymob instanceof EntitySkeleton || entitymob instanceof EntityZombie))
            {
                entitymob.mountEntity(this);
                break;
            }
        }
        }
    }

}
 
Example 22
@Override
public void setChild(boolean child) {
	if(!(this.mob instanceof EntityZombie)) return;
	
	((EntityZombie)this.mob).setChild(child);
}