Files
ThisRocks/src/main/java/eu/midnightdust/motschen/rocks/block/NetherGeyser.java
Motschen 2e8f562270 This Rocks 1.4.0 - 1.17 and QOL
- Update to 1.17-pre1 and Java 16
- Make starfish items contain variations
- Fix bugs
2021-05-30 13:07:44 +02:00

67 lines
2.6 KiB
Java
Executable File

package eu.midnightdust.motschen.rocks.block;
import eu.midnightdust.motschen.rocks.block.blockentity.BlockEntityInit;
import eu.midnightdust.motschen.rocks.block.blockentity.NetherGeyserBlockEntity;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.BlockEntityTicker;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
public class NetherGeyser extends BlockWithEntity implements BlockEntityProvider {
private static final VoxelShape SHAPE;
public static final BooleanProperty ACTIVE = BooleanProperty.of("active");
public NetherGeyser() {
super(FabricBlockSettings.copy(Blocks.STONE).strength(10).noCollision().nonOpaque().sounds(BlockSoundGroup.STONE));
this.setDefaultState(this.stateManager.getDefaultState().with(ACTIVE, false));
}
@Override
public BlockRenderType getRenderType(BlockState state) {
return BlockRenderType.MODEL;
}
@Override
public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
return new NetherGeyserBlockEntity(pos, state);
}
@Nullable
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state, BlockEntityType<T> type) {
return checkType(type, BlockEntityInit.NETHER_GEYSER_BE, NetherGeyserBlockEntity::tick);
}
@Override
public BlockState getPlacementState(ItemPlacementContext itemPlacementContext) {
return Objects.requireNonNull(super.getPlacementState(itemPlacementContext))
.with(ACTIVE, false);
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(ACTIVE);
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
return SHAPE;
}
static {
SHAPE = createCuboidShape(5, 0, 5, 11, 1, 11);
}
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
return world.getBlockState(pos.down()).isSideSolidFullSquare(world,pos,Direction.UP);
}
}