Redesigned stopping attacks on cooldown
This commit is contained in:
parent
891011ad39
commit
55cb1b1615
|
|
@ -0,0 +1,32 @@
|
||||||
|
package xyz.nearmisses.patience.mc_rebalance.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
import net.minecraft.world.entity.EntityType;
|
||||||
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.ItemCooldowns;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
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(Player.class)
|
||||||
|
public abstract class CooldownAttacksTweak extends LivingEntity {
|
||||||
|
@Shadow
|
||||||
|
public abstract ItemCooldowns getCooldowns();
|
||||||
|
|
||||||
|
protected CooldownAttacksTweak(EntityType<? extends LivingEntity> entityType, Level level) {
|
||||||
|
super(entityType, level);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method="attack", at=@At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;getWeaponItem()Lnet/minecraft/world/item/ItemStack;"), cancellable = true)
|
||||||
|
private void attack(Entity entity, CallbackInfo ci){
|
||||||
|
ItemStack itemStack = this.getWeaponItem();
|
||||||
|
if(this.getCooldowns().isOnCooldown(itemStack.getItem())){
|
||||||
|
ci.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
package xyz.nearmisses.patience.mc_rebalance.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
|
||||||
import net.minecraft.world.entity.player.Player;
|
|
||||||
import net.minecraft.world.item.DiggerItem;
|
|
||||||
import net.minecraft.world.item.ItemStack;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
|
||||||
|
|
||||||
// Required for the Windup enchantment effect to work correctly. Why would this not happen by default?
|
|
||||||
@Mixin(DiggerItem.class)
|
|
||||||
public class DiggerItemHitCooldownsTweak {
|
|
||||||
@Inject(method = "hurtEnemy", at = @At("HEAD"), cancellable = true)
|
|
||||||
private static void hurtEnemy(ItemStack itemStack, LivingEntity owner, LivingEntity target, CallbackInfoReturnable<Boolean> cir){
|
|
||||||
if(owner instanceof Player && ((Player)owner).getCooldowns().isOnCooldown(itemStack.getItem())){
|
|
||||||
cir.setReturnValue(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"BlazeAIRework",
|
"BlazeAIRework",
|
||||||
"BlazeRework",
|
"BlazeRework",
|
||||||
|
"CooldownAttacksTweak",
|
||||||
"CreakingRework",
|
"CreakingRework",
|
||||||
"DiggerItemHitCooldownsTweak",
|
|
||||||
"ExperienceOrbRework",
|
"ExperienceOrbRework",
|
||||||
"HappyGhastTweak",
|
"HappyGhastTweak",
|
||||||
"WardenRework",
|
"WardenRework",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue