mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-03 23:07:40 +01:00
Add PlayerAttackEntityCooldownResetEvent
This commit is contained in:
parent
dd3e099c9c
commit
c157d209f3
@ -383,17 +383,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -985,26 +1131,57 @@
|
||||
|
||||
public final boolean addEffect(MobEffectInstance effect) {
|
||||
@@ -987,24 +1133,55 @@
|
||||
return this.addEffect(effect, (Entity) null);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean addEffect(MobEffectInstance mobeffect, EntityPotionEffectEvent.Cause cause) {
|
||||
+ return this.addEffect(mobeffect, (Entity) null, cause);
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
public boolean addEffect(MobEffectInstance effect, @Nullable Entity source) {
|
||||
- if (!this.canBeAffected(effect)) {
|
||||
+ return this.addEffect(effect, source, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
||||
@ -1022,7 +1020,7 @@
|
||||
int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
|
||||
int j = 25 - i;
|
||||
float f1 = amount * (float) j;
|
||||
@@ -1884,18 +2275,144 @@
|
||||
@@ -1884,18 +2275,154 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -1123,7 +1121,17 @@
|
||||
+ }
|
||||
+
|
||||
+ if (damagesource.getEntity() instanceof net.minecraft.world.entity.player.Player) {
|
||||
+ ((net.minecraft.world.entity.player.Player) damagesource.getEntity()).resetAttackStrengthTicker(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
|
||||
+ // Paper start - PlayerAttackEntityCooldownResetEvent
|
||||
+ //((net.minecraft.world.entity.player.Player) damagesource.getEntity()).resetAttackStrengthTicker(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
|
||||
+ if (damagesource.getEntity() instanceof ServerPlayer) {
|
||||
+ ServerPlayer player = (ServerPlayer) damagesource.getEntity();
|
||||
+ if (new com.destroystokyo.paper.event.player.PlayerAttackEntityCooldownResetEvent(player.getBukkitEntity(), this.getBukkitEntity(), player.getAttackStrengthScale(0F)).callEvent()) {
|
||||
+ player.resetAttackStrengthTicker();
|
||||
+ }
|
||||
+ } else {
|
||||
+ ((net.minecraft.world.entity.player.Player) damagesource.getEntity()).resetAttackStrengthTicker();
|
||||
+ }
|
||||
+ // Paper end - PlayerAttackEntityCooldownResetEvent
|
||||
+ }
|
||||
+
|
||||
+ // Resistance
|
||||
@ -1176,7 +1184,7 @@
|
||||
|
||||
if (entity instanceof ServerPlayer) {
|
||||
ServerPlayer entityplayer = (ServerPlayer) entity;
|
||||
@@ -1904,13 +2421,48 @@
|
||||
@@ -1904,13 +2431,48 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -1229,7 +1237,7 @@
|
||||
}
|
||||
|
||||
public CombatTracker getCombatTracker() {
|
||||
@@ -1935,8 +2487,18 @@
|
||||
@@ -1935,8 +2497,18 @@
|
||||
}
|
||||
|
||||
public final void setArrowCount(int stuckArrowCount) {
|
||||
@ -1249,7 +1257,7 @@
|
||||
|
||||
public final int getStingerCount() {
|
||||
return (Integer) this.entityData.get(LivingEntity.DATA_STINGER_COUNT_ID);
|
||||
@@ -1999,7 +2561,7 @@
|
||||
@@ -1999,7 +2571,7 @@
|
||||
this.playSound(soundeffect, this.getSoundVolume(), (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||
}
|
||||
|
||||
@ -1258,7 +1266,7 @@
|
||||
this.setHealth(0.0F);
|
||||
this.die(this.damageSources().generic());
|
||||
}
|
||||
@@ -2182,6 +2744,12 @@
|
||||
@@ -2182,6 +2754,12 @@
|
||||
|
||||
public abstract ItemStack getItemBySlot(EquipmentSlot slot);
|
||||
|
||||
@ -1271,7 +1279,7 @@
|
||||
public abstract void setItemSlot(EquipmentSlot slot, ItemStack stack);
|
||||
|
||||
public Iterable<ItemStack> getHandSlots() {
|
||||
@@ -2494,7 +3062,7 @@
|
||||
@@ -2494,7 +3072,7 @@
|
||||
|
||||
}
|
||||
|
||||
@ -1280,7 +1288,7 @@
|
||||
Vec3 vec3d1 = this.getRiddenInput(controllingPlayer, movementInput);
|
||||
|
||||
this.tickRidden(controllingPlayer, vec3d1);
|
||||
@@ -2507,13 +3075,13 @@
|
||||
@@ -2507,13 +3085,13 @@
|
||||
|
||||
}
|
||||
|
||||
@ -1297,7 +1305,7 @@
|
||||
return this.getSpeed();
|
||||
}
|
||||
|
||||
@@ -2571,7 +3139,7 @@
|
||||
@@ -2571,7 +3149,7 @@
|
||||
double d1 = Mth.clamp(motion.z, -0.15000000596046448D, 0.15000000596046448D);
|
||||
double d2 = Math.max(motion.y, -0.15000000596046448D);
|
||||
|
||||
@ -1306,7 +1314,7 @@
|
||||
d2 = 0.0D;
|
||||
}
|
||||
|
||||
@@ -2586,7 +3154,7 @@
|
||||
@@ -2586,7 +3164,7 @@
|
||||
}
|
||||
|
||||
protected float getFlyingSpeed() {
|
||||
@ -1315,7 +1323,7 @@
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
@@ -2634,7 +3202,7 @@
|
||||
@@ -2634,7 +3212,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -1324,7 +1332,7 @@
|
||||
if (this.tickCount % 20 == 0) {
|
||||
this.getCombatTracker().recheckStatus();
|
||||
}
|
||||
@@ -2741,7 +3309,7 @@
|
||||
@@ -2741,7 +3319,7 @@
|
||||
this.elytraAnimationState.tick();
|
||||
}
|
||||
|
||||
@ -1333,14 +1341,15 @@
|
||||
Map<EquipmentSlot, ItemStack> map = this.collectEquipmentChanges();
|
||||
|
||||
if (map != null) {
|
||||
@@ -2778,10 +3346,17 @@
|
||||
@@ -2778,10 +3356,17 @@
|
||||
throw new MatchException((String) null, (Throwable) null);
|
||||
}
|
||||
|
||||
- ItemStack itemstack2 = itemstack1;
|
||||
+ ItemStack itemstack2 = itemstack1; final ItemStack oldEquipment = itemstack2; // Paper - PlayerArmorChangeEvent - obfhelper
|
||||
|
||||
-
|
||||
- itemstack = this.getItemBySlot(enumitemslot);
|
||||
+ ItemStack itemstack2 = itemstack1; final ItemStack oldEquipment = itemstack2; // Paper - PlayerArmorChangeEvent - obfhelper
|
||||
+
|
||||
+ itemstack = this.getItemBySlot(enumitemslot); final ItemStack newEquipment = itemstack;// Paper - PlayerArmorChangeEvent - obfhelper
|
||||
if (this.equipmentHasChanged(itemstack2, itemstack)) {
|
||||
+ // Paper start - PlayerArmorChangeEvent
|
||||
@ -1353,7 +1362,7 @@
|
||||
if (map == null) {
|
||||
map = Maps.newEnumMap(EquipmentSlot.class);
|
||||
}
|
||||
@@ -2974,8 +3549,10 @@
|
||||
@@ -2974,8 +3559,10 @@
|
||||
} else if (this.isInLava() && (!this.onGround() || d3 > d4)) {
|
||||
this.jumpInLiquid(FluidTags.LAVA);
|
||||
} else if ((this.onGround() || flag && d3 <= d4) && this.noJumpDelay == 0) {
|
||||
@ -1364,7 +1373,7 @@
|
||||
}
|
||||
} else {
|
||||
this.noJumpDelay = 0;
|
||||
@@ -3000,7 +3577,7 @@
|
||||
@@ -3000,7 +3587,7 @@
|
||||
{
|
||||
LivingEntity entityliving = this.getControllingPassenger();
|
||||
|
||||
@ -1373,7 +1382,7 @@
|
||||
if (this.isAlive()) {
|
||||
this.travelRidden(entityhuman, vec3d1);
|
||||
break label112;
|
||||
@@ -3063,6 +3640,7 @@
|
||||
@@ -3063,6 +3650,7 @@
|
||||
this.checkSlowFallDistance();
|
||||
if (!this.level().isClientSide) {
|
||||
if (!this.canGlide()) {
|
||||
@ -1381,7 +1390,7 @@
|
||||
this.setSharedFlag(7, false);
|
||||
return;
|
||||
}
|
||||
@@ -3113,12 +3691,26 @@
|
||||
@@ -3113,12 +3701,26 @@
|
||||
Level world = this.level();
|
||||
|
||||
if (!(world instanceof ServerLevel worldserver)) {
|
||||
@ -1410,7 +1419,7 @@
|
||||
|
||||
if (i > 0 && list.size() > i - 1 && this.random.nextInt(4) == 0) {
|
||||
int j = 0;
|
||||
@@ -3138,10 +3730,12 @@
|
||||
@@ -3138,10 +3740,12 @@
|
||||
}
|
||||
|
||||
Iterator iterator1 = list.iterator();
|
||||
@ -1425,7 +1434,7 @@
|
||||
this.doPush(entity1);
|
||||
}
|
||||
}
|
||||
@@ -3190,9 +3784,15 @@
|
||||
@@ -3190,9 +3794,15 @@
|
||||
|
||||
@Override
|
||||
public void stopRiding() {
|
||||
@ -1442,7 +1451,7 @@
|
||||
if (entity != null && entity != this.getVehicle() && !this.level().isClientSide) {
|
||||
this.dismountVehicle(entity);
|
||||
}
|
||||
@@ -3305,15 +3905,22 @@
|
||||
@@ -3305,15 +3915,22 @@
|
||||
|
||||
@Override
|
||||
public boolean isPickable() {
|
||||
@ -1467,7 +1476,7 @@
|
||||
public float getYHeadRot() {
|
||||
return this.yHeadRot;
|
||||
}
|
||||
@@ -3342,7 +3949,7 @@
|
||||
@@ -3342,7 +3959,7 @@
|
||||
}
|
||||
|
||||
public final void setAbsorptionAmount(float absorptionAmount) {
|
||||
@ -1476,7 +1485,7 @@
|
||||
}
|
||||
|
||||
protected void internalSetAbsorptionAmount(float absorptionAmount) {
|
||||
@@ -3410,9 +4017,14 @@
|
||||
@@ -3410,9 +4027,14 @@
|
||||
}
|
||||
|
||||
public void startUsingItem(InteractionHand hand) {
|
||||
@ -1492,7 +1501,7 @@
|
||||
this.useItem = itemstack;
|
||||
this.useItemRemaining = itemstack.getUseDuration(this);
|
||||
if (!this.level().isClientSide) {
|
||||
@@ -3483,13 +4095,49 @@
|
||||
@@ -3483,13 +4105,49 @@
|
||||
this.releaseUsingItem();
|
||||
} else {
|
||||
if (!this.useItem.isEmpty() && this.isUsingItem()) {
|
||||
@ -1506,7 +1515,7 @@
|
||||
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand);
|
||||
+ event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand); // Paper
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Update client
|
||||
+ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE);
|
||||
@ -1517,7 +1526,7 @@
|
||||
+ entityPlayer.getBukkitEntity().updateScaledHealth();
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
+
|
||||
+ itemstack = (craftItem.equals(event.getItem())) ? this.useItem.finishUsingItem(this.level(), this) : CraftItemStack.asNMSCopy(event.getItem()).finishUsingItem(this.level(), this);
|
||||
+ } else {
|
||||
+ itemstack = this.useItem.finishUsingItem(this.level(), this);
|
||||
@ -1543,7 +1552,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3544,12 +4192,69 @@
|
||||
@@ -3544,12 +4202,69 @@
|
||||
if (this.isUsingItem() && !this.useItem.isEmpty()) {
|
||||
Item item = this.useItem.getItem();
|
||||
|
||||
@ -1614,7 +1623,7 @@
|
||||
public boolean isSuppressingSlidingDownLadder() {
|
||||
return this.isShiftKeyDown();
|
||||
}
|
||||
@@ -3568,12 +4273,18 @@
|
||||
@@ -3568,12 +4283,18 @@
|
||||
}
|
||||
|
||||
public boolean randomTeleport(double x, double y, double z, boolean particleEffects) {
|
||||
@ -1635,7 +1644,7 @@
|
||||
Level world = this.level();
|
||||
|
||||
if (world.hasChunkAt(blockposition)) {
|
||||
@@ -3592,18 +4303,43 @@
|
||||
@@ -3592,18 +4313,43 @@
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
@ -1647,7 +1656,7 @@
|
||||
+ this.setPos(d0, d6, d2);
|
||||
if (world.noCollision((Entity) this) && !world.containsAnyLiquid(this.getBoundingBox())) {
|
||||
flag1 = true;
|
||||
+ }
|
||||
}
|
||||
+ // now revert and call event if the teleport place is valid
|
||||
+ this.setPos(d3, d4, d5);
|
||||
+
|
||||
@ -1667,7 +1676,7 @@
|
||||
+ return Optional.empty();
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
@ -1683,7 +1692,7 @@
|
||||
world.broadcastEntityEvent(this, (byte) 46);
|
||||
}
|
||||
|
||||
@@ -3613,7 +4349,7 @@
|
||||
@@ -3613,7 +4359,7 @@
|
||||
entitycreature.getNavigation().stop();
|
||||
}
|
||||
|
||||
@ -1692,7 +1701,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3706,7 +4442,7 @@
|
||||
@@ -3706,7 +4452,7 @@
|
||||
}
|
||||
|
||||
public void stopSleeping() {
|
||||
@ -1701,7 +1710,7 @@
|
||||
Level world = this.level();
|
||||
|
||||
java.util.Objects.requireNonNull(world);
|
||||
@@ -3718,9 +4454,9 @@
|
||||
@@ -3718,9 +4464,9 @@
|
||||
|
||||
this.level().setBlock(blockposition, (BlockState) iblockdata.setValue(BedBlock.OCCUPIED, false), 3);
|
||||
Vec3 vec3d = (Vec3) BedBlock.findStandUpPosition(this.getType(), this.level(), blockposition, enumdirection, this.getYRot()).orElseGet(() -> {
|
||||
@ -1713,7 +1722,7 @@
|
||||
});
|
||||
Vec3 vec3d1 = Vec3.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
|
||||
float f = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||
@@ -3740,7 +4476,7 @@
|
||||
@@ -3740,7 +4486,7 @@
|
||||
|
||||
@Nullable
|
||||
public Direction getBedOrientation() {
|
||||
@ -1722,7 +1731,7 @@
|
||||
|
||||
return blockposition != null ? BedBlock.getBedOrientation(this.level(), blockposition) : null;
|
||||
}
|
||||
@@ -3905,7 +4641,7 @@
|
||||
@@ -3905,7 +4651,7 @@
|
||||
public float maxUpStep() {
|
||||
float f = (float) this.getAttributeValue(Attributes.STEP_HEIGHT);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user