Add PlayerStopUsingItemEvent
This commit is contained in:
@@ -969,12 +969,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1681,8 +2057,22 @@
|
@@ -1683,6 +2059,20 @@
|
||||||
|
|
||||||
public LivingEntity.Fallsounds getFallSounds() {
|
|
||||||
return new LivingEntity.Fallsounds(SoundEvents.GENERIC_SMALL_FALL, SoundEvents.GENERIC_BIG_FALL);
|
return new LivingEntity.Fallsounds(SoundEvents.GENERIC_SMALL_FALL, SoundEvents.GENERIC_BIG_FALL);
|
||||||
+ }
|
}
|
||||||
+
|
|
||||||
+ // CraftBukkit start - Add delegate methods
|
+ // CraftBukkit start - Add delegate methods
|
||||||
+ public SoundEvent getHurtSound0(DamageSource damagesource) {
|
+ public SoundEvent getHurtSound0(DamageSource damagesource) {
|
||||||
+ return this.getHurtSound(damagesource);
|
+ return this.getHurtSound(damagesource);
|
||||||
@@ -982,8 +980,8 @@
|
|||||||
+
|
+
|
||||||
+ public SoundEvent getDeathSound0() {
|
+ public SoundEvent getDeathSound0() {
|
||||||
+ return this.getDeathSound();
|
+ return this.getDeathSound();
|
||||||
}
|
+ }
|
||||||
|
+
|
||||||
+ public SoundEvent getFallDamageSound0(int fallHeight) {
|
+ public SoundEvent getFallDamageSound0(int fallHeight) {
|
||||||
+ return this.getFallDamageSound(fallHeight);
|
+ return this.getFallDamageSound(fallHeight);
|
||||||
+ }
|
+ }
|
||||||
@@ -1602,7 +1600,7 @@
|
|||||||
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand);
|
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand);
|
||||||
+ event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand); // Paper
|
+ event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand); // Paper
|
||||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||||
|
+
|
||||||
+ if (event.isCancelled()) {
|
+ if (event.isCancelled()) {
|
||||||
+ // Update client
|
+ // Update client
|
||||||
+ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE);
|
+ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE);
|
||||||
@@ -1626,7 +1624,7 @@
|
|||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
+
|
|
||||||
if (itemstack != this.useItem) {
|
if (itemstack != this.useItem) {
|
||||||
this.setItemInHand(enumhand, itemstack);
|
this.setItemInHand(enumhand, itemstack);
|
||||||
}
|
}
|
||||||
@@ -1640,7 +1638,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3544,12 +4242,69 @@
|
@@ -3512,6 +4210,7 @@
|
||||||
|
|
||||||
|
public void releaseUsingItem() {
|
||||||
|
if (!this.useItem.isEmpty()) {
|
||||||
|
+ if (this instanceof ServerPlayer) new io.papermc.paper.event.player.PlayerStopUsingItemEvent((Player) getBukkitEntity(), useItem.asBukkitMirror(), getTicksUsingItem()).callEvent(); // Paper - Add PlayerStopUsingItemEvent
|
||||||
|
this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks());
|
||||||
|
if (this.useItem.useOnRelease()) {
|
||||||
|
this.updatingUsingItem();
|
||||||
|
@@ -3544,12 +4243,69 @@
|
||||||
if (this.isUsingItem() && !this.useItem.isEmpty()) {
|
if (this.isUsingItem() && !this.useItem.isEmpty()) {
|
||||||
Item item = this.useItem.getItem();
|
Item item = this.useItem.getItem();
|
||||||
|
|
||||||
@@ -1711,7 +1717,7 @@
|
|||||||
public boolean isSuppressingSlidingDownLadder() {
|
public boolean isSuppressingSlidingDownLadder() {
|
||||||
return this.isShiftKeyDown();
|
return this.isShiftKeyDown();
|
||||||
}
|
}
|
||||||
@@ -3568,12 +4323,18 @@
|
@@ -3568,12 +4324,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean randomTeleport(double x, double y, double z, boolean particleEffects) {
|
public boolean randomTeleport(double x, double y, double z, boolean particleEffects) {
|
||||||
@@ -1732,7 +1738,7 @@
|
|||||||
Level world = this.level();
|
Level world = this.level();
|
||||||
|
|
||||||
if (world.hasChunkAt(blockposition)) {
|
if (world.hasChunkAt(blockposition)) {
|
||||||
@@ -3592,18 +4353,43 @@
|
@@ -3592,18 +4354,43 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag2) {
|
if (flag2) {
|
||||||
@@ -1780,7 +1786,7 @@
|
|||||||
world.broadcastEntityEvent(this, (byte) 46);
|
world.broadcastEntityEvent(this, (byte) 46);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3613,7 +4399,7 @@
|
@@ -3613,7 +4400,7 @@
|
||||||
entitycreature.getNavigation().stop();
|
entitycreature.getNavigation().stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1789,7 +1795,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3706,7 +4492,7 @@
|
@@ -3706,7 +4493,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopSleeping() {
|
public void stopSleeping() {
|
||||||
@@ -1798,7 +1804,7 @@
|
|||||||
Level world = this.level();
|
Level world = this.level();
|
||||||
|
|
||||||
java.util.Objects.requireNonNull(world);
|
java.util.Objects.requireNonNull(world);
|
||||||
@@ -3718,9 +4504,9 @@
|
@@ -3718,9 +4505,9 @@
|
||||||
|
|
||||||
this.level().setBlock(blockposition, (BlockState) iblockdata.setValue(BedBlock.OCCUPIED, false), 3);
|
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(() -> {
|
Vec3 vec3d = (Vec3) BedBlock.findStandUpPosition(this.getType(), this.level(), blockposition, enumdirection, this.getYRot()).orElseGet(() -> {
|
||||||
@@ -1810,7 +1816,7 @@
|
|||||||
});
|
});
|
||||||
Vec3 vec3d1 = Vec3.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
|
Vec3 vec3d1 = Vec3.atBottomCenterOf(blockposition).subtract(vec3d).normalize();
|
||||||
float f = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
float f = (float) Mth.wrapDegrees(Mth.atan2(vec3d1.z, vec3d1.x) * 57.2957763671875D - 90.0D);
|
||||||
@@ -3740,7 +4526,7 @@
|
@@ -3740,7 +4527,7 @@
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Direction getBedOrientation() {
|
public Direction getBedOrientation() {
|
||||||
@@ -1819,7 +1825,7 @@
|
|||||||
|
|
||||||
return blockposition != null ? BedBlock.getBedOrientation(this.level(), blockposition) : null;
|
return blockposition != null ? BedBlock.getBedOrientation(this.level(), blockposition) : null;
|
||||||
}
|
}
|
||||||
@@ -3905,7 +4691,7 @@
|
@@ -3905,7 +4692,7 @@
|
||||||
public float maxUpStep() {
|
public float maxUpStep() {
|
||||||
float f = (float) this.getAttributeValue(Attributes.STEP_HEIGHT);
|
float f = (float) this.getAttributeValue(Attributes.STEP_HEIGHT);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user