Fix: Fluid valve isn't waterloggable #3744

This commit is contained in:
MoarDm 2022-09-17 17:12:39 +03:00
parent aeee9f8793
commit a398d64df6

View file

@ -9,6 +9,7 @@ import com.simibubi.create.AllTileEntities;
import com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock;
import com.simibubi.create.content.contraptions.fluids.FluidPropagator;
import com.simibubi.create.foundation.block.ITE;
import com.simibubi.create.foundation.block.ProperWaterloggedBlock;
import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.core.BlockPos;
@ -16,26 +17,33 @@ import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.network.protocol.game.DebugPackets;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition.Builder;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.ticks.TickPriority;
public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxisPipe, ITE<FluidValveTileEntity> {
public class FluidValveBlock extends DirectionalAxisKineticBlock
implements IAxisPipe, ITE<FluidValveTileEntity>, ProperWaterloggedBlock {
public static final BooleanProperty ENABLED = BooleanProperty.create("enabled");
public FluidValveBlock(Properties properties) {
super(properties);
registerDefaultState(defaultBlockState().setValue(ENABLED, false));
registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false));
}
@Override
@ -46,7 +54,7 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi
@Override
protected void createBlockStateDefinition(Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder.add(ENABLED));
super.createBlockStateDefinition(builder.add(ENABLED, WATERLOGGED));
}
@Override
@ -141,4 +149,22 @@ public class FluidValveBlock extends DirectionalAxisKineticBlock implements IAxi
return AllTileEntities.FLUID_VALVE.get();
}
@Override
public BlockState getStateForPlacement(BlockPlaceContext context) {
return withWater(super.getStateForPlacement(context), context);
}
@Override
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world,
BlockPos pos, BlockPos neighbourPos) {
updateWater(world, state, pos);
return state;
}
@Override
public FluidState getFluidState(BlockState state) {
return state.getValue(BlockStateProperties.WATERLOGGED)
? Fluids.WATER.getSource(false)
: Fluids.EMPTY.defaultFluidState();
}
}