Improve support for custom block path types (#5203)
Co-authored-by: tterrag <tterrag1098@gmail.com>
This commit is contained in:
parent
fa708f93ee
commit
2baa05ace9
4 changed files with 60 additions and 19 deletions
|
@ -0,0 +1,21 @@
|
|||
--- a/net/minecraft/pathfinding/FlyingNodeProcessor.java
|
||||
+++ b/net/minecraft/pathfinding/FlyingNodeProcessor.java
|
||||
@@ -206,7 +206,9 @@
|
||||
EnumSet<PathNodeType> enumset = EnumSet.noneOf(PathNodeType.class);
|
||||
PathNodeType pathnodetype = PathNodeType.BLOCKED;
|
||||
BlockPos blockpos = new BlockPos(p_186319_5_);
|
||||
+ this.currentEntity = p_186319_5_;
|
||||
pathnodetype = this.func_193577_a(p_186319_1_, p_186319_2_, p_186319_3_, p_186319_4_, p_186319_6_, p_186319_7_, p_186319_8_, p_186319_9_, p_186319_10_, enumset, pathnodetype, blockpos);
|
||||
+ this.currentEntity = null;
|
||||
if (enumset.contains(PathNodeType.FENCE)) {
|
||||
return PathNodeType.FENCE;
|
||||
} else {
|
||||
@@ -238,6 +240,8 @@
|
||||
if (pathnodetype1 != PathNodeType.DAMAGE_FIRE && block != Blocks.field_196814_hQ && pathnodetype1 != PathNodeType.LAVA) {
|
||||
if (pathnodetype1 == PathNodeType.DAMAGE_CACTUS) {
|
||||
pathnodetype = PathNodeType.DAMAGE_CACTUS;
|
||||
+ } else if (pathnodetype1 == PathNodeType.DAMAGE_OTHER) { // Forge: consider modded damage types
|
||||
+ pathnodetype = PathNodeType.DAMAGE_OTHER;
|
||||
} else {
|
||||
pathnodetype = pathnodetype1 != PathNodeType.WALKABLE && pathnodetype1 != PathNodeType.OPEN && pathnodetype1 != PathNodeType.WATER ? PathNodeType.WALKABLE : PathNodeType.OPEN;
|
||||
}
|
|
@ -1,24 +1,55 @@
|
|||
--- a/net/minecraft/pathfinding/WalkNodeProcessor.java
|
||||
+++ b/net/minecraft/pathfinding/WalkNodeProcessor.java
|
||||
@@ -343,10 +343,11 @@
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
public class WalkNodeProcessor extends NodeProcessor {
|
||||
protected float field_176183_h;
|
||||
+ protected EntityLiving currentEntity;
|
||||
|
||||
public void func_186315_a(IBlockReader p_186315_1_, EntityLiving p_186315_2_) {
|
||||
super.func_186315_a(p_186315_1_, p_186315_2_);
|
||||
@@ -254,7 +255,9 @@
|
||||
PathNodeType pathnodetype = PathNodeType.BLOCKED;
|
||||
double d0 = (double)p_186319_5_.field_70130_N / 2.0D;
|
||||
BlockPos blockpos = new BlockPos(p_186319_5_);
|
||||
+ this.currentEntity = p_186319_5_;
|
||||
pathnodetype = this.func_193577_a(p_186319_1_, p_186319_2_, p_186319_3_, p_186319_4_, p_186319_6_, p_186319_7_, p_186319_8_, p_186319_9_, p_186319_10_, enumset, pathnodetype, blockpos);
|
||||
+ this.currentEntity = p_186319_5_;
|
||||
if (enumset.contains(PathNodeType.FENCE)) {
|
||||
return PathNodeType.FENCE;
|
||||
} else {
|
||||
@@ -331,6 +334,7 @@
|
||||
if (pathnodetype1 == PathNodeType.DAMAGE_CACTUS) {
|
||||
pathnodetype = PathNodeType.DAMAGE_CACTUS;
|
||||
}
|
||||
+ if (pathnodetype1 == PathNodeType.DAMAGE_OTHER) pathnodetype = PathNodeType.DAMAGE_OTHER; // Forge: consider modded damage types
|
||||
}
|
||||
|
||||
pathnodetype = this.func_193578_a(p_186330_1_, p_186330_2_, p_186330_3_, p_186330_4_, pathnodetype);
|
||||
@@ -343,11 +347,15 @@
|
||||
for(int i = -1; i <= 1; ++i) {
|
||||
for(int j = -1; j <= 1; ++j) {
|
||||
if (i != 0 || j != 0) {
|
||||
- Block block = p_193578_1_.func_180495_p(blockpos$pooledmutableblockpos.func_181079_c(i + p_193578_2_, p_193578_3_, j + p_193578_4_)).func_177230_c();
|
||||
- if (block == Blocks.field_150434_aF) {
|
||||
+ IBlockState state = p_193578_1_.func_180495_p(blockpos$pooledmutableblockpos.func_181079_c(i + p_193578_2_, p_193578_3_, j + p_193578_4_));
|
||||
+ Block block = state.func_177230_c();
|
||||
if (block == Blocks.field_150434_aF) {
|
||||
+ PathNodeType type = block.getAiPathNodeType(state, p_193578_1_, blockpos$pooledmutableblockpos, this.currentEntity);
|
||||
+ if (block == Blocks.field_150434_aF || type == PathNodeType.DAMAGE_CACTUS) {
|
||||
p_193578_5_ = PathNodeType.DANGER_CACTUS;
|
||||
- } else if (block == Blocks.field_150480_ab) {
|
||||
+ } else if (block == Blocks.field_150480_ab || state.isBurning(p_193578_1_, blockpos$pooledmutableblockpos)) {
|
||||
+ } else if (block == Blocks.field_150480_ab || state.isBurning(p_193578_1_, blockpos$pooledmutableblockpos) || type == PathNodeType.DAMAGE_FIRE) {
|
||||
p_193578_5_ = PathNodeType.DANGER_FIRE;
|
||||
+ } else if (type == PathNodeType.DAMAGE_OTHER) {
|
||||
+ p_193578_5_ = PathNodeType.DAMAGE_OTHER;
|
||||
}
|
||||
}
|
||||
@@ -361,9 +362,11 @@
|
||||
}
|
||||
@@ -361,9 +369,11 @@
|
||||
protected PathNodeType func_189553_b(IBlockReader p_189553_1_, int p_189553_2_, int p_189553_3_, int p_189553_4_) {
|
||||
BlockPos blockpos = new BlockPos(p_189553_2_, p_189553_3_, p_189553_4_);
|
||||
IBlockState iblockstate = p_189553_1_.func_180495_p(blockpos);
|
||||
+ PathNodeType type = iblockstate.getAiPathNodeType(p_189553_1_, blockpos);
|
||||
+ PathNodeType type = iblockstate.getAiPathNodeType(p_189553_1_, blockpos, this.currentEntity);
|
||||
+ if (type != null) return type;
|
||||
Block block = iblockstate.func_177230_c();
|
||||
Material material = iblockstate.func_185904_a();
|
||||
|
|
|
@ -920,7 +920,7 @@ public interface IForgeBlock
|
|||
* @return the PathNodeType
|
||||
*/
|
||||
@Nullable
|
||||
default PathNodeType getAiPathNodeType(IBlockState state, IBlockReader world, BlockPos pos)
|
||||
default PathNodeType getAiPathNodeType(IBlockState state, IBlockReader world, BlockPos pos, @Nullable EntityLiving entity)
|
||||
{
|
||||
return state.isBurning(world, pos) ? PathNodeType.DAMAGE_FIRE : null;
|
||||
}
|
||||
|
|
|
@ -774,17 +774,6 @@ public interface IForgeBlockState
|
|||
return getBlockState().getBlock().canBeConnectedTo(getBlockState(), world, pos, facing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@code PathNodeType} for this block. Return {@code null} for vanilla behavior.
|
||||
*
|
||||
* @return the PathNodeType
|
||||
*/
|
||||
@Nullable
|
||||
default PathNodeType getAiPathNodeType(IWorldReader world, BlockPos pos)
|
||||
{
|
||||
return getBlockState().getBlock().getAiPathNodeType(getBlockState(), world, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param blockState The state for this block
|
||||
* @param world The world this block is in
|
||||
|
@ -932,8 +921,8 @@ public interface IForgeBlockState
|
|||
* @return the PathNodeType
|
||||
*/
|
||||
@Nullable
|
||||
default PathNodeType getAiPathNodeType(IBlockReader world, BlockPos pos)
|
||||
default PathNodeType getAiPathNodeType(IBlockReader world, BlockPos pos, @Nullable EntityLiving entity)
|
||||
{
|
||||
return getBlockState().getBlock().getAiPathNodeType(getBlockState(), world, pos);
|
||||
return getBlockState().getBlock().getAiPathNodeType(getBlockState(), world, pos, entity);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue