mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
Added goat ram event
This commit is contained in:
@@ -1,70 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: SageSphinx63920 <sage@sagesphinx63920.dev>
|
|
||||||
Date: Sat, 29 Oct 2022 00:06:05 +0200
|
|
||||||
Subject: [PATCH] Added goat ram event
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/GoatRamEntityEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/GoatRamEntityEvent.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..f0a7fe694db145294ff93d320382d1baecc68702
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/GoatRamEntityEvent.java
|
|
||||||
@@ -0,0 +1,58 @@
|
|
||||||
+package org.purpurmc.purpur.event.entity;
|
|
||||||
+
|
|
||||||
+import org.bukkit.entity.Goat;
|
|
||||||
+import org.bukkit.entity.LivingEntity;
|
|
||||||
+import org.bukkit.event.Cancellable;
|
|
||||||
+import org.bukkit.event.HandlerList;
|
|
||||||
+import org.bukkit.event.entity.EntityEvent;
|
|
||||||
+import org.jetbrains.annotations.ApiStatus;
|
|
||||||
+import org.jspecify.annotations.NullMarked;
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * Called when a goat rams an entity
|
|
||||||
+ */
|
|
||||||
+@NullMarked
|
|
||||||
+public class GoatRamEntityEvent extends EntityEvent implements Cancellable {
|
|
||||||
+ private static final HandlerList handlers = new HandlerList();
|
|
||||||
+ private final LivingEntity rammedEntity;
|
|
||||||
+ private boolean cancelled;
|
|
||||||
+
|
|
||||||
+ @ApiStatus.Internal
|
|
||||||
+ public GoatRamEntityEvent(Goat goat, LivingEntity rammedEntity) {
|
|
||||||
+ super(goat);
|
|
||||||
+ this.rammedEntity = rammedEntity;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Returns the entity that was rammed by the goat
|
|
||||||
+ *
|
|
||||||
+ * @return The rammed entity
|
|
||||||
+ */
|
|
||||||
+ public LivingEntity getRammedEntity() {
|
|
||||||
+ return this.rammedEntity;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public Goat getEntity() {
|
|
||||||
+ return (Goat) super.getEntity();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public HandlerList getHandlers() {
|
|
||||||
+ return handlers;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static HandlerList getHandlerList() {
|
|
||||||
+ return handlers;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public boolean isCancelled() {
|
|
||||||
+ return this.cancelled;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public void setCancelled(boolean cancel) {
|
|
||||||
+ this.cancelled = cancel;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: SageSphinx63920 <sage@sagesphinx63920.dev>
|
|
||||||
Date: Sat, 29 Oct 2022 00:06:41 +0200
|
|
||||||
Subject: [PATCH] Added got ram event
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/entity/animal/goat/Goat.java b/net/minecraft/world/entity/animal/goat/Goat.java
|
|
||||||
index 214a97aa88c569f55619512e712b7bfe32d26b30..54485641271a0570a4c6229eb1c5cb8ddff534b4 100644
|
|
||||||
--- a/net/minecraft/world/entity/animal/goat/Goat.java
|
|
||||||
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
|
|
||||||
@@ -435,6 +435,7 @@ public class Goat extends Animal {
|
|
||||||
|
|
||||||
// Paper start - Goat ram API
|
|
||||||
public void ram(net.minecraft.world.entity.LivingEntity entity) {
|
|
||||||
+ if(!new org.purpurmc.purpur.event.entity.GoatRamEntityEvent((org.bukkit.entity.Goat) getBukkitEntity(), (org.bukkit.entity.LivingEntity) entity.getBukkitLivingEntity()).callEvent()) return; // Purpur
|
|
||||||
Brain<Goat> brain = this.getBrain();
|
|
||||||
brain.setMemory(MemoryModuleType.RAM_TARGET, entity.position());
|
|
||||||
brain.eraseMemory(MemoryModuleType.RAM_COOLDOWN_TICKS);
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package org.purpurmc.purpur.event.entity;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Goat;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.entity.EntityEvent;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
import org.jspecify.annotations.NullMarked;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a goat rams an entity
|
||||||
|
*/
|
||||||
|
@NullMarked
|
||||||
|
public class GoatRamEntityEvent extends EntityEvent implements Cancellable {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private final LivingEntity rammedEntity;
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public GoatRamEntityEvent(Goat goat, LivingEntity rammedEntity) {
|
||||||
|
super(goat);
|
||||||
|
this.rammedEntity = rammedEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the entity that was rammed by the goat
|
||||||
|
*
|
||||||
|
* @return The rammed entity
|
||||||
|
*/
|
||||||
|
public LivingEntity getRammedEntity() {
|
||||||
|
return this.rammedEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Goat getEntity() {
|
||||||
|
return (Goat) super.getEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return this.cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancelled = cancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
--- a/net/minecraft/world/entity/animal/goat/Goat.java
|
||||||
|
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
|
||||||
|
@@ -393,6 +_,7 @@
|
||||||
|
|
||||||
|
// Paper start - Goat ram API
|
||||||
|
public void ram(net.minecraft.world.entity.LivingEntity entity) {
|
||||||
|
+ if(!new org.purpurmc.purpur.event.entity.GoatRamEntityEvent((org.bukkit.entity.Goat) getBukkitEntity(), entity.getBukkitLivingEntity()).callEvent()) return; // Purpur - Added goat ram event
|
||||||
|
Brain<Goat> brain = this.getBrain();
|
||||||
|
brain.setMemory(MemoryModuleType.RAM_TARGET, entity.position());
|
||||||
|
brain.eraseMemory(MemoryModuleType.RAM_COOLDOWN_TICKS);
|
||||||
Reference in New Issue
Block a user