mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-17 11:05:40 +00:00
Allow block to specify their type for AI pathfinding (#3546)
This commit is contained in:
1 parent
9835e3705c
commit
df0f1c4e75
3 files changed
+60
-4
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user