public EventTracker(EntityVillager villager) { this( villager.getEntityId(), villager.getPosition(), villager.getCustomNameTag(), new Object[] {villager.getProfession(), villager.isChild()}); }
@Override public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (!player.isSneaking()) { DebugHelper.debug(player, world, x, y, z); } else if (world.getBlock(x, y, z) instanceof BlockBush) { if (player.isSneaking()) { world.getBlock(x, y, z).updateTick(world, x, y, z, world.rand); } } else { if (!world.isRemote) { EntityVillager entityvillager = new EntityVillagerFarmer(world, WorldGen.getVillagerId()); entityvillager.setLocationAndAngles( (double) x + 0.5D, (double) y + 1, (double) z + 0.5D, 0.0F, 0.0F); world.spawnEntityInWorld(entityvillager); } } return false; }
@Override public void process(List<String> list, Entity entity) { if (entity instanceof EntityVillager) { EntityVillager villager = (EntityVillager) entity; switch (villager.getProfession()) { case 0: list.add(StatCollector.translateToLocal("smartcursor.mob.profession_0")); break; case 1: list.add(StatCollector.translateToLocal("smartcursor.mob.profession_1")); break; case 2: list.add(StatCollector.translateToLocal("smartcursor.mob.profession_2")); break; case 3: list.add(StatCollector.translateToLocal("smartcursor.mob.profession_3")); break; case 4: list.add(StatCollector.translateToLocal("smartcursor.mob.profession_4")); break; default: list.add(StatCollector.translateToLocal("smartcursor.mob.profession")); break; } if (villager.isTrading()) list.add(StatCollector.translateToLocal("smartcursor.mob.trade")); } }
@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(); } } }
@Override protected Optional<List<TradeOffer>> getVal(EntityVillager entity) { if (entity.buyingList == null) { entity.populateBuyingList(); } return Optional.of(toTradeOfferList(entity.buyingList)); }
/** main AI tick function, replaces updateEntityActionState */ @Override protected void updateAITick() { if (!this.isTrading() && this.timeUntilReset > 0) { --this.timeUntilReset; if (this.timeUntilReset <= 0) { if (this.needsInitilization) { if (this.buyingList.size() > 1) { Iterator var3 = this.buyingList.iterator(); while (var3.hasNext()) { MerchantRecipe var2 = (MerchantRecipe) var3.next(); if (var2.func_82784_g()) { var2.func_82783_a(this.rand.nextInt(6) + this.rand.nextInt(6) + 2); } } } this.addDefaultEquipmentAndRecipies(1); this.needsInitilization = false; } this.addPotionEffect(new PotionEffect(Potion.regeneration.id, 200, 0)); } } super.updateAITick(); }
/** * Updates a villager entity with the zombie info this object is tracking. * * @param villager */ public void updateVillager(EntityVillager villager) { // Note: I must trust that this object actually contain a zombie info. If not, the cast below // will fail. final ExtendedVillagerZombie properties = (ExtendedVillagerZombie) this.getObject(); // Custom name if (this.getCustomName() != "") { villager.setCustomNameTag(this.getCustomName()); } // Profession if (properties.getProfession() >= 0 && properties.getProfession() <= 4) { // vanilla professions villager.setProfession(properties.getProfession()); } }
/** (abstract) Protected helper method to write subclass entity data to NBT. */ @Override public void writeEntityToNBT(NBTTagCompound var1) { super.writeEntityToNBT(var1); if (this.buyingList != null) { var1.setCompoundTag("Offers", this.buyingList.getRecipiesAsTags()); } }
/** (abstract) Protected helper method to read subclass entity data from NBT. */ @Override public void readEntityFromNBT(NBTTagCompound var1) { super.readEntityFromNBT(var1); if (var1.hasKey("Offers")) { NBTTagCompound var2 = var1.getCompoundTag("Offers"); this.buyingList = new MerchantRecipeList(var2); } }
/** This event fires on BOTH sides */ @SubscribeEvent public void onInteract(EntityInteractEvent event) { ItemStack stack = event.entityPlayer.getHeldItem(); if (event.target instanceof EntityVillager && Result.DEFAULT != NpcHelper.convertVillager(event.entityPlayer, (EntityVillager) event.target, true)) { event.setCanceled(true); } // Check if the held item has any special interaction upon right-clicking an entity if (!event.isCanceled() && stack != null && stack.getItem() instanceof IRightClickEntity) { event.setCanceled( ((IRightClickEntity) stack.getItem()) .onRightClickEntity(stack, event.entityPlayer, event.target)); } // If the event is not yet canceled, check for Mask interactions if (!event.isCanceled() && event.target instanceof INpc) { ItemStack helm = event.entityPlayer.getCurrentArmor(ArmorIndex.WORN_HELM); if (helm != null && helm.getItem() instanceof ItemMask) { event.setCanceled( ((ItemMask) helm.getItem()).onInteract(helm, event.entityPlayer, event.target)); } } // Finally, check for interactions with the Cursed Man if (!event.isCanceled() && event.target.getClass() == EntityVillager.class && ("Cursed Man").equals(((EntityVillager) event.target).getCustomNameTag())) { EntityVillager villager = (EntityVillager) event.target; if (stack == null || (stack.getItem() != ZSSItems.skulltulaToken && stack.getItem() != Items.name_tag)) { int tokens = ZSSPlayerInfo.get(event.entityPlayer).getSkulltulaTokens(); if (villager.worldObj.isRemote) { // don't send chat - will be sent from server } else if (villager.isChild()) { PlayerUtils.sendTranslatedChat(event.entityPlayer, "chat.zss.npc.cursed_man.child"); } else if (tokens > 0) { PlayerUtils.sendTranslatedChat( event.entityPlayer, "chat.zss.npc.cursed_man.amount", tokens); } else { PlayerUtils.sendTranslatedChat( event.entityPlayer, "chat.zss.npc.cursed_man." + event.entity.worldObj.rand.nextInt(4)); } event.setCanceled(true); } } }
/** * Called when left-clicking a villager with the item in hand * * @param stack The player's currently held item (stack.getItem() is 'this') */ protected void handleTrade(ItemStack stack, EntityPlayer player, EntityVillager villager) { MerchantRecipeList trades = villager.getRecipes(player); if (villager.isChild()) { PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.generic.child"); } else if (villager.getClass() != EntityVillager.class) { PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.generic.sorry.0"); } else if (trades != null && sellPrice > 0) { MerchantRecipe trade = new MerchantRecipe(stack.copy(), new ItemStack(Items.emerald, sellPrice)); if (player.worldObj.rand.nextFloat() < 0.2F && MerchantRecipeHelper.addToListWithCheck(trades, trade)) { PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.generic.sell.0"); } else { PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.generic.sorry.1"); } } else { PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.generic.sorry.0"); } }
@Override @SideOnly(Side.CLIENT) public void handleHealthUpdate(byte var1) { if (var1 == 12) { this.generateRandomParticles("heart"); } else if (var1 == 13) { this.generateRandomParticles("angryVillager"); } else if (var1 == 14) { this.generateRandomParticles("happyVillager"); } else { super.handleHealthUpdate(var1); } }
@SuppressWarnings("unchecked") public static void addEmeraldSellRecipe( EntityVillager villager, MerchantRecipeList list, Random random, Item item, float chance, int min, int max) { if (min > 0 && max > 0) { EntityVillager.field_70960_bC.put(item.field_77779_bT, new Tuple(min, max)); } EntityVillager.func_70949_b(list, item.func_77612_l(), random, chance); }
protected void co() { EntityVillager entityvillager = new EntityVillager(this.o); entityvillager.m(this); entityvillager.a(this.o.E(new BlockPos(entityvillager)), (IEntityLivingData) null); entityvillager.cn(); if (this.i_()) { entityvillager.b(-24000); } this.o.e((Entity) this); this.o.d((Entity) entityvillager); entityvillager.c(new PotionEffect(Potion.k.H, 200, 0)); this.o.a((EntityPlayer) null, 1017, new BlockPos((int) this.s, (int) this.t, (int) this.u), 0); }
/** Convert this zombie into a villager. */ protected void convertToVillager() { EntityVillager entityvillager = new EntityVillager(this.worldObj); entityvillager.func_82149_j(this); entityvillager.initCreature(); entityvillager.func_82187_q(); if (this.isChild()) { entityvillager.setGrowingAge(-24000); } this.worldObj.removeEntity(this); this.worldObj.spawnEntityInWorld(entityvillager); entityvillager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0)); this.worldObj.playAuxSFXAtEntity( (EntityPlayer) null, 1017, (int) this.posX, (int) this.posY, (int) this.posZ, 0); }
/** Convert this zombie into a villager. */ protected void convertToVillager() { EntityVillager entityvillager = new EntityVillager(this.worldObj); entityvillager.copyLocationAndAnglesFrom(this); entityvillager.onSpawnWithEgg((EntityLivingData) null); entityvillager.func_82187_q(); if (this.isChild()) { entityvillager.setGrowingAge(-24000); } this.worldObj.removeEntity(this); this.worldObj.spawnEntityInWorld(entityvillager); entityvillager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0)); this.worldObj.playAuxSFXAtEntity( (EntityPlayer) null, 1017, (int) this.posX, (int) this.posY, (int) this.posZ, 0); }
@Override protected boolean set(EntityVillager entity, List<TradeOffer> value) { entity.buyingList = toMerchantRecipeList(value); return true; }
public EntityVillager func_90011_a(EntityAgeable p_90012_1_) { EntityVillager var2 = new EntityVillager(this.field_70170_p); var2.func_110161_a((IEntityLivingData) null); return var2; }
@Override protected void entityInit() { super.entityInit(); }
public void setRevengeTarget(EntityLiving var1) { super.setRevengeTarget(var1); }
public static void applyRandomTrade(EntityVillager villager, Random rand) { int extra = instance().newVillagerIds.size(); int trade = rand.nextInt(5 + extra); villager.func_70938_b(trade < 5 ? trade : instance().newVillagerIds.get(trade - 5)); }