Fix portal StackOverflow
This commit is contained in:
parent
736c82c095
commit
7f479c2086
1 changed files with 9 additions and 3 deletions
|
@ -135,6 +135,12 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockPos.Mutable findCenter(World world, BlockPos.Mutable pos, Direction.Axis axis) {
|
private BlockPos.Mutable findCenter(World world, BlockPos.Mutable pos, Direction.Axis axis) {
|
||||||
|
return this.findCenter(world, pos, axis, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlockPos.Mutable findCenter(World world, BlockPos.Mutable pos, Direction.Axis axis, int step) {
|
||||||
|
if (step > 21) return pos;
|
||||||
|
|
||||||
BlockState right, left;
|
BlockState right, left;
|
||||||
Direction rightDir, leftDir;
|
Direction rightDir, leftDir;
|
||||||
if (axis == Direction.Axis.X) {
|
if (axis == Direction.Axis.X) {
|
||||||
|
@ -150,13 +156,13 @@ public class EndPortalBlock extends NetherPortalBlock implements IRenderTypeable
|
||||||
}
|
}
|
||||||
BlockState down = world.getBlockState(pos.down());
|
BlockState down = world.getBlockState(pos.down());
|
||||||
if (down.isOf(this)) {
|
if (down.isOf(this)) {
|
||||||
return findCenter(world, pos.move(Direction.DOWN), axis);
|
return findCenter(world, pos.move(Direction.DOWN), axis, ++step);
|
||||||
} else if (right.isOf(this) && left.isOf(this)) {
|
} else if (right.isOf(this) && left.isOf(this)) {
|
||||||
return pos;
|
return pos;
|
||||||
} else if (right.isOf(this)) {
|
} else if (right.isOf(this)) {
|
||||||
return findCenter(world, pos.move(rightDir), axis);
|
return findCenter(world, pos.move(rightDir), axis, ++step);
|
||||||
} else if (left.isOf(this)) {
|
} else if (left.isOf(this)) {
|
||||||
return findCenter(world, pos.move(leftDir), axis);
|
return findCenter(world, pos.move(leftDir), axis, ++step);
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue