-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow block to specify their type for AI pathfinding (#3546)
- Loading branch information
1 parent
9835e37
commit df0f1c4
Showing
3 changed files
with
60 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/test/java/net/minecraftforge/test/BlockAiNodeTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package net.minecraftforge.test; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.pathfinding.PathNodeType; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.IBlockAccess; | ||
import net.minecraftforge.event.RegistryEvent; | ||
import net.minecraftforge.fml.common.Mod; | ||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; | ||
|
||
@Mod(modid = "ainodetypetest", name="AiNodeTypeTest", version = "1.0") | ||
@Mod.EventBusSubscriber | ||
public class BlockAiNodeTypeTest | ||
{ | ||
|
||
private static final Block TEST_BLOCK = new TestBlock(); | ||
|
||
@SubscribeEvent | ||
public static void register(RegistryEvent.Register<Block> event) | ||
{ | ||
event.getRegistry().register(TEST_BLOCK); | ||
} | ||
|
||
private static final class TestBlock extends Block { | ||
|
||
TestBlock() { | ||
super(Material.ROCK); | ||
setRegistryName("testblock"); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public PathNodeType getAiPathNodeType(IBlockState state, IBlockAccess world, BlockPos pos) | ||
{ | ||
return PathNodeType.DOOR_OPEN; | ||
} | ||
} | ||
|
||
} |