Ejemplo n.º 1
0
 @Override
 public void writeEntityToNBT(NBTTagCompound nbt) {
   super.writeEntityToNBT(nbt);
   nbt.setInteger("spiderType", spiderType.getId());
   nbt.setInteger("abilityCounter", abilityCounter);
   nbt.setInteger("abilityThreshold", abilityThreshold);
   nbt.setInteger("killsUntilLevelUp", killsUntilLevelUp);
   nbt.setLong("ownerMSB", owner.getMostSignificantBits());
   nbt.setLong("ownerLSB", owner.getLeastSignificantBits());
   nbt.setTag("inventory", inventory.saveInventoryToNBT());
 }
Ejemplo n.º 2
0
 @Override
 public void readEntityFromNBT(NBTTagCompound nbt) {
   super.readEntityFromNBT(nbt);
   spiderType = EnumSpiderType.byId(nbt.getInteger("spiderType"));
   abilityCounter = nbt.getInteger("abilityCounter");
   abilityThreshold = nbt.getInteger("abilityThreshold");
   killsUntilLevelUp = nbt.getInteger("killsUntilLevelUp");
   owner = new UUID(nbt.getLong("ownerMSB"), nbt.getLong("ownerLSB"));
   final NBTTagList tagList = nbt.getTagList("inventory", 10);
   inventory.loadInventoryFromNBT(tagList);
 }
Ejemplo n.º 3
0
  @Override
  public void onUpdate() {
    super.onUpdate();
    updateEntityAttributes();
    updateAbility();
    setHitboxSize();

    if (!worldObj.isRemote) {
      setBesideClimbableBlock(isCollidedHorizontally);

      if (getHealth() > 0) {
        // Since attributes can change over this spider's life time, consistently update the
        // attributes.
        updateEntityAttributes();
      }

      // Always try to follow the owner first.
      if (!tryFollowOwnerPlayer()) {
        // If we can't, then attack our target if we have one.
        if (target != null && !target.isDead) {
          attackEntity(target, 3.5F);
        }

        // Or if our target is now dead, reset the target and register it as a kill.
        else if (target != null && target.isDead) {
          registerKill();
          target = null;
        } else // With no target, find one.
        {
          target = findEntityToAttack();
        }

        // Move to the spider rod inline with attacking to keep the spider in range of the rod
        // but still be able to defend itself.
        tryMoveToSpiderRod();
      }

      // The pack spider scans the area for items and picks them up if they're within 3 blocks.
      if (this.getSpiderType() == EnumSpiderType.PACK) {
        for (Entity entity :
            RadixLogic.getAllEntitiesOfTypeWithinDistance(EntityItem.class, this, 3)) {
          EntityItem item = (EntityItem) entity;
          item.setDead();

          inventory.addItemStackToInventory(item.getEntityItem());
        }
      }
    }
  }