Beispiel #1
0
  public boolean a(ItemStack itemstack, EntityHuman entityhuman, EntityLiving entityliving) {
    if (!itemstack.hasName()) {
      return false;
    } else if (entityliving instanceof EntityInsentient) {
      EntityInsentient entityinsentient = (EntityInsentient) entityliving;

      entityinsentient.setCustomName(itemstack.getName());
      entityinsentient.bz();
      --itemstack.count;
      return true;
    } else {
      return super.a(itemstack, entityhuman, entityliving);
    }
  }
Beispiel #2
0
  public ItemStack a(ItemStack itemstack, World world, EntityHuman entityhuman) {
    int i = EntityInsentient.b(itemstack) - 1;
    ItemStack itemstack1 = entityhuman.r(i);

    if (itemstack1 == null) {
      entityhuman.setEquipment(i, itemstack.cloneItemStack());
      itemstack.count = 0;
    }

    return itemstack;
  }
  public boolean a(Entity entity) {
    if (!entity.isAlive()) {
      return false;
    } else if (!(entity instanceof EntityLiving)) {
      return false;
    } else {
      EntityLiving entityliving = (EntityLiving) entity;

      return entityliving.getEquipment(EntityInsentient.b(this.c)) != null
          ? false
          : (entityliving instanceof EntityInsentient
              ? ((EntityInsentient) entityliving).bH()
              : entityliving instanceof EntityHuman);
    }
  }
Beispiel #4
0
 public static boolean isEquipment(ItemStack itemstack) {
   int slot = EntityInsentient.b(itemstack);
   if (slot == 0) {
     if (itemstack.getItem() instanceof ItemSword) {
       return true;
     } else if (itemstack.getItem() instanceof ItemAxe) {
       return true;
     } else if (itemstack.getItem() instanceof ItemSpade) {
       return true;
     } else if (itemstack.getItem() instanceof ItemHoe) {
       return true;
     } else if (itemstack.getItem() instanceof ItemPickaxe) {
       return true;
     } else if (itemstack.getItem() instanceof ItemBow) {
       return true;
     }
     return false;
   }
   return true;
 }
Beispiel #5
0
 @Override
 public boolean isEquipment(org.bukkit.inventory.ItemStack itemStack) {
   {
     ItemStack itemstack = CraftItemStack.asNMSCopy(itemStack);
     int slot = EntityInsentient.d(itemstack).c();
     if (slot == 0) {
       if (itemstack.getItem() instanceof ItemSword) {
         return true;
       } else if (itemstack.getItem() instanceof ItemAxe) {
         return true;
       } else if (itemstack.getItem() instanceof ItemSpade) {
         return true;
       } else if (itemstack.getItem() instanceof ItemHoe) {
         return true;
       } else if (itemstack.getItem() instanceof ItemPickaxe) {
         return true;
       } else if (itemstack.getItem() instanceof ItemBow) {
         return true;
       }
       return false;
     }
     return true;
   }
 }
Beispiel #6
0
  static void ride(float sideMot, float forMot, EntityHuman passenger, EntityInsentient entity) {
    if (!(entity instanceof EntityBase))
      throw new IllegalArgumentException("The entity field should implements EntityBase");

    EntityBase entityBase = (EntityBase) entity;

    WrapperEntityInsentient wEntity = new WrapperEntityInsentient(entity);
    WrapperEntityHuman wPassenger = new WrapperEntityHuman(passenger);

    if (passenger != null) {
      entity.lastYaw = entity.yaw = passenger.yaw % 360f;
      entity.pitch = (passenger.pitch * 0.5F) % 360f;

      wEntity.setRenderYawOffset(entity.yaw);
      wEntity.setRotationYawHead(entity.yaw);

      sideMot = wPassenger.getMoveStrafing() * 0.25f;
      forMot = wPassenger.getMoveForward() * 0.5f;

      if (forMot <= 0.0F) forMot *= 0.25F;

      wEntity.setJumping(wPassenger.isJumping());

      if (wPassenger.isJumping() && (entity.onGround || entityBase.canFly())) {
        entity.motY = 0.4D;

        float f2 = MathHelper.sin(entity.yaw * 0.017453292f);
        float f3 = MathHelper.cos(entity.yaw * 0.017453292f);
        entity.motX += (double) (-0.4f * f2);
        entity.motZ += (double) (0.4f * f3);
      }

      wEntity.setStepHeight(1.0f);
      wEntity.setJumpMovementFactor(wEntity.getMoveSpeed() * 0.1f);

      wEntity.setRotationYawHead(entity.yaw);

      if (wEntity.canPassengerSteer()) {
        wEntity.setMoveSpeed(0.35f * entityBase.getSpeed());
        entityBase.g_(sideMot, forMot);
      }

      wEntity.setPrevLimbSwingAmount(wEntity.getLimbSwingAmount());

      double dx = entity.locX - entity.lastX;
      double dz = entity.locZ - entity.lastZ;

      float f4 = MathHelper.sqrt(dx * dx + dz * dz) * 4;

      if (f4 > 1) f4 = 1;

      wEntity.setLimbSwingAmount(
          wEntity.getLimbSwingAmount() + (f4 - wEntity.getLimbSwingAmount()) * 0.4f);
      wEntity.setLimbSwing(wEntity.getLimbSwing() + wEntity.getLimbSwingAmount());
    } else {
      wEntity.setStepHeight(0.5f);
      wEntity.setJumpMovementFactor(0.02f);

      entityBase.g_(sideMot, forMot);
    }
  }