mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-04 22:14:40 +01:00
#650: Add method to get player's attack cooldown
This commit is contained in:
parent
ef706b064e
commit
893ad93b3e
3 changed files with 26 additions and 9 deletions
|
@ -221,6 +221,15 @@
|
|||
}
|
||||
|
||||
public void openSign(TileEntitySign tileentitysign) {}
|
||||
@@ -939,7 +1030,7 @@
|
||||
|
||||
f *= 0.2F + f2 * f2 * 0.8F;
|
||||
f1 *= f2;
|
||||
- this.ey();
|
||||
+ // this.ey(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt
|
||||
if (f > 0.0F || f1 > 0.0F) {
|
||||
boolean flag = f2 > 0.9F;
|
||||
boolean flag1 = false;
|
||||
@@ -978,8 +1069,15 @@
|
||||
if (entity instanceof EntityLiving) {
|
||||
f3 = ((EntityLiving) entity).getHealth();
|
||||
|
|
|
@ -551,7 +551,7 @@
|
|||
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
|
||||
int j = 25 - i;
|
||||
float f1 = f * (float) j;
|
||||
@@ -1293,28 +1543,170 @@
|
||||
@@ -1293,28 +1543,173 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -629,6 +629,9 @@
|
|||
+ float absorptionModifier = absorption.apply((double) f).floatValue();
|
||||
+
|
||||
+ EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption);
|
||||
+ if (damagesource.getEntity() instanceof EntityHuman) {
|
||||
+ ((EntityHuman) damagesource.getEntity()).ey(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
|
||||
+ }
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
|
@ -732,7 +735,7 @@
|
|||
}
|
||||
|
||||
public CombatTracker getCombatTracker() {
|
||||
@@ -1401,6 +1793,7 @@
|
||||
@@ -1401,6 +1796,7 @@
|
||||
public AttributeMapBase getAttributeMap() {
|
||||
if (this.attributeMap == null) {
|
||||
this.attributeMap = new AttributeMapServer();
|
||||
|
@ -740,7 +743,7 @@
|
|||
}
|
||||
|
||||
return this.attributeMap;
|
||||
@@ -1771,6 +2164,7 @@
|
||||
@@ -1771,6 +2167,7 @@
|
||||
}
|
||||
|
||||
if (this.onGround && !this.world.isClientSide) {
|
||||
|
@ -748,7 +751,7 @@
|
|||
this.setFlag(7, false);
|
||||
}
|
||||
} else {
|
||||
@@ -2168,6 +2562,7 @@
|
||||
@@ -2168,6 +2565,7 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide) {
|
||||
|
@ -756,7 +759,7 @@
|
|||
this.setFlag(7, flag);
|
||||
}
|
||||
|
||||
@@ -2296,12 +2691,12 @@
|
||||
@@ -2296,12 +2694,12 @@
|
||||
|
||||
@Override
|
||||
public boolean isInteractable() {
|
||||
|
@ -771,7 +774,7 @@
|
|||
}
|
||||
|
||||
@Override
|
||||
@@ -2484,7 +2879,27 @@
|
||||
@@ -2484,7 +2882,27 @@
|
||||
} else {
|
||||
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
|
||||
this.b(this.activeItem, 16);
|
||||
|
@ -800,7 +803,7 @@
|
|||
this.dH();
|
||||
}
|
||||
|
||||
@@ -2571,10 +2986,18 @@
|
||||
@@ -2571,10 +2989,18 @@
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
|
@ -822,7 +825,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
@@ -2661,7 +3084,7 @@
|
||||
@@ -2661,7 +3087,7 @@
|
||||
}
|
||||
|
||||
public void entityWakeup() {
|
||||
|
@ -831,7 +834,7 @@
|
|||
World world = this.world;
|
||||
|
||||
this.world.getClass();
|
||||
@@ -2725,7 +3148,7 @@
|
||||
@@ -2725,7 +3151,7 @@
|
||||
Pair<MobEffect, Float> pair = (Pair) iterator.next();
|
||||
|
||||
if (!world.isClientSide && pair.getLeft() != null && world.random.nextFloat() < (Float) pair.getRight()) {
|
||||
|
|
|
@ -490,6 +490,11 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
return getHandle().getExpToLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAttackCooldown() {
|
||||
return getHandle().s(0.5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCooldown(Material material) {
|
||||
Preconditions.checkArgument(material != null, "material");
|
||||
|
|
Loading…
Reference in a new issue