Flat fence

- Added ai deterrents for crossing track blocks
This commit is contained in:
simibubi 2022-09-21 10:16:48 +02:00
parent 7579187dd0
commit ac6369a276
2 changed files with 14 additions and 0 deletions

View file

@ -10,6 +10,7 @@ import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
@ -21,6 +22,7 @@ import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition.Builder; import net.minecraft.world.level.block.state.StateDefinition.Builder;
import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.pathfinder.BlockPathTypes;
import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
@ -43,6 +45,11 @@ public class FakeTrackBlock extends Block implements EntityBlock, ProperWaterlog
public RenderShape getRenderShape(BlockState pState) { public RenderShape getRenderShape(BlockState pState) {
return RenderShape.ENTITYBLOCK_ANIMATED; return RenderShape.ENTITYBLOCK_ANIMATED;
} }
@Override
public BlockPathTypes getAiPathNodeType(BlockState state, BlockGetter world, BlockPos pos, Mob entity) {
return BlockPathTypes.DAMAGE_OTHER;
}
@Override @Override
protected void createBlockStateDefinition(Builder<Block, BlockState> pBuilder) { protected void createBlockStateDefinition(Builder<Block, BlockState> pBuilder) {

View file

@ -66,6 +66,7 @@ import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult; import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.item.context.BlockPlaceContext;
@ -89,6 +90,7 @@ import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.levelgen.structure.BoundingBox; import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.PushReaction; import net.minecraft.world.level.material.PushReaction;
import net.minecraft.world.level.pathfinder.BlockPathTypes;
import net.minecraft.world.level.portal.PortalForcer; import net.minecraft.world.level.portal.PortalForcer;
import net.minecraft.world.level.portal.PortalInfo; import net.minecraft.world.level.portal.PortalInfo;
import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.AABB;
@ -119,6 +121,11 @@ public class TrackBlock extends Block
protected void createBlockStateDefinition(Builder<Block, BlockState> p_49915_) { protected void createBlockStateDefinition(Builder<Block, BlockState> p_49915_) {
super.createBlockStateDefinition(p_49915_.add(SHAPE, HAS_TE, WATERLOGGED)); super.createBlockStateDefinition(p_49915_.add(SHAPE, HAS_TE, WATERLOGGED));
} }
@Override
public BlockPathTypes getAiPathNodeType(BlockState state, BlockGetter world, BlockPos pos, Mob entity) {
return BlockPathTypes.RAIL;
}
@Override @Override
public FluidState getFluidState(BlockState state) { public FluidState getFluidState(BlockState state) {