net.minecraft.entity.passive.EntityVillager Java Examples

The following examples show how to use net.minecraft.entity.passive.EntityVillager. 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: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
public void spawnEvent(EntityJoinWorldEvent event) {
	if (event.entity instanceof EntityPig) {
		EntityPig pig = (EntityPig) event.entity;
		if (EtFuturum.enableBeetroot)
			pig.tasks.addTask(4, new EntityAITempt(pig, 1.2, ModItems.beetroot, false));
	} else if (event.entity instanceof EntityChicken) {
		EntityChicken chicken = (EntityChicken) event.entity;
		if (EtFuturum.enableBeetroot)
			chicken.tasks.addTask(3, new EntityAITempt(chicken, 1.0D, ModItems.beetroot_seeds, false));
	} else if (event.entity instanceof EntityWolf) {
		EntityWolf wolf = (EntityWolf) event.entity;
		if (EtFuturum.enableRabbit)
			wolf.targetTasks.addTask(4, new EntityAITargetNonTamed(wolf, EntityRabbit.class, 200, false));
	} else if (event.entity instanceof EntityVillager) {
		EntityVillager villager = (EntityVillager) event.entity;
		for (Object obj : villager.tasks.taskEntries) {
			EntityAITaskEntry entry = (EntityAITaskEntry) obj;
			if (entry.action instanceof EntityAIOpenDoor) {
				villager.tasks.removeTask(entry.action);
				villager.tasks.addTask(entry.priority, new EntityAIOpenCustomDoor(villager, true));
				break;
			}
		}
	}
}
 
Example #2
Source File: EntityZombieVillager.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@Override
protected void convertToVillager() {
	EntityVillager villager = new EntityVillager(worldObj);
	villager.copyLocationAndAnglesFrom(this);
	villager.onSpawnWithEgg((IEntityLivingData) null);
	villager.setLookingForHome();
	villager.setProfession(getType());

	if (isChild())
		villager.setGrowingAge(-24000);

	worldObj.removeEntity(this);
	worldObj.spawnEntityInWorld(villager);
	villager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0));
	worldObj.playAuxSFXAtEntity(null, 1017, (int) posX, (int) posY, (int) posZ, 0);
}
 
Example #3
Source File: RenderShopkeeper.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Allows the render to do state modifications necessary before the model is
 * rendered.
 */
protected void preRenderCallback(EntityVillager entitylivingbaseIn, float partialTickTime) {
	float f = 0.9375F;

	if (entitylivingbaseIn.getGrowingAge() < 0) {
		f = (float) ((double) f * 0.5D);
		this.shadowSize = 0.25F;
	} else {
		this.shadowSize = 0.5F;
	}

	GlStateManager.scale(f, f, f);
}
 
Example #4
Source File: VillagerHereticManager.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 5 votes vote down vote up
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random random) {
    if(villager.getProfession() == Config.hereticID) {
        /*recipeList.add(new MerchantRecipe(new ItemStack(ConfigItems.itemResource, 20 + random.nextInt(3), 18), new ItemStack(Items.emerald)));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald), new ItemStack(ConfigItems.itemResource, 1, 9)));
        recipeList.add(new MerchantRecipe(new ItemStack(ConfigItems.itemResource, 4 + random.nextInt(3), 3), new ItemStack(Items.emerald)));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald), new ItemStack(ConfigItems.itemResource, 1, 0)));
        recipeList.add(new MerchantRecipe(new ItemStack(ConfigItems.itemResource, 4 + random.nextInt(3), 6), new ItemStack(Items.emerald)));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald), new ItemStack(ConfigItems.itemResource, 1, 1)));
        recipeList.add(new MerchantRecipe(new ItemStack(ConfigItems.itemNuggetChicken, 24 + random.nextInt(8), 0), new ItemStack(Items.emerald)));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.book, 4 + random.nextInt(3), 0), new ItemStack(ConfigItems.itemResource, 1, 9)));
        recipeList.add(new MerchantRecipe(new ItemStack(ConfigItems.itemNuggetBeef, 24 + random.nextInt(8), 0), new ItemStack(Items.emerald)));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald), new ItemStack(ConfigItems.itemShard, 2 + random.nextInt(2), random.nextInt(6))));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald), new ItemStack(ConfigItems.itemManaBean, 1 + random.nextInt(2), 0)));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 5 + random.nextInt(3)), new ItemStack(ConfigItems.itemBathSalts, 1, 0)));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 5 + random.nextInt(3)), new ItemStack(ConfigItems.itemRingRunic, 1, 0)));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 5 + random.nextInt(3)), new ItemStack(ConfigItems.itemAmuletVis, 1, 0)));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 5 + random.nextInt(3)), new ItemStack(ConfigItems.itemBaubleBlanks, 1, 3 + random.nextInt(6))));
        */
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 1 + random.nextInt(2)), new ItemStack(ForbiddenItems.deadlyShards, 3 + random.nextInt(2), 6)));
        if(!Config.noLust)
            recipeList.add(new MerchantRecipe(new ItemStack(ForbiddenItems.deadlyShards, 2 + random.nextInt(4), 4), new ItemStack(Items.emerald)));
        recipeList.add(new MerchantRecipe(new ItemStack(ForbiddenItems.deadlyShards, 4 + random.nextInt(6), 0), new ItemStack(Items.emerald)));
        recipeList.add(new MerchantRecipe(new ItemStack(ForbiddenItems.gluttonyShard, 4 + random.nextInt(6), 0), new ItemStack(Items.emerald)));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 1 + random.nextInt(3)), new ItemStack(Items.skull, 1, 0)));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 4 + random.nextInt(4)), new ItemStack(Items.ghast_tear, 1)));
        recipeList.add(new MerchantRecipe(new ItemStack(Items.emerald, 1), new ItemStack(Items.glowstone_dust, 8 + random.nextInt(9))));

        ItemStack wand = new ItemStack(ConfigItems.itemWandCasting, 1, 36);
        ((ItemWandCasting) wand.getItem()).setCap(wand, (WandCap) WandCap.caps.get("iron"));
        ((ItemWandCasting) wand.getItem()).setRod(wand, (WandRod) WandRod.rods.get("profane"));
        ((ItemWandCasting) wand.getItem()).storeAllVis(wand, new AspectList().add(Aspect.FIRE, 5000).add(Aspect.WATER, 5000).add(Aspect.EARTH, 5000).add(Aspect.AIR, 5000).add(Aspect.ORDER, 5000).add(Aspect.ENTROPY, 5000));
        MerchantRecipe profane = new MerchantRecipe(new ItemStack(Items.emerald, 8 + random.nextInt(5)), new ItemStack(Items.stick), wand);
        profane.func_82783_a(-6);
        recipeList.add(profane);
        MerchantRecipe fire = new MerchantRecipe(new ItemStack(Items.emerald, 4 + random.nextInt(5)), new ItemStack(Items.diamond, 1), new ItemStack(ConfigItems.itemFocusFire, 1));
        fire.func_82783_a(-6);
        recipeList.add(fire);
    }

}
 
Example #5
Source File: EntityHalloweenCow.java    From Moo-Fluids with GNU General Public License v3.0 5 votes vote down vote up
protected void applyEntityAI() {
  this.tasks.addTask(4, new EntityHalloweenCow.AICowAttack(this));
  this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
  targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityPlayer>
      (this, EntityPlayer.class, true));
  targetTasks.addTask(3, new EntityAINearestAttackableTarget<EntityVillager>
      (this, EntityVillager.class, false));
  targetTasks.addTask(3, new EntityAINearestAttackableTarget<EntityIronGolem>
      (this, EntityIronGolem.class, true));
}
 
Example #6
Source File: EntityVillagerMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(EntityVillager target, Vec3 relativePos) {
	Map<String, Object> map = Maps.newHashMap();

	map.put("profession", target.getProfession());
	map.put("isMating", target.isMating());
	map.put("isPlaying", target.isPlaying());

	boolean isTrading = target.isTrading();
	map.put("isTrading", isTrading);
	if (isTrading) map.put("customer", target.getCustomer().getGameProfile());

	return map;
}
 
Example #7
Source File: VillagerTradeHelper.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Field getTradeArrayFromClass(Class c){
	// search for 4D array of ITradeList objects
	for(Field f : c.getDeclaredFields()){
		if(f.getType().isArray() // D1
				&& f.getType().getComponentType().isArray() // D2
				&& f.getType().getComponentType().getComponentType().isArray() // D3
				&& f.getType().getComponentType().getComponentType().getComponentType().isArray() // D4
				&& f.getType().getComponentType().getComponentType().getComponentType().getComponentType().isAssignableFrom(EntityVillager.ITradeList.class)) {
			return f;
		}
	}
	return null;
}
 
Example #8
Source File: VillagerTradeHelper.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Inserts one or more trades to the defaul villager trade table using dark magic (aka java reflection).
 * @param professionID Villager profession ID (0-4)
 * @param careerID Villager career ID (1-3)
 * @param tradeLevel Level of trade (1+)
 * @param trades Trades to add to the given level
 * @throws NoSuchFieldException Thrown if java reflection has been disabled for security reasons
 * @throws IllegalAccessException Thrown if java reflection has been disabled for security reasons
 */
public static void insertTrades(int professionID, int careerID, int tradeLevel, EntityVillager.ITradeList... trades) throws NoSuchFieldException, IllegalAccessException {
	ResourceLocation profession = professionList[professionID];
	insertTrades(profession,careerID,tradeLevel,trades);
	/*
	FMLLog.info("%s: injecting villager trades %s into default trade array table at position [%s][%s][%s][*]", BaseMetals.MODID, Arrays.toString(trades), professionID, careerID-1, tradeLevel-1);
	Field vanillaTradeField = getTradeArrayFromClass(EntityVillager.class);
	unlockPrivateFinalField(vanillaTradeField);
	Object tradeTable = vanillaTradeField.get(null); // is static
	appendToMultidimensionalArray(trades,tradeTable,professionID,Math.max(0,careerID-1),Math.max(0,tradeLevel-1));
	*/
}
 
Example #9
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
@SubscribeEvent
public void entityStruckByLightning(EntityStruckByLightningEvent event) {
	if (EtFuturum.enableVillagerTurnsIntoWitch && event.entity instanceof EntityVillager) {
		EntityVillager villager = (EntityVillager) event.entity;
		if (!villager.worldObj.isRemote) {
			EntityWitch witch = new EntityWitch(villager.worldObj);
			witch.copyLocationAndAnglesFrom(villager);
			witch.onSpawnWithEgg(null);
			villager.worldObj.spawnEntityInWorld(witch);
			villager.setDead();
		}
	}
}
 
Example #10
Source File: EntitySamuraiIllager.java    From Sakura_mod with MIT License 5 votes vote down vote up
protected void initEntityAI() {
    super.initEntityAI();
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIRestrictOpenDoor(this));
    this.tasks.addTask(2, new EntityAIOpenDoor(this, true));
    this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
    this.tasks.addTask(8, new EntityAIWander(this, 0.6D));
    this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 3.0F, 1.0F));
    this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[]{AbstractIllager.class}));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityPlayer>(this, EntityPlayer.class, true));
    this.targetTasks.addTask(3, new EntityAINearestAttackableTarget<EntityVillager>(this, EntityVillager.class, true));
    this.targetTasks.addTask(3, new EntityAINearestAttackableTarget<EntityIronGolem>(this, EntityIronGolem.class, true));
}
 
Example #11
Source File: ActivationRange.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
/**
 * These entities are excluded from Activation range checks.
 *
 * @param entity
 * @param world
 * @return boolean If it should always tick.
 */
public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
{
    // Cauldron start - another fix for Proxy Worlds
    if (config == null && DimensionManager.getWorld(0) != null)
    {
        config = DimensionManager.getWorld(0).spigotConfig;
    }
    else
    {
        return true;
    }
    // Cauldron end

    if ( ( entity.activationType == 3 && config.miscActivationRange == 0 )
            || ( entity.activationType == 2 && config.animalActivationRange == 0 )
            || ( entity.activationType == 1 && config.monsterActivationRange == 0 )
            || (entity instanceof EntityPlayer && !(entity instanceof FakePlayer)) // Cauldron
            || entity instanceof EntityThrowable
            || entity instanceof EntityDragon
            || entity instanceof EntityDragonPart
            || entity instanceof EntityWither
            || entity instanceof EntityFireball
            || entity instanceof EntityWeatherEffect
            || entity instanceof EntityTNTPrimed
            || entity instanceof EntityFallingBlock // PaperSpigot - Always tick falling blocks
            || entity instanceof EntityEnderCrystal
            || entity instanceof EntityFireworkRocket
            || entity instanceof EntityVillager
            // Cauldron start - force ticks for entities with superclass of Entity and not a creature/monster
            || (entity.getClass().getSuperclass() == Entity.class && !entity.isCreatureType(EnumCreatureType.creature, false)
            && !entity.isCreatureType(EnumCreatureType.ambient, false) && !entity.isCreatureType(EnumCreatureType.monster, false)
            && !entity.isCreatureType(EnumCreatureType.waterCreature, false)))
    {
        return true;
    }

    return false;
}
 
Example #12
Source File: RenderFugitive.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Allows the render to do state modifications necessary before the model is
 * rendered.
 */
protected void preRenderCallback(EntityVillager entitylivingbaseIn, float partialTickTime) {
	float f = 0.9375F;

	if (entitylivingbaseIn.getGrowingAge() < 0) {
		f = (float) ((double) f * 0.5D);
		this.shadowSize = 0.25F;
	} else {
		this.shadowSize = 0.5F;
	}

	GlStateManager.scale(f, f, f);
}
 
Example #13
Source File: EntitySpawning.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private void removeVillager(LivingUpdateEvent event) {
	List<EntityVillager> list = event.getEntity().world.getEntitiesWithinAABB(EntityVillager.class,
			new AxisAlignedBB(event.getEntity().getPosition()));
	if (list.size() < 1) {
		return;
	}
	list.get(0).setDead();
}
 
Example #14
Source File: EntitySpawning.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onCreateVillager(EntityJoinWorldEvent event) {
	if (!event.getWorld().isRemote && event.getEntity() instanceof EntityVillager) {

		cleanMap();

		if (handlePossibleConversion((EntityLiving) event.getEntity(), null)) {
			event.getEntity().setDead();
		}
	}
}
 
Example #15
Source File: EntityVampireBat.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void initEntityAI() {
	tasks.addTask(2, new EntityAIAttackMelee(this, 0.4D, false));
	targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
	targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityToroNpc.class, true));
	targetTasks.addTask(4, new EntityAINearestAttackableTarget(this, EntityVillager.class, false));
	targetTasks.addTask(5, new EntityAINearestAttackableTarget(this, EntityAnimal.class, false));
}
 
Example #16
Source File: EntityUtils.java    From ForgeHax with MIT License 5 votes vote down vote up
/**
 * If the mob is friendly (not aggressive)
 */
public static boolean isFriendlyMob(Entity entity) {
  return (entity.isCreatureType(EnumCreatureType.CREATURE, false)
      && !EntityUtils.isNeutralMob(entity))
      || (entity.isCreatureType(EnumCreatureType.AMBIENT, false) && !isBatsDisabled)
      || entity instanceof EntityVillager
      || entity instanceof EntityIronGolem
      || (isNeutralMob(entity) && !EntityUtils.isMobAggressive(entity));
}
 
Example #17
Source File: FriendlyMob.java    From ForgeHax with MIT License 5 votes vote down vote up
@Override
public boolean isMobType(Entity entity) {
  return entity.isCreatureType(EnumCreatureType.CREATURE, false)
      || entity.isCreatureType(EnumCreatureType.AMBIENT, false)
      || entity.isCreatureType(EnumCreatureType.WATER_CREATURE, false)
      || entity instanceof EntityVillager
      || entity instanceof EntityGolem;
}
 
Example #18
Source File: IntegratorPressureChamber.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private void handleVillagers(int x, int y, List<IWidget> locatedTextures){
    locatedTextures.add(new LocatedEntity(EntityVillager.class, x + 70, y + 95, 2F));

    LocatedEntity locatedEntity = new LocatedEntity(EntityVillager.class, x + 215, y + 125, 2F);
    EntityVillager villager = (EntityVillager)locatedEntity.entity;
    villager.setProfession(Config.villagerMechanicID);
    locatedTextures.add(locatedEntity);
}
 
Example #19
Source File: ActivationRange.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * If an entity is not in range, do some more checks to see if we should
 * give it a shot.
 *
 * @param entity
 * @return
 */
public static boolean checkEntityImmunities(Entity entity) {
    // quick checks.
    if (entity.inWater || entity.fire > 0) {
        return true;
    }
    if (!(entity instanceof EntityArrow)) {
        if (!entity.onGround || !entity.riddenByEntities.isEmpty() || entity.isRiding()) {
            return true;
        }
    } else if (!((EntityArrow) entity).inGround) {
        return true;
    }
    // special cases.
    if (entity instanceof EntityLiving) {
        EntityLiving living = (EntityLiving) entity;
        if ( /*TODO: Missed mapping? living.attackTicks > 0 || */ living.hurtTime > 0 || living.activePotionsMap.size() > 0) {
            return true;
        }
        if (entity instanceof EntityCreature && ((EntityCreature) entity).getAttackTarget() != null) {
            return true;
        }
        if (entity instanceof EntityVillager && ((EntityVillager) entity).isMating()) {
            return true;
        }
        if (entity instanceof EntityAnimal) {
            EntityAnimal animal = (EntityAnimal) entity;
            if (animal.isChild() || animal.isInLove()) {
                return true;
            }
            if (entity instanceof EntitySheep && ((EntitySheep) entity).getSheared()) {
                return true;
            }
        }
        if (entity instanceof EntityCreeper && ((EntityCreeper) entity).hasIgnited()) { // isExplosive
            return true;
        }
    }
    return false;
}
 
Example #20
Source File: CraftingRegistrator.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private static void registerAmadronOffers(){
    PneumaticRecipeRegistry registry = PneumaticRecipeRegistry.getInstance();
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 8), new ItemStack(Itemss.PCBBlueprint));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 8), new ItemStack(Itemss.assemblyProgram, 1, 0));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 8), new ItemStack(Itemss.assemblyProgram, 1, 1));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 14), new ItemStack(Itemss.assemblyProgram, 1, 2));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.oil, 5000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.diesel, 4000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.lubricant, 2500), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.kerosene, 3000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.gasoline, 2000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new FluidStack(Fluids.lpg, 1000), new ItemStack(Items.emerald, 1));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald), new FluidStack(Fluids.oil, 1000));
    registry.registerDefaultStaticAmadronOffer(new ItemStack(Items.emerald, 5), new FluidStack(Fluids.lubricant, 1000));

    for(int i = 0; i < 256; i++) {
        try {
            for(int j = 0; j < 10; j++) {
                EntityVillager villager = new EntityVillager(null, i);
                MerchantRecipeList list = villager.getRecipes(null);
                for(MerchantRecipe recipe : (List<MerchantRecipe>)list) {
                    if(recipe.getSecondItemToBuy() == null && recipe.getItemToBuy() != null && recipe.getItemToBuy().getItem() != null && recipe.getItemToSell() != null && recipe.getItemToSell().getItem() != null) {
                        registry.registerDefaultPeriodicAmadronOffer(recipe.getItemToBuy(), recipe.getItemToSell());
                    }
                }
            }
        } catch(Throwable e) {}
    }
}
 
Example #21
Source File: VillagerHandler.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void manipulateTradesForVillager(EntityVillager villager, MerchantRecipeList recipeList, Random rand){
    recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(net.minecraft.init.Items.emerald, 10 + rand.nextInt(10)), null, new ItemStack(Itemss.PCBBlueprint)));
    for(int i = 0; i < ItemAssemblyProgram.PROGRAMS_AMOUNT; i++) {
        recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(net.minecraft.init.Items.emerald, rand.nextInt(5) + 7), null, new ItemStack(Itemss.assemblyProgram, 1, i)));
    }
    recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(net.minecraft.init.Items.emerald, rand.nextInt(5) + 1), null, new ItemStack(Itemss.nukeVirus)));
    recipeList.addToListWithCheck(new MerchantRecipe(new ItemStack(net.minecraft.init.Items.emerald, rand.nextInt(5) + 1), null, new ItemStack(Itemss.stopWorm)));
}
 
Example #22
Source File: EntityClayGolem.java    From Artifacts with MIT License 5 votes vote down vote up
public EntityClayGolem(World par1World)
{
    super(par1World);
    //this.moveSpeed = 0.16F;
    /*this.setSize(1.4F, 2.9F);
    this.getNavigator().setAvoidsWater(true);
    this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, 0.288D, false));
    this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityZombie.class, 0.288D, true));
    this.tasks.addTask(3, new EntityAIMoveTowardsRestriction(this, 0.16D));
    this.tasks.addTask(4, new EntityAIWander(this, 0.16D));
    this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    this.tasks.addTask(6, new EntityAILookIdle(this));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
    this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityZombie.class, 0, true));
    //this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true, true, IMob.mobSelector));
    //this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityZombie.class, 0, false, true, IMob.mobSelector));*/
    this.getNavigator().setAvoidsWater(true);
    this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
    this.tasks.addTask(3, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, true));
    this.tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, 1.0D));
    this.tasks.addTask(5, new EntityAIMoveThroughVillage(this, 1.0D, false));
    this.tasks.addTask(6, new EntityAIWander(this, 1.0D));
    this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
    this.tasks.addTask(7, new EntityAILookIdle(this));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, false));
}
 
Example #23
Source File: ActivationRange.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
/**
 * If an entity is not in range, do some more checks to see if we should
 * give it a shot.
 *
 * @param entity
 * @return
 */
public static boolean checkEntityImmunities(Entity entity)
{
    // quick checks.
    if ( entity.inWater /* isInWater */ || entity.fire > 0 )
    {
        return true;
    }
    if ( !( entity instanceof EntityArrow ) )
    {
        if ( !entity.onGround || entity.riddenByEntity != null
                || entity.ridingEntity != null )
        {
            return true;
        }
    } else if ( !( (EntityArrow) entity ).inGround )
    {
        return true;
    }
    // special cases.
    if ( entity instanceof EntityLiving )
    {
        EntityLiving living = (EntityLiving) entity;
        if ( living.attackTime > 0 || living.hurtTime > 0 || living.activePotionsMap.size() > 0 )
        {
            return true;
        }
        if ( entity instanceof EntityCreature && ( (EntityCreature) entity ).entityToAttack != null )
        {
            return true;
        }
        if ( entity instanceof EntityVillager && ( (EntityVillager) entity ).isMating() /* Getter for first boolean */ )
        {
            return true;
        }
        if ( entity instanceof EntityAnimal )
        {
            EntityAnimal animal = (EntityAnimal) entity;
            if ( animal.isChild() || animal.isInLove() /*love*/ )
            {
                return true;
            }
            if ( entity instanceof EntitySheep && ( (EntitySheep) entity ).getSheared() )
            {
                return true;
            }
        }
    }
    return false;
}
 
Example #24
Source File: EntityFallenKnight.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public EntityFallenKnight(World world) {
  super(world);
  targetTasks.addTask(2, new EntityAINearestAttackableTarget<EntityVillager>(this, EntityVillager.class, false));
}
 
Example #25
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 #26
Source File: CraftVillager.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityVillager getHandle() {
    return (EntityVillager) entity;
}
 
Example #27
Source File: CraftVillager.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftVillager(CraftServer server, EntityVillager entity) {
    super(server, entity);
}
 
Example #28
Source File: EntityUtils.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isMob(final Entity entity) {
    return entity instanceof EntityMob || entity instanceof EntityVillager || entity instanceof EntitySlime ||
            entity instanceof EntityGhast || entity instanceof EntityDragon;
}
 
Example #29
Source File: VillagerTradeHelper.java    From BaseMetals with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Inserts one or more trades to the defaul villager trade table using dark magic (aka java reflection).
 * @param profession Villager profession
 * @param careerID Villager career ID (1-3)
 * @param tradeLevel Level of trade (1+)
 * @param trades Trades to add to the given level
 */
public static void insertTrades(ResourceLocation profession, int careerID, int tradeLevel, EntityVillager.ITradeList... trades) {
	for(EntityVillager.ITradeList trade : trades) {
		VillagerRegistry.instance().getRegistry().getValue(profession).getCareer(careerID-1).addTrade(tradeLevel, trade);
	}
}