mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Gave earth ponies a slightly increased mining speed (suggested by kerplamp)
This commit is contained in:
parent
a544724751
commit
872bdb44f2
4 changed files with 21 additions and 2 deletions
|
@ -4,6 +4,7 @@ import com.minelittlepony.unicopia.Race;
|
||||||
import com.minelittlepony.unicopia.ability.data.Hit;
|
import com.minelittlepony.unicopia.ability.data.Hit;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.minelittlepony.unicopia.util.RayTraceHelper;
|
import com.minelittlepony.unicopia.util.RayTraceHelper;
|
||||||
|
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket;
|
import net.minecraft.network.packet.s2c.play.EntityPassengersSetS2CPacket;
|
||||||
|
|
|
@ -17,10 +17,14 @@ import net.minecraft.util.registry.Registry;
|
||||||
public class PlayerAttributes implements Tickable {
|
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 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));
|
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 =
|
private static final EntityAttributeModifier EARTH_PONY_STRENGTH =
|
||||||
new EntityAttributeModifier(UUID.fromString("777a5505-521e-480b-b9d5-6ea54f259564"), "Earth Pony Strength", 0.6, Operation.MULTIPLY_TOTAL);
|
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 =
|
private static final EntityAttributeModifier PEGASUS_SPEED =
|
||||||
new EntityAttributeModifier(UUID.fromString("9e2699fc-3b8d-4f71-9d2d-fb92ee19b4f7"), "Pegasus Speed", 0.2, Operation.MULTIPLY_TOTAL);
|
new EntityAttributeModifier(UUID.fromString("9e2699fc-3b8d-4f71-9d2d-fb92ee19b4f7"), "Pegasus Speed", 0.2, Operation.MULTIPLY_TOTAL);
|
||||||
private static final EntityAttributeModifier PEGASUS_REACH =
|
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_MOVEMENT_SPEED, PEGASUS_SPEED, race.canFly());
|
||||||
toggleAttribute(entity, EntityAttributes.GENERIC_ATTACK_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, 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) {
|
private void toggleAttribute(PlayerEntity entity, EntityAttribute attribute, EntityAttributeModifier modifier, boolean enable) {
|
||||||
|
|
|
@ -110,6 +110,7 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
||||||
|
|
||||||
public static void registerAttributes(DefaultAttributeContainer.Builder builder) {
|
public static void registerAttributes(DefaultAttributeContainer.Builder builder) {
|
||||||
builder.add(PlayerAttributes.EXTENDED_REACH_DISTANCE);
|
builder.add(PlayerAttributes.EXTENDED_REACH_DISTANCE);
|
||||||
|
builder.add(PlayerAttributes.EXTRA_MINING_SPEED);
|
||||||
builder.add(PlayerAttributes.ENTITY_GRAVTY_MODIFIER);
|
builder.add(PlayerAttributes.ENTITY_GRAVTY_MODIFIER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,6 +198,10 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
||||||
return (float)entity.getAttributeInstance(PlayerAttributes.EXTENDED_REACH_DISTANCE).getValue();
|
return (float)entity.getAttributeInstance(PlayerAttributes.EXTENDED_REACH_DISTANCE).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getBlockBreakingSpeed() {
|
||||||
|
return (float)entity.getAttributeInstance(PlayerAttributes.EXTRA_MINING_SPEED).getValue();
|
||||||
|
}
|
||||||
|
|
||||||
public Motion getMotion() {
|
public Motion getMotion() {
|
||||||
return gravity;
|
return gravity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.minelittlepony.unicopia.entity.Equine;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
import com.mojang.datafixers.util.Either;
|
import com.mojang.datafixers.util.Either;
|
||||||
|
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.EntityDimensions;
|
import net.minecraft.entity.EntityDimensions;
|
||||||
import net.minecraft.entity.EntityPose;
|
import net.minecraft.entity.EntityPose;
|
||||||
import net.minecraft.entity.ItemEntity;
|
import net.minecraft.entity.ItemEntity;
|
||||||
|
@ -53,7 +54,7 @@ abstract class MixinPlayerEntity extends LivingEntity implements PonyContainer<P
|
||||||
|
|
||||||
@Inject(method = "eatFood(Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/ItemStack;",
|
@Inject(method = "eatFood(Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;)Lnet/minecraft/item/ItemStack;",
|
||||||
at = @At("HEAD"))
|
at = @At("HEAD"))
|
||||||
public void onEatFood(World world, ItemStack stack, CallbackInfoReturnable<ItemStack> info) {
|
private void onEatFood(World world, ItemStack stack, CallbackInfoReturnable<ItemStack> info) {
|
||||||
if (stack.isFood()) {
|
if (stack.isFood()) {
|
||||||
get().onEat(stack);
|
get().onEat(stack);
|
||||||
}
|
}
|
||||||
|
@ -97,7 +98,14 @@ abstract class MixinPlayerEntity extends LivingEntity implements PonyContainer<P
|
||||||
@Inject(method = "getDimensions(Lnet/minecraft/entity/EntityPose;)Lnet/minecraft/entity/EntityDimensions;",
|
@Inject(method = "getDimensions(Lnet/minecraft/entity/EntityPose;)Lnet/minecraft/entity/EntityDimensions;",
|
||||||
at = @At("RETURN"),
|
at = @At("RETURN"),
|
||||||
cancellable = true)
|
cancellable = true)
|
||||||
public void onGetDimensions(EntityPose pose, CallbackInfoReturnable<EntityDimensions> info) {
|
private void onGetDimensions(EntityPose pose, CallbackInfoReturnable<EntityDimensions> info) {
|
||||||
info.setReturnValue(get().getMotion().getDimensions().calculateDimensions(info.getReturnValue()));
|
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<Float> info) {
|
||||||
|
info.setReturnValue(info.getReturnValue() * get().getBlockBreakingSpeed());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue