Patch village distance checking to use floats instead of ints, to avoid int wrapping
This commit is contained in:
parent
40afc35985
commit
4d626bf025
|
@ -0,0 +1,17 @@
|
|||
--- ../src_base/minecraft/net/minecraft/util/ChunkCoordinates.java
|
||||
+++ ../src_work/minecraft/net/minecraft/util/ChunkCoordinates.java
|
||||
@@ -64,10 +64,10 @@
|
||||
*/
|
||||
public float getDistanceSquared(int par1, int par2, int par3)
|
||||
{
|
||||
- int l = this.posX - par1;
|
||||
- int i1 = this.posY - par2;
|
||||
- int j1 = this.posZ - par3;
|
||||
- return (float)(l * l + i1 * i1 + j1 * j1);
|
||||
+ float l = this.posX - par1;
|
||||
+ float i1 = this.posY - par2;
|
||||
+ float j1 = this.posZ - par3;
|
||||
+ return l * l + i1 * i1 + j1 * j1;
|
||||
}
|
||||
|
||||
/**
|
|
@ -0,0 +1,24 @@
|
|||
--- ../src_base/minecraft/net/minecraft/village/VillageCollection.java
|
||||
+++ ../src_work/minecraft/net/minecraft/village/VillageCollection.java
|
||||
@@ -128,9 +128,9 @@
|
||||
|
||||
if (f1 < f)
|
||||
{
|
||||
- int i1 = par4 + village1.getVillageRadius();
|
||||
-
|
||||
- if (f1 <= (float)(i1 * i1))
|
||||
+ float i1 = par4 + village1.getVillageRadius();
|
||||
+
|
||||
+ if (f1 <= i1 * i1)
|
||||
{
|
||||
village = village1;
|
||||
f = f1;
|
||||
@@ -165,7 +165,7 @@
|
||||
{
|
||||
Village village = (Village)iterator.next();
|
||||
int j = (int)village.getCenter().getDistanceSquared(villagedoorinfo.posX, villagedoorinfo.posY, villagedoorinfo.posZ);
|
||||
- int k = 32 + village.getVillageRadius();
|
||||
+ float k = 32f + village.getVillageRadius();
|
||||
|
||||
if (j > k * k)
|
||||
{
|
Loading…
Reference in New Issue