NaturesAura/src/main/java/de/ellpeck/naturesaura/blocks/BlockAutoCrafter.java

41 lines
1.7 KiB
Java
Raw Normal View History

2019-01-08 01:14:19 +01:00
package de.ellpeck.naturesaura.blocks;
2021-12-04 15:40:09 +01:00
import de.ellpeck.naturesaura.blocks.tiles.BlockEntityAutoCrafter;
2020-01-29 01:34:58 +01:00
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
2019-11-04 19:08:49 +01:00
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
2019-01-08 01:14:19 +01:00
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
2019-11-04 19:08:49 +01:00
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
import net.minecraft.state.StateContainer;
import net.minecraft.state.properties.BlockStateProperties;
2019-01-08 01:14:19 +01:00
2020-01-29 01:34:58 +01:00
public class BlockAutoCrafter extends BlockContainerImpl implements ICustomBlockState {
2019-11-04 19:08:49 +01:00
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
2019-01-08 01:14:19 +01:00
public BlockAutoCrafter() {
2021-12-04 15:40:09 +01:00
super("auto_crafter", BlockEntityAutoCrafter::new, Properties.create(Material.WOOD).hardnessAndResistance(1.5F).sound(SoundType.WOOD));
2019-01-08 01:14:19 +01:00
}
@Override
2019-11-04 19:08:49 +01:00
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder) {
super.fillStateContainer(builder);
2019-11-04 19:08:49 +01:00
builder.add(FACING);
2019-01-08 01:14:19 +01:00
}
@Override
2019-11-04 19:08:49 +01:00
public BlockState getStateForPlacement(BlockItemUseContext context) {
return super.getStateForPlacement(context).with(FACING, context.getPlayer().getHorizontalFacing());
2019-01-08 01:14:19 +01:00
}
2020-01-29 01:34:58 +01:00
@Override
public void generateCustomBlockState(BlockStateGenerator generator) {
generator.horizontalBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
generator.modLoc("block/" + this.getBaseName()),
generator.modLoc("block/" + this.getBaseName() + "_bottom"),
generator.modLoc("block/" + this.getBaseName() + "_top")));
}
2019-01-08 01:14:19 +01:00
}