Ejemplo n.º 1
0
  @Override
  public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {

    EntityPlayer par3EntityPlayer = (EntityPlayer) player;

    DataInputStream dis = new DataInputStream(new ByteArrayInputStream(packet.data));

    ItemStack par1ItemStack;
    try {
      par1ItemStack = Packet.readItemStack(dis);
      Entity entityID = par3EntityPlayer.worldObj.getEntityByID(dis.readInt());

      if (par1ItemStack.getTagCompound() == null)
        par1ItemStack.setTagCompound(new NBTTagCompound());

      if (par1ItemStack.getTagCompound().hasKey(ModBreeds.tag)
          && (!par1ItemStack.getTagCompound().getString(ModBreeds.tag).equals("none"))) {
        par3EntityPlayer.addChatMessage(
            "Pet trap still has a  " + EntityList.getEntityString(entityID) + " inside !");
      } else {
        NBTTagCompound nbt = new NBTTagCompound();
        nbt.setString(ModBreeds.tag, EntityList.getEntityString(entityID));
        par1ItemStack.setTagCompound(nbt);
        entityID.setDead();
        par3EntityPlayer.setCurrentItemOrArmor(0, par1ItemStack);
        if (!par3EntityPlayer.worldObj.isRemote)
          par3EntityPlayer.addChatMessage(
              "Stored a " + EntityList.getEntityString(entityID) + " in the Animal trap");
      }

    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  /** Teleports the entity to another dimension. Params: Dimension number to teleport to */
  public static void travelEntityToDimension(Entity entity, int dimensionId, int x, int y, int z) {
    if (!entity.worldObj.isRemote && !entity.isDead) {
      entity.worldObj.theProfiler.startSection("changeDimension");
      MinecraftServer minecraftserver = MinecraftServer.getServer();
      int j = entity.dimension;
      WorldServer worldserver = minecraftserver.worldServerForDimension(j);
      WorldServer worldserver1 = minecraftserver.worldServerForDimension(dimensionId);
      entity.dimension = dimensionId;

      if (j == 1 && dimensionId == 1) {
        worldserver1 = minecraftserver.worldServerForDimension(0);
        entity.dimension = 0;
      }

      entity.worldObj.removeEntity(entity);
      entity.isDead = false;
      entity.worldObj.theProfiler.startSection("reposition");
      minecraftserver
          .getConfigurationManager()
          .transferEntityToWorld(entity, j, worldserver, worldserver1);
      entity.worldObj.theProfiler.endStartSection("reloading");
      Entity newEntity =
          EntityList.createEntityByName(EntityList.getEntityString(entity), worldserver1);

      if (newEntity != null) {
        newEntity.copyDataFrom(entity, true);

        if (j == 1 && dimensionId == 1) {
          ChunkCoordinates chunkcoordinates = worldserver1.getSpawnPoint();
          chunkcoordinates.posY =
              entity.worldObj.getTopSolidOrLiquidBlock(
                  chunkcoordinates.posX, chunkcoordinates.posZ);
          newEntity.setLocationAndAngles(
              (double) chunkcoordinates.posX,
              (double) chunkcoordinates.posY,
              (double) chunkcoordinates.posZ,
              newEntity.rotationYaw,
              newEntity.rotationPitch);
        }

        worldserver1.spawnEntityInWorld(newEntity);
        newEntity.setPosition(x + 0.5D, y, z + 0.5D);
      }

      entity.isDead = true;
      entity.worldObj.theProfiler.endSection();
      worldserver.resetUpdateEntityTick();
      worldserver1.resetUpdateEntityTick();
      entity.worldObj.theProfiler.endSection();
    }
  }
  protected boolean spawnMob(IBeeGenome genome, IBeeHousing housing) {
    boolean flag = false;

    World w = housing.getWorld();
    int roll = 0;

    for (int i = 0; i < this.spawnChance.length && !flag; ++i) {
      roll = 100 - w.rand.nextInt(100) + 1;
      if (roll < this.spawnChance[i]) {
        flag = true;
        Entity mob = EntityList.createEntityByName(this.entityNames[i], w);
        // .createEntityByName method returns null when spawning a ghast in the overworld
        if (mob == null) return false;
        double[] coords = this.randomMobSpawnCoords(w, genome, housing);

        mob.setPositionAndRotation(coords[0], coords[1], coords[2], w.rand.nextFloat() * 360f, 0f);
        if (mob instanceof EntityLiving) {
          if (((EntityLiving) mob).getCanSpawnHere()) {
            w.spawnEntityInWorld(mob);
          }
        } else {
          w.spawnEntityInWorld(mob);
        }
      }
    }

    return flag;
  }
Ejemplo n.º 4
0
    @Override
    public void readFromNBT(NBTTagCompound tagCom) {
      TEC.idToUsername.clear();
      NBTTagList idUsernameTag = tagCom.getTagList("idUsernames", 10);
      for (int i = 0; i < idUsernameTag.tagCount(); i++) {
        NBTTagCompound tag = idUsernameTag.getCompoundTagAt(i);
        TEC.idToUsername.put(
            UUID.fromString(tagCom.getString("UUID")), tagCom.getString("playerName"));
      }

      TEC.aspectBuffer.clear();
      NBTTagList bufferTag = tagCom.getTagList("bufferTag", 10);
      for (int i = 0; i < bufferTag.tagCount(); i++) {
        NBTTagCompound idedBuffer = bufferTag.getCompoundTagAt(i);
        UUID playerID = UUID.fromString(idedBuffer.getString("playerID"));
        NBTTagList playersBuffer = idedBuffer.getTagList("buffer", 10);
        for (int j = 0; j < playersBuffer.tagCount(); j++) {
          NBTTagCompound bufferEntry = playersBuffer.getCompoundTagAt(j);

          NBTTagCompound scanTag = bufferEntry.getCompoundTag("scan");
          ScanResult scan =
              new ScanResult(
                  scanTag.getByte("type"),
                  scanTag.getInteger("id"),
                  scanTag.getInteger("meta"),
                  EntityList.createEntityFromNBT(
                      scanTag.getCompoundTag("entityTag"), DimensionManager.getWorld(0)),
                  scanTag.getString("phenomena"));

          TEC.addAspect(
              playerID, scan, bufferEntry.getDouble("chance"), bufferEntry.getDouble("percent"));
        }
      }
    }
  private void spawnMob() {
    // TODO Check how many mobs are in the local area and don't spawn if > configurable amount

    @SuppressWarnings("unchecked")
    Iterator<EntityEggInfo> iterator = EntityList.entityEggs.values().iterator();
    List<Integer> ids = new ArrayList<Integer>();
    while (iterator.hasNext()) {
      EntityEggInfo entityegginfo = iterator.next();
      ids.add(entityegginfo.spawnedID);
    }
    // shuffle and pick from IDs
    Collections.shuffle(ids);
    int id = ids.get(0);
    Entity entity = null;
    entity = EntityList.createEntityByID(id, worldObj);

    if (entity != null && entity instanceof EntityLivingBase) {
      EntityLiving entityliving = (EntityLiving) entity;
      entity.setLocationAndAngles(
          xCoord + 2 + MathHelper.randomDoubleInRange(0, xLength - 3),
          yCoord + 1.0,
          zCoord + 2 + MathHelper.randomDoubleInRange(0, zLength - 3),
          net.minecraft.util.MathHelper.wrapAngleTo180_float(worldObj.rand.nextFloat() * 360.0f),
          0.0f);
      worldObj.spawnEntityInWorld(entity);
      entityliving.playLivingSound();
    }
  }
 public TemplateRuleVanillaEntity(World world, Entity entity, int turns, int x, int y, int z) {
   this.mobID = EntityList.getStringFromID(EntityList.getEntityID(entity));
   rotation = (entity.rotationYaw + 90.f * turns) % 360.f;
   float x1, z1;
   x1 = (float) (entity.posX % 1.d);
   z1 = (float) (entity.posZ % 1.d);
   if (x1 < 0) {
     x1++;
   }
   if (z1 < 0) {
     z1++;
   }
   xOffset = BlockTools.rotateFloatX(x1, z1, turns);
   zOffset = BlockTools.rotateFloatZ(x1, z1, turns);
   yOffset = (float) (entity.posY % 1.d);
 }
Ejemplo n.º 7
0
 @Override
 public List<String> getWailaBody(
     Entity entity,
     List<String> currenttip,
     IWailaEntityAccessor accessor,
     IWailaConfigHandler config) {
   Entity currentEntity = accessor.getEntity();
   Class currentEntityClass = currentEntity.getClass();
   if (EntityList.classToStringMapping.containsKey(currentEntityClass)) {
     NBTTagCompound n = accessor.getNBTData();
     // LogHelper.info(n.toString());
     EntityPlayer player = accessor.getPlayer();
     ItemStack holdItemReal = player.getHeldItem();
     String holdItemNameReal = "";
     if (holdItemReal != null) {
       holdItemNameReal = Item.itemRegistry.getNameForObject(holdItemReal.getItem());
     }
     NBTHandler.flag = 1;
     NBTHandler.id = EntityList.getEntityString(currentEntity);
     // currenttip.add(NBTHandler.id);
     List<String> tips = NBTHandler.getTipsFromNBT(n, holdItemNameReal);
     currenttip.addAll(tips);
   }
   return currenttip;
 }
  /// Called when this entity is killed.
  @Override
  protected void dropFewItems(boolean hit, int looting) {
    super.dropFewItems(hit, looting);
    if (hit && (this.rand.nextInt(3) == 0 || this.rand.nextInt(1 + looting) > 0)) {
      this.entityDropItem(
          new ItemStack(
              Items.spawn_egg, 1, EntityList.getEntityID(new EntitySpider(this.worldObj))),
          0.0F);
    }

    if (!this.worldObj.isRemote) {
      EntityBabySpider baby = null;
      for (int i = this.babies; i-- > 0; ) {
        baby = new EntityBabySpider(this.worldObj);
        baby.copyLocationAndAnglesFrom(this);
        baby.setTarget(this.getEntityToAttack());
        baby.onSpawnWithEgg((IEntityLivingData) null);
        this.worldObj.spawnEntityInWorld(baby);
      }
      if (baby != null) {
        this.worldObj.playSoundAtEntity(
            baby, "random.pop", 1.0F, 2.0F / (this.rand.nextFloat() * 0.4F + 0.8F));
        baby.spawnExplosionParticle();
      }
    }
  }
Ejemplo n.º 9
0
  @Override
  public boolean itemInteractionForEntity(
      ItemStack item, EntityPlayer player, EntityLivingBase entity) {

    if (entity.worldObj.isRemote) {
      return false;
    }
    boolean isCreative = player != null && player.capabilities.isCreativeMode;
    if (containsSoul(item) && !isCreative) {
      return false;
    }
    if (entity instanceof EntityPlayer) {
      return false;
    }

    String entityId = EntityList.getEntityString(entity);
    if (isBlackListed(entityId)) {
      return false;
    }

    if (!Config.soulVesselCapturesBosses && entity instanceof IBossDisplayData) {
      return false;
    }

    NBTTagCompound root = new NBTTagCompound();
    root.setString("id", entityId);
    entity.writeToNBT(root);

    ItemStack capturedMobVessel = new ItemStack(EnderIO.itemSoulVessel);
    capturedMobVessel.setTagCompound(root);
    setDisplayNameFromEntityNameTag(capturedMobVessel, entity);

    player.swingItem();
    if (!isCreative) {
      entity.setDead();
      if (entity.isDead) {
        item.stackSize--;
        if (!player.inventory.addItemStackToInventory(capturedMobVessel)) {
          entity.worldObj.spawnEntityInWorld(
              new EntityItem(
                  entity.worldObj, entity.posX, entity.posY, entity.posZ, capturedMobVessel));
        }
        player.setCurrentItemOrArmor(0, item);
        ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
        return true;
      }
    } else {
      if (!player.inventory.addItemStackToInventory(
          capturedMobVessel)) // Inventory full, drop it in the world!
      {
        entity.worldObj.spawnEntityInWorld(
            new EntityItem(
                entity.worldObj, entity.posX, entity.posY, entity.posZ, capturedMobVessel));
      }
      ((EntityPlayerMP) player).sendContainerToPlayer(player.inventoryContainer);
      return true;
    }
    return false;
  }
Ejemplo n.º 10
0
 public static void func_151178_a() {
   func_151181_c();
   initStats();
   func_151179_e();
   initCraftableStats();
   AchievementList.init();
   EntityList.func_151514_a();
 }
Ejemplo n.º 11
0
  public static void addDungeonMobs(Collection<String> names) {
    List<String> list = EntityList.getEntityNameList();

    for (String name : names) {
      if (!Strings.isNullOrEmpty(name) && list.contains(name)) {
        dungeonMobs.add(name);
      }
    }
  }
Ejemplo n.º 12
0
  public Entity func_98281_h() {
    if (this.field_98291_j == null) {
      Entity var1 = EntityList.createEntityByName(this.getEntityNameToSpawn(), (World) null);
      var1 = this.func_98265_a(var1);
      this.field_98291_j = var1;
    }

    return this.field_98291_j;
  }
 @Override
 public void handlePlacement(World world, int turns, int x, int y, int z) {
   Entity e = EntityList.createEntityByName(mobID, world);
   float x1 = BlockTools.rotateFloatX(xOffset, zOffset, turns);
   float z1 = BlockTools.rotateFloatZ(xOffset, zOffset, turns);
   float yaw = (rotation + 90.f * turns) % 360.f;
   e.setPosition(x + x1, y + yOffset, z + z1);
   e.rotationYaw = yaw;
   world.spawnEntityInWorld(e);
 }
Ejemplo n.º 14
0
  public Entity func_98265_a(Entity p_98265_1_) {
    if (this.getRandomMinecart() != null) {
      NBTTagCompound var2 = new NBTTagCompound();
      p_98265_1_.writeToNBTOptional(var2);
      Iterator var3 = this.getRandomMinecart().field_98222_b.func_150296_c().iterator();

      while (var3.hasNext()) {
        String var4 = (String) var3.next();
        NBTBase var5 = this.getRandomMinecart().field_98222_b.getTag(var4);
        var2.setTag(var4, var5.copy());
      }

      p_98265_1_.readFromNBT(var2);

      if (p_98265_1_.worldObj != null) {
        p_98265_1_.worldObj.spawnEntityInWorld(p_98265_1_);
      }

      NBTTagCompound var11;

      for (Entity var10 = p_98265_1_; var2.func_150297_b("Riding", 10); var2 = var11) {
        var11 = var2.getCompoundTag("Riding");
        Entity var12 = EntityList.createEntityByName(var11.getString("id"), p_98265_1_.worldObj);

        if (var12 != null) {
          NBTTagCompound var6 = new NBTTagCompound();
          var12.writeToNBTOptional(var6);
          Iterator var7 = var11.func_150296_c().iterator();

          while (var7.hasNext()) {
            String var8 = (String) var7.next();
            NBTBase var9 = var11.getTag(var8);
            var6.setTag(var8, var9.copy());
          }

          var12.readFromNBT(var6);
          var12.setLocationAndAngles(
              var10.posX, var10.posY, var10.posZ, var10.rotationYaw, var10.rotationPitch);

          if (p_98265_1_.worldObj != null) {
            p_98265_1_.worldObj.spawnEntityInWorld(var12);
          }

          var10.mountEntity(var12);
        }

        var10 = var12;
      }
    } else if (p_98265_1_ instanceof EntityLivingBase && p_98265_1_.worldObj != null) {
      ((EntityLiving) p_98265_1_).onSpawnWithEgg((IEntityLivingData) null);
      this.getSpawnerWorld().spawnEntityInWorld(p_98265_1_);
    }

    return p_98265_1_;
  }
  @SideOnly(Side.CLIENT)
  public Entity getEntityForRenderer() {
    if (this.renderedEntity == null) {
      Entity entity = EntityList.createEntityByName(this.getEntityNameToSpawn(), getSpawnerWorld());
      entity = this.spawnEntity(entity);
      if (entity instanceof EntitySkeleton) ((EntitySkeleton) entity).setSkeletonType(skeletonType);
      this.renderedEntity = entity;
    }

    return this.renderedEntity;
  }
Ejemplo n.º 16
0
 public static StatBase func_151176_b(EntityList.EntityEggInfo p_151176_0_) {
   String var1 = EntityList.getStringFromID(p_151176_0_.spawnedID);
   return var1 == null
       ? null
       : (new StatBase(
               "stat.entityKilledBy." + var1,
               new ChatComponentTranslation(
                   "stat.entityKilledBy",
                   new Object[] {
                     new ChatComponentTranslation("entity." + var1 + ".name", new Object[0])
                   })))
           .registerStat();
 }
Ejemplo n.º 17
0
  public ItemStack createVesselWithEntity(Entity ent) {

    String entityId = EntityList.getEntityString(ent);
    NBTTagCompound root = new NBTTagCompound();
    root.setString("id", entityId);
    ent.writeToNBT(root);

    ItemStack res = new ItemStack(this);
    res.stackTagCompound = root;

    setDisplayNameFromEntityNameTag(res, ent);
    return res;
  }
  /** Called when the mob's health reaches 0. */
  public void onDeath(DamageSource p_70645_1_) {
    if (ForgeHooks.onLivingDeath(this, p_70645_1_)) return;
    this.mcServer.getConfigurationManager().sendChatMsg(this.getCombatTracker().func_151521_b());

    if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) {
      captureDrops = true;
      capturedDrops.clear();

      this.inventory.dropAllItems();

      captureDrops = false;
      PlayerDropsEvent event =
          new PlayerDropsEvent(this, p_70645_1_, capturedDrops, recentlyHit > 0);
      if (!MinecraftForge.EVENT_BUS.post(event)) {
        for (EntityItem item : capturedDrops) {
          joinEntityItemWithWorld(item);
        }
      }
    }

    Collection collection =
        this.worldObj.getScoreboard().func_96520_a(IScoreObjectiveCriteria.deathCount);
    Iterator iterator = collection.iterator();

    while (iterator.hasNext()) {
      ScoreObjective scoreobjective = (ScoreObjective) iterator.next();
      Score score =
          this.getWorldScoreboard()
              .getValueFromObjective(this.getCommandSenderName(), scoreobjective);
      score.func_96648_a();
    }

    EntityLivingBase entitylivingbase = this.func_94060_bK();

    if (entitylivingbase != null) {
      int i = EntityList.getEntityID(entitylivingbase);
      EntityList.EntityEggInfo entityegginfo =
          (EntityList.EntityEggInfo) EntityList.entityEggs.get(Integer.valueOf(i));

      if (entityegginfo != null) {
        this.addStat(entityegginfo.field_151513_e, 1);
      }

      entitylivingbase.addToPlayerScore(this, this.scoreValue);
    }

    this.addStat(StatList.deathsStat, 1);
    this.getCombatTracker().func_94549_h();
  }
Ejemplo n.º 19
0
  @Override
  public boolean itemInteractionForEntity(
      ItemStack item, EntityPlayer player, EntityLivingBase entity) {

    player.triggerAchievement(ContentHandler.achDataChecker);

    if (player.worldObj.isRemote) return false;

    String outputString =
        StatCollector.translateToLocal("chat.colorfulmobs.name")
            + ": "
            + EntityList.getEntityString(entity)
            + " ";

    if (ColorProperties.hasProperties(entity)) {

      ColorProperties obj = ColorProperties.getProperties(entity);
      outputString =
          outputString
              + EnumChatFormatting.RED
              + StatCollector.translateToLocal("chat.colorfulmobs.red")
              + ": "
              + (int) (obj.getColorObj().getRed() * 255)
              + " "
              + EnumChatFormatting.GREEN
              + StatCollector.translateToLocal("chat.colorfulmobs.green")
              + ": "
              + (int) (obj.getColorObj().getGreen() * 255)
              + " "
              + EnumChatFormatting.BLUE
              + StatCollector.translateToLocal("chat.colorfulmobs.blue")
              + ": "
              + (int) (obj.getColorObj().getBlue() * 255)
              + " "
              + EnumChatFormatting.RESET
              + StatCollector.translateToLocal("chat.colorfulmobs.transparency")
              + ": "
              + (100 - (int) (obj.getColorObj().getAlpha() * 100))
              + "%";
      obj.sync();
    }

    player.addChatMessage(new ChatComponentText(outputString));
    return true;
  }
Ejemplo n.º 20
0
    protected void drawSlot(
        int p_180791_1_,
        int p_180791_2_,
        int p_180791_3_,
        int p_180791_4_,
        int p_180791_5_,
        int p_180791_6_) {
      EntityList.EntityEggInfo var7 =
          (EntityList.EntityEggInfo) this.field_148222_l.get(p_180791_1_);
      String var8 =
          Translator.format(
              "entity." + EntityList.getStringFromID(var7.spawnedID) + ".name", new Object[0]);
      int var9 = GuiStats.this.field_146546_t.writeStat(var7.field_151512_d);
      int var10 = GuiStats.this.field_146546_t.writeStat(var7.field_151513_e);
      String var11 =
          Translator.format("stat.entityKills", new Object[] {Integer.valueOf(var9), var8});
      String var12 =
          Translator.format("stat.entityKilledBy", new Object[] {var8, Integer.valueOf(var10)});

      if (var9 == 0) {
        var11 = Translator.format("stat.entityKills.none", new Object[] {var8});
      }

      if (var10 == 0) {
        var12 = Translator.format("stat.entityKilledBy.none", new Object[] {var8});
      }

      GuiStats.this.drawString(
          GuiStats.this.fontRenderer, var8, p_180791_2_ + 2 - 10, p_180791_3_ + 1, 16777215);
      GuiStats.this.drawString(
          GuiStats.this.fontRenderer,
          var11,
          p_180791_2_ + 2,
          p_180791_3_ + 1 + GuiStats.this.fontRenderer.FONT_HEIGHT,
          var9 == 0 ? 6316128 : 9474192);
      GuiStats.this.drawString(
          GuiStats.this.fontRenderer,
          var12,
          p_180791_2_ + 2,
          p_180791_3_ + 1 + GuiStats.this.fontRenderer.FONT_HEIGHT * 2,
          var10 == 0 ? 6316128 : 9474192);
    }
Ejemplo n.º 21
0
 public static void registerGlobalEntityID(Class <? extends Entity > entityClass, String entityName, int id, int backgroundEggColour, int foregroundEggColour)
 {
     if (EntityList.classToStringMapping.containsKey(entityClass))
     {
         ModContainer activeModContainer = Loader.instance().activeModContainer();
         String modId = "unknown";
         if (activeModContainer != null)
         {
             modId = activeModContainer.getModId();
         }
         else
         {
             FMLLog.severe("There is a rogue mod failing to register entities from outside the context of mod loading. This is incredibly dangerous and should be stopped.");
         }
         FMLLog.warning("The mod %s tried to register the entity class %s which was already registered - if you wish to override default naming for FML mod entities, register it here first", modId, entityClass);
         return;
     }
     instance().validateAndClaimId(id);
     EntityList.addMapping(entityClass, entityName, id, backgroundEggColour, foregroundEggColour);
 }
Ejemplo n.º 22
0
  public ItemStack compact(EntityLiving entity) {
    int id = EntityList.getEntityID(entity);
    ItemStack holder = new ItemStack(CompactMobsItems.fullMobHolder, 1);
    NBTTagCompound nbttag = holder.stackTagCompound;
    if (nbttag == null) {
      nbttag = new NBTTagCompound();
    }
    nbttag.setInteger("entityId", id);

    if (entity instanceof EntityAgeable) {
      EntityAgeable entityAge = (EntityAgeable) entity;
      nbttag.setInteger("entityGrowingAge", entityAge.getGrowingAge());
    }

    if (entity instanceof EntitySheep) {
      EntitySheep entitySheep = (EntitySheep) entity;
      nbttag.setBoolean("entitySheared", entitySheep.getSheared());
      nbttag.setInteger("entityColor", entitySheep.getFleeceColor());
    }

    if (CompactMobsCore.instance.useFullTagCompound) {
      NBTTagCompound entityTags = new NBTTagCompound();

      NBTTagCompound var2 = new NBTTagCompound();
      entity.writeToNBT(var2);

      nbttag.setCompoundTag("entityTags", var2);
      CompactMobsCore.instance.cmLog.info(var2.toString());
    }

    String name = entity.getEntityName();
    nbttag.setString("name", name);
    holder.setItemDamage(id);

    holder.setTagCompound(nbttag);
    entity.worldObj.removeEntity(entity);
    return holder;
  }
Ejemplo n.º 23
0
  /** Draws the hover event specified by the given chat component */
  protected void handleComponentHover(
      IChatComponent p_175272_1_, int p_175272_2_, int p_175272_3_) {
    if (p_175272_1_ != null && p_175272_1_.getChatStyle().getChatHoverEvent() != null) {
      HoverEvent hoverevent = p_175272_1_.getChatStyle().getChatHoverEvent();

      if (hoverevent.getAction() == HoverEvent.Action.SHOW_ITEM) {
        ItemStack itemstack = null;

        try {
          NBTBase nbtbase = JsonToNBT.getTagFromJson(hoverevent.getValue().getUnformattedText());

          if (nbtbase instanceof NBTTagCompound) {
            itemstack = ItemStack.loadItemStackFromNBT((NBTTagCompound) nbtbase);
          }
        } catch (NBTException var11) {;
        }

        if (itemstack != null) {
          this.renderToolTip(itemstack, p_175272_2_, p_175272_3_);
        } else {
          this.drawCreativeTabHoveringText(
              EnumChatFormatting.RED + "Invalid Item!", p_175272_2_, p_175272_3_);
        }
      } else if (hoverevent.getAction() == HoverEvent.Action.SHOW_ENTITY) {
        if (this.mc.gameSettings.advancedItemTooltips) {
          try {
            NBTBase nbtbase1 = JsonToNBT.getTagFromJson(hoverevent.getValue().getUnformattedText());

            if (nbtbase1 instanceof NBTTagCompound) {
              List<String> list1 = Lists.<String>newArrayList();
              NBTTagCompound nbttagcompound = (NBTTagCompound) nbtbase1;
              list1.add(nbttagcompound.getString("name"));

              if (nbttagcompound.hasKey("type", 8)) {
                String s = nbttagcompound.getString("type");
                list1.add("Type: " + s + " (" + EntityList.getIDFromString(s) + ")");
              }

              list1.add(nbttagcompound.getString("id"));
              this.drawHoveringText(list1, p_175272_2_, p_175272_3_);
            } else {
              this.drawCreativeTabHoveringText(
                  EnumChatFormatting.RED + "Invalid Entity!", p_175272_2_, p_175272_3_);
            }
          } catch (NBTException var10) {
            this.drawCreativeTabHoveringText(
                EnumChatFormatting.RED + "Invalid Entity!", p_175272_2_, p_175272_3_);
          }
        }
      } else if (hoverevent.getAction() == HoverEvent.Action.SHOW_TEXT) {
        this.drawHoveringText(
            NEWLINE_SPLITTER.splitToList(hoverevent.getValue().getFormattedText()),
            p_175272_2_,
            p_175272_3_);
      } else if (hoverevent.getAction() == HoverEvent.Action.SHOW_ACHIEVEMENT) {
        StatBase statbase = StatList.getOneShotStat(hoverevent.getValue().getUnformattedText());

        if (statbase != null) {
          IChatComponent ichatcomponent = statbase.getStatName();
          IChatComponent ichatcomponent1 =
              new ChatComponentTranslation(
                  "stats.tooltip.type." + (statbase.isAchievement() ? "achievement" : "statistic"),
                  new Object[0]);
          ichatcomponent1.getChatStyle().setItalic(Boolean.valueOf(true));
          String s1 =
              statbase instanceof Achievement ? ((Achievement) statbase).getDescription() : null;
          List<String> list =
              Lists.newArrayList(
                  new String[] {
                    ichatcomponent.getFormattedText(), ichatcomponent1.getFormattedText()
                  });

          if (s1 != null) {
            list.addAll(this.fontRendererObj.listFormattedStringToWidth(s1, 150));
          }

          this.drawHoveringText(list, p_175272_2_, p_175272_3_);
        } else {
          this.drawCreativeTabHoveringText(
              EnumChatFormatting.RED + "Invalid statistic/achievement!", p_175272_2_, p_175272_3_);
        }
      }

      GlStateManager.disableLighting();
    }
  }
Ejemplo n.º 24
0
  @Override
  public boolean onItemUse(
      ItemStack itemstack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float xOffset,
      float yOffset,
      float zOffset) {

    if (world.isRemote) {
      return true;
    }
    if (!containsSoul(itemstack)) {
      return false;
    }
    if (player == null) {
      return false;
    }

    Entity mob;
    NBTTagCompound root = itemstack.stackTagCompound;
    if (root.hasKey("isStub")) {
      String entityId = root.getString("id");
      mob = EntityList.createEntityByName(entityId, world);
    } else {
      mob = EntityList.createEntityFromNBT(root, world);
    }
    if (mob == null) {
      return true;
    }
    mob.readFromNBT(root);

    Block blk = world.getBlock(x, y, z);
    double spawnX = x + Facing.offsetsXForSide[side] + 0.5;
    double spawnY = y + Facing.offsetsYForSide[side];
    double spawnZ = z + Facing.offsetsZForSide[side] + 0.5;
    if (side == ForgeDirection.UP.ordinal()
        && (blk instanceof BlockFence || blk instanceof BlockWall)) {
      spawnY += 0.5;
    }
    mob.setLocationAndAngles(spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0);

    boolean spaceClear =
        world.checkNoEntityCollision(mob.boundingBox)
            && world.getCollidingBoundingBoxes(mob, mob.boundingBox).isEmpty();
    if (!spaceClear) {
      return false;
    }

    if (itemstack.hasDisplayName() && mob instanceof EntityLiving) {
      ((EntityLiving) mob).setCustomNameTag(itemstack.getDisplayName());
    }

    world.spawnEntityInWorld(mob);
    if (mob instanceof EntityLiving) {
      ((EntityLiving) mob).playLivingSound();
    }

    Entity riddenByEntity = mob.riddenByEntity;
    while (riddenByEntity != null) {
      riddenByEntity.setLocationAndAngles(
          spawnX, spawnY, spawnZ, world.rand.nextFloat() * 360.0F, 0.0F);
      world.spawnEntityInWorld(riddenByEntity);
      if (riddenByEntity instanceof EntityLiving) {
        ((EntityLiving) riddenByEntity).playLivingSound();
      }
      riddenByEntity = riddenByEntity.riddenByEntity;
    }

    if (!player.capabilities.isCreativeMode) {
      if (itemstack.stackSize > 1) {
        itemstack.stackSize--;
        player.inventory.addItemStackToInventory(new ItemStack(this));
        player.inventoryContainer.detectAndSendChanges();
      } else {
        itemstack.setTagCompound(null);
      }
    }

    return true;
  }
  public void spawnGuildMembers(float f, float f1, float f2) {
    world = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(0);
    f += 0.5F;
    f1 += 0.0F;
    f2 += 0.5F;

    EntityLiving entityliving = new EntityGuildMaster(world);
    EntityLiving entityliving1 = new EntityGuildMember(world);
    EntityLiving entityliving2 = new EntityGuildMember(world);
    EntityLiving entityliving3 = new EntityGuildMember(world);
    EntityLiving entityliving4 = new EntityGuildMember(world);
    EntityLiving entityliving5 = new EntityGuildMember(world);
    EntityLiving entityliving6 = new EntityGuildMember(world);
    EntityLiving entityliving7 = new EntityGuildMember(world);
    EntityLiving entityliving8 = new EntityGuildMember(world);
    EntityLiving entityliving9 = new EntityGuildMember(world);
    EntityLiving entityliving10 = new EntityGuildMember(world);
    EntityLiving entityliving11 = new EntityGuildMember(world);
    EntityLiving entityliving12 = new EntityGuildMember(world);
    EntityLiving entityliving13 = new EntityGuildMember(world);
    EntityLiving entityliving14 = new EntityGuildMember(world);
    EntityLiving entityliving15 = new EntityGuildMember(world);
    EntityLiving entityliving16 = new EntityGuildMember(world);
    EntityLiving entityliving17 = new EntityGuildMember(world);
    EntityLiving entityliving18 = new EntityGuildMember(world);
    EntityLiving entityliving19 = new EntityGuildMember(world);
    EntityLiving entityliving20 = new EntityGuildMember(world);
    EntityLiving entityliving21 = new EntityGuildMember(world);
    EntityLiving entityliving22 = new EntityGuildMember(world);
    EntityLiving entityliving23 = new EntityGuildMember(world);
    EntityLiving entityliving24 = new EntityGuildMember(world);
    EntityLiving entityliving25 = new EntityGuildMember(world);
    EntityLiving entityliving26 = new EntityGuildMember(world);
    EntityLiving entityliving27 = new EntityGuildMember(world);
    EntityLiving entityliving28 = new EntityGuildMember(world);
    EntityLiving entityliving29 = new EntityGuildMember(world);
    EntityLiving entityliving30 = new EntityFarmerKeeper(world);
    EntityLiving entityliving31 = new EntityWeaponKeeper(world);

    EntityList.createEntityByName("GuildMaster", world);
    entityliving.setLocationAndAngles(f + 34F, f1 + 16F, f2 + 66F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving);

    EntityList.createEntityByName("GuildMember", world);
    entityliving1.setLocationAndAngles((double) f + 12.5D, f1 + 11F, f2 + 68F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving1);

    EntityList.createEntityByName("GuildMember", world);
    entityliving2.setLocationAndAngles(f + 12F, f1 + 11F, f2 + 40F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving2);

    EntityList.createEntityByName("GuildMember", world);
    entityliving3.setLocationAndAngles(f + 28F, f1 + 2.0F, f2 + 42F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving3);

    EntityList.createEntityByName("GuildMember", world);
    entityliving4.setLocationAndAngles(f + 10F, f1 + 11F, f2 + 60F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving4);

    EntityList.createEntityByName("GuildMember", world);
    entityliving5.setLocationAndAngles(f + 11F, f1 + 18F, f2 + 52F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving5);

    EntityList.createEntityByName("GuildMember", world);
    entityliving6.setLocationAndAngles(f + 11F, f1 + 18F, f2 + 57F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving6);

    EntityList.createEntityByName("GuildMember", world);
    entityliving7.setLocationAndAngles(f + 16F, f1 + 11F, f2 + 48F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving7);

    EntityList.createEntityByName("GuildMember", world);
    entityliving8.setLocationAndAngles(f + 16F, f1 + 18F, f2 + 43F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving8);

    EntityList.createEntityByName("GuildMember", world);
    entityliving9.setLocationAndAngles(f + 16F, f1 + 18F, f2 + 61F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving9);

    EntityList.createEntityByName("GuildMember", world);
    entityliving10.setLocationAndAngles(f + 19F, f1 + 11F, f2 + 46F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving10);

    EntityList.createEntityByName("GuildMember", world);
    entityliving11.setLocationAndAngles(f + 19F, f1 + 11F, f2 + 66F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving11);

    EntityList.createEntityByName("GuildMember", world);
    entityliving12.setLocationAndAngles(f + 20F, f1 + 10F, f2 + 26F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving12);

    EntityList.createEntityByName("GuildMember", world);
    entityliving13.setLocationAndAngles(f + 20F, f1 + 11F, f2 + 56F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving13);

    EntityList.createEntityByName("GuildMember", world);
    entityliving14.setLocationAndAngles(f + 20F, f1 + 18F, f2 + 40F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving14);

    EntityList.createEntityByName("GuildMember", world);
    entityliving15.setLocationAndAngles(f + 24F, f1 + 8F, f2 + 66F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving15);

    EntityList.createEntityByName("GuildMember", world);
    entityliving16.setLocationAndAngles(f + 25F, f1 + 10F, f2 + 15F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving16);

    EntityList.createEntityByName("GuildMember", world);
    entityliving17.setLocationAndAngles(f + 28F, f1 + 8F, f2 + 66F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving17);

    EntityList.createEntityByName("GuildMember", world);
    entityliving18.setLocationAndAngles(f + 31F, f1 + 2.0F, f2 + 32F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving18);

    EntityList.createEntityByName("GuildMember", world);
    entityliving19.setLocationAndAngles(f + 32F, f1 + 9F, f2 + 38F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving19);

    EntityList.createEntityByName("GuildMember", world);
    entityliving20.setLocationAndAngles(f + 34F, f1 + 8F, f2 + 66F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving20);

    EntityList.createEntityByName("GuildMember", world);
    entityliving21.setLocationAndAngles(f + 41F, f1 + 9F, f2 + 41F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving21);

    EntityList.createEntityByName("GuildMember", world);
    entityliving22.setLocationAndAngles(f + 41F, f1 + 9F, f2 + 59F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving22);

    EntityList.createEntityByName("GuildMember", world);
    entityliving23.setLocationAndAngles(f + 42F, f1 + 2.0F, f2 + 23F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving23);

    EntityList.createEntityByName("GuildMember", world);
    entityliving24.setLocationAndAngles(f + 43F, f1 + 10F, f2 + 13F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving24);

    EntityList.createEntityByName("GuildMember", world);
    entityliving25.setLocationAndAngles(f + 50F, f1 + 2.0F, f2 + 36F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving25);

    EntityList.createEntityByName("GuildMember", world);
    entityliving26.setLocationAndAngles(f + 50F, f1 + 3F, f2 + 54F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving26);

    EntityList.createEntityByName("GuildMember", world);
    entityliving27.setLocationAndAngles(f + 57F, f1 + 12F, f2 + 39F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving27);

    EntityList.createEntityByName("GuildMember", world);
    entityliving28.setLocationAndAngles(f + 70F, f1 + 17F, f2 + 48F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving28);

    EntityList.createEntityByName("GuildMember", world);
    entityliving29.setLocationAndAngles(f + 70F, f1 + 25F, f2 + 45F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving29);

    EntityList.createEntityByName("Farmer", world);
    entityliving30.setLocationAndAngles(f + 54F, f1 + 2.0F, f2 + 50F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving30);

    EntityList.createEntityByName("WeaponKeeper", world);
    entityliving31.setLocationAndAngles(f + 49F, f1 + 3F, f2 + 25F, 0.0F, 0.0F);
    world.spawnEntityInWorld(entityliving31);
  }
 // Mob Generation
 public static int getUniqueEntityId() {
   do {
     startEntityId++;
   } while (EntityList.getStringFromID(startEntityId) != null);
   return startEntityId++;
 }
  public void initializeConnectionToPlayer(NetworkManager netManager, EntityPlayerMP playerIn) {
    GameProfile var3 = playerIn.getGameProfile();
    PlayerProfileCache var4 = this.mcServer.getPlayerProfileCache();
    GameProfile var5 = var4.func_152652_a(var3.getId());
    String var6 = var5 == null ? var3.getName() : var5.getName();
    var4.func_152649_a(var3);
    NBTTagCompound var7 = this.readPlayerDataFromFile(playerIn);
    playerIn.setWorld(this.mcServer.worldServerForDimension(playerIn.dimension));
    playerIn.theItemInWorldManager.setWorld((WorldServer) playerIn.worldObj);
    String var8 = "local";

    if (netManager.getRemoteAddress() != null) {
      var8 = netManager.getRemoteAddress().toString();
    }

    logger.info(
        playerIn.getName()
            + "["
            + var8
            + "] logged in with entity id "
            + playerIn.getEntityId()
            + " at ("
            + playerIn.posX
            + ", "
            + playerIn.posY
            + ", "
            + playerIn.posZ
            + ")");
    WorldServer var9 = this.mcServer.worldServerForDimension(playerIn.dimension);
    WorldInfo var10 = var9.getWorldInfo();
    BlockPos var11 = var9.getSpawnPoint();
    this.func_72381_a(playerIn, (EntityPlayerMP) null, var9);
    NetHandlerPlayServer var12 = new NetHandlerPlayServer(this.mcServer, netManager, playerIn);
    var12.sendPacket(
        new S01PacketJoinGame(
            playerIn.getEntityId(),
            playerIn.theItemInWorldManager.getGameType(),
            var10.isHardcoreModeEnabled(),
            var9.provider.getDimensionId(),
            var9.getDifficulty(),
            this.getMaxPlayers(),
            var10.getTerrainType(),
            var9.getGameRules().getGameRuleBooleanValue("reducedDebugInfo")));
    var12.sendPacket(
        new S3FPacketCustomPayload(
            "MC|Brand",
            (new PacketBuffer(Unpooled.buffer()))
                .writeString(this.getServerInstance().getServerModName())));
    var12.sendPacket(
        new S41PacketServerDifficulty(var10.getDifficulty(), var10.isDifficultyLocked()));
    var12.sendPacket(new S05PacketSpawnPosition(var11));
    var12.sendPacket(new S39PacketPlayerAbilities(playerIn.capabilities));
    var12.sendPacket(new S09PacketHeldItemChange(playerIn.inventory.currentItem));
    playerIn.getStatFile().func_150877_d();
    playerIn.getStatFile().func_150884_b(playerIn);
    this.func_96456_a((ServerScoreboard) var9.getScoreboard(), playerIn);
    this.mcServer.refreshStatusNextTick();
    ChatComponentTranslation var13;

    if (!playerIn.getName().equalsIgnoreCase(var6)) {
      var13 =
          new ChatComponentTranslation(
              "multiplayer.player.joined.renamed", new Object[] {playerIn.getDisplayName(), var6});
    } else {
      var13 =
          new ChatComponentTranslation(
              "multiplayer.player.joined", new Object[] {playerIn.getDisplayName()});
    }

    var13.getChatStyle().setColor(EnumChatFormatting.YELLOW);
    this.sendChatMsg(var13);
    this.playerLoggedIn(playerIn);
    var12.setPlayerLocation(
        playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch);
    this.updateTimeAndWeatherForPlayer(playerIn, var9);

    if (this.mcServer.getResourcePackUrl().length() > 0) {
      playerIn.func_175397_a(
          this.mcServer.getResourcePackUrl(), this.mcServer.getResourcePackHash());
    }

    Iterator var14 = playerIn.getActivePotionEffects().iterator();

    while (var14.hasNext()) {
      PotionEffect var15 = (PotionEffect) var14.next();
      var12.sendPacket(new S1DPacketEntityEffect(playerIn.getEntityId(), var15));
    }

    playerIn.addSelfToInternalCraftingInventory();

    if (var7 != null && var7.hasKey("Riding", 10)) {
      Entity var16 = EntityList.createEntityFromNBT(var7.getCompoundTag("Riding"), var9);

      if (var16 != null) {
        var16.forceSpawn = true;
        var9.spawnEntityInWorld(var16);
        playerIn.mountEntity(var16);
        var16.forceSpawn = false;
      }
    }
  }
Ejemplo n.º 28
0
  public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr) {
    if (par2ArrayOfStr.length >= 1) {
      String var3 = par2ArrayOfStr[0];
      double var4 = (double) par1ICommandSender.getCommandSenderPosition().posX + 0.5D;
      double var6 = (double) par1ICommandSender.getCommandSenderPosition().posY;
      double var8 = (double) par1ICommandSender.getCommandSenderPosition().posZ + 0.5D;

      if (par2ArrayOfStr.length >= 4) {
        var4 = func_110666_a(par1ICommandSender, var4, par2ArrayOfStr[1]);
        var6 = func_110666_a(par1ICommandSender, var6, par2ArrayOfStr[2]);
        var8 = func_110666_a(par1ICommandSender, var8, par2ArrayOfStr[3]);
      }

      World var10 = par1ICommandSender.getEntityWorld();

      if (!var10.blockExists((int) var4, (int) var6, (int) var8)) {
        notifyAdmins(par1ICommandSender, "commands.summon.outOfWorld", new Object[0]);
      } else {
        NBTTagCompound var11 = new NBTTagCompound();
        boolean var12 = false;

        if (par2ArrayOfStr.length >= 5) {
          IChatComponent var13 = func_147178_a(par1ICommandSender, par2ArrayOfStr, 4);

          try {
            NBTBase var14 = JsonToNBT.func_150315_a(var13.getUnformattedText());

            if (!(var14 instanceof NBTTagCompound)) {
              notifyAdmins(
                  par1ICommandSender, "commands.summon.tagError", new Object[] {"Not a valid tag"});
              return;
            }

            var11 = (NBTTagCompound) var14;
            var12 = true;
          } catch (NBTException var17) {
            notifyAdmins(
                par1ICommandSender, "commands.summon.tagError", new Object[] {var17.getMessage()});
            return;
          }
        }

        var11.setString("id", var3);
        Entity var18 = EntityList.createEntityFromNBT(var11, var10);

        if (var18 != null) {
          var18.setLocationAndAngles(var4, var6, var8, var18.rotationYaw, var18.rotationPitch);

          if (!var12 && var18 instanceof EntityLiving) {
            ((EntityLiving) var18).onSpawnWithEgg((IEntityLivingData) null);
          }

          var10.spawnEntityInWorld(var18);
          Entity var19 = var18;

          for (NBTTagCompound var15 = var11;
              var15.func_150297_b("Riding", 10);
              var15 = var15.getCompoundTag("Riding")) {
            Entity var16 = EntityList.createEntityFromNBT(var15.getCompoundTag("Riding"), var10);

            if (var16 != null) {
              var16.setLocationAndAngles(var4, var6, var8, var16.rotationYaw, var16.rotationPitch);
              var10.spawnEntityInWorld(var16);
              var19.mountEntity(var16);
            }

            var19 = var16;
          }

          notifyAdmins(par1ICommandSender, "commands.summon.success", new Object[0]);
        } else {
          notifyAdmins(par1ICommandSender, "commands.summon.failed", new Object[0]);
        }
      }
    } else {
      throw new WrongUsageException("commands.summon.usage", new Object[0]);
    }
  }
Ejemplo n.º 29
0
 protected String[] func_147182_d() {
   return (String[]) EntityList.func_151515_b().toArray(new String[0]);
 }
Ejemplo n.º 30
0
 @Override
 protected Entity getNewEntity(World world, Random random, int count) {
   return EntityList.createEntityByID(entityId, world);
 }