Added logic to Player class to read elytra cooldowns
This commit is contained in:
parent
72e7e24693
commit
82f09e2bac
|
|
@ -21,11 +21,7 @@ public record SmackEffect(LevelBasedValue amount) implements EnchantmentEntityEf
|
|||
|
||||
@Override
|
||||
public void apply(ServerLevel world, int level, EnchantedItemInUse context, Entity target, Vec3 pos) {
|
||||
/*boolean playerAndCharged;
|
||||
if(context.owner()!=null && context.owner() instanceof Player player && player){
|
||||
playerAndCharged=true;
|
||||
}*/
|
||||
if (context.owner() != null && target instanceof Player player && player.getInventory().getArmor(1).is(Items.ELYTRA)) {
|
||||
if (target instanceof Player player && player.getInventory().getArmor(2).is(Items.ELYTRA)) {
|
||||
player.getCooldowns().addCooldown(Items.ELYTRA, (int)(20 * this.amount.calculate(level)) ); // Tick conversion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package xyz.nearmisses.patience.mc_rebalance.mixin;
|
|||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemCooldowns;
|
||||
|
|
@ -12,16 +13,18 @@ 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;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Player.class)
|
||||
public abstract class CooldownAttacksTweak extends LivingEntity {
|
||||
public abstract class PlayerTweaks extends LivingEntity {
|
||||
@Shadow
|
||||
public abstract ItemCooldowns getCooldowns();
|
||||
|
||||
protected CooldownAttacksTweak(EntityType<? extends LivingEntity> entityType, Level level) {
|
||||
protected PlayerTweaks(EntityType<? extends LivingEntity> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
}
|
||||
|
||||
// Disable attacks from tools on cooldown (item tier variants intentionally omitted out of curiosity)
|
||||
@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();
|
||||
|
|
@ -29,4 +32,12 @@ public abstract class CooldownAttacksTweak extends LivingEntity {
|
|||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
// Disable elytra flight (should work on modded variants)
|
||||
@Inject(method="tryToStartFallFlying", at=@At("HEAD"), cancellable = true)
|
||||
private void tryToStartFallFlying(CallbackInfoReturnable<Boolean> cir){
|
||||
if(!this.getItemBySlot(EquipmentSlot.CHEST).isEmpty() && this.getCooldowns().isOnCooldown(this.getItemBySlot(EquipmentSlot.CHEST).getItem())){
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,9 +5,10 @@
|
|||
"mixins": [
|
||||
"BlazeAIRework",
|
||||
"BlazeRework",
|
||||
"CooldownAttacksTweak",
|
||||
"PlayerTweaks",
|
||||
"CreakingRework",
|
||||
"ExperienceOrbRework",
|
||||
"GrowRateTweak",
|
||||
"HappyGhastTweak",
|
||||
"WardenRework",
|
||||
"WitherSkeletonRework"
|
||||
|
|
|
|||
Loading…
Reference in a new issue