Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build-data/paper.at
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ public net.minecraft.world.entity.player.Player getFireImmuneTicks()I
public net.minecraft.world.entity.player.Player hurtDir
public net.minecraft.world.entity.player.Player removeEntitiesOnShoulder()V
public net.minecraft.world.entity.player.Player sleepCounter
public net.minecraft.world.entity.player.Player canCriticalAttack(Lnet/minecraft/world/entity/Entity;)Z
public net.minecraft.world.entity.projectile.EvokerFangs warmupDelayTicks
public net.minecraft.world.entity.projectile.EyeOfEnder life
public net.minecraft.world.entity.projectile.EyeOfEnder surviveAfterDeath
Expand Down
11 changes: 11 additions & 0 deletions paper-api/src/main/java/org/bukkit/entity/HumanEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,17 @@ default Location getPotentialBedLocation() {
*/
public void startRiptideAttack(int duration, float attackStrength, @Nullable ItemStack attackItem);

/**
* Check if the player can critical attack the target {@link Entity}
* <br>
* Note: When hitting an entity, Minecraft also checks that the result of {@link #getAttackCooldown()} is {@code > 0.9F}
* to determine if the critical attack will happen.
*
* @param entity target entity to check if can critical attack.
* @return Whether they can critical attack the target entity.
*/
public boolean canCriticalAttack(Entity entity);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im not sure about the name also based in NMS this is not the full logic for consider its a critical (fullStrengthAttack in NMS) so maybe you can mention in the docs...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add the fullStrengthAttack logic too if you want?

it would defo make more sense in the way I use this API in my own project to also account for that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i fell can be good expose that

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I know what you mean by that ngl xd

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be good expose the fullStrengthAttack in the API.


/**
* Gets the location of the bed the player is currently sleeping in
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.bukkit.craftbukkit.inventory.util.CraftMenus;
import org.bukkit.craftbukkit.util.CraftLocation;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Firework;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Item;
Expand Down Expand Up @@ -227,6 +228,13 @@ public void startRiptideAttack(int duration, float damage, ItemStack attackItem)
this.getHandle().startAutoSpinAttack(duration, damage, CraftItemStack.asNMSCopy(attackItem));
}

@Override
public boolean canCriticalAttack(Entity entity) {
Preconditions.checkArgument(entity != null, "entity cannot be null");

return this.getHandle().canCriticalAttack(((CraftEntity) entity).getHandle()) && !this.getHandle().level().paperConfig().entities.behavior.disablePlayerCrits;
}

@Override
public Location getBedLocation() {
Preconditions.checkState(this.isSleeping(), "Not sleeping");
Expand Down