Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.85 KB | None | 0 0
  1. package net.minecraft.block;
  2.  
  3. import net.minecraft.entity.Entity;
  4. import net.minecraft.entity.LivingEntity;
  5. import net.minecraft.util.math.BlockPos;
  6. import net.minecraft.util.math.Vec3d;
  7. import net.minecraft.world.IBlockReader;
  8. import net.minecraft.world.World;
  9.  
  10. public class SlimeBlock extends BreakableBlock {
  11.    public SlimeBlock(Block.Properties properties) {
  12.       super(properties);
  13.    }
  14.  
  15.    /**
  16.     * Block's chance to react to a living entity falling on it.
  17.     */
  18.    public void onFallenUpon(World worldIn, BlockPos pos, Entity entityIn, float fallDistance) {
  19.       if (entityIn.func_226272_bl_()) {
  20.          super.onFallenUpon(worldIn, pos, entityIn, fallDistance);
  21.       } else {
  22.          entityIn.func_225503_b_(fallDistance, 0.0F);
  23.       }
  24.  
  25.    }
  26.  
  27.    /**
  28.     * Called when an Entity lands on this Block. This method *must* update motionY because the entity will not do that
  29.     * on its own
  30.     */
  31.    public void onLanded(IBlockReader worldIn, Entity entityIn) {
  32.       if (entityIn.func_226272_bl_()) {
  33.          super.onLanded(worldIn, entityIn);
  34.       } else {
  35.          this.func_226946_a_(entityIn);
  36.       }
  37.  
  38.    }
  39.  
  40.    private void func_226946_a_(Entity p_226946_1_) {
  41.       Vec3d vec3d = p_226946_1_.getMotion();
  42.       if (vec3d.y < 0.0D) {
  43.          double d0 = p_226946_1_ instanceof LivingEntity ? 1.0D : 0.8D;
  44.          p_226946_1_.setMotion(vec3d.x, -vec3d.y * d0, vec3d.z);
  45.       }
  46.  
  47.    }
  48.  
  49.    /**
  50.     * Called when the given entity walks on this Block
  51.     */
  52.    public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn) {
  53.       double d0 = Math.abs(entityIn.getMotion().y);
  54.       if (d0 < 0.1D && !entityIn.func_226271_bk_()) {
  55.          double d1 = 0.4D + d0 * 0.2D;
  56.          entityIn.setMotion(entityIn.getMotion().mul(d1, 1.0D, d1));
  57.       }
  58.  
  59.       super.onEntityWalk(worldIn, pos, entityIn);
  60.    }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement