Skip to content

Commit

Permalink
new: entity.fast_hand_swing: only calculate hand swing progress when …
Browse files Browse the repository at this point in the history
…hand is swinging
  • Loading branch information
2No2Name committed Jan 9, 2022
1 parent d80292c commit 52e8cab
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ private LithiumConfig() {
this.addMixinRule("entity.data_tracker.no_locks", true);
this.addMixinRule("entity.data_tracker.use_arrays", true);
this.addMixinRule("entity.fast_elytra_check", true);
this.addMixinRule("entity.fast_hand_swing", true);
this.addMixinRule("entity.fast_powder_snow_check", true);
this.addMixinRule("entity.fast_retrieval", true);
this.addMixinRule("entity.inactive_navigations", true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package me.jellysquid.mods.lithium.mixin.entity.fast_hand_swing;

import net.minecraft.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin {
@Shadow
public boolean handSwinging;

@Shadow
public int handSwingTicks;

@Inject(
method = "tickHandSwing()V",
at = @At("HEAD"),
cancellable = true
)
private void skipGetDuration(CallbackInfo ci) {
if (!this.handSwinging && this.handSwingTicks == 0) {
ci.cancel();
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/lithium.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"entity.data_tracker.no_locks.DataTrackerMixin",
"entity.data_tracker.use_arrays.DataTrackerMixin",
"entity.fast_elytra_check.LivingEntityMixin",
"entity.fast_hand_swing.LivingEntityMixin",
"entity.fast_powder_snow_check.LivingEntityMixin",
"entity.fast_retrieval.SectionedEntityCacheMixin",
"entity.inactive_navigations.DrownedEntityLeaveWaterGoalMixin",
Expand Down

0 comments on commit 52e8cab

Please sign in to comment.