Java 类net.minecraft.entity.INpc 实例源码

项目:Progression    文件:FilterEntityType.java   
@Override
protected boolean matches(EntityLivingBase entity) {
    if (type == BOSS) return !entity.isNonBoss();
    else if (!entity.isNonBoss()) return false;

    switch (type) {
        case ANIMAL:    return entity instanceof EntityAnimal;
        case MONSTER:   return entity instanceof IMob;
        case TAMEABLE:  return entity instanceof IEntityOwnable;
        case PLAYER:    return entity instanceof EntityPlayer;
        case WATER:     return entity instanceof EntityWaterMob || entity instanceof EntityGuardian;
        case NPC:       return entity instanceof INpc;
        case GOLEM:     return entity instanceof EntityGolem;
        default:        return false;
    }
}
项目:ZeldaSwordSkills    文件:ItemBomb.java   
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
    if (entity instanceof EntityNpcBarnes) {
        if (!player.worldObj.isRemote) {
            if (((EntityNpcBarnes) entity).addBombBagTrade()) {
                PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.bomb.add");
            } else {
                PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.bomb.careful");
            }
        }
        return true;
    } else if (entity instanceof INpc) {
        if (!player.worldObj.isRemote) {
            PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.bomb.careful");
        }
        return true;
    }
    return super.onLeftClickEntity(stack, player, entity);
}
项目:DecompiledMinecraft    文件:WorldServer.java   
/**
 * Will update the entity in the world if the chunk the entity is in is currently loaded or its forced to update.
 * Args: entity, forceUpdate
 */
public void updateEntityWithOptionalForce(Entity entityIn, boolean forceUpdate)
{
    if (!this.canSpawnAnimals() && (entityIn instanceof EntityAnimal || entityIn instanceof EntityWaterMob))
    {
        entityIn.setDead();
    }

    if (!this.canSpawnNPCs() && entityIn instanceof INpc)
    {
        entityIn.setDead();
    }

    super.updateEntityWithOptionalForce(entityIn, forceUpdate);
}
项目:DecompiledMinecraft    文件:WorldServer.java   
/**
 * Will update the entity in the world if the chunk the entity is in is currently loaded or its forced to update.
 * Args: entity, forceUpdate
 */
public void updateEntityWithOptionalForce(Entity entityIn, boolean forceUpdate)
{
    if (!this.canSpawnAnimals() && (entityIn instanceof EntityAnimal || entityIn instanceof EntityWaterMob))
    {
        entityIn.setDead();
    }

    if (!this.canSpawnNPCs() && entityIn instanceof INpc)
    {
        entityIn.setDead();
    }

    super.updateEntityWithOptionalForce(entityIn, forceUpdate);
}
项目:BaseClient    文件:WorldServer.java   
/**
 * Will update the entity in the world if the chunk the entity is in is currently loaded or its forced to update.
 * Args: entity, forceUpdate
 */
public void updateEntityWithOptionalForce(Entity entityIn, boolean forceUpdate)
{
    if (!this.canSpawnAnimals() && (entityIn instanceof EntityAnimal || entityIn instanceof EntityWaterMob))
    {
        entityIn.setDead();
    }

    if (!this.canSpawnNPCs() && entityIn instanceof INpc)
    {
        entityIn.setDead();
    }

    super.updateEntityWithOptionalForce(entityIn, forceUpdate);
}
项目:BaseClient    文件:WorldServer.java   
/**
 * Will update the entity in the world if the chunk the entity is in is currently loaded or its forced to update.
 * Args: entity, forceUpdate
 */
public void updateEntityWithOptionalForce(Entity entityIn, boolean forceUpdate)
{
    if (!this.canSpawnAnimals() && (entityIn instanceof EntityAnimal || entityIn instanceof EntityWaterMob))
    {
        entityIn.setDead();
    }

    if (!this.canSpawnNPCs() && entityIn instanceof INpc)
    {
        entityIn.setDead();
    }

    super.updateEntityWithOptionalForce(entityIn, forceUpdate);
}
项目:Backmemed    文件:WorldServer.java   
/**
 * Updates the entity in the world if the chunk the entity is in is currently loaded or its forced to update.
 */
public void updateEntityWithOptionalForce(Entity entityIn, boolean forceUpdate)
{
    if (!this.canSpawnAnimals() && (entityIn instanceof EntityAnimal || entityIn instanceof EntityWaterMob))
    {
        entityIn.setDead();
    }

    if (!this.canSpawnNPCs() && entityIn instanceof INpc)
    {
        entityIn.setDead();
    }

    super.updateEntityWithOptionalForce(entityIn, forceUpdate);
}
项目:CustomWorldGen    文件:WorldServer.java   
/**
 * Updates the entity in the world if the chunk the entity is in is currently loaded or its forced to update.
 */
public void updateEntityWithOptionalForce(Entity entityIn, boolean forceUpdate)
{
    if (!this.canSpawnAnimals() && (entityIn instanceof EntityAnimal || entityIn instanceof EntityWaterMob))
    {
        entityIn.setDead();
    }

    if (!this.canSpawnNPCs() && entityIn instanceof INpc)
    {
        entityIn.setDead();
    }

    super.updateEntityWithOptionalForce(entityIn, forceUpdate);
}
项目:Factorization    文件:TileEntityAnthroGen.java   
@Override
public void handle(Coord here) {
    for (ClassInheritanceMultiMap<Entity> list : here.getChunk().getEntityLists()) {
        for (Entity ent : list) {
            if (!(ent instanceof INpc)) continue;
            if (hashEnt(ent)) {
                satisfactory_villagers++;
            }
        }
    }
}
项目:Jiffy    文件:WorldServer.java   
/**
 * Will update the entity in the world if the chunk the entity is in is
 * currently loaded or its forced to update. Args: entity, forceUpdate
 */
public void updateEntityWithOptionalForce(Entity entity, boolean forceUpdate) {
    if (!this.mcServer.getCanSpawnAnimals()
            && (entity instanceof EntityAnimal || entity instanceof EntityWaterMob)) {
        entity.setDead();
    }

    if (!this.mcServer.getCanSpawnNPCs() && entity instanceof INpc) {
        entity.setDead();
    }

    super.updateEntityWithOptionalForce(entity, forceUpdate);
}
项目:Resilience-Client-Source    文件:WorldServer.java   
/**
 * Will update the entity in the world if the chunk the entity is in is currently loaded or its forced to update.
 * Args: entity, forceUpdate
 */
public void updateEntityWithOptionalForce(Entity par1Entity, boolean par2)
{
    if (!this.mcServer.getCanSpawnAnimals() && (par1Entity instanceof EntityAnimal || par1Entity instanceof EntityWaterMob))
    {
        par1Entity.setDead();
    }

    if (!this.mcServer.getCanSpawnNPCs() && par1Entity instanceof INpc)
    {
        par1Entity.setDead();
    }

    super.updateEntityWithOptionalForce(par1Entity, par2);
}
项目:Cauldron    文件:WorldServer.java   
public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_)
{
    if (!this.mcServer.getCanSpawnAnimals() && (p_72866_1_ instanceof EntityAnimal || p_72866_1_ instanceof EntityWaterMob))
    {
        p_72866_1_.setDead();
    }

    if (!this.mcServer.getCanSpawnNPCs() && p_72866_1_ instanceof INpc)
    {
        p_72866_1_.setDead();
    }

    super.updateEntityWithOptionalForce(p_72866_1_, p_72866_2_);
}
项目:Cauldron    文件:WorldServer.java   
public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_)
{
    if (!this.mcServer.getCanSpawnAnimals() && (p_72866_1_ instanceof EntityAnimal || p_72866_1_ instanceof EntityWaterMob))
    {
        p_72866_1_.setDead();
    }

    if (!this.mcServer.getCanSpawnNPCs() && p_72866_1_ instanceof INpc)
    {
        p_72866_1_.setDead();
    }

    super.updateEntityWithOptionalForce(p_72866_1_, p_72866_2_);
}
项目:ZeldaSwordSkills    文件:ItemTreasure.java   
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
    if (player.worldObj.isRemote) {
        return true;
    } else if (entity instanceof EntityNpcMaskTrader && ((EntityNpcMaskTrader) entity).checkShopStatus(player, false, true)) {
        return true; // allows quest to complete without having to convert a villager if Salesman already in town
    } else if (entity instanceof EntityVillager && Result.DEFAULT == NpcHelper.convertVillager(player, (EntityVillager) entity, false)) {
        // villager not converted, try other treasure interactions (note that conversion handles beginnings of several quests)
        handleTrade(stack, player, entity, true);
    } else if (entity instanceof INpc) {
        handleTrade(stack, player, entity, true);
    }
    return true;
}
项目:ZeldaSwordSkills    文件:ItemTreasure.java   
private boolean handleTrade(ItemStack stack, EntityPlayer player, Entity entity, boolean isLeftClick) {
    Treasures treasure = Treasures.byDamage(stack.getItemDamage());
    if (treasure.isBiggoronTrade()) {
        return handleBiggoronQuest(stack, player, entity, isLeftClick);
    } else if (entity instanceof EntityVillager) {
        if (treasure == Treasures.ZELDAS_LETTER) {
            PlayerUtils.sendTranslatedChat(player, "chat.zss.treasure." + treasure.name + (((EntityVillager) entity).isChild() ? ".child" : ".fail") + (isLeftClick ? ".give" : ".show"));
        } else if (!handleVillagerTrade(stack, player, (EntityVillager) entity, isLeftClick)) {
            PlayerUtils.sendTranslatedChat(player, "chat.zss.treasure." + treasure.uninterested + ".uninterested");
        }
        return true;
    } else if (entity instanceof INpc) {
        if (entity instanceof EntityAgeable && ((EntityAgeable) entity).isChild()) {
            handleChildTrade(stack, player, isLeftClick);
        } else if (treasure == Treasures.ZELDAS_LETTER && entity instanceof EntityNpcMaskTrader) {
            ZSSQuests quests = ZSSQuests.get(player);
            if (quests.hasCompleted(QuestMaskSales.class)) {
                PlayerUtils.sendTranslatedChat(player, "chat.zss.npc.mask_salesman.shop.open");
            } else {
                IQuest quest = quests.get(QuestMaskShop.class);
                if (quest != null) {
                    IChatComponent hint = quest.getHint(player);
                    if (hint != null) {
                        player.addChatMessage(hint);
                    }
                } else {
                    PlayerUtils.sendTranslatedChat(player, "chat.zss.npc.mask_salesman.shop.hint." + itemRand.nextInt(4));
                }
            }
        } else if (treasure == Treasures.KNIGHTS_CREST && entity instanceof EntityNpcOrca) {
            PlayerUtils.sendTranslatedChat(player, "chat.zss.treasure." + treasure.uninterested + ".uninterested.orca");
        } else {
            PlayerUtils.sendTranslatedChat(player, "chat.zss.treasure." + treasure.uninterested + ".uninterested");
        }
        return true;
    }
    return false;
}
项目:ZeldaSwordSkills    文件:ItemMask.java   
/**
 * Called when the player right-clicks on an entity while wearing a mask
 * @return returning true will cancel the interact event (preventing trade
 * gui from opening for villagers, for example)
 */
public boolean onInteract(ItemStack stack, EntityPlayer player, Entity entity) {
    if (!player.worldObj.isRemote) {
        if (entity instanceof EntityVillager) {
            EntityVillager villager = (EntityVillager) entity;
            if (entity.getClass() == EntityVillager.class && this == ZSSVillagerInfo.get(villager).getMaskDesired()) {
                QuestMaskSales quest = (QuestMaskSales) ZSSQuests.get(player).get(QuestMaskSales.class);
                if (!quest.hasSold(this)) {
                    new TimedChatDialogue(player,
                            new ChatComponentTranslation("chat.zss.npc.mask_salesman.sales.buyer.0"),
                            new ChatComponentTranslation("chat.zss.npc.mask_salesman.sales.buyer.1", getSellPrice()));
                } else { // player already sold this mask
                    PlayerUtils.sendTranslatedChat(player, "chat.zss.npc.mask_salesman.sales.repeat." + player.worldObj.rand.nextInt(4));
                }
            } else {
                // Custom villager professions all use the same chat message
                int p = villager.getProfession();
                String s = (p < 0 || p > EnumVillager.values().length) ? "custom" : String.valueOf(p);
                PlayerUtils.sendTranslatedChat(player, "chat." + getUnlocalizedName().substring(5) + "." + s);
            }
        } else if (entity instanceof EntityNpcMaskTrader) {
            PlayerUtils.sendTranslatedChat(player, "chat." + getUnlocalizedName().substring(5) + ".salesman");
        } else if (entity instanceof INpc) {
            PlayerUtils.sendTranslatedChat(player, "chat." + getUnlocalizedName().substring(5) + ".custom");
        } else {
            return false;
        }
    }
    return true;
}
项目:ZeldaSwordSkills    文件:ItemWhip.java   
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
    if (!player.worldObj.isRemote && entity.getClass() == EntityVillager.class) {
        EntityVillager villager = (EntityVillager) entity;
        MerchantRecipeList trades = villager.getRecipes(player);
        if (villager.getProfession() == EnumVillager.BUTCHER.ordinal() && trades != null) {
            switch(WhipType.fromDamage(stack.getItemDamage())) {
            case WHIP_SHORT:
                MerchantRecipe trade = new MerchantRecipe(new ItemStack(this, 1, WhipType.WHIP_SHORT.ordinal()), new ItemStack(Items.emerald, 64), new ItemStack(this, 1, WhipType.WHIP_LONG.ordinal()));
                if (MerchantRecipeHelper.addUniqueTrade(trades, trade)) {
                    PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.whip.upgrade.new");
                } else {
                    PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.whip.upgrade.old");
                }
                break;
            case WHIP_LONG:
                PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.whip.long");
                break;
            case WHIP_MAGIC:
                PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.whip.magic");
                break;
            }
        } else {
            PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.whip.sorry");
        }
    } else if (!player.worldObj.isRemote && entity instanceof INpc) {
        PlayerUtils.sendTranslatedChat(player, "chat.zss.trade.whip.sorry");
    }
    return true;
}
项目:ZeldaSwordSkills    文件:ZSSEntityEvents.java   
/**
 * 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));
        }
    }
    // Check for Lon Lon Milk cow interaction
    if (!event.isCanceled() && stack != null && stack.getItem() == Items.glass_bottle && event.target.getClass() == EntityCow.class) {
        event.setCanceled(ZSSPlayerSongs.get(event.entityPlayer).milkLonLonCow(event.entityPlayer, (EntityCow) event.target));
    }
    // Finally, check for interactions with the Cursed Man
    if (!event.isCanceled() && event.target.getClass() == EntityVillager.class && ("Cursed Man").equals(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);
        }
    }
}
项目:RuneCraftery    文件:WorldServer.java   
public void func_72866_a(Entity p_72866_1_, boolean p_72866_2_) {
   if(!this.field_73061_a.func_71268_U() && (p_72866_1_ instanceof EntityAnimal || p_72866_1_ instanceof EntityWaterMob)) {
      p_72866_1_.func_70106_y();
   }

   if(!this.field_73061_a.func_71220_V() && p_72866_1_ instanceof INpc) {
      p_72866_1_.func_70106_y();
   }

   super.func_72866_a(p_72866_1_, p_72866_2_);
}
项目:RuneCraftery    文件:WorldServer.java   
/**
 * Will update the entity in the world if the chunk the entity is in is currently loaded or its forced to update.
 * Args: entity, forceUpdate
 */
public void updateEntityWithOptionalForce(Entity par1Entity, boolean par2)
{
    if (!this.mcServer.getCanSpawnAnimals() && (par1Entity instanceof EntityAnimal || par1Entity instanceof EntityWaterMob))
    {
        par1Entity.setDead();
    }

    if (!this.mcServer.getCanSpawnNPCs() && par1Entity instanceof INpc)
    {
        par1Entity.setDead();
    }

    super.updateEntityWithOptionalForce(par1Entity, par2);
}
项目:MyEssentials-Core    文件:EntityUtils.java   
private static String getEntityTypeNonCache(Entity e) {
    if (e instanceof EntityGolem) {
        return "Golem";
    } else if (e instanceof IBossDisplayData) {
        return "Boss";
    } else if (e instanceof IAnimals) {
        return "Animal";
    } else if (e instanceof IMob) {
        return "Monster";
    } else if (e instanceof IProjectile) {
        return "Projectile";
    } else if (e instanceof INpc) {
        return "NPC";
    } else if (e instanceof EntityItem) {
        return "Item";
    } else if (e instanceof EntityMob) {
        return "Monster";
    } else if (e instanceof EntityPlayer) {
        return "Player";
    } else if (e instanceof EntityFireball) {
        return "Projectile";
    } else if (e instanceof EntityTNTPrimed) {
        return "TNT";
    } else {
        return "Unknown"; // e.getClass().getName();
    }
}
项目:BetterNutritionMod    文件:WorldServer.java   
/**
 * Will update the entity in the world if the chunk the entity is in is currently loaded or its forced to update.
 * Args: entity, forceUpdate
 */
public void updateEntityWithOptionalForce(Entity par1Entity, boolean par2)
{
    if (!this.mcServer.getCanSpawnAnimals() && (par1Entity instanceof EntityAnimal || par1Entity instanceof EntityWaterMob))
    {
        par1Entity.setDead();
    }

    if (!this.mcServer.getCanSpawnNPCs() && par1Entity instanceof INpc)
    {
        par1Entity.setDead();
    }

    super.updateEntityWithOptionalForce(par1Entity, par2);
}