Ejemplo n.º 1
0
  @SubscribeEvent
  public void onLivingUpdateEvent(LivingUpdateEvent event) {
    Entity entity = event.entityLiving;
    World world = entity.worldObj;

    /*
     * The purpose of the function is to manifest sprint particles
     * and adjust slipperiness when entity is moving on block, so check
     * that the conditions are met first.
     */
    if (!isMovingOnGround(entity)) {
      return;
    }

    TEBase TE = getTileEntityAtFeet(entity);
    if (TE != null) {

      ItemStack itemStack = getSurfaceItemStack(TE);

      /* Spawn sprint particles client-side. */

      if (world.isRemote && entity.isSprinting() && !entity.isInWater()) {
        ParticleHelper.spawnTileParticleAt(entity, itemStack);
      }

      /* Adjust block slipperiness according to cover. */

      Block block = BlockProperties.toBlock(itemStack);
      if (block instanceof BlockCoverable) {
        TE.getBlockType().slipperiness = Blocks.dirt.slipperiness;
      } else {
        TE.getBlockType().slipperiness = block.slipperiness;
      }
    }
  }
Ejemplo n.º 2
0
 @Override
 protected boolean isValidTarget(Entity ent) {
   if (ent instanceof TargetEntity) return ((TargetEntity) ent).shouldTarget(this, placerUUID);
   if (!(ent instanceof EntityLivingBase)) return false;
   EntityLivingBase elb = (EntityLivingBase) ent;
   if (elb.isDead || elb.getHealth() <= 0) return false;
   if (ent.onGround || ent.isInWater() || ent.isInsideOfMaterial(Material.lava)) return false;
   if (elb instanceof EntityFlying && ReikaEntityHelper.isHostile(elb)) {
     return ReikaMathLibrary.py3d(
             ent.posX - xCoord - 0.5, ent.posY - yCoord - 0.5, ent.posZ - zCoord - 0.5)
         > 2;
   }
   if (ent instanceof EntityBlaze || ent instanceof EntityWither || ent instanceof EntityDragon) {
     return ReikaMathLibrary.py3d(
             ent.posX - xCoord - 0.5, ent.posY - yCoord - 0.5, ent.posZ - zCoord - 0.5)
         > 2;
   }
   if (ent instanceof FlyingMob) {
     FlyingMob fm = (FlyingMob) ent;
     return fm.isCurrentlyFlying()
         && fm.isHostile()
         && ReikaMathLibrary.py3d(
                 ent.posX - xCoord - 0.5, ent.posY - yCoord - 0.5, ent.posZ - zCoord - 0.5)
             > 2;
   }
   if (InterfaceCache.BCROBOT.instanceOf(ent)) {
     return true;
   }
   return false;
 }