Path: blob/1.21.x/src/main/java/net/minecraftforge/common/extensions/IForgeBaseRailBlock.java
7393 views
/*1* Copyright (c) Forge Development LLC and contributors2* SPDX-License-Identifier: LGPL-2.1-only3*/45package net.minecraftforge.common.extensions;67import net.minecraft.world.entity.vehicle.MinecartFurnace;8import net.minecraft.world.level.block.state.BlockState;9import net.minecraft.world.entity.vehicle.AbstractMinecart;10import net.minecraft.world.level.block.state.properties.RailShape;11import net.minecraft.core.BlockPos;12import net.minecraft.world.level.BlockGetter;13import net.minecraft.world.level.Level;14import org.jetbrains.annotations.Nullable;1516public interface IForgeBaseRailBlock17{1819/**20* Return true if the rail can make corners.21* Used by placement logic.22* @param level The level.23* @param pos Block's position in level24* @return True if the rail can make corners.25*/26boolean isFlexibleRail(BlockState state, BlockGetter level, BlockPos pos);2728/**29* Returns true if the rail can make up and down slopes.30* Used by placement logic.31* @param level The level.32* @param pos Block's position in level33* @return True if the rail can make slopes.34*/35default boolean canMakeSlopes(BlockState state, BlockGetter level, BlockPos pos)36{37return true;38}3940/**41* Return the rail's direction.42* Can be used to make the cart think the rail is a different shape,43* for example when making diamond junctions or switches.44* The cart parameter will often be null unless it it called from EntityMinecart.45*46* @param level The level.47* @param pos Block's position in level48* @param state The BlockState49* @param cart The cart asking for the metadata, null if it is not called by EntityMinecart.50* @return The direction.51*/52RailShape getRailDirection(BlockState state, BlockGetter level, BlockPos pos, @Nullable AbstractMinecart cart);5354/**55* Returns the max speed of the rail at the specified position.56* @param level The level.57* @param cart The cart on the rail, may be null.58* @param pos Block's position in level59* @return The max speed of the current rail.60*/61default float getRailMaxSpeed(BlockState state, Level level, BlockPos pos, AbstractMinecart cart)62{63if (cart instanceof MinecartFurnace) return cart.isInWater() ? 0.15f : 0.2f;64else return cart.isInWater() ? 0.2f : 0.4f;65}6667/**68* This function is called by any minecart that passes over this rail.69* It is called once per update tick that the minecart is on the rail.70* @param level The level.71* @param cart The cart on the rail.72* @param pos Block's position in level73*/74default void onMinecartPass(BlockState state, Level level, BlockPos pos, AbstractMinecart cart){}7576/**77* Returns true if the given {@link RailShape} is valid for this rail block.78* This is called when the RailShape for the initial placement of this block is calculated or79* when another rail block tries to connect to this block and this block's RailState calculates80* the new RailShape for its current neigbors.81* @param shape The new RailShape82* @return True when the given RailShape is valid83*/84default boolean isValidRailShape(RailShape shape)85{86return true;87}88}899091