mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
e9eef0114e
Helps with development to not need to cast as much... No clue why upstream makes some of the decisions they do....
160 lines
No EOL
7.3 KiB
Diff
160 lines
No EOL
7.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
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
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java
|
|
index ceed50d8de..4c2cd41700 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityCreature.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityCreature.java
|
|
@@ -0,0 +0,0 @@ import org.bukkit.event.entity.EntityUnleashEvent;
|
|
public abstract class EntityCreature extends EntityInsentient {
|
|
|
|
public org.bukkit.craftbukkit.entity.CraftCreature getBukkitEntity() { return (org.bukkit.craftbukkit.entity.CraftCreature) super.getBukkitEntity(); } // Paper
|
|
+ public BlockPosition movingTarget = null; public BlockPosition getMovingTarget() { return movingTarget; } // Paper
|
|
private BlockPosition a;
|
|
private float b;
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
index 05546ff4db..422b826d61 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
|
@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity {
|
|
public float aT;
|
|
public float aU;
|
|
public EntityHuman killer;
|
|
- protected int lastDamageByPlayerTime;
|
|
+ public int lastDamageByPlayerTime; // Paper - public
|
|
protected boolean aX;
|
|
protected int ticksFarFromPlayer;
|
|
protected float aZ;
|
|
diff --git a/src/main/java/net/minecraft/server/EntityLlama.java b/src/main/java/net/minecraft/server/EntityLlama.java
|
|
index bb86ecb2fb..5cd8c3f288 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityLlama.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityLlama.java
|
|
@@ -0,0 +0,0 @@ public class EntityLlama extends EntityHorseChestedAbstract implements IRangedEn
|
|
return this.bR != null;
|
|
}
|
|
|
|
+ public boolean inCaravan() { return this.en(); } // Paper - OBFHELPER
|
|
public boolean en() {
|
|
return this.bQ != null;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/PathfinderGoal.java b/src/main/java/net/minecraft/server/PathfinderGoal.java
|
|
index a146a8b459..a19853463c 100644
|
|
--- a/src/main/java/net/minecraft/server/PathfinderGoal.java
|
|
+++ b/src/main/java/net/minecraft/server/PathfinderGoal.java
|
|
@@ -0,0 +0,0 @@ public abstract class PathfinderGoal {
|
|
|
|
public void c() {}
|
|
|
|
- public void d() {}
|
|
+ public void d() {
|
|
+ onTaskReset(); // Paper
|
|
+ }
|
|
+ public void onTaskReset() {} // Paper
|
|
|
|
public void e() {}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java b/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
|
|
index d5c08aa7cb..fe6570c88d 100644
|
|
--- a/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
|
|
+++ b/src/main/java/net/minecraft/server/PathfinderGoalGotoTarget.java
|
|
@@ -0,0 +0,0 @@ package net.minecraft.server;
|
|
|
|
public abstract class PathfinderGoalGotoTarget extends PathfinderGoal {
|
|
|
|
- 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;
|
|
public int e;
|
|
|
|
+ // Paper start - activation range improvements
|
|
+ @Override
|
|
+ public void onTaskReset() {
|
|
+ super.onTaskReset();
|
|
+ setTarget(BlockPosition.ZERO);
|
|
+ }
|
|
+ // Paper end
|
|
public PathfinderGoalGotoTarget(EntityCreature entitycreature, double d0, int i) {
|
|
this(entitycreature, d0, i, 1);
|
|
}
|
|
@@ -0,0 +0,0 @@ public abstract class PathfinderGoalGotoTarget extends PathfinderGoal {
|
|
for (int j1 = i1 < l && i1 > -l ? l : 0; j1 <= l; j1 = j1 > 0 ? -j1 : 1 - j1) {
|
|
blockposition_mutableblockposition.g(blockposition).d(i1, k - 1, j1);
|
|
if (this.f.f((BlockPosition) blockposition_mutableblockposition) && this.a(this.f.world, blockposition_mutableblockposition)) {
|
|
- this.d = blockposition_mutableblockposition;
|
|
+ setTarget(blockposition_mutableblockposition); // Paper
|
|
return true;
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
|
index e02647f806..cdbf769e7b 100644
|
|
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
|
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
|
@@ -0,0 +0,0 @@ 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;
|
|
@@ -0,0 +0,0 @@ public class ActivationRange
|
|
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 )
|
|
{
|
|
- return true;
|
|
+ // Paper start
|
|
+ EntityCreature creature = (EntityCreature) entity;
|
|
+ if (creature.getGoalTarget() != null || creature.getMovingTarget() != null) {
|
|
+ return true;
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
if ( entity instanceof EntityVillager && ( (EntityVillager) entity ).isInLove() )
|
|
{
|
|
return true;
|
|
}
|
|
+ // Paper start
|
|
+ if ( entity instanceof EntityLlama && ( (EntityLlama ) entity ).inCaravan() )
|
|
+ {
|
|
+ return true;
|
|
+ }
|
|
+ // Paper end
|
|
if ( entity instanceof EntityAnimal )
|
|
{
|
|
EntityAnimal animal = (EntityAnimal) entity;
|
|
@@ -0,0 +0,0 @@ public class ActivationRange
|
|
{
|
|
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
|
|
// Make sure not on edge of unloaded chunk
|
|
- Chunk chunk = entity.world.getChunkIfLoaded( x >> 4, z >> 4 );
|
|
+ Chunk chunk = entity.getChunkAtLocation(); // Paper
|
|
if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) )
|
|
{
|
|
isActive = false;
|
|
--
|