Paper/Spigot-Server-Patches/0291-Slime-Pathfinder-Events.patch

171 lines
7.5 KiB
Diff
Raw Normal View History

2019-07-20 06:01:24 +02:00
From c1aebef600be981587f5720b073036ed868e11ff Mon Sep 17 00:00:00 2001
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Fri, 24 Aug 2018 08:18:42 -0500
Subject: [PATCH] Slime Pathfinder Events
diff --git a/src/main/java/net/minecraft/server/EntitySlime.java b/src/main/java/net/minecraft/server/EntitySlime.java
2019-07-20 06:01:24 +02:00
index a5238c6734..253ff9594c 100644
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
--- a/src/main/java/net/minecraft/server/EntitySlime.java
+++ b/src/main/java/net/minecraft/server/EntitySlime.java
@@ -3,6 +3,14 @@ package net.minecraft.server;
2019-05-05 10:33:44 +02:00
import java.util.EnumSet;
import java.util.Random;
import javax.annotation.Nullable;
+// Paper start
+import com.destroystokyo.paper.event.entity.SlimeChangeDirectionEvent;
+import com.destroystokyo.paper.event.entity.SlimeSwimEvent;
+import com.destroystokyo.paper.event.entity.SlimeTargetLivingEntityEvent;
+import com.destroystokyo.paper.event.entity.SlimeWanderEvent;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Slime;
+// Paper end
// CraftBukkit start
import java.util.ArrayList;
import java.util.List;
@@ -64,6 +72,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
super.b(nbttagcompound);
nbttagcompound.setInt("Size", this.getSize() - 1);
2019-05-05 10:33:44 +02:00
nbttagcompound.setBoolean("wasOnGround", this.bA);
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
+ nbttagcompound.setBoolean("Paper.canWander", this.canWander); // Paper
}
2019-05-05 10:33:44 +02:00
@Override
@@ -77,6 +86,11 @@ public class EntitySlime extends EntityInsentient implements IMonster {
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
this.setSize(i + 1, false);
2019-05-05 10:33:44 +02:00
this.bA = nbttagcompound.getBoolean("wasOnGround");
+ // Paper start - check exists before loading or this will be loaded as false
+ if (nbttagcompound.hasKey("Paper.canWander")) {
+ this.canWander = nbttagcompound.getBoolean("Paper.canWander");
+ }
+ // Paper end
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
}
2019-07-20 06:01:24 +02:00
public boolean ea() {
@@ -342,7 +356,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
2019-05-05 10:33:44 +02:00
@Override
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
public boolean a() {
2019-05-05 10:33:44 +02:00
- return !this.a.isPassenger();
+ return !this.a.isPassenger() && this.a.canWander && new SlimeWanderEvent((Slime) this.a.getBukkitEntity()).callEvent(); // Paper
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
}
2019-05-05 10:33:44 +02:00
@Override
@@ -363,7 +377,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
2019-05-05 10:33:44 +02:00
@Override
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
public boolean a() {
- return (this.a.isInWater() || this.a.aD()) && this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime;
+ return (this.a.isInWater() || this.a.aD()) && this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime && this.a.canWander && new SlimeSwimEvent((Slime) this.a.getBukkitEntity()).callEvent(); // Paper
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
}
2019-05-05 10:33:44 +02:00
@Override
@@ -389,14 +403,18 @@ public class EntitySlime extends EntityInsentient implements IMonster {
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
2019-05-05 10:33:44 +02:00
@Override
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
public boolean a() {
- return this.a.getGoalTarget() == null && (this.a.onGround || this.a.isInWater() || this.a.aD() || this.a.hasEffect(MobEffects.LEVITATION)) && this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime;
+ return this.a.canWander && this.a.getGoalTarget() == null && (this.a.onGround || this.a.isInWater() || this.a.aD() || this.a.hasEffect(MobEffects.LEVITATION)) && this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime;
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
}
2019-05-05 10:33:44 +02:00
@Override
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
public void e() {
if (--this.c <= 0) {
this.c = 40 + this.a.getRandom().nextInt(60);
- this.b = (float) this.a.getRandom().nextInt(360);
+ // Paper start
+ SlimeChangeDirectionEvent event = new SlimeChangeDirectionEvent((Slime) this.a.getBukkitEntity(), (float) this.a.getRandom().nextInt(360));
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
+ if (!this.a.canWander || !event.callEvent()) return;
+ this.b = event.getNewYaw();
+ // Paper end
}
((EntitySlime.ControllerMoveSlime) this.a.getControllerMove()).a(this.b, false);
@@ -417,7 +435,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
public boolean a() {
EntityLiving entityliving = this.a.getGoalTarget();
2019-05-05 10:33:44 +02:00
- return entityliving == null ? false : (!entityliving.isAlive() ? false : (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable ? false : this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime));
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
+ // Paper start
+ if (entityliving == null || !entityliving.isAlive()) {
+ return false;
+ }
+ if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) {
+ return false;
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
+ }
2019-05-05 10:33:44 +02:00
+ return this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime && this.a.canWander && new SlimeTargetLivingEntityEvent((Slime) this.a.getBukkitEntity(), (LivingEntity) entityliving.getBukkitEntity()).callEvent();
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
+ // Paper end
}
2019-05-05 10:33:44 +02:00
@Override
@@ -430,7 +456,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
public boolean b() {
EntityLiving entityliving = this.a.getGoalTarget();
- return entityliving == null ? false : (!entityliving.isAlive() ? false : (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable ? false : --this.b > 0));
+ // Paper start
+ if (entityliving == null || !entityliving.isAlive()) {
+ return false;
+ }
+ if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) {
+ return false;
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
+ }
+ return --this.b > 0 && this.a.canWander && new SlimeTargetLivingEntityEvent((Slime) this.a.getBukkitEntity(), (LivingEntity) entityliving.getBukkitEntity()).callEvent();
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
+ // Paper end
}
2019-05-05 10:33:44 +02:00
@Override
@@ -438,6 +472,13 @@ public class EntitySlime extends EntityInsentient implements IMonster {
this.a.a((Entity) this.a.getGoalTarget(), 10.0F, 10.0F);
2019-07-20 06:01:24 +02:00
((EntitySlime.ControllerMoveSlime) this.a.getControllerMove()).a(this.a.yaw, this.a.dV());
}
+
+ // Paper start - clear timer and target when goal resets
+ public void d() {
+ this.b = 0;
+ this.a.setGoalTarget(null);
+ }
+ // Paper end
}
static class ControllerMoveSlime extends ControllerMove {
@@ -496,4 +537,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
}
}
}
+
+ // Paper start
+ private boolean canWander = true;
+ public boolean canWander() {
+ return canWander;
+ }
+
+ public void setWander(boolean canWander) {
+ this.canWander = canWander;
+ }
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
2019-07-20 06:01:24 +02:00
index ce6ed6e890..6e9f1b66df 100644
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
2019-05-06 04:58:04 +02:00
@@ -35,4 +35,14 @@ public class CraftSlime extends CraftMob implements Slime {
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00
public EntityType getType() {
return EntityType.SLIME;
}
+
+ // Paper start
+ public boolean canWander() {
+ return getHandle().canWander();
+ }
+
+ public void setWander(boolean canWander) {
+ getHandle().setWander(canWander);
+ }
+ // Paper end
}
--
2.22.0
1.13: Slime Patherfinder Events (#1246) Replaces PR #1161 for 1.13 Resolves #930 Adds new slime pathfinder related events. All events can be cancelled. - `SlimePathfindEvent` is the base event of all added events. Cancelling this event will cancel all pathfinders. - `SlimeWanderEvent` is called when slimes wander around by either swimming or moving/jumping forward. Cancelling this event will prevent slimes from moving around and jumping, but they will still look around and target players. - `SlimeSwimEvent`is called when slimes are swimming in water/lava. Cancelling will prevent the slimes from moving/jumping in water/lava. - `SlimeChangeDirectionEvent` is called when a slime changes directions. It contains the new `yaw` position the slime wants to change to, and it can be set to another value. Cancelling this event will prevent slimes from changing directions (except for when targeting players). - `SlimeTargetLivingEntityEvent` is called when a slime targets a player. NMS uses EntityLiving here so it is named this. Contains the LivingEntity the slime has targeted. Cancelling this event will prevent the slime from targeting the entity and will make it lose current focus. Adds `Slime#canWander()` and `Slime#setWander(boolean)` for a more persistent control (does not persist server restarts) over all 4 pathfinder types without the spammy event having to be cancelled a bajillion times a second. Video demonstration: https://youtu.be/8hcLqazmO28 Test plugin: https://pastebin.com/cFgcgdWV
2018-08-24 16:40:14 +02:00