diff --git a/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java index 96085b24..c0b6b1dc 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/CarryAbility.java @@ -4,6 +4,7 @@ import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.util.RayTraceHelper; + import net.minecraft.entity.LivingEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket; diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerAttributes.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerAttributes.java index 38eed00c..0823ad63 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerAttributes.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerAttributes.java @@ -17,10 +17,14 @@ import net.minecraft.util.registry.Registry; public class PlayerAttributes implements Tickable { public static final EntityAttribute EXTENDED_REACH_DISTANCE = register("unicopia.pegasus.reach", new ClampedEntityAttribute("player.reachDistance", 0, 0, 10).setTracked(true)); + public static final EntityAttribute EXTRA_MINING_SPEED = register("unicopia.earth.mining_speed", new ClampedEntityAttribute("player.miningSpeed", 1, 0, 5).setTracked(true)); public static final EntityAttribute ENTITY_GRAVTY_MODIFIER = register("unicopia.player.gravity", (new EntityAttribute("player.gravityModifier", 1) {}).setTracked(true)); private static final EntityAttributeModifier EARTH_PONY_STRENGTH = new EntityAttributeModifier(UUID.fromString("777a5505-521e-480b-b9d5-6ea54f259564"), "Earth Pony Strength", 0.6, Operation.MULTIPLY_TOTAL); + private static final EntityAttributeModifier EARTH_PONY_MINING_SPEED = + new EntityAttributeModifier(UUID.fromString("9fc9e269-152e-0b48-9bd5-564a546e59f2"), "Earth Pony Mining Speed", 0.4, Operation.MULTIPLY_TOTAL); + private static final EntityAttributeModifier PEGASUS_SPEED = new EntityAttributeModifier(UUID.fromString("9e2699fc-3b8d-4f71-9d2d-fb92ee19b4f7"), "Pegasus Speed", 0.2, Operation.MULTIPLY_TOTAL); private static final EntityAttributeModifier PEGASUS_REACH = @@ -45,6 +49,7 @@ public class PlayerAttributes implements Tickable { toggleAttribute(entity, EntityAttributes.GENERIC_MOVEMENT_SPEED, PEGASUS_SPEED, race.canFly()); toggleAttribute(entity, EntityAttributes.GENERIC_ATTACK_SPEED, PEGASUS_SPEED, race.canFly()); toggleAttribute(entity, EXTENDED_REACH_DISTANCE, PEGASUS_REACH, race.canFly()); + toggleAttribute(entity, EXTRA_MINING_SPEED, EARTH_PONY_MINING_SPEED, race.canUseEarth()); } private void toggleAttribute(PlayerEntity entity, EntityAttribute attribute, EntityAttributeModifier modifier, boolean enable) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java index 1f450e7e..7947b9cc 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -110,6 +110,7 @@ public class Pony implements Caster, Equine, Transmi public static void registerAttributes(DefaultAttributeContainer.Builder builder) { builder.add(PlayerAttributes.EXTENDED_REACH_DISTANCE); + builder.add(PlayerAttributes.EXTRA_MINING_SPEED); builder.add(PlayerAttributes.ENTITY_GRAVTY_MODIFIER); } @@ -197,6 +198,10 @@ public class Pony implements Caster, Equine, Transmi return (float)entity.getAttributeInstance(PlayerAttributes.EXTENDED_REACH_DISTANCE).getValue(); } + public float getBlockBreakingSpeed() { + return (float)entity.getAttributeInstance(PlayerAttributes.EXTRA_MINING_SPEED).getValue(); + } + public Motion getMotion() { return gravity; } diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java index 4e37d680..aa8975e0 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/MixinPlayerEntity.java @@ -11,6 +11,7 @@ import com.minelittlepony.unicopia.entity.Equine; import com.minelittlepony.unicopia.entity.player.Pony; import com.mojang.datafixers.util.Either; +import net.minecraft.block.BlockState; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityPose; import net.minecraft.entity.ItemEntity; @@ -53,7 +54,7 @@ abstract class MixinPlayerEntity extends LivingEntity implements PonyContainer

info) { + private void onEatFood(World world, ItemStack stack, CallbackInfoReturnable info) { if (stack.isFood()) { get().onEat(stack); } @@ -97,7 +98,14 @@ abstract class MixinPlayerEntity extends LivingEntity implements PonyContainer

info) { + private void onGetDimensions(EntityPose pose, CallbackInfoReturnable info) { info.setReturnValue(get().getMotion().getDimensions().calculateDimensions(info.getReturnValue())); } + + @Inject(method = "getBlockBreakingSpeed(Lnet/minecraft/block/BlockState;)F", + at = @At("RETURN"), + cancellable = true) + private void onGetBlockBreakingSpeed(BlockState state, CallbackInfoReturnable info) { + info.setReturnValue(info.getReturnValue() * get().getBlockBreakingSpeed()); + } }