Fix random position generator's tendency to move north-west

Fixes the issue of mobs constantly going North-West in pens and other areas
backported from 1.8
This commit is contained in:
Zach Brown 2014-07-22 22:04:05 -05:00
parent 5cfd799cff
commit f07313c43f
27 changed files with 194 additions and 27 deletions

View file

@ -0,0 +1,89 @@
From 03a8823864b8a5bd6e36333137fb486378e3a63d Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com>
Date: Tue, 22 Jul 2014 21:05:53 -0500
Subject: [PATCH] mc-dev imports
diff --git a/src/main/java/net/minecraft/server/RandomPositionGenerator.java b/src/main/java/net/minecraft/server/RandomPositionGenerator.java
new file mode 100644
index 0000000..9342a3f
--- /dev/null
+++ b/src/main/java/net/minecraft/server/RandomPositionGenerator.java
@@ -0,0 +1,74 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+public class RandomPositionGenerator {
+
+ private static Vec3D a = Vec3D.a(0.0D, 0.0D, 0.0D);
+
+ public static Vec3D a(EntityCreature entitycreature, int i, int j) {
+ return c(entitycreature, i, j, (Vec3D) null);
+ }
+
+ public static Vec3D a(EntityCreature entitycreature, int i, int j, Vec3D vec3d) {
+ a.a = vec3d.a - entitycreature.locX;
+ a.b = vec3d.b - entitycreature.locY;
+ a.c = vec3d.c - entitycreature.locZ;
+ return c(entitycreature, i, j, a);
+ }
+
+ public static Vec3D b(EntityCreature entitycreature, int i, int j, Vec3D vec3d) {
+ a.a = entitycreature.locX - vec3d.a;
+ a.b = entitycreature.locY - vec3d.b;
+ a.c = entitycreature.locZ - vec3d.c;
+ return c(entitycreature, i, j, a);
+ }
+
+ private static Vec3D c(EntityCreature entitycreature, int i, int j, Vec3D vec3d) {
+ Random random = entitycreature.aI();
+ boolean flag = false;
+ int k = 0;
+ int l = 0;
+ int i1 = 0;
+ float f = -99999.0F;
+ boolean flag1;
+
+ if (entitycreature.bY()) {
+ double d0 = (double) (entitycreature.bV().e(MathHelper.floor(entitycreature.locX), MathHelper.floor(entitycreature.locY), MathHelper.floor(entitycreature.locZ)) + 4.0F);
+ double d1 = (double) (entitycreature.bW() + (float) i);
+
+ flag1 = d0 < d1 * d1;
+ } else {
+ flag1 = false;
+ }
+
+ for (int j1 = 0; j1 < 10; ++j1) {
+ int k1 = random.nextInt(2 * i) - i;
+ int l1 = random.nextInt(2 * j) - j;
+ int i2 = random.nextInt(2 * i) - i;
+
+ if (vec3d == null || (double) k1 * vec3d.a + (double) i2 * vec3d.c >= 0.0D) {
+ k1 += MathHelper.floor(entitycreature.locX);
+ l1 += MathHelper.floor(entitycreature.locY);
+ i2 += MathHelper.floor(entitycreature.locZ);
+ if (!flag1 || entitycreature.b(k1, l1, i2)) {
+ float f1 = entitycreature.a(k1, l1, i2);
+
+ if (f1 > f) {
+ f = f1;
+ k = k1;
+ l = l1;
+ i1 = i2;
+ flag = true;
+ }
+ }
+ }
+ }
+
+ if (flag) {
+ return Vec3D.a((double) k, (double) l, (double) i1);
+ } else {
+ return null;
+ }
+ }
+}
--
1.9.1

View file

@ -1,4 +1,4 @@
From e97b935204b2a83b7d89c497f50e21a578d73fd7 Mon Sep 17 00:00:00 2001 From d5ec5c8c5934108fe0ba76de561d704450d2b6dc Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Sat, 12 Jul 2014 19:36:18 -0500 Date: Sat, 12 Jul 2014 19:36:18 -0500
Subject: [PATCH] Allow undead horse types to be leashed Subject: [PATCH] Allow undead horse types to be leashed

View file

@ -1,4 +1,4 @@
From 4fe9d7419abffc0cfc9b9df05ddd841c3c27b567 Mon Sep 17 00:00:00 2001 From 67c533b734ea9fbc764bc0ad817ce87970db47e2 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Sat, 17 May 2014 02:12:39 -0500 Date: Sat, 17 May 2014 02:12:39 -0500
Subject: [PATCH] Teleport passenger/vehicle with player Subject: [PATCH] Teleport passenger/vehicle with player

View file

@ -1,4 +1,4 @@
From e2b1954fec83b8bf2b6cb87d05f15083074fdc0d Mon Sep 17 00:00:00 2001 From 4a4dbdc85d1ba862ac43f5ab115bd4be3a2957ee Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Mon, 21 Jul 2014 18:46:53 -0500 Date: Mon, 21 Jul 2014 18:46:53 -0500
Subject: [PATCH] Invisible players don't have rights Subject: [PATCH] Invisible players don't have rights
@ -44,7 +44,7 @@ index 7f8a33b..73f52ac 100644
if (movingobjectposition.type == EnumMovingObjectType.BLOCK && this.world.getType(movingobjectposition.b, movingobjectposition.c, movingobjectposition.d) == Blocks.PORTAL) { if (movingobjectposition.type == EnumMovingObjectType.BLOCK && this.world.getType(movingobjectposition.b, movingobjectposition.c, movingobjectposition.d) == Blocks.PORTAL) {
this.ah(); this.ah();
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index b7509c4..4326dd7 100644 index 744d942..a204966 100644
--- a/src/main/java/net/minecraft/server/World.java --- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java
@@ -1666,6 +1666,13 @@ public abstract class World implements IBlockAccess { @@ -1666,6 +1666,13 @@ public abstract class World implements IBlockAccess {

View file

@ -1,4 +1,4 @@
From 3f93ef064552c89e5f00bccff99ecd3589f48b2d Mon Sep 17 00:00:00 2001 From 6c1fb82fc1e33cae85db1d30ae31dffbc0e26636 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Mon, 19 May 2014 19:30:58 -0500 Date: Mon, 19 May 2014 19:30:58 -0500
Subject: [PATCH] Configurable squid spawn ranges Subject: [PATCH] Configurable squid spawn ranges

View file

@ -1,4 +1,4 @@
From f67c6952b8a3653548157d3bcfd6acace37d0c5b Mon Sep 17 00:00:00 2001 From c524cf90c856318e8b84e32e7cdad8eba7c67043 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Tue, 24 Jun 2014 07:39:37 -0500 Date: Tue, 24 Jun 2014 07:39:37 -0500
Subject: [PATCH] Configurable damage multiplier for PvP blocking Subject: [PATCH] Configurable damage multiplier for PvP blocking

View file

@ -1,4 +1,4 @@
From 426e4a4f067697487906fbc5323643b6cacb4d7c Mon Sep 17 00:00:00 2001 From 9990656f0898c13e7cb844b1d16ab3ca38122c8d Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Tue, 24 Jun 2014 07:44:59 -0500 Date: Tue, 24 Jun 2014 07:44:59 -0500
Subject: [PATCH] Configurable cactus and reed natural growth heights Subject: [PATCH] Configurable cactus and reed natural growth heights

View file

@ -1,4 +1,4 @@
From c8341d72780a26dd551a32e45b60f69f3f078b57 Mon Sep 17 00:00:00 2001 From ef49848716a837e9d6f7bf25cf00cc74e37a57f5 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Wed, 21 May 2014 15:35:12 -0500 Date: Wed, 21 May 2014 15:35:12 -0500
Subject: [PATCH] Configurable baby zombie movement speed Subject: [PATCH] Configurable baby zombie movement speed

View file

@ -1,4 +1,4 @@
From fefd33739e5a68b9d0e41e094201e78db618c0da Mon Sep 17 00:00:00 2001 From 2061a29a13433a363db267060f55d7190c5752d4 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Fri, 30 May 2014 19:42:50 -0500 Date: Fri, 30 May 2014 19:42:50 -0500
Subject: [PATCH] Make destroyed boats drop the boat item Subject: [PATCH] Make destroyed boats drop the boat item

View file

@ -1,4 +1,4 @@
From c4877d01ec94b74594b67ec8562dd9ae171235cc Mon Sep 17 00:00:00 2001 From 4c099f1b1105f8fbdcbf7cf360a304b00ca2b139 Mon Sep 17 00:00:00 2001
From: gsand <gsandowns@gmail.com> From: gsand <gsandowns@gmail.com>
Date: Sun, 6 Jul 2014 02:46:20 -0500 Date: Sun, 6 Jul 2014 02:46:20 -0500
Subject: [PATCH] Inverted Daylight Detector Toggle Subject: [PATCH] Inverted Daylight Detector Toggle

View file

@ -1,4 +1,4 @@
From 9b570819fcba55db1a21034c10a98d310df9a894 Mon Sep 17 00:00:00 2001 From ea2ab58dbe50e2e9fb276de0e41d67daebfdc692 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Tue, 10 Jun 2014 18:22:19 -0500 Date: Tue, 10 Jun 2014 18:22:19 -0500
Subject: [PATCH] Add 1.8 recipes for stone variants Subject: [PATCH] Add 1.8 recipes for stone variants

View file

@ -1,4 +1,4 @@
From 32f83c3e5e184f422e20a900d6fa2403b14f537b Mon Sep 17 00:00:00 2001 From ba45279e3c472cf8a1ac8af1915cff787aa1a7d9 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Sat, 12 Jul 2014 19:37:16 -0500 Date: Sat, 12 Jul 2014 19:37:16 -0500
Subject: [PATCH] Ability to disable asynccatcher Subject: [PATCH] Ability to disable asynccatcher

View file

@ -1,4 +1,4 @@
From f8f2c9df9dc012f9ecab05981dbaa1a1e8008c0d Mon Sep 17 00:00:00 2001 From 8f949ae7d13ce3aefdd0f4cedcf3cecfd1966314 Mon Sep 17 00:00:00 2001
From: Iceee <andrew@opticgaming.tv> From: Iceee <andrew@opticgaming.tv>
Date: Thu, 12 Jun 2014 13:37:35 -0500 Date: Thu, 12 Jun 2014 13:37:35 -0500
Subject: [PATCH] Fix redstone lag issues Subject: [PATCH] Fix redstone lag issues

View file

@ -1,4 +1,4 @@
From 50cb1a7534483cdfffc0ab32218d92f578f783e8 Mon Sep 17 00:00:00 2001 From a3bd76b89d96e8f989463ae55b869e7dcb70548a Mon Sep 17 00:00:00 2001
From: T00thpick1 <t00thpick1dirko@gmail.com> From: T00thpick1 <t00thpick1dirko@gmail.com>
Date: Mon, 23 Jun 2014 21:37:24 -0500 Date: Mon, 23 Jun 2014 21:37:24 -0500
Subject: [PATCH] Do not remove player in world change Subject: [PATCH] Do not remove player in world change

View file

@ -1,4 +1,4 @@
From 2cc49b6da05fdd330386ec56aa45b1e936a085ea Mon Sep 17 00:00:00 2001 From 5976ecf2a73580d4526173250e84235e7688f509 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Fri, 11 Jul 2014 03:54:06 -0500 Date: Fri, 11 Jul 2014 03:54:06 -0500
Subject: [PATCH] Fix directional TNT bias Subject: [PATCH] Fix directional TNT bias

View file

@ -1,4 +1,4 @@
From 63e82d929f85e503904764ba2f41585336bbeae1 Mon Sep 17 00:00:00 2001 From 39e9a4a5740484b1ade5cbb41cc445613cda057b Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Tue, 24 Jun 2014 22:55:30 -0500 Date: Tue, 24 Jun 2014 22:55:30 -0500
Subject: [PATCH] Fix zombie sieges and their spawn mechanics Subject: [PATCH] Fix zombie sieges and their spawn mechanics

View file

@ -1,4 +1,4 @@
From 94e7e4ebcaa1e17fc85d42895a7528e4be896d67 Mon Sep 17 00:00:00 2001 From db7ac74f4f1a87642f72e9d3afc2c2c2cf7fb6f7 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Sun, 29 Jun 2014 13:22:09 -0500 Date: Sun, 29 Jun 2014 13:22:09 -0500
Subject: [PATCH] Configurable fishing time ranges Subject: [PATCH] Configurable fishing time ranges

View file

@ -1,4 +1,4 @@
From cc15f8f6363eb257724925f880758621b7205ebd Mon Sep 17 00:00:00 2001 From 83a26547cdc879226ad2e8c996ce54e21b56b040 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Sun, 29 Jun 2014 13:32:36 -0500 Date: Sun, 29 Jun 2014 13:32:36 -0500
Subject: [PATCH] Allow nerfed mobs to jump Subject: [PATCH] Allow nerfed mobs to jump

View file

@ -1,4 +1,4 @@
From bbc895c7c73ab8e4a2f2cedf152264f9afbf64db Mon Sep 17 00:00:00 2001 From 6e0dd036af4916841749c3a12b968c7b0b56f31b Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Wed, 16 Jul 2014 14:11:08 -0500 Date: Wed, 16 Jul 2014 14:11:08 -0500
Subject: [PATCH] Toggle for player interact limiter Subject: [PATCH] Toggle for player interact limiter

View file

@ -1,4 +1,4 @@
From 6d23494e84e5fc782b166de87b7f7c77d54b8fd1 Mon Sep 17 00:00:00 2001 From 83ecf982af0d6ad2ce531e2dabefe0e3e1d27b97 Mon Sep 17 00:00:00 2001
From: gsand <gsandowns@gmail.com> From: gsand <gsandowns@gmail.com>
Date: Tue, 8 Jul 2014 21:41:43 -0500 Date: Tue, 8 Jul 2014 21:41:43 -0500
Subject: [PATCH] Player Exhaustion Multipliers Subject: [PATCH] Player Exhaustion Multipliers

View file

@ -1,4 +1,4 @@
From 142126c2dc5383028d591f9dfda2dcdd9c478336 Mon Sep 17 00:00:00 2001 From c2ea4c55f6bacf5d06871b5065063e7a879ba636 Mon Sep 17 00:00:00 2001
From: Suddenly <suddenly@suddenly.coffee> From: Suddenly <suddenly@suddenly.coffee>
Date: Mon, 7 Jul 2014 04:11:34 +0100 Date: Mon, 7 Jul 2014 04:11:34 +0100
Subject: [PATCH] Add configurable despawn distances for living entities Subject: [PATCH] Add configurable despawn distances for living entities

View file

@ -1,4 +1,4 @@
From ef87dbbaa845be4b480f2ec851c9dcab75d579e3 Mon Sep 17 00:00:00 2001 From 8661e9266f9c8823257b23db91a75b7faba679ee Mon Sep 17 00:00:00 2001
From: Dmck2b <itallhappenedverysuddenly@gmail.com> From: Dmck2b <itallhappenedverysuddenly@gmail.com>
Date: Thu, 10 Jul 2014 16:57:10 +0100 Date: Thu, 10 Jul 2014 16:57:10 +0100
Subject: [PATCH] Allow for toggling of spawn chunks Subject: [PATCH] Allow for toggling of spawn chunks
@ -6,7 +6,7 @@ Subject: [PATCH] Allow for toggling of spawn chunks
Now with 100% more confirmed working by creator Now with 100% more confirmed working by creator
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 4326dd7..db025bf 100644 index a204966..e82cb35 100644
--- a/src/main/java/net/minecraft/server/World.java --- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java
@@ -222,6 +222,7 @@ public abstract class World implements IBlockAccess { @@ -222,6 +222,7 @@ public abstract class World implements IBlockAccess {

View file

@ -1,4 +1,4 @@
From f9963b2942e34664e4940ef0507ce7ac2ea62c14 Mon Sep 17 00:00:00 2001 From 4784e3e92058a9092fbbcc9d8b6a023ef6c31623 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Tue, 8 Jul 2014 22:39:41 -0500 Date: Tue, 8 Jul 2014 22:39:41 -0500
Subject: [PATCH] Better EULA handling Subject: [PATCH] Better EULA handling

View file

@ -1,4 +1,4 @@
From 7157550a84f45bb3e4d87f417585e46699aacf2a Mon Sep 17 00:00:00 2001 From 221e27c07fcc4d17bc05bf571712c303cd911f6e Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Wed, 9 Jul 2014 17:38:48 -0500 Date: Wed, 9 Jul 2014 17:38:48 -0500
Subject: [PATCH] Configurable nerf for TNT cannons Subject: [PATCH] Configurable nerf for TNT cannons

View file

@ -1,4 +1,4 @@
From 9d0c463f0d044f4f7f291ee25f8755a2eccf7aba Mon Sep 17 00:00:00 2001 From 3b0c5832c4aeb770174fcba76448eaeca9e6f577 Mon Sep 17 00:00:00 2001
From: Iceee <andrew@opticgaming.tv> From: Iceee <andrew@opticgaming.tv>
Date: Fri, 11 Jul 2014 01:31:43 -0500 Date: Fri, 11 Jul 2014 01:31:43 -0500
Subject: [PATCH] Don't tick chests Subject: [PATCH] Don't tick chests

View file

@ -1,4 +1,4 @@
From 6ae22ba0f985aa7b9b5a05d5da742bd9764c109a Mon Sep 17 00:00:00 2001 From e1c032b6c6917835b571ca24c66fac7b95004d41 Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com> From: Zach Brown <Zbob750@live.com>
Date: Mon, 14 Jul 2014 01:20:46 -0500 Date: Mon, 14 Jul 2014 01:20:46 -0500
Subject: [PATCH] Configurable AI target selector delay Subject: [PATCH] Configurable AI target selector delay

View file

@ -0,0 +1,78 @@
From 30b5f3c128191e2131c7482ff4f0bde0f8e4bc6f Mon Sep 17 00:00:00 2001
From: Zach Brown <Zbob750@live.com>
Date: Tue, 22 Jul 2014 21:52:19 -0500
Subject: [PATCH] Fix random position generator tendency to move north west
Fixes mobs sticking to one side of pens and "migrating" to the north west constantly
Backported fix from 1.8
diff --git a/src/main/java/net/minecraft/server/RandomPositionGenerator.java b/src/main/java/net/minecraft/server/RandomPositionGenerator.java
index 9342a3f..fa20a7d 100644
--- a/src/main/java/net/minecraft/server/RandomPositionGenerator.java
+++ b/src/main/java/net/minecraft/server/RandomPositionGenerator.java
@@ -27,9 +27,11 @@ public class RandomPositionGenerator {
private static Vec3D c(EntityCreature entitycreature, int i, int j, Vec3D vec3d) {
Random random = entitycreature.aI();
boolean flag = false;
- int k = 0;
- int l = 0;
- int i1 = 0;
+ // PaperSpigot start - int -> double
+ double k = 0;
+ double l = 0;
+ double i1 = 0;
+ // PaperSpigot end
float f = -99999.0F;
boolean flag1;
@@ -43,22 +45,27 @@ public class RandomPositionGenerator {
}
for (int j1 = 0; j1 < 10; ++j1) {
- int k1 = random.nextInt(2 * i) - i;
- int l1 = random.nextInt(2 * j) - j;
- int i2 = random.nextInt(2 * i) - i;
+ // PaperSpigot start - Even distribution and average of 0
+ int k1 = random.nextInt(2 * i + 1) - i;
+ int l1 = random.nextInt(2 * j + 1) - j;
+ int i2 = random.nextInt(2 * i + 1) - i;
+ // PaperSpigot end
if (vec3d == null || (double) k1 * vec3d.a + (double) i2 * vec3d.c >= 0.0D) {
- k1 += MathHelper.floor(entitycreature.locX);
- l1 += MathHelper.floor(entitycreature.locY);
- i2 += MathHelper.floor(entitycreature.locZ);
- if (!flag1 || entitycreature.b(k1, l1, i2)) {
- float f1 = entitycreature.a(k1, l1, i2);
+ // PaperSpigot start - Use truncated absolute destination position for checking things
+ int k1Mod = k1 + MathHelper.floor(entitycreature.locX);
+ int l1Mod = l1 + MathHelper.floor(entitycreature.locY);
+ int i2Mod = i2 + MathHelper.floor(entitycreature.locZ);
+ if (!flag1 || entitycreature.b(k1Mod, l1Mod, i2Mod)) {
+ float f1 = entitycreature.a(k1Mod, l1Mod, i2Mod);
if (f1 > f) {
f = f1;
- k = k1;
- l = l1;
- i1 = i2;
+ // but then the full value to set where to move
+ k = entitycreature.locX + k1;
+ l = entitycreature.locY + l1;
+ i1 = entitycreature.locZ + i2;
+ // PaperSpigot end
flag = true;
}
}
@@ -66,7 +73,7 @@ public class RandomPositionGenerator {
}
if (flag) {
- return Vec3D.a((double) k, (double) l, (double) i1);
+ return Vec3D.a(k, l, i1); // PaperSpigot remove unnecessary cast
} else {
return null;
}
--
1.9.1