67 lignes
2.6 KiB
Java
67 lignes
2.6 KiB
Java
package com.gastinelweather.block;
|
|
|
|
import com.gastinelweather.GastinelWeatherMod;
|
|
import com.gastinelweather.integration.MinecraftHeightSampler;
|
|
import com.gastinelweather.weather.HeightSampler;
|
|
import com.gastinelweather.weather.SynopticState;
|
|
import com.gastinelweather.weather.WeatherSample;
|
|
import com.gastinelweather.weather.WeatherSystem;
|
|
import com.mojang.serialization.MapCodec;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.network.chat.Component;
|
|
import net.minecraft.sounds.SoundEvents;
|
|
import net.minecraft.sounds.SoundSource;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.level.block.Block;
|
|
import net.minecraft.world.level.block.HorizontalDirectionalBlock;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.level.block.state.StateDefinition;
|
|
import net.minecraft.world.phys.BlockHitResult;
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
import org.joml.Vector3f;
|
|
|
|
public class Vp2ConsoleBlock extends HorizontalDirectionalBlock {
|
|
|
|
public static final MapCodec<Vp2ConsoleBlock> CODEC = simpleCodec(Vp2ConsoleBlock::new);
|
|
private static final VoxelShape SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 10.0, 14.0);
|
|
|
|
public Vp2ConsoleBlock(Properties properties) {
|
|
super(properties);
|
|
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
|
|
}
|
|
|
|
@Override
|
|
protected MapCodec<? extends HorizontalDirectionalBlock> codec() {
|
|
return CODEC;
|
|
}
|
|
|
|
@Override
|
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
|
builder.add(FACING);
|
|
}
|
|
|
|
@Override
|
|
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
|
return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite());
|
|
}
|
|
|
|
@Override
|
|
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
|
|
return SHAPE;
|
|
}
|
|
|
|
@Override
|
|
protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) {
|
|
if (level.isClientSide) {
|
|
com.gastinelweather.client.ClientHooks.openVp2ConsoleScreen(pos);
|
|
}
|
|
return InteractionResult.sidedSuccess(level.isClientSide);
|
|
}
|
|
}
|