2018-09-29 01:31:59 +02:00
From 41be89ac350a161565254c71c675b9b3f06d6021 Mon Sep 17 00:00:00 2001
2016-12-28 06:19:58 +01:00
From: Aikar <aikar@aikar.co>
Date: Tue, 27 Dec 2016 22:38:06 -0500
Subject: [PATCH] Activation Range Improvements
Fixes and adds new Immunities to improve gameplay behavior
2018-09-01 00:56:57 +02:00
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
index f4ed98d2d9..1dfd71df0a 100644
--- a/src/main/java/net/minecraft/server/BlockPosition.java
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
@@ -326,6 +326,7 @@ public class BlockPosition extends BaseBlockPosition {
this.c = i;
}
+ public BlockPosition toBlockPosition() { return h(); } // Paper - OBFHELPER
public BlockPosition h() {
return new BlockPosition(this);
}
2016-12-28 06:19:58 +01:00
diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java
2018-09-01 00:56:57 +02:00
index a5c147b989..9e88897a07 100644
2016-12-28 06:19:58 +01:00
--- a/src/main/java/net/minecraft/server/EntityCreature.java
+++ b/src/main/java/net/minecraft/server/EntityCreature.java
2018-08-04 23:03:53 +02:00
@@ -7,6 +7,7 @@ import org.bukkit.event.entity.EntityUnleashEvent;
2018-07-17 22:32:05 +02:00
public abstract class EntityCreature extends EntityInsentient {
2016-12-28 06:19:58 +01:00
2018-09-01 00:56:57 +02:00
public org.bukkit.craftbukkit.entity.CraftCreature getBukkitCreature() { return (org.bukkit.craftbukkit.entity.CraftCreature) super.getBukkitEntity(); } // Paper
2016-12-28 06:19:58 +01:00
+ public BlockPosition movingTarget = null; public BlockPosition getMovingTarget() { return movingTarget; } // Paper
private BlockPosition a;
private float b;
2018-07-17 22:32:05 +02:00
2016-12-28 06:19:58 +01:00
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
2018-09-29 01:31:59 +02:00
index 4fe91b5a2f..91f831326c 100644
2016-12-28 06:19:58 +01:00
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2018-07-20 21:57:43 +02:00
@@ -74,7 +74,7 @@ public abstract class EntityLiving extends Entity {
2018-07-17 22:32:05 +02:00
public float aT;
public float aU;
2016-12-28 06:19:58 +01:00
public EntityHuman killer;
- protected int lastDamageByPlayerTime;
+ public int lastDamageByPlayerTime; // Paper - public
2018-07-17 22:32:05 +02:00
protected boolean aX;
2016-12-28 06:19:58 +01:00
protected int ticksFarFromPlayer;
2018-07-17 22:32:05 +02:00
protected float aZ;
2016-12-28 06:19:58 +01:00
diff --git a/src/main/java/net/minecraft/server/EntityLlama.java b/src/main/java/net/minecraft/server/EntityLlama.java
2018-09-01 00:56:57 +02:00
index b661a86901..26184f463a 100644
2016-12-28 06:19:58 +01:00
--- a/src/main/java/net/minecraft/server/EntityLlama.java
+++ b/src/main/java/net/minecraft/server/EntityLlama.java
2018-09-01 00:56:57 +02:00
@@ -340,6 +340,7 @@ public class EntityLlama extends EntityHorseChestedAbstract implements IRangedEn
2018-07-17 22:32:05 +02:00
return this.bR != null;
2016-12-28 06:19:58 +01:00
}
2018-08-26 20:11:49 +02:00
+ public boolean inCaravan() { return this.em(); } // Paper - OBFHELPER
public boolean em() {
2018-07-17 22:32:05 +02:00
return this.bQ != null;
2016-12-28 06:19:58 +01:00
}
diff --git a/src/main/java/net/minecraft/server/PathfinderGoal.java b/src/main/java/net/minecraft/server/PathfinderGoal.java
2018-09-01 00:56:57 +02:00
index acc099e955..339c78eec9 100644
2016-12-28 06:19:58 +01:00
--- a/src/main/java/net/minecraft/server/PathfinderGoal.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoal.java
2018-09-01 00:56:57 +02:00
@@ -20,7 +20,9 @@ public abstract class PathfinderGoal {
}
2016-12-28 06:19:58 +01:00
2018-09-01 00:56:57 +02:00
public void d() {
2016-12-28 06:19:58 +01:00
+ onTaskReset(); // Paper
2018-09-01 00:56:57 +02:00
}
2016-12-28 06:19:58 +01:00
+ public void onTaskReset() {} // Paper
2018-09-01 00:56:57 +02:00
public void e() {
}
2016-12-28 06:19:58 +01:00
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java b/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
2018-09-01 00:56:57 +02:00
index 9a75cb63ba..cf10605aaa 100644
2016-12-28 06:19:58 +01:00
--- a/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
+++ b/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
2018-09-01 00:56:57 +02:00
@@ -1,12 +1,12 @@
package net.minecraft.server;
2016-12-28 06:19:58 +01:00
public abstract class PathfinderGoalGotoTarget extends PathfinderGoal {
2018-07-17 22:32:05 +02:00
- private final EntityCreature f;
+ private final EntityCreature f; public EntityCreature getEntity() { return f; } // Paper - OBFHELPER
public double a;
protected int b;
protected int c;
private int g;
- protected BlockPosition d;
+ protected BlockPosition d; public BlockPosition getTarget() { return d; } public void setTarget(BlockPosition pos) { this.d = pos; getEntity().movingTarget = pos != BlockPosition.ZERO ? pos : null; } // Paper - OBFHELPER
private boolean h;
private final int i;
private final int j;
2018-09-01 00:56:57 +02:00
@@ -15,6 +15,13 @@ public abstract class PathfinderGoalGotoTarget extends PathfinderGoal {
public PathfinderGoalGotoTarget(EntityCreature entitycreature, double d0, int ix) {
this(entitycreature, d0, ix, 1);
}
2018-07-17 22:32:05 +02:00
+ // Paper start - activation range improvements
2016-12-28 06:19:58 +01:00
+ @Override
+ public void onTaskReset() {
+ super.onTaskReset();
+ setTarget(BlockPosition.ZERO);
+ }
+ // Paper end
2018-09-01 00:56:57 +02:00
public PathfinderGoalGotoTarget(EntityCreature entitycreature, double d0, int ix, int jx) {
this.d = BlockPosition.ZERO;
@@ -93,6 +100,7 @@ public abstract class PathfinderGoalGotoTarget extends PathfinderGoal {
blockposition$mutableblockposition.g(blockposition).d(i1, k - 1, j1);
if (this.f.f(blockposition$mutableblockposition) && this.a(this.f.world, blockposition$mutableblockposition)) {
this.d = blockposition$mutableblockposition;
+ setTarget(blockposition$mutableblockposition.toBlockPosition()); // Paper
2016-12-28 06:19:58 +01:00
return true;
}
}
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
2018-09-29 01:31:59 +02:00
index f9bb19fed6..03ca577b4c 100644
2016-12-28 06:19:58 +01:00
--- a/src/main/java/org/spigotmc/ActivationRange.java
+++ b/src/main/java/org/spigotmc/ActivationRange.java
@@ -20,6 +20,7 @@ import net.minecraft.server.EntityFireball;
import net.minecraft.server.EntityFireworks;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityLiving;
+import net.minecraft.server.EntityLlama;
import net.minecraft.server.EntityMonster;
import net.minecraft.server.EntityProjectile;
import net.minecraft.server.EntitySheep;
2018-07-17 22:32:05 +02:00
@@ -212,18 +213,29 @@ public class ActivationRange
2016-12-28 06:19:58 +01:00
if ( entity instanceof EntityLiving )
{
EntityLiving living = (EntityLiving) entity;
- if ( /*TODO: Missed mapping? living.attackTicks > 0 || */ living.hurtTicks > 0 || living.effects.size() > 0 )
+ if ( living.lastDamageByPlayerTime > 0 || living.hurtTicks > 0 || living.effects.size() > 0 ) // Paper
{
return true;
}
- if ( entity instanceof EntityCreature && ( (EntityCreature) entity ).getGoalTarget() != null )
+ if ( entity instanceof EntityCreature )
2017-06-08 16:16:51 +02:00
{
- return true;
2016-12-28 06:19:58 +01:00
+ // Paper start
+ EntityCreature creature = (EntityCreature) entity;
+ if (creature.getGoalTarget() != null || creature.getMovingTarget() != null) {
+ return true;
+ }
+ // Paper end
2017-06-08 16:16:51 +02:00
}
if ( entity instanceof EntityVillager && ( (EntityVillager) entity ).isInLove() )
2016-12-28 06:19:58 +01:00
{
return true;
}
+ // Paper start
+ if ( entity instanceof EntityLlama && ( (EntityLlama ) entity ).inCaravan() )
2017-06-08 16:16:51 +02:00
+ {
+ return true;
+ }
2016-12-28 06:19:58 +01:00
+ // Paper end
if ( entity instanceof EntityAnimal )
{
EntityAnimal animal = (EntityAnimal) entity;
2018-07-17 22:32:05 +02:00
@@ -276,10 +288,10 @@ public class ActivationRange
2018-07-12 22:42:56 +02:00
{
isActive = false;
}
- int x = MathHelper.floor( entity.locX );
- int z = MathHelper.floor( entity.locZ );
+ //int x = MathHelper.floor( entity.locX ); // Paper
+ //int z = MathHelper.floor( entity.locZ ); // Paper
2018-07-04 09:55:24 +02:00
// Make sure not on edge of unloaded chunk
- Chunk chunk = entity.world.getChunkIfLoaded( x >> 4, z >> 4 );
2018-07-12 22:42:56 +02:00
+ Chunk chunk = entity.getChunkAtLocation(); // Paper
2018-07-04 09:55:24 +02:00
if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) )
{
isActive = false;
2016-12-28 06:19:58 +01:00
--
2018-09-29 01:31:59 +02:00
2.19.0
2016-12-28 06:19:58 +01:00