Skip to content

Commit de5e119

Browse files
committed
- Added voxel shape and block states to corpses.
1 parent e574660 commit de5e119

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

‎src/main/java/net/limit/cubliminal/block/custom/CorpseBlock.java‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,34 @@
88
import net.minecraft.item.ItemPlacementContext;
99
import net.minecraft.item.ItemStack;
1010
import net.minecraft.state.StateManager;
11+
import net.minecraft.state.property.BooleanProperty;
1112
import net.minecraft.state.property.EnumProperty;
13+
import net.minecraft.state.property.IntProperty;
1214
import net.minecraft.util.ActionResult;
1315
import net.minecraft.util.hit.BlockHitResult;
1416
import net.minecraft.util.math.BlockPos;
1517
import net.minecraft.util.math.Direction;
18+
import net.minecraft.util.shape.VoxelShape;
19+
import net.minecraft.world.BlockView;
1620
import net.minecraft.world.World;
1721
import org.jetbrains.annotations.Nullable;
1822

1923
public class CorpseBlock extends BlockWithEntity {
2024
public static final EnumProperty<Direction> FACING = HorizontalFacingBlock.FACING;
21-
25+
public static final IntProperty AGE = IntProperty.of("age", 0, 15);
26+
public static final BooleanProperty SKIN_STOLEN = BooleanProperty.of("skin_stolen");
27+
public static final VoxelShape SHAPE = Block.createCuboidShape(0, 0, -8, 16, 4, 24);
2228
public static final MapCodec<CorpseBlock> CODEC = createCodec(CorpseBlock::new);
2329

2430
public CorpseBlock(Settings settings) {
2531
super(settings);
26-
// Sets default facing state to NORTH.
27-
setDefaultState(getDefaultState().with(FACING, Direction.NORTH));
32+
// Sets the default state for facing, age, and if skin is stolen.
33+
setDefaultState(
34+
getDefaultState()
35+
.with(FACING, Direction.NORTH)
36+
.with(SKIN_STOLEN, false)
37+
.with(AGE, 0)
38+
);
2839
}
2940

3041
@Override
@@ -41,7 +52,7 @@ protected MapCodec<? extends BlockWithEntity> getCodec() {
4152
// Builds and appends the properties.
4253
@Override
4354
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
44-
builder.add(FACING);
55+
builder.add(FACING).add(AGE).add(SKIN_STOLEN);
4556
}
4657

4758
@Override
@@ -77,4 +88,9 @@ protected ActionResult onUse(BlockState state, World world, BlockPos pos, Player
7788
}
7889
return ActionResult.SUCCESS;
7990
}
91+
92+
@Override
93+
protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
94+
return SHAPE;
95+
}
8096
}

0 commit comments

Comments
 (0)