package com.thebrokenrail.energonrelics.block.battery; import com.thebrokenrail.energonrelics.block.entity.battery.BatteryControllerBlockEntity; import com.thebrokenrail.energonrelics.block.util.EnergyProviderBlock; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Material; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.BlockEntityType; import net.minecraft.item.ItemPlacementContext; import net.minecraft.state.StateManager; import net.minecraft.state.property.DirectionProperty; import net.minecraft.state.property.Properties; import net.minecraft.util.BlockMirror; import net.minecraft.util.BlockRotation; import net.minecraft.util.math.Direction; import java.util.function.Function; @SuppressWarnings("deprecation") public class BatteryControllerBlock extends EnergyProviderBlock { public static final DirectionProperty FACING = Properties.FACING; public BatteryControllerBlock() { super(FabricBlockSettings.of(Material.STONE).requiresTool().strength(1.5f, 6.0f)); setDefaultState(getDefaultState().with(FACING, Direction.NORTH)); } @Override protected void appendProperties(StateManager.Builder builder) { builder.add(FACING); } @Override public BlockState rotate(BlockState state, BlockRotation rotation) { return state.with(FACING, rotation.rotate(state.get(FACING))); } @Override public BlockState mirror(BlockState state, BlockMirror mirror) { return state.rotate(mirror.getRotation(state.get(FACING))); } @Override public BlockState getPlacementState(ItemPlacementContext ctx) { return getDefaultState().with(FACING, ctx.getPlayerLookDirection().getOpposite()); } @Override protected Function, BlockEntity> getFactory() { return BatteryControllerBlockEntity::new; } }