mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Damage to blocks when stomping now depends on the hardness of that block
This commit is contained in:
parent
872bdb44f2
commit
1222bd6831
2 changed files with 14 additions and 3 deletions
|
@ -41,6 +41,9 @@ public class BlockDestructionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int damageBlock(BlockPos pos, int amount) {
|
public int damageBlock(BlockPos pos, int amount) {
|
||||||
|
if (amount == 0) {
|
||||||
|
return getBlockDestruction(pos);
|
||||||
|
}
|
||||||
amount = Math.max(getBlockDestruction(pos), 0) + amount;
|
amount = Math.max(getBlockDestruction(pos), 0) + amount;
|
||||||
setBlockDestruction(pos, amount);
|
setBlockDestruction(pos, amount);
|
||||||
return amount;
|
return amount;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import net.minecraft.particle.ParticleTypes;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Box;
|
import net.minecraft.util.math.Box;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
@ -132,7 +133,14 @@ public class EarthPonyStompAbility implements Ability<Hit> {
|
||||||
BlockDestructionManager destr = ((BlockDestructionManager.Source)w).getDestructionManager();
|
BlockDestructionManager destr = ((BlockDestructionManager.Source)w).getDestructionManager();
|
||||||
|
|
||||||
if (!state.isAir() && w.getBlockState(pos.up()).isAir()) {
|
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);
|
w.breakBlock(pos, true);
|
||||||
} else {
|
} else {
|
||||||
WorldEvent.play(WorldEvent.DESTROY_BLOCK, w, pos, state);
|
WorldEvent.play(WorldEvent.DESTROY_BLOCK, w, pos, state);
|
||||||
|
@ -155,7 +163,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnParticleRing(PlayerEntity player, int timeDiff, double yVel) {
|
private void spawnParticleRing(PlayerEntity player, int timeDiff, double yVel) {
|
||||||
int animationTicks = timeDiff / 10;
|
int animationTicks = timeDiff / 7;
|
||||||
if (animationTicks < 6) {
|
if (animationTicks < 6) {
|
||||||
Shape shape = new Sphere(true, animationTicks, 1, 0, 1);
|
Shape shape = new Sphere(true, animationTicks, 1, 0, 1);
|
||||||
|
|
||||||
|
@ -167,7 +175,7 @@ public class EarthPonyStompAbility implements Ability<Hit> {
|
||||||
Vec3d point = shape.computePoint(player.getEntityWorld().random).add(player.getPos());
|
Vec3d point = shape.computePoint(player.getEntityWorld().random).add(player.getPos());
|
||||||
player.world.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.DIRT.getDefaultState()),
|
player.world.addParticle(new BlockStateParticleEffect(ParticleTypes.BLOCK, Blocks.DIRT.getDefaultState()),
|
||||||
point.x,
|
point.x,
|
||||||
point.y + y,
|
point.y,
|
||||||
point.z,
|
point.z,
|
||||||
0, yVel, 0
|
0, yVel, 0
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue