Skip to content

Commit

Permalink
Merge pull request #30 from ManasMods/1.19.2/minh
Browse files Browse the repository at this point in the history
Flying Speed & Smol Ticking SKill changes.
  • Loading branch information
Charismara authored Feb 15, 2024
2 parents 883f55d + d9c8c42 commit 73c0389
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ forgeVersion=43.3.5
# Parchment Version
parchmentVersion=2022.11.27
# Mod Information see https://mcforge.readthedocs.io/en/1.18.x/gettingstarted/versioning/#examples
modVersion=2.1.3.2
modVersion=2.1.3.3
modId=manascore
# Mixin Extras
mixinExtrasVersion=0.3.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public boolean canInteractSkill(ManasSkillInstance instance , LivingEntity livin
* @return the maximum number of ticks that this skill can be held down with the skill activation button.
* </p>
*/
public int getMaxHeldTime() {
public int getMaxHeldTime(ManasSkillInstance instance , LivingEntity living) {
return 72000;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public boolean canInteractSkill(LivingEntity living) {
* @return the maximum number of ticks that this skill can be held down with the skill activation button.
* </p>
*/
public int getMaxHeldTime() {
return this.getSkill().getMaxHeldTime();
public int getMaxHeldTime(LivingEntity living) {
return this.getSkill().getMaxHeldTime(this, living);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,25 @@

public class TickingSkill {
private int duration = 0;
private final int maxDuration;
@Getter
private final ManasSkill skill;
public TickingSkill(ManasSkill skill) {
this.skill = skill;
this.maxDuration = skill.getMaxHeldTime();
}

public boolean tick(SkillStorage storage, LivingEntity entity) {
Optional<ManasSkillInstance> optional = storage.getSkill(skill);
if (optional.isEmpty()) return false;

if (reachedMaxDuration()) return false;
ManasSkillInstance instance = optional.get();
if (reachedMaxDuration(instance, entity)) return false;

if (!instance.canInteractSkill(entity)) return false;
return instance.onHeld(entity, this.duration++);
}

public boolean reachedMaxDuration() {
public boolean reachedMaxDuration(ManasSkillInstance instance, LivingEntity entity) {
int maxDuration = instance.getMaxHeldTime(entity);
if (maxDuration == -1) return false;
return duration >= maxDuration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class ManasCoreAttributes {
() -> new RangedAttribute("manascore.attribute.crit_multiplier.name", 1.5, 0, 1024).setSyncable(true));
public static final RegistryObject<Attribute> JUMP_POWER = registry.register("jump_power",
() -> new RangedAttribute("manascore.attribute.jump_power.name", 0.42, 0, 1024).setSyncable(true));
public static final RegistryObject<Attribute> FLYING_SPEED_MULTIPLIER = registry.register("flying_speed_multiplier",
() -> new RangedAttribute("manascore.attribute.flying_speed.name", 1.0, 0, 1024).setSyncable(true));
public static final RegistryObject<Attribute> MINING_SPEED_MULTIPLIER = registry.register("mining_speed_multiplier",
() -> new RangedAttribute("manascore.attribute.mining_speed.name", 1.0, 0, 1024).setSyncable(true));
public static final RegistryObject<Attribute> SPRINTING_SPEED_MULTIPLIER = registry.register("sprinting_speed_multiplier",
Expand All @@ -43,6 +45,7 @@ private static void applyAttributesToEntities(final EntityAttributeModificationE
e.getTypes().forEach(type -> {
e.add(type, CRIT_CHANCE.get());
e.add(type, CRIT_MULTIPLIER.get());
e.add(type, FLYING_SPEED_MULTIPLIER.get());
e.add(type, SPRINTING_SPEED_MULTIPLIER.get());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ public class MixinLivingEntity {
@Inject(method = "getFrictionInfluencedSpeed", at = @At(value = "RETURN"), cancellable = true)
private void additionSprintingSpeed(float friction, CallbackInfoReturnable<Float> cir) {
LivingEntity entity = (LivingEntity) (Object) this;
if (!entity.isOnGround() || !entity.isSprinting()) return;

AttributeInstance instance = entity.getAttribute(ManasCoreAttributes.SPRINTING_SPEED_MULTIPLIER.get());
if (instance == null) return;
cir.setReturnValue((float) (cir.getReturnValue() * instance.getValue()));
if (!entity.isOnGround()) {
AttributeInstance instance = entity.getAttribute(ManasCoreAttributes.FLYING_SPEED_MULTIPLIER.get());
if (instance == null) return;
cir.setReturnValue((float) (cir.getReturnValue() * instance.getValue()));
} else if (entity.isSprinting()) {
AttributeInstance instance = entity.getAttribute(ManasCoreAttributes.SPRINTING_SPEED_MULTIPLIER.get());
if (instance == null) return;
cir.setReturnValue((float) (cir.getReturnValue() * instance.getValue()));
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/assets/manascore/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"manascore.attribute.crit_chance.name": "% Critical Chance",
"manascore.attribute.crit_multiplier.name": "Additional Critical Multiplier",
"manascore.attribute.jump_power.name": "Jump Power",
"manascore.attribute.flying_speed.name": "Flying Speed Multiplier",
"manascore.attribute.mining_speed.name": "Mining Speed Multiplier",
"manascore.attribute.sprinting_speed.name": "Sprinting Speed Multiplier",
"manascore.attribute.sweep_chance.name": "Sweeping Chance",
Expand Down

0 comments on commit 73c0389

Please sign in to comment.