Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
5c7081fecc
* Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories CraftBukkit Changes:4090d01f
SPIGOT-5047: Correct slot types for 1.14 inventoriese8c08362
SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.d445af3b
SPIGOT-5067: Add item meta for 1.14 spawn eggs * Bring Chunk load checks in-line with spigot As of the last upstream merge spigot now checks ticket level status when returning loaded chunks for a world from api. Now our checks will respect that decision. * Fix spawn ticket levels Vanilla would keep the inner chunks of spawn available for ticking, however my changes made all chunks non-ticking. Resolve by changing ticket levels for spawn chunks inside the border to respect this behavior. * Make World#getChunkIfLoadedImmediately return only entity ticking chunks Mojang appears to be using chunks with level > 33 (non-ticking chunks) as cached chunks and not actually loaded chunks. * Bring all loaded checks in line with spigot Loaded chunks must be at least border chunks, or level <= 33
171 Zeilen
7.5 KiB
Diff
171 Zeilen
7.5 KiB
Diff
From b92ac87aaa7dc9eb195df2af855c238950803372 Mon Sep 17 00:00:00 2001
|
|
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
|
|
index 96cf4bccea..e28c0673dd 100644
|
|
--- a/src/main/java/net/minecraft/server/EntitySlime.java
|
|
+++ b/src/main/java/net/minecraft/server/EntitySlime.java
|
|
@@ -2,6 +2,14 @@ package net.minecraft.server;
|
|
|
|
import java.util.EnumSet;
|
|
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;
|
|
@@ -63,6 +71,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
super.b(nbttagcompound);
|
|
nbttagcompound.setInt("Size", this.getSize() - 1);
|
|
nbttagcompound.setBoolean("wasOnGround", this.bA);
|
|
+ nbttagcompound.setBoolean("Paper.canWander", this.canWander); // Paper
|
|
}
|
|
|
|
@Override
|
|
@@ -76,6 +85,11 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
|
|
this.setSize(i + 1, false);
|
|
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
|
|
}
|
|
|
|
public boolean ea() {
|
|
@@ -344,7 +358,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
|
|
@Override
|
|
public boolean a() {
|
|
- return !this.a.isPassenger();
|
|
+ return !this.a.isPassenger() && this.a.canWander && new SlimeWanderEvent((Slime) this.a.getBukkitEntity()).callEvent(); // Paper
|
|
}
|
|
|
|
@Override
|
|
@@ -365,7 +379,7 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
|
|
@Override
|
|
public boolean a() {
|
|
- return (this.a.isInWater() || this.a.aC()) && this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime;
|
|
+ return (this.a.isInWater() || this.a.aC()) && this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime && this.a.canWander && new SlimeSwimEvent((Slime) this.a.getBukkitEntity()).callEvent(); // Paper
|
|
}
|
|
|
|
@Override
|
|
@@ -391,14 +405,18 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
|
|
@Override
|
|
public boolean a() {
|
|
- return this.a.getGoalTarget() == null && (this.a.onGround || this.a.isInWater() || this.a.aC() || 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.aC() || this.a.hasEffect(MobEffects.LEVITATION)) && this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime; // Paper
|
|
}
|
|
|
|
@Override
|
|
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));
|
|
+ if (!this.a.canWander || !event.callEvent()) return;
|
|
+ this.b = event.getNewYaw();
|
|
+ // Paper end
|
|
}
|
|
|
|
((EntitySlime.ControllerMoveSlime) this.a.getControllerMove()).a(this.b, false);
|
|
@@ -419,7 +437,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
public boolean a() {
|
|
EntityLiving entityliving = this.a.getGoalTarget();
|
|
|
|
- return entityliving == null ? false : (!entityliving.isAlive() ? false : (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable ? false : this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime));
|
|
+ // Paper start
|
|
+ if (entityliving == null || !entityliving.isAlive()) {
|
|
+ return false;
|
|
+ }
|
|
+ if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) {
|
|
+ return false;
|
|
+ }
|
|
+ return this.a.getControllerMove() instanceof EntitySlime.ControllerMoveSlime && this.a.canWander && new SlimeTargetLivingEntityEvent((Slime) this.a.getBukkitEntity(), (LivingEntity) entityliving.getBukkitEntity()).callEvent();
|
|
+ // Paper end
|
|
}
|
|
|
|
@Override
|
|
@@ -432,7 +458,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
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;
|
|
+ }
|
|
+ return --this.b > 0 && this.a.canWander && new SlimeTargetLivingEntityEvent((Slime) this.a.getBukkitEntity(), (LivingEntity) entityliving.getBukkitEntity()).callEvent();
|
|
+ // Paper end
|
|
}
|
|
|
|
@Override
|
|
@@ -440,6 +474,13 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
this.a.a((Entity) this.a.getGoalTarget(), 10.0F, 10.0F);
|
|
((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 {
|
|
@@ -498,4 +539,15 @@ public class EntitySlime extends EntityInsentient implements IMonster {
|
|
}
|
|
}
|
|
}
|
|
+
|
|
+ // 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
|
|
index ce6ed6e890..6e9f1b66df 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftSlime.java
|
|
@@ -35,4 +35,14 @@ public class CraftSlime extends CraftMob implements Slime {
|
|
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.21.0
|
|
|