2018-10-14 14:27:18 +02:00
|
|
|
package de.ellpeck.naturesaura.blocks;
|
|
|
|
|
2018-10-18 13:34:37 +02:00
|
|
|
import de.ellpeck.naturesaura.Helper;
|
2020-02-25 20:07:26 +01:00
|
|
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
|
|
|
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
|
2021-12-04 15:40:09 +01:00
|
|
|
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityNatureAltar;
|
2021-12-19 15:32:45 +01:00
|
|
|
import de.ellpeck.naturesaura.blocks.tiles.ModBlockEntities;
|
2018-11-21 20:36:55 +01:00
|
|
|
import de.ellpeck.naturesaura.blocks.tiles.render.RenderNatureAltar;
|
2020-01-29 00:40:28 +01:00
|
|
|
import de.ellpeck.naturesaura.data.BlockStateGenerator;
|
|
|
|
import de.ellpeck.naturesaura.reg.ICustomBlockState;
|
2018-11-21 20:36:55 +01:00
|
|
|
import de.ellpeck.naturesaura.reg.ITESRProvider;
|
2021-12-15 16:24:53 +01:00
|
|
|
import net.minecraft.client.renderer.blockentity.BlockEntityRenderers;
|
2021-12-04 15:40:09 +01:00
|
|
|
import net.minecraft.core.BlockPos;
|
2021-12-15 16:24:53 +01:00
|
|
|
import net.minecraft.world.InteractionHand;
|
2021-12-04 15:40:09 +01:00
|
|
|
import net.minecraft.world.InteractionResult;
|
2021-12-15 16:24:53 +01:00
|
|
|
import net.minecraft.world.entity.player.Player;
|
|
|
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
2021-12-04 15:40:09 +01:00
|
|
|
import net.minecraft.world.level.BlockGetter;
|
|
|
|
import net.minecraft.world.level.Level;
|
2021-12-15 16:24:53 +01:00
|
|
|
import net.minecraft.world.level.block.Block;
|
2021-12-04 15:40:09 +01:00
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
2021-12-15 16:24:53 +01:00
|
|
|
import net.minecraft.world.level.block.state.StateDefinition;
|
2021-12-04 15:40:09 +01:00
|
|
|
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
2021-12-15 16:24:53 +01:00
|
|
|
import net.minecraft.world.level.material.Material;
|
|
|
|
import net.minecraft.world.phys.BlockHitResult;
|
2021-12-04 15:40:09 +01:00
|
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
|
|
|
import net.minecraft.world.phys.shapes.Shapes;
|
|
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
2018-10-14 14:27:18 +02:00
|
|
|
|
2020-02-25 20:07:26 +01:00
|
|
|
import javax.annotation.Nullable;
|
2020-01-28 18:08:56 +01:00
|
|
|
|
2021-12-04 15:40:09 +01:00
|
|
|
public class BlockNatureAltar extends BlockContainerImpl implements ITESRProvider<BlockEntityNatureAltar>, ICustomBlockState {
|
2018-10-14 14:27:18 +02:00
|
|
|
|
2021-12-04 15:40:09 +01:00
|
|
|
private static final VoxelShape SHAPE = Shapes.create(0, 0, 0, 1, 12 / 16F, 1);
|
2020-02-25 20:07:26 +01:00
|
|
|
public static final BooleanProperty NETHER = BooleanProperty.create("nether");
|
2020-01-23 16:05:52 +01:00
|
|
|
|
2018-10-14 14:27:18 +02:00
|
|
|
public BlockNatureAltar() {
|
2021-12-19 15:32:45 +01:00
|
|
|
super("nature_altar", BlockEntityNatureAltar.class, Block.Properties.of(Material.STONE).strength(4F));
|
2021-12-15 16:24:53 +01:00
|
|
|
this.registerDefaultState(this.defaultBlockState().setValue(NETHER, false));
|
2018-10-14 14:27:18 +02:00
|
|
|
}
|
|
|
|
|
2020-02-05 14:30:17 +01:00
|
|
|
@Override
|
|
|
|
protected boolean hasWaterlogging() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-10-18 13:34:37 +02:00
|
|
|
@Override
|
2021-12-04 15:40:09 +01:00
|
|
|
public VoxelShape getShape(BlockState state, BlockGetter levelIn, BlockPos pos, CollisionContext context) {
|
2020-01-23 16:05:52 +01:00
|
|
|
return SHAPE;
|
2018-10-14 14:27:18 +02:00
|
|
|
}
|
2018-10-16 11:49:30 +02:00
|
|
|
|
|
|
|
@Override
|
2021-12-04 15:40:09 +01:00
|
|
|
|
2021-12-15 16:24:53 +01:00
|
|
|
public InteractionResult use(BlockState state, Level levelIn, BlockPos pos, Player player, InteractionHand handIn, BlockHitResult hit) {
|
2020-01-23 16:05:52 +01:00
|
|
|
return Helper.putStackOnTile(player, handIn, pos, 0, true);
|
2018-11-05 20:52:29 +01:00
|
|
|
}
|
|
|
|
|
2020-01-29 00:40:28 +01:00
|
|
|
@Override
|
|
|
|
public void generateCustomBlockState(BlockStateGenerator generator) {
|
2020-02-25 20:07:26 +01:00
|
|
|
// noop
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2021-12-15 16:24:53 +01:00
|
|
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
|
|
|
super.createBlockStateDefinition(builder);
|
2020-02-25 20:07:26 +01:00
|
|
|
builder.add(NETHER);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
@Override
|
2021-12-15 16:24:53 +01:00
|
|
|
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
2021-12-15 16:30:22 +01:00
|
|
|
var nether = IAuraType.forLevel(context.getLevel()).isSimilar(NaturesAuraAPI.TYPE_NETHER);
|
2021-12-15 16:24:53 +01:00
|
|
|
return super.getStateForPlacement(context).setValue(NETHER, nether);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void registerTESR() {
|
2021-12-19 15:32:45 +01:00
|
|
|
BlockEntityRenderers.register(ModBlockEntities.NATURE_ALTAR, RenderNatureAltar::new);
|
2020-01-29 00:40:28 +01:00
|
|
|
}
|
2018-10-14 14:27:18 +02:00
|
|
|
}
|