net.minecraft.entity.monster.EntityPigZombie Java Examples

The following examples show how to use net.minecraft.entity.monster.EntityPigZombie. 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 File: EntityUtils.java    From ForgeHax with MIT License 6 votes vote down vote up
/**
 * Checks if the mob could be possibly hostile towards us (we can't detect their attack target
 * easily) Current entities: PigZombie: Aggressive if arms are raised, when arms are put down a
 * internal timer is slowly ticked down from 400 Wolf: Aggressive if the owner isn't the local
 * player and the wolf is angry Enderman: Aggressive if making screaming sounds
 */
public static boolean isMobAggressive(Entity entity) {
  if (entity instanceof EntityPigZombie) {
    // arms raised = aggressive, angry = either game or we have set the anger cooldown
    if (((EntityPigZombie) entity).isArmsRaised() || ((EntityPigZombie) entity).isAngry()) {
      if (!((EntityPigZombie) entity).isAngry()) {
        // set pigmens anger to 400 if it hasn't been angered already
        FastReflection.Fields.EntityPigZombie_angerLevel.set(entity, 400);
      }
      return true;
    }
  } else if (entity instanceof EntityWolf) {
    return ((EntityWolf) entity).isAngry() && !MC.player.equals(((EntityWolf) entity).getOwner());
  } else if (entity instanceof EntityEnderman) {
    return ((EntityEnderman) entity).isScreaming();
  }
  return false;
}
 
Example #2
Source File: EntityBackupZombie.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void applyEntityAI() {
	this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, EntityPigZombie.class));
	this.targetTasks.addTask(4, new EntityAITargetFiltered<>(this, EntityMob.class, false, new Predicate<Entity>() {
		public boolean apply(@Nullable Entity entity) {
			if (entity == null) return false;
			if (entity.getDataManager().getAll() == null) return false;

			boolean success = false;
			for (EntityDataManager.DataEntry<?> entry : entity.getDataManager().getAll()) {
				if (entry.getKey().equals(OWNER)) {
					success = true;
					break;
				}
			}
			if (!success) return false;

			UUID theirOwner = null;
			Object ownerObj = entity.getDataManager().get(OWNER);
			if (ownerObj != null && ownerObj instanceof Optional && ((Optional<?>) ownerObj).isPresent() && ((Optional<?>) ownerObj).get() instanceof UUID)
				theirOwner = entity.getDataManager().get(OWNER).orNull();

			return !(theirOwner != null && getDataManager().get(OWNER).isPresent() && theirOwner.equals(getDataManager().get(OWNER).get()));
		}
	}));
}
 
Example #3
Source File: MoCreatures.java    From mocreaturesdev with 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 #4
Source File: PigmenAngerCooldownService.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onUpdate(LivingEvent.LivingUpdateEvent event) {
  if (event.getEntityLiving() instanceof EntityPigZombie) {
    // update pigmens anger level
    EntityPigZombie pigZombie = (EntityPigZombie) event.getEntityLiving();
    if (pigZombie.isArmsRaised()) {
      FastReflection.Fields.EntityPigZombie_angerLevel.set(pigZombie, 400);
    } else if (pigZombie.isAngry()) {
      FastReflection.Fields.EntityPigZombie_angerLevel.set(
          pigZombie, FastReflection.Fields.EntityPigZombie_angerLevel.get(pigZombie) - 1);
    }
  }
}
 
Example #5
Source File: CraftPigZombie.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftPigZombie(CraftServer server, EntityPigZombie entity) {
    super(server, entity);
}
 
Example #6
Source File: CraftPigZombie.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityPigZombie getHandle() {
    return (EntityPigZombie) entity;
}
 
Example #7
Source File: KillauraHack.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onUpdate(WUpdateEvent event)
{
	EntityPlayerSP player = event.getPlayer();
	World world = WPlayer.getWorld(player);
	
	if(player.getCooledAttackStrength(0) < 1)
		return;
	
	double rangeSq = Math.pow(range.getValue(), 2);
	Stream<EntityLivingBase> stream = world.loadedEntityList
		.parallelStream().filter(e -> e instanceof EntityLivingBase)
		.map(e -> (EntityLivingBase)e)
		.filter(e -> !e.isDead && e.getHealth() > 0)
		.filter(e -> WEntity.getDistanceSq(player, e) <= rangeSq)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof EntityFakePlayer));
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPlayer));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPlayer
			&& ((EntityPlayer)e).isPlayerSleeping()));
	
	if(filterFlying.getValue() > 0)
		stream = stream.filter(e -> {
			
			if(!(e instanceof EntityPlayer))
				return true;
			
			AxisAlignedBB box = e.getEntityBoundingBox();
			box = box.union(box.offset(0, -filterFlying.getValue(), 0));
			// Using expand() with negative values doesn't work in 1.10.2.
			return world.collidesWithAnyBlock(box);
		});
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof IMob));
	
	if(filterPigmen.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPigZombie));
	
	if(filterEndermen.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityEnderman));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityAnimal
			|| e instanceof EntityAmbientCreature
			|| e instanceof EntityWaterMob));
	
	if(filterBabies.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityAgeable
			&& ((EntityAgeable)e).isChild()));
	
	if(filterPets.isChecked())
		stream = stream
			.filter(e -> !(e instanceof EntityTameable
				&& ((EntityTameable)e).isTamed()))
			.filter(e -> !WEntity.isTamedHorse(e));
	
	if(filterVillagers.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityVillager));
	
	if(filterGolems.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityGolem));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	target = stream.min(priority.getSelected().comparator).orElse(null);
	if(target == null)
		return;
	
	RotationUtils
		.faceVectorPacket(target.getEntityBoundingBox().getCenter());
	mc.playerController.attackEntity(player, target);
	player.swingArm(EnumHand.MAIN_HAND);
}
 
Example #8
Source File: PigZombieMob.java    From ForgeHax with MIT License 4 votes vote down vote up
@Override
public boolean isMobType(Entity entity) {
  return entity instanceof EntityPigZombie;
}
 
Example #9
Source File: PigZombieMob.java    From ForgeHax with MIT License 4 votes vote down vote up
@Override
protected MobTypeEnum getMobTypeUnchecked(Entity entity) {
  EntityPigZombie zombie = (EntityPigZombie) entity;
  return (zombie.isArmsRaised() || zombie.isAngry()) ? MobTypeEnum.HOSTILE : MobTypeEnum.NEUTRAL;
}
 
Example #10
Source File: EntityUtils.java    From ForgeHax with MIT License 4 votes vote down vote up
/**
 * If the mob by default wont attack the player, but will if the player attacks it
 */
public static boolean isNeutralMob(Entity entity) {
  return entity instanceof EntityPigZombie
      || entity instanceof EntityWolf
      || entity instanceof EntityEnderman;
}
 
Example #11
Source File: FMEventHandler.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 4 votes vote down vote up
@SubscribeEvent
public void onSpawn(LivingSpawnEvent event) {
    if (event.entityLiving.worldObj.provider.dimensionId == -1 && event.entityLiving instanceof EntityPigZombie && randy.nextInt(175) == 1)
        event.entityLiving.setCurrentItemOrArmor(0, new ItemStack(ForbiddenItems.deadlyShards, 1, 1));
}