Exemple #1
0
 public void onLanded(World worldIn, Entity entityIn) {
   if (entityIn.isSneaking()) {
     super.onLanded(worldIn, entityIn);
   } else if (entityIn.motionY < 0.0D) {
     entityIn.motionY = -entityIn.motionY;
   }
 }
 @Override
 public void onFallenUpon(World w, BlockPos pos, Entity entityIn, float fallDistance) {
   if (!w.isRemote
       && entityIn instanceof EntityLivingBase
       && entityIn.isSneaking()
       && fallDistance > .2f) smashContainer(w, pos, entityIn);
 }
Exemple #3
0
 public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance) {
   if (entityIn.isSneaking()) {
     super.onFallenUpon(worldIn, pos, entityIn, fallDistance);
   } else {
     entityIn.fall(fallDistance, 0);
   }
 }
Exemple #4
0
 public void onEntityCollidedWithBlock(World w, BlockPos pos, Entity entity) {
   if (!entity.isSneaking() && Math.abs(entity.motionY) >= 0.25d) {
     entity.motionY += 0.0155 * (entity.fallDistance < 1 ? 1 : entity.fallDistance);
   } else {
     entity.motionY = 0;
   }
   super.onEntityCollidedWithBlock(w, pos, entity);
 }
  @Override
  public void onLanded(World worldIn, Entity entityIn) {
    if (entityIn.isSneaking()) {
      entityIn.motionY = 0;
    } else {
      entityIn.motionY = -entityIn.motionY;

      if (!(entityIn instanceof EntityLivingBase)) {
        entityIn.motionY *= 0.8D;
      } else if (entityIn.motionY < 1 && entityIn.motionY < 1.2) entityIn.motionY *= 1.5;
    }
  }
  @Override
  public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {

    float shrinkAmount = 1f / 45f;
    if (entity.boundingBox.minY >= y + (1f - shrinkAmount)
        || entity.boundingBox.maxY <= y + shrinkAmount) return;
    entity.fallDistance = 0;
    if (entity.isCollidedHorizontally) {
      entity.motionY = 0.2D;
    } else if (entity.isSneaking()) {
      double diff = entity.prevPosY - entity.posY;
      entity.boundingBox.minY += diff;
      entity.boundingBox.maxY += diff;
      entity.posY = entity.prevPosY;
    } else {
      entity.motionY = -0.12D;
    }
  }
 @Override
 public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
   if (entity.isSneaking()) {
     tank11.rotateAngleX = 0.5F;
     tank12.rotateAngleX = 0.5F;
     tank21.rotateAngleX = 0.5F;
     tank22.rotateAngleX = 0.5F;
     tank31.rotateAngleX = 0.5F;
     tank32.rotateAngleX = 0.5F;
     tank41.rotateAngleX = 0.5F;
     tank42.rotateAngleX = 0.5F;
     strap1.rotateAngleX = 0.5F;
     strap2.rotateAngleX = 0.5F;
     strap3.rotateAngleX = 0.5F;
     pipeleft1.rotateAngleX = 0.5F;
     pipeleft2.rotateAngleX = 0.5F;
     pipeleft3.rotateAngleX = 0.5F;
     piperight1.rotateAngleX = 0.5F;
     piperight2.rotateAngleX = 0.5F;
     piperight3.rotateAngleX = 0.5F;
   } else {
     tank11.rotateAngleX = 0F;
     tank12.rotateAngleX = 0F;
     tank21.rotateAngleX = 0F;
     tank22.rotateAngleX = 0F;
     tank31.rotateAngleX = 0F;
     tank32.rotateAngleX = 0F;
     tank41.rotateAngleX = 0F;
     tank42.rotateAngleX = 0F;
     strap1.rotateAngleX = 0F;
     strap2.rotateAngleX = 0F;
     strap3.rotateAngleX = 0F;
     pipeleft1.rotateAngleX = 0F;
     pipeleft2.rotateAngleX = 0F;
     pipeleft3.rotateAngleX = 0F;
     piperight1.rotateAngleX = 0F;
     piperight2.rotateAngleX = 0F;
     piperight3.rotateAngleX = 0F;
   }
   super.render(entity, f, f1, f2, f3, f4, 0.0525F);
 }
  /**
   * Triggered whenever an entity collides with this block (enters into the block). Args: world, x,
   * y, z, entity
   */
  @Override
  public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
    if (entity instanceof EntityLivingBase && headInQuicksand(world, x, y, z, entity)) {
      // If the entity is inside of a quicksand block, give some damage. It's only 0.5f damage, so a
      // quarter heart.
      entity.attackEntityFrom(DamageSourceQuicksand.instance, 0.5f);

      // I tried to make it render the texture on your screen like if you're in a block,
      // but it turned out to be a private method.
    }
    if (insideQuicksand(world, x, y, z, entity)) {
      // If the entity inside of the quicksand is a player, make the player fall slowly.
      // If the player is moving horizontally ("struggling"), make them fall faster.
      // If the player is sneaking, make them "swim" upwards.
      if (entity instanceof EntityPlayer) {
        double horizMotion =
            Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ);
        if (horizMotion > 0.0) {
          if (debug) System.out.println("Horizonal Motion: " + horizMotion);
        }
        if (entity.isSneaking()) {
          // Make the player go up slowly. Weird numbers, right?
          entity.motionY = 0.085102044;
        } else {
          // Make the player go down slowly. Seriously, I don't know why these numbers are so exact.
          entity.motionY = 0.074897955;
        }
        if (horizMotion > 0.001) {
          // If the player is moving significantly horizontally, make them sink faster.
          entity.motionY -= horizMotion * 0.3;
        }
        entity.fallDistance = 0;
      } else {
        // If not a player, just set the entity in a web.
        // It's a bit glitchy otherwise... especially with chickens, who don't sink.
        entity.setInWeb();
      }
    }
  }