Skip to content

Commit 25ea03b

Browse files
Cleanup pathfinding
1 parent 7ea1f84 commit 25ea03b

File tree

3 files changed

+27
-658
lines changed

3 files changed

+27
-658
lines changed
Lines changed: 11 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -1,202 +1,22 @@
11
--- before/net/minecraft/pathfinding/FlyingNodeProcessor.java
22
+++ after/net/minecraft/pathfinding/FlyingNodeProcessor.java
3-
@@ -13,21 +13,18 @@
4-
5-
public class FlyingNodeProcessor extends WalkNodeProcessor
6-
{
7-
- @Override
8-
public void init(IBlockAccess sourceIn, EntityLiving mob)
9-
{
10-
super.init(sourceIn, mob);
11-
this.avoidsWater = mob.getPathPriority(PathNodeType.WATER);
12-
}
13-
14-
- @Override
15-
public void postProcess()
16-
{
17-
this.entity.setPathPriority(PathNodeType.WATER, this.avoidsWater);
18-
super.postProcess();
19-
}
20-
21-
- @Override
22-
public PathPoint getStart()
23-
{
24-
int i;
25-
@@ -35,23 +32,17 @@
26-
if (this.getCanSwim() && this.entity.isInWater())
27-
{
28-
i = (int)this.entity.getEntityBoundingBox().minY;
29-
- BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(
30-
- MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ)
31-
- );
32-
+ BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));
33-
34-
- for (Block block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock();
35-
- block == Blocks.FLOWING_WATER || block == Blocks.WATER;
36-
- block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock()
37-
- )
38-
+ for (Block block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock(); block == Blocks.FLOWING_WATER || block == Blocks.WATER; block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock())
39-
{
40-
- blockpos$mutableblockpos.setPos(
41-
- MathHelper.floor(this.entity.posX), ++i, MathHelper.floor(this.entity.posZ)
42-
- );
43-
+ ++i;
44-
+ blockpos$mutableblockpos.setPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));
45-
}
46-
}
47-
else
48-
{
49-
- i = MathHelper.floor(this.entity.getEntityBoundingBox().minY + 0.5);
50-
+ i = MathHelper.floor(this.entity.getEntityBoundingBox().minY + 0.5D);
51-
}
52-
53-
BlockPos blockpos1 = new BlockPos(this.entity);
54-
@@ -59,7 +50,7 @@
55-
56-
if (this.entity.getPathPriority(pathnodetype1) < 0.0F)
57-
{
58-
- Set<BlockPos> set = Sets.newHashSet();
59-
+ Set<BlockPos> set = Sets.<BlockPos>newHashSet();
60-
set.add(new BlockPos(this.entity.getEntityBoundingBox().minX, (double)i, this.entity.getEntityBoundingBox().minZ));
61-
set.add(new BlockPos(this.entity.getEntityBoundingBox().minX, (double)i, this.entity.getEntityBoundingBox().maxZ));
62-
set.add(new BlockPos(this.entity.getEntityBoundingBox().maxX, (double)i, this.entity.getEntityBoundingBox().minZ));
63-
@@ -79,13 +70,11 @@
64-
return super.openPoint(blockpos1.getX(), i, blockpos1.getZ());
65-
}
66-
67-
- @Override
68-
public PathPoint getPathPointToCoords(double x, double y, double z)
69-
{
70-
return super.openPoint(MathHelper.floor(x), MathHelper.floor(y), MathHelper.floor(z));
71-
}
72-
73-
- @Override
74-
public int findPathOptions(PathPoint[] pathOptions, PathPoint currentPoint, PathPoint targetPoint, float maxDistance)
75-
{
76-
int i = 0;
77-
@@ -257,7 +246,6 @@
78-
}
79-
80-
@Nullable
81-
- @Override
82-
protected PathPoint openPoint(int x, int y, int z)
83-
{
84-
PathPoint pathpoint = null;
85-
@@ -272,33 +260,21 @@
86-
87-
if (pathnodetype == PathNodeType.WALKABLE)
88-
{
89-
- pathpoint.costMalus++;
90-
+ ++pathpoint.costMalus;
91-
}
92-
}
93-
94-
return pathnodetype != PathNodeType.OPEN && pathnodetype != PathNodeType.WALKABLE ? pathpoint : pathpoint;
95-
}
96-
97-
- @Override
98-
- public PathNodeType getPathNodeType(
99-
- IBlockAccess blockaccessIn,
100-
- int x,
101-
- int y,
102-
- int z,
103-
- EntityLiving entitylivingIn,
104-
- int xSize,
105-
- int ySize,
106-
- int zSize,
107-
- boolean canBreakDoorsIn,
108-
- boolean canEnterDoorsIn
109-
- )
110-
+ public PathNodeType getPathNodeType(IBlockAccess blockaccessIn, int x, int y, int z, EntityLiving entitylivingIn, int xSize, int ySize, int zSize, boolean canBreakDoorsIn, boolean canEnterDoorsIn)
111-
{
112-
- EnumSet<PathNodeType> enumset = EnumSet.noneOf(PathNodeType.class);
113-
+ EnumSet<PathNodeType> enumset = EnumSet.<PathNodeType>noneOf(PathNodeType.class);
3+
@@ -296,9 +296,11 @@
4+
EnumSet<PathNodeType> enumset = EnumSet.noneOf(PathNodeType.class);
1145
PathNodeType pathnodetype = PathNodeType.BLOCKED;
1156
BlockPos blockpos = new BlockPos(entitylivingIn);
116-
- pathnodetype = this.getPathNodeType(
117-
- blockaccessIn, x, y, z, xSize, ySize, zSize, canBreakDoorsIn, canEnterDoorsIn, enumset, pathnodetype, blockpos
118-
- );
1197
+ this.currentEntity = entitylivingIn;
120-
+ pathnodetype = this.getPathNodeType(blockaccessIn, x, y, z, xSize, ySize, zSize, canBreakDoorsIn, canEnterDoorsIn, enumset, pathnodetype, blockpos);
8+
pathnodetype = this.getPathNodeType(
9+
blockaccessIn, x, y, z, xSize, ySize, zSize, canBreakDoorsIn, canEnterDoorsIn, enumset, pathnodetype, blockpos
10+
);
12111
+ this.currentEntity = null;
12212

12313
if (enumset.contains(PathNodeType.FENCE))
12414
{
125-
@@ -321,11 +297,17 @@
126-
}
127-
}
128-
129-
- return pathnodetype == PathNodeType.OPEN && entitylivingIn.getPathPriority(pathnodetype1) == 0.0F ? PathNodeType.OPEN : pathnodetype1;
130-
+ if (pathnodetype == PathNodeType.OPEN && entitylivingIn.getPathPriority(pathnodetype1) == 0.0F)
131-
+ {
132-
+ return PathNodeType.OPEN;
133-
+ }
134-
+ else
135-
+ {
136-
+ return pathnodetype1;
137-
+ }
138-
}
139-
}
140-
141-
- @Override
142-
public PathNodeType getPathNodeType(IBlockAccess blockaccessIn, int x, int y, int z)
143-
{
144-
PathNodeType pathnodetype = this.getPathNodeTypeRaw(blockaccessIn, x, y, z);
145-
@@ -335,23 +317,26 @@
146-
Block block = blockaccessIn.getBlockState(new BlockPos(x, y - 1, z)).getBlock();
147-
PathNodeType pathnodetype1 = this.getPathNodeTypeRaw(blockaccessIn, x, y - 1, z);
148-
149-
- if (pathnodetype1 == PathNodeType.DAMAGE_FIRE || block == Blocks.MAGMA || pathnodetype1 == PathNodeType.LAVA)
150-
+ if (pathnodetype1 != PathNodeType.DAMAGE_FIRE && block != Blocks.MAGMA && pathnodetype1 != PathNodeType.LAVA)
151-
+ {
152-
+ if (pathnodetype1 == PathNodeType.DAMAGE_CACTUS)
153-
+ {
154-
+ pathnodetype = PathNodeType.DAMAGE_CACTUS;
155-
+ }
156-
+ else if (pathnodetype1 == PathNodeType.DAMAGE_OTHER) pathnodetype = PathNodeType.DAMAGE_OTHER;
157-
+ else
158-
+ {
159-
+ pathnodetype = pathnodetype1 != PathNodeType.WALKABLE && pathnodetype1 != PathNodeType.OPEN && pathnodetype1 != PathNodeType.WATER ? PathNodeType.WALKABLE : PathNodeType.OPEN;
160-
+ }
161-
+ }
162-
+ else
15+
@@ -343,6 +345,7 @@
16316
{
164-
pathnodetype = PathNodeType.DAMAGE_FIRE;
17+
pathnodetype = PathNodeType.DAMAGE_CACTUS;
16518
}
166-
- else if (pathnodetype1 == PathNodeType.DAMAGE_CACTUS)
167-
- {
168-
- pathnodetype = PathNodeType.DAMAGE_CACTUS;
169-
- }
170-
- else
171-
- {
172-
- pathnodetype = pathnodetype1 != PathNodeType.WALKABLE && pathnodetype1 != PathNodeType.OPEN && pathnodetype1 != PathNodeType.WATER
173-
- ? PathNodeType.WALKABLE
174-
- : PathNodeType.OPEN;
175-
- }
176-
}
177-
178-
- return this.checkNeighborBlocks(blockaccessIn, x, y, z, pathnodetype);
179-
+ pathnodetype = this.checkNeighborBlocks(blockaccessIn, x, y, z, pathnodetype);
180-
+ return pathnodetype;
181-
}
182-
183-
private PathNodeType getPathNodeType(EntityLiving p_192559_1_, BlockPos p_192559_2_)
184-
@@ -361,17 +346,6 @@
185-
186-
private PathNodeType getPathNodeType(EntityLiving p_192558_1_, int p_192558_2_, int p_192558_3_, int p_192558_4_)
187-
{
188-
- return this.getPathNodeType(
189-
- this.blockaccess,
190-
- p_192558_2_,
191-
- p_192558_3_,
192-
- p_192558_4_,
193-
- p_192558_1_,
194-
- this.entitySizeX,
195-
- this.entitySizeY,
196-
- this.entitySizeZ,
197-
- this.getCanOpenDoors(),
198-
- this.getCanEnterDoors()
199-
- );
200-
+ return this.getPathNodeType(this.blockaccess, p_192558_2_, p_192558_3_, p_192558_4_, p_192558_1_, this.entitySizeX, this.entitySizeY, this.entitySizeZ, this.getCanOpenDoors(), this.getCanEnterDoors());
201-
}
202-
}
19+
+ else if (pathnodetype1 == PathNodeType.DAMAGE_OTHER) pathnodetype = PathNodeType.DAMAGE_OTHER;
20+
else
21+
{
22+
pathnodetype = pathnodetype1 != PathNodeType.WALKABLE && pathnodetype1 != PathNodeType.OPEN && pathnodetype1 != PathNodeType.WATER
Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
11
--- before/net/minecraft/pathfinding/PathNavigateClimber.java
22
+++ after/net/minecraft/pathfinding/PathNavigateClimber.java
3-
@@ -57,11 +57,11 @@
3+
@@ -57,7 +57,7 @@
44
{
55
if (this.targetPosition != null)
66
{
77
- double d0 = this.entity.width * this.entity.width;
8-
+ double d0 = Math.max((this.entity.width * this.entity.width), 1.0D);
8+
+ double d0 = Math.max((this.entity.width * this.entity.width), 1.0);
99

1010
if (!(this.entity.getDistanceSqToCenter(this.targetPosition) < d0)
1111
&& (
12-
- !(this.entity.posY > this.targetPosition.getY())
13-
+ !(this.entity.posY > (double)this.targetPosition.getY())
14-
|| !(
15-
this.entity
16-
.getDistanceSqToCenter(
17-
@@ -78,7 +78,10 @@
18-
this.entity
19-
.getMoveHelper()
20-
.setMoveTo(
21-
- this.targetPosition.getX(), this.targetPosition.getY(), this.targetPosition.getZ(), this.speed
22-
+ (double)this.targetPosition.getX(),
23-
+ (double)this.targetPosition.getY(),
24-
+ (double)this.targetPosition.getZ(),
25-
+ this.speed
26-
);
27-
}
28-
else

0 commit comments

Comments
 (0)