|
18 | 18 | import net.minecraft.core.BlockPos; |
19 | 19 | import net.minecraft.core.Direction; |
20 | 20 | import net.minecraft.tags.BlockTags; |
| 21 | +import net.minecraft.world.entity.Entity; |
| 22 | +import net.minecraft.world.entity.LivingEntity; |
21 | 23 | import net.minecraft.world.entity.player.Player; |
22 | 24 | import net.minecraft.world.item.ItemStack; |
23 | 25 | import net.minecraft.world.level.BlockGetter; |
|
31 | 33 | import net.minecraft.world.level.block.state.properties.IntegerProperty; |
32 | 34 | import net.minecraft.world.level.material.FluidState; |
33 | 35 | import net.minecraft.world.phys.HitResult; |
| 36 | +import net.minecraft.world.phys.Vec3; |
34 | 37 | import net.minecraft.world.phys.shapes.CollisionContext; |
35 | 38 | import net.minecraft.world.phys.shapes.VoxelShape; |
36 | 39 | import org.jetbrains.annotations.Nullable; |
@@ -276,6 +279,10 @@ public List<BlockPos> getRing (LevelAccessor level, BlockPos pos, int radius){ |
276 | 279 | return positions; |
277 | 280 | } |
278 | 281 |
|
| 282 | + /////////////////////////////////////////// |
| 283 | + // PROPERTIES |
| 284 | + /////////////////////////////////////////// |
| 285 | + |
279 | 286 | public static boolean canCapReplace(BlockState state){ |
280 | 287 | // Mushroom caps take precedence over leaves |
281 | 288 | return state.canBeReplaced() || state.is(DTBlockTags.FOLIAGE) || state.is(BlockTags.LEAVES); |
@@ -303,6 +310,31 @@ public boolean onDestroyedByPlayer(BlockState state, Level level, BlockPos pos, |
303 | 310 | return destroyed; |
304 | 311 | } |
305 | 312 |
|
| 313 | + //Same behavior as beds |
| 314 | + @Override |
| 315 | + public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, float fallDistance) { |
| 316 | + super.fallOn(level, state, pos, entity, fallDistance * 0.5F); |
| 317 | + } |
| 318 | + |
| 319 | + //Same behavior as beds |
| 320 | + @Override |
| 321 | + public void updateEntityAfterFallOn(BlockGetter level, Entity entity) { |
| 322 | + if (entity.isSuppressingBounce()) { |
| 323 | + super.updateEntityAfterFallOn(level, entity); |
| 324 | + } else { |
| 325 | + this.bounceUp(entity); |
| 326 | + } |
| 327 | + } |
| 328 | + |
| 329 | + //Same behavior as beds |
| 330 | + private void bounceUp(Entity entity) { |
| 331 | + Vec3 vec3 = entity.getDeltaMovement(); |
| 332 | + if (vec3.y < 0.0) { |
| 333 | + double d0 = entity instanceof LivingEntity ? 1.0 : 0.8; |
| 334 | + entity.setDeltaMovement(vec3.x, -vec3.y * 0.66F * d0, vec3.z); |
| 335 | + } |
| 336 | + } |
| 337 | + |
306 | 338 | /////////////////////////////////////////// |
307 | 339 | // SHAPE |
308 | 340 | /////////////////////////////////////////// |
|
0 commit comments