This commit is contained in:
Owen1212055 2024-03-23 16:19:07 -04:00
parent 6945613892
commit 95daa596eb
No known key found for this signature in database
GPG Key ID: 2133292072886A30
2 changed files with 28 additions and 25 deletions

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Added EntityDamageDoorEvent and implemented into Server.
diff --git a/src/main/java/io/papermc/paper/event/entity/EntityDamageDoorEvent.java b/src/main/java/io/papermc/paper/event/entity/EntityDamageDoorEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..403ede1eece18d5b70117a789f27903887525581
index 0000000000000000000000000000000000000000..dcba0dca1713ad836fe4af90342d58ce5049db9d
--- /dev/null
+++ b/src/main/java/io/papermc/paper/event/entity/EntityDamageDoorEvent.java
@@ -0,0 +1,125 @@
@@ -0,0 +1,128 @@
+package io.papermc.paper.event.entity;
+
+import com.google.common.base.Preconditions;
@ -31,17 +31,17 @@ index 0000000000000000000000000000000000000000..403ede1eece18d5b70117a789f279038
+
+ private final BlockData damagedDoor;
+ private boolean cancelled;
+ private int breakTime;
+ private final int doorBreakTime;
+ private boolean playEffect;
+ private int currentBreakTicks;
+ private final int requiredBreakTicks;
+ private boolean playsEffect;
+
+ @ApiStatus.Internal
+ public EntityDamageDoorEvent(final @NotNull Entity what, final @NotNull BlockData damagedDoor, final int breakTime, final int doorBreakTime, boolean playEffect) {
+ public EntityDamageDoorEvent(final @NotNull Entity what, final @NotNull BlockData damagedDoor, final int currentBreakTicks, final int requiredBreakTicks, boolean playsEffect) {
+ super(what);
+ this.damagedDoor = damagedDoor;
+ this.breakTime = breakTime;
+ this.doorBreakTime = doorBreakTime;
+ this.playEffect = playEffect;
+ this.currentBreakTicks = currentBreakTicks;
+ this.requiredBreakTicks = requiredBreakTicks;
+ this.playsEffect = playsEffect;
+ }
+
+ /**
@ -52,7 +52,7 @@ index 0000000000000000000000000000000000000000..403ede1eece18d5b70117a789f279038
+ */
+ @NotNull
+ public BlockData getDamagedDoor() {
+ return this.damagedDoor;
+ return this.damagedDoor.clone();
+ }
+
+ /**
@ -63,20 +63,23 @@ index 0000000000000000000000000000000000000000..403ede1eece18d5b70117a789f279038
+ * @return The breaking progress value.
+ */
+ @Range(from = 0, to = Integer.MAX_VALUE)
+ public int getBreakTime() {
+ return this.breakTime;
+ public int getCurrentBreakTicks() {
+ return this.currentBreakTicks;
+ }
+
+ /**
+ * Set the current progress in ticks that
+ * this entity has spent damaging the door.
+ * <p>
+ * To instantly break this door, supply {@link EntityDamageDoorEvent#getRequiredBreakTicks()} - 1 into this
+ * method.
+ *
+ * @param breakTime The ticks spent damaging the door.
+ * @param breakTicks The ticks spent damaging the door.
+ */
+ public void setBreakTime(@Range(from = 0, to = Integer.MAX_VALUE) final int breakTime) {
+ Preconditions.checkArgument(breakTime >= 0, "The breaking progress must be at least 0!");
+ Preconditions.checkArgument(breakTime < this.doorBreakTime, "The door breaking time cannot be greater than or equal to the amount of ticks required to break the door!");
+ this.breakTime = breakTime;
+ public void setCurrentBreakTicks(@Range(from = 0, to = Integer.MAX_VALUE) final int breakTicks) {
+ Preconditions.checkArgument(breakTicks >= 0, "The breaking progress must be at least 0!");
+ Preconditions.checkArgument(breakTicks < this.requiredBreakTicks, "The door breaking time cannot be greater than or equal to the amount of ticks required to break the door!");
+ this.currentBreakTicks = breakTicks;
+ }
+
+ /**
@ -86,8 +89,8 @@ index 0000000000000000000000000000000000000000..403ede1eece18d5b70117a789f279038
+ * @return The amount of ticks necessary for the entity to break the door.
+ */
+ @Range(from = 0, to = Integer.MAX_VALUE)
+ public int getDoorBreakTime() {
+ return this.doorBreakTime;
+ public int getRequiredBreakTicks() {
+ return this.requiredBreakTicks;
+ }
+
+ /**
@ -97,17 +100,17 @@ index 0000000000000000000000000000000000000000..403ede1eece18d5b70117a789f279038
+ * @return will play effect
+ */
+ public boolean playsEffect() {
+ return this.playEffect;
+ return this.playsEffect;
+ }
+
+ /**
+ * Sets if this should play an effect when damaging the door.
+ * This includes the sound, and arm swing (if the entity isn't currently swinging)
+ *
+ * @param playEffects will play effect
+ * @param playsEffect will play effect
+ */
+ public void playsEffect(final boolean playEffects) {
+ this.playEffect = playEffects;
+ public void playsEffect(final boolean playsEffect) {
+ this.playsEffect = playsEffect;
+ }
+
+ @Override

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Added EntityDamageDoorEvent and implemented into Server.
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java
index a85885ee51df585fa11ae9f8fcd67ff2a71c5a18..a9f1cdeacaa8d73b1385da1f643a1fce99269693 100644
index a85885ee51df585fa11ae9f8fcd67ff2a71c5a18..165f09d15f3c5ace37441035c18fe8c67e4a2efc 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/BreakDoorGoal.java
@@ -55,7 +55,20 @@ public class BreakDoorGoal extends DoorInteractGoal {
@ -22,7 +22,7 @@ index a85885ee51df585fa11ae9f8fcd67ff2a71c5a18..a9f1cdeacaa8d73b1385da1f643a1fce
+ return;
+ }
+
+ this.breakTime = event.getBreakTime();
+ this.breakTime = event.getCurrentBreakTicks();
+ playEffect = event.playsEffect();
+ // Paper end
+