From 1222bd68317fbc521c87875d463b7608e5a1d8f0 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 27 Jan 2021 17:16:15 +0200 Subject: [PATCH] Damage to blocks when stomping now depends on the hardness of that block --- .../unicopia/BlockDestructionManager.java | 3 +++ .../unicopia/ability/EarthPonyStompAbility.java | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/BlockDestructionManager.java b/src/main/java/com/minelittlepony/unicopia/BlockDestructionManager.java index 45a842bc..adb2dbef 100644 --- a/src/main/java/com/minelittlepony/unicopia/BlockDestructionManager.java +++ b/src/main/java/com/minelittlepony/unicopia/BlockDestructionManager.java @@ -41,6 +41,9 @@ public class BlockDestructionManager { } public int damageBlock(BlockPos pos, int amount) { + if (amount == 0) { + return getBlockDestruction(pos); + } amount = Math.max(getBlockDestruction(pos), 0) + amount; setBlockDestruction(pos, amount); return amount; diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java index 2f43f913..fae15b96 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyStompAbility.java @@ -23,6 +23,7 @@ import net.minecraft.particle.ParticleTypes; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Box; import net.minecraft.util.math.Direction; +import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; @@ -132,7 +133,14 @@ public class EarthPonyStompAbility implements Ability { BlockDestructionManager destr = ((BlockDestructionManager.Source)w).getDestructionManager(); if (!state.isAir() && w.getBlockState(pos.up()).isAir()) { - if (destr.damageBlock(pos, (int)((1 - dist / rad) * 9)) >= BlockDestructionManager.MAX_DAMAGE) { + + double amount = (1 - dist / rad) * 9; + float hardness = state.getHardness(w, pos); + float scaledHardness = (1 - hardness / 70); + + int damage = hardness < 0 ? 0 : MathHelper.clamp((int)(amount * scaledHardness), 2, 9); + + if (destr.damageBlock(pos, damage) >= BlockDestructionManager.MAX_DAMAGE) { w.breakBlock(pos, true); } else { WorldEvent.play(WorldEvent.DESTROY_BLOCK, w, pos, state); @@ -155,7 +163,7 @@ public class EarthPonyStompAbility implements Ability { } private void spawnParticleRing(PlayerEntity player, int timeDiff, double yVel) { - int animationTicks = timeDiff / 10; + int animationTicks = timeDiff / 7; if (animationTicks < 6) { Shape shape = new Sphere(true, animationTicks, 1, 0, 1); @@ -167,7 +175,7 @@ public class EarthPonyStompAbility implements Ability { Vec3d point = shape.computePoint(player.getEntityWorld().random).add(player.getPos()); player.world.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.DIRT.getDefaultState()), point.x, - point.y + y, + point.y, point.z, 0, yVel, 0 );