chore: shape migration

This commit is contained in:
Michael Hillcox 2021-02-26 19:52:21 +00:00
parent 03eba1564e
commit e86ed6cd0f
3 changed files with 137 additions and 165 deletions

View file

@ -5,40 +5,140 @@ import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.util.math.shapes.VoxelShapes;
import java.util.Optional;
import java.util.stream.Stream; import java.util.stream.Stream;
/** /**
* This class just contains messy code for the block shapes. * This class just contains messy code for the block shapes.
*/ */
public final class BlockShapes { public final class BlockShapes {
public static final VoxelShape BATTERYBOX_SHAPE = Stream.of( public static class ShapeBuilder {
Block.makeCuboidShape(2, 1, 1, 14, 2, 2), Block.makeCuboidShape(0, 0, 0, 16, 1, 16), Stream.Builder<VoxelShape> shapes = Stream.builder();
Block.makeCuboidShape(2, 2, 2, 14, 5, 14), Block.makeCuboidShape(5, 5, 5, 6, 7, 6),
Block.makeCuboidShape(10, 5, 10, 11, 7, 11), Block.makeCuboidShape(5, 5, 10, 6, 7, 11),
Block.makeCuboidShape(1, 1, 14, 2, 6, 15), Block.makeCuboidShape(14, 1, 14, 15, 6, 15),
Block.makeCuboidShape(1, 1, 1, 2, 6, 2), Block.makeCuboidShape(14, 1, 1, 15, 6, 2),
Block.makeCuboidShape(1, 5, 2, 2, 6, 14), Block.makeCuboidShape(14, 1, 2, 15, 2, 14),
Block.makeCuboidShape(14, 5, 2, 15, 6, 14), Block.makeCuboidShape(1, 1, 2, 2, 2, 14),
Block.makeCuboidShape(2, 5, 14, 14, 6, 15), Block.makeCuboidShape(2, 5, 1, 14, 6, 2),
Block.makeCuboidShape(2, 1, 14, 14, 2, 15), Block.makeCuboidShape(10, 5, 5, 11, 7, 6),
Block.makeCuboidShape(5.5, 6, 6, 6, 7, 10), Block.makeCuboidShape(10, 6, 6, 10.5, 7, 10),
Block.makeCuboidShape(6, 6, 5.5, 10, 7, 6), Block.makeCuboidShape(6, 6, 10, 10, 7, 10.5),
Block.makeCuboidShape(6, 5, 6, 10, 7, 10)
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get();
public static final VoxelShape FEEDER_SHAPE = Stream.of( public ShapeBuilder add(double x1, double y1, double z1, double x2, double y2, double z2) {
Block.makeCuboidShape(0, 15, 0, 1, 16, 16), Block.makeCuboidShape(15, 15, 0, 16, 16, 16), shapes.add(Block.makeCuboidShape(x1, y1, z1, x2, y2, z2));
Block.makeCuboidShape(1, 15, 0, 15, 16, 1), Block.makeCuboidShape(1, 15, 15, 15, 16, 16), return this;
Block.makeCuboidShape(1, 0, 15, 15, 1, 16), Block.makeCuboidShape(1, 0, 0, 15, 1, 1), }
Block.makeCuboidShape(15, 0, 0, 16, 1, 16), Block.makeCuboidShape(0, 0, 0, 1, 1, 16),
Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(15, 1, 15, 16, 15, 16), public Stream<VoxelShape> build() {
Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(0, 1, 0, 1, 15, 1), return shapes.build();
Block.makeCuboidShape(11, 14, 11, 12, 15, 12), Block.makeCuboidShape(11, 14, 4, 12, 15, 5), }
Block.makeCuboidShape(4, 14, 11, 5, 15, 12), Block.makeCuboidShape(4, 14, 4, 5, 15, 5),
Block.makeCuboidShape(4, 13, 4, 12, 14, 12), Block.makeCuboidShape(4, 14, 12, 12, 15, 15), public Optional<VoxelShape> standardReduceBuild() {
Block.makeCuboidShape(4, 14, 1, 12, 15, 4), Block.makeCuboidShape(1, 14, 1, 4, 15, 15), return shapes.build().reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR));
Block.makeCuboidShape(12, 14, 1, 15, 15, 15), Block.makeCuboidShape(1, 1, 1, 15, 2, 15), }
Block.makeCuboidShape(14, 2, 1, 15, 14, 15), Block.makeCuboidShape(1, 2, 1, 2, 14, 15),
Block.makeCuboidShape(2, 2, 14, 14, 14, 15), Block.makeCuboidShape(2, 2, 1, 14, 14, 2) public static ShapeBuilder get() {
).reduce((v1, v2) -> VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR)).get(); return new ShapeBuilder();
}
}
public static final VoxelShape BATTERYBOX_SHAPE = ShapeBuilder.get()
.add(2, 1, 1, 14, 2, 2).add(0, 0, 0, 16, 1, 16).add(2, 2, 2, 14, 5, 14)
.add(5, 5, 5, 6, 7, 6).add(10, 5, 10, 11, 7, 11).add(5, 5, 10, 6, 7, 11)
.add(1, 1, 14, 2, 6, 15).add(14, 1, 14, 15, 6, 15).add(1, 1, 1, 2, 6, 2)
.add(14, 1, 1, 15, 6, 2).add(1, 5, 2, 2, 6, 14).add(14, 1, 2, 15, 2, 14)
.add(14, 5, 2, 15, 6, 14).add(1, 1, 2, 2, 2, 14).add(2, 5, 14, 14, 6, 15)
.add(2, 5, 1, 14, 6, 2).add(2, 1, 14, 14, 2, 15).add(10, 5, 5, 11, 7, 6)
.add(5.5, 6, 6, 6, 7, 10).add(10, 6, 6, 10.5, 7, 10).add(6, 6, 5.5, 10, 7, 6)
.add(6, 6, 10, 10, 7, 10.5).add(6, 5, 6, 10, 7, 10)
.standardReduceBuild().get();
public static final VoxelShape FEEDER_SHAPE = ShapeBuilder.get()
.add(0, 15, 0, 1, 16, 16).add(15, 15, 0, 16, 16, 16)
.add(1, 15, 0, 15, 16, 1).add(1, 15, 15, 15, 16, 16).add(1, 0, 15, 15, 1, 16)
.add(1, 0, 0, 15, 1, 1).add(15, 0, 0, 16, 1, 16).add(0, 0, 0, 1, 1, 16)
.add(0, 1, 15, 1, 15, 16).add(15, 1, 15, 16, 15, 16).add(15, 1, 0, 16, 15, 1)
.add(0, 1, 0, 1, 15, 1).add(11, 14, 11, 12, 15, 12).add(11, 14, 4, 12, 15, 5)
.add(4, 14, 11, 5, 15, 12).add(4, 14, 4, 5, 15, 5).add(4, 13, 4, 12, 14, 12)
.add(4, 14, 12, 12, 15, 15).add(4, 14, 1, 12, 15, 4).add(1, 14, 1, 4, 15, 15)
.add(12, 14, 1, 15, 15, 15).add(1, 1, 1, 15, 2, 15).add(14, 2, 1, 15, 14, 15)
.add(1, 2, 1, 2, 14, 15).add(2, 2, 14, 14, 14, 15).add(2, 2, 1, 14, 14, 2)
.standardReduceBuild().get();
public static final VoxelShape SOLIDIFIER_SHAPE = ShapeBuilder.get()
.add(15, 0, 1, 16, 1, 15).add(1, 1, 1, 15, 15, 15).add(0, 0, 0, 16, 1, 1)
.add(0, 0, 15, 16, 1, 16).add(0, 15, 0, 16, 16, 1).add(0, 15, 15, 16, 16, 16)
.add(0, 0, 1, 1, 1, 15).add(0, 15, 1, 1, 16, 15).add(15, 15, 1, 16, 16, 15)
.add(0, 1, 0, 1, 15, 1).add(0, 1, 15, 1, 15, 16).add(15, 1, 15, 16, 15, 16)
.add(15, 1, 0, 16, 15, 1)
.standardReduceBuild().get();
public static class BioReactorShape {
public static final VoxelShape SHAPE_N = ShapeBuilder.get()
.add(15, 1, 15, 16, 15, 16).add(0, 0, 0, 1, 1, 16).add(1, 0, 15, 15, 1, 16)
.add(15, 0, 0, 16, 1, 16).add(1, 0, 0, 15, 1, 1).add(0, 15, 0, 1, 16, 16)
.add(15, 15, 0, 16, 16, 16).add(1, 15, 0, 15, 16, 1).add(1, 15, 15, 15, 16, 16)
.add(0, 1, 15, 1, 15, 16).add(15, 1, 0, 16, 15, 1).add(0, 1, 0, 1, 15, 1)
.add(15, 11, 5, 16, 12, 11).add(0, 11, 5, 1, 12, 11).add(15, 4, 5, 16, 5, 11)
.add(0, 4, 5, 1, 5, 11).add(15, 4, 11, 16, 12, 12).add(0, 4, 11, 1, 12, 12)
.add(15, 4, 4, 16, 12, 5).add(0, 4, 4, 1, 12, 5).add(15, 12, 4, 16, 13, 12)
.add(0, 12, 4, 1, 13, 12).add(15, 3, 4, 16, 4, 12).add(0, 3, 4, 1, 4, 12)
.add(15, 3, 12, 16, 13, 13).add(0, 3, 12, 1, 13, 13).add(15, 3, 3, 16, 13, 4)
.add(0, 3, 3, 1, 13, 4).add(4, 13, 4, 12, 14, 12).add(11, 14, 4, 12, 15, 5)
.add(4, 14, 4, 5, 15, 5).add(4, 14, 11, 5, 15, 12).add(11, 14, 11, 12, 15, 12)
.add(2, 14, 2, 4, 15, 14).add(4, 14, 2, 12, 15, 4).add(4, 14, 12, 12, 15, 14)
.add(12, 14, 2, 14, 15, 14).add(2, 0, 2, 14, 1, 14).add(1, 0, 2, 2, 15, 14)
.add(14, 0, 2, 15, 15, 14).add(1, 0, 14, 15, 15, 15).add(1, 0, 1, 15, 15, 2)
.add(0, 8, 6, 1, 9, 7).add(15, 8, 6, 16, 9, 7).add(0, 9, 7, 1, 10, 8)
.add(15, 9, 7, 16, 10, 8).add(0, 6, 9, 1, 7, 10).add(15, 6, 9, 16, 7, 10)
.standardReduceBuild().get();
public static final VoxelShape SHAPE_E = ShapeBuilder.get()
.add(0, 1, 15, 1, 15, 16).add(0, 0, 0, 16, 1, 1).add(0, 0, 1, 1, 1, 15)
.add(0, 0, 15, 16, 1, 16).add(15, 0, 1, 16, 1, 15).add(0, 15, 0, 16, 16, 1)
.add(0, 15, 15, 16, 16, 16).add(15, 15, 1, 16, 16, 15).add(0, 15, 1, 1, 16, 15)
.add(0, 1, 0, 1, 15, 1).add(15, 1, 15, 16, 15, 16).add(15, 1, 0, 16, 15, 1)
.add(5, 11, 15, 11, 12, 16).add(5, 11, 0, 11, 12, 1).add(5, 4, 15, 11, 5, 16)
.add(5, 4, 0, 11, 5, 1).add(4, 4, 15, 5, 12, 16).add(4, 4, 0, 5, 12, 1)
.add(11, 4, 15, 12, 12, 16).add(11, 4, 0, 12, 12, 1).add(4, 12, 15, 12, 13, 16)
.add(4, 12, 0, 12, 13, 1).add(4, 3, 15, 12, 4, 16).add(4, 3, 0, 12, 4, 1)
.add(3, 3, 15, 4, 13, 16).add(3, 3, 0, 4, 13, 1).add(12, 3, 15, 13, 13, 16)
.add(12, 3, 0, 13, 13, 1).add(4, 13, 4, 12, 14, 12).add(11, 14, 11, 12, 15, 12)
.add(11, 14, 4, 12, 15, 5).add(4, 14, 4, 5, 15, 5).add(4, 14, 11, 5, 15, 12)
.add(2, 14, 2, 14, 15, 4).add(12, 14, 4, 14, 15, 12).add(2, 14, 4, 4, 15, 12)
.add(2, 14, 12, 14, 15, 14).add(2, 0, 2, 14, 1, 14).add(2, 0, 1, 14, 15, 2)
.add(2, 0, 14, 14, 15, 15).add(1, 0, 1, 2, 15, 15).add(14, 0, 1, 15, 15, 15)
.add(9, 8, 0, 10, 9, 1).add(9, 8, 15, 10, 9, 16).add(8, 9, 0, 9, 10, 1)
.add(8, 9, 15, 9, 10, 16).add(6, 6, 0, 7, 7, 1).add(6, 6, 15, 7, 7, 16)
.standardReduceBuild().get();
public static final VoxelShape SHAPE_S = ShapeBuilder.get()
.add(0, 1, 0, 1, 15, 1).add(15, 0, 0, 16, 1, 16).add(1, 0, 0, 15, 1, 1)
.add(0, 0, 0, 1, 1, 16).add(1, 0, 15, 15, 1, 16).add(15, 15, 0, 16, 16, 16)
.add(0, 15, 0, 1, 16, 16).add(1, 15, 15, 15, 16, 16).add(1, 15, 0, 15, 16, 1)
.add(15, 1, 0, 16, 15, 1).add(0, 1, 15, 1, 15, 16).add(15, 1, 15, 16, 15, 16)
.add(0, 11, 5, 1, 12, 11).add(15, 11, 5, 16, 12, 11).add(0, 4, 5, 1, 5, 11)
.add(15, 4, 5, 16, 5, 11).add(0, 4, 4, 1, 12, 5).add(15, 4, 4, 16, 12, 5)
.add(0, 4, 11, 1, 12, 12).add(15, 4, 11, 16, 12, 12).add(0, 12, 4, 1, 13, 12)
.add(15, 12, 4, 16, 13, 12).add(0, 3, 4, 1, 4, 12).add(15, 3, 4, 16, 4, 12)
.add(0, 3, 3, 1, 13, 4).add(15, 3, 3, 16, 13, 4).add(0, 3, 12, 1, 13, 13)
.add(15, 3, 12, 16, 13, 13).add(4, 13, 4, 12, 14, 12).add(4, 14, 11, 5, 15, 12)
.add(11, 14, 11, 12, 15, 12).add(11, 14, 4, 12, 15, 5).add(4, 14, 4, 5, 15, 5)
.add(12, 14, 2, 14, 15, 14).add(4, 14, 12, 12, 15, 14).add(4, 14, 2, 12, 15, 4)
.add(2, 14, 2, 4, 15, 14).add(2, 0, 2, 14, 1, 14).add(14, 0, 2, 15, 15, 14)
.add(1, 0, 2, 2, 15, 14).add(1, 0, 1, 15, 15, 2).add(1, 0, 14, 15, 15, 15)
.add(15, 8, 9, 16, 9, 10).add(0, 8, 9, 1, 9, 10).add(15, 9, 8, 16, 10, 9)
.add(0, 9, 8, 1, 10, 9).add(15, 6, 6, 16, 7, 7).add(0, 6, 6, 1, 7, 7)
.standardReduceBuild().get();
public static final VoxelShape SHAPE_W = ShapeBuilder.get()
.add(15, 1, 0, 16, 15, 1).add(0, 0, 15, 16, 1, 16).add(15, 0, 1, 16, 1, 15)
.add(0, 0, 0, 16, 1, 1).add(0, 0, 1, 1, 1, 15).add(0, 15, 15, 16, 16, 16)
.add(0, 15, 0, 16, 16, 1).add(0, 15, 1, 1, 16, 15).add(15, 15, 1, 16, 16, 15)
.add(15, 1, 15, 16, 15, 16).add(0, 1, 0, 1, 15, 1).add(0, 1, 15, 1, 15, 16)
.add(5, 11, 0, 11, 12, 1).add(5, 11, 15, 11, 12, 16).add(5, 4, 0, 11, 5, 1)
.add(5, 4, 15, 11, 5, 16).add(11, 4, 0, 12, 12, 1).add(11, 4, 15, 12, 12, 16)
.add(4, 4, 0, 5, 12, 1).add(4, 4, 15, 5, 12, 16).add(4, 12, 0, 12, 13, 1)
.add(4, 12, 15, 12, 13, 16).add(4, 3, 0, 12, 4, 1).add(4, 3, 15, 12, 4, 16)
.add(12, 3, 0, 13, 13, 1).add(12, 3, 15, 13, 13, 16).add(3, 3, 0, 4, 13, 1)
.add(3, 3, 15, 4, 13, 16).add(4, 13, 4, 12, 14, 12).add(4, 14, 4, 5, 15, 5)
.add(4, 14, 11, 5, 15, 12).add(11, 14, 11, 12, 15, 12).add(11, 14, 4, 12, 15, 5)
.add(2, 14, 12, 14, 15, 14).add(2, 14, 4, 4, 15, 12).add(12, 14, 4, 14, 15, 12)
.add(2, 14, 2, 14, 15, 4).add(2, 0, 2, 14, 1, 14).add(2, 0, 14, 14, 15, 15)
.add(2, 0, 1, 14, 15, 2).add(14, 0, 1, 15, 15, 15).add(1, 0, 1, 2, 15, 15)
.add(6, 8, 15, 7, 9, 16).add(6, 8, 0, 7, 9, 1).add(7, 9, 15, 8, 10, 16)
.add(7, 9, 0, 8, 10, 1).add(9, 6, 15, 10, 7, 16).add(9, 6, 0, 10, 7, 1)
.standardReduceBuild().get();
}
} }

View file

@ -1,21 +1,16 @@
package de.ellpeck.actuallyadditions.common.blocks.functional; package de.ellpeck.actuallyadditions.common.blocks.functional;
import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlock; import de.ellpeck.actuallyadditions.common.blocks.BlockShapes;
import de.ellpeck.actuallyadditions.common.blocks.HorizontallyDirectionalBlock; import de.ellpeck.actuallyadditions.common.blocks.HorizontallyDirectionalBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.state.DirectionProperty; import net.minecraft.state.DirectionProperty;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import java.util.stream.Stream;
public class BioReactorBlock extends HorizontallyDirectionalBlock { public class BioReactorBlock extends HorizontallyDirectionalBlock {
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING; public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
@ -23,127 +18,19 @@ public class BioReactorBlock extends HorizontallyDirectionalBlock {
super(Properties.create(Material.ROCK)); super(Properties.create(Material.ROCK));
} }
private static final VoxelShape SHAPE_N = Stream.of(
Block.makeCuboidShape(15, 1, 15, 16, 15, 16), Block.makeCuboidShape(0, 0, 0, 1, 1, 16),
Block.makeCuboidShape(1, 0, 15, 15, 1, 16), Block.makeCuboidShape(15, 0, 0, 16, 1, 16),
Block.makeCuboidShape(1, 0, 0, 15, 1, 1), Block.makeCuboidShape(0, 15, 0, 1, 16, 16),
Block.makeCuboidShape(15, 15, 0, 16, 16, 16), Block.makeCuboidShape(1, 15, 0, 15, 16, 1),
Block.makeCuboidShape(1, 15, 15, 15, 16, 16), Block.makeCuboidShape(0, 1, 15, 1, 15, 16),
Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(0, 1, 0, 1, 15, 1),
Block.makeCuboidShape(15, 11, 5, 16, 12, 11), Block.makeCuboidShape(0, 11, 5, 1, 12, 11),
Block.makeCuboidShape(15, 4, 5, 16, 5, 11), Block.makeCuboidShape(0, 4, 5, 1, 5, 11),
Block.makeCuboidShape(15, 4, 11, 16, 12, 12), Block.makeCuboidShape(0, 4, 11, 1, 12, 12),
Block.makeCuboidShape(15, 4, 4, 16, 12, 5), Block.makeCuboidShape(0, 4, 4, 1, 12, 5),
Block.makeCuboidShape(15, 12, 4, 16, 13, 12), Block.makeCuboidShape(0, 12, 4, 1, 13, 12),
Block.makeCuboidShape(15, 3, 4, 16, 4, 12), Block.makeCuboidShape(0, 3, 4, 1, 4, 12),
Block.makeCuboidShape(15, 3, 12, 16, 13, 13), Block.makeCuboidShape(0, 3, 12, 1, 13, 13),
Block.makeCuboidShape(15, 3, 3, 16, 13, 4), Block.makeCuboidShape(0, 3, 3, 1, 13, 4),
Block.makeCuboidShape(4, 13, 4, 12, 14, 12), Block.makeCuboidShape(11, 14, 4, 12, 15, 5),
Block.makeCuboidShape(4, 14, 4, 5, 15, 5), Block.makeCuboidShape(4, 14, 11, 5, 15, 12),
Block.makeCuboidShape(11, 14, 11, 12, 15, 12), Block.makeCuboidShape(2, 14, 2, 4, 15, 14),
Block.makeCuboidShape(4, 14, 2, 12, 15, 4), Block.makeCuboidShape(4, 14, 12, 12, 15, 14),
Block.makeCuboidShape(12, 14, 2, 14, 15, 14), Block.makeCuboidShape(2, 0, 2, 14, 1, 14),
Block.makeCuboidShape(1, 0, 2, 2, 15, 14), Block.makeCuboidShape(14, 0, 2, 15, 15, 14),
Block.makeCuboidShape(1, 0, 14, 15, 15, 15), Block.makeCuboidShape(1, 0, 1, 15, 15, 2),
Block.makeCuboidShape(0, 8, 6, 1, 9, 7), Block.makeCuboidShape(15, 8, 6, 16, 9, 7),
Block.makeCuboidShape(0, 9, 7, 1, 10, 8), Block.makeCuboidShape(15, 9, 7, 16, 10, 8),
Block.makeCuboidShape(0, 6, 9, 1, 7, 10), Block.makeCuboidShape(15, 6, 9, 16, 7, 10)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
private static final VoxelShape SHAPE_E = Stream.of(
Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(0, 0, 0, 16, 1, 1),
Block.makeCuboidShape(0, 0, 1, 1, 1, 15), Block.makeCuboidShape(0, 0, 15, 16, 1, 16),
Block.makeCuboidShape(15, 0, 1, 16, 1, 15), Block.makeCuboidShape(0, 15, 0, 16, 16, 1),
Block.makeCuboidShape(0, 15, 15, 16, 16, 16), Block.makeCuboidShape(15, 15, 1, 16, 16, 15),
Block.makeCuboidShape(0, 15, 1, 1, 16, 15), Block.makeCuboidShape(0, 1, 0, 1, 15, 1),
Block.makeCuboidShape(15, 1, 15, 16, 15, 16), Block.makeCuboidShape(15, 1, 0, 16, 15, 1),
Block.makeCuboidShape(5, 11, 15, 11, 12, 16), Block.makeCuboidShape(5, 11, 0, 11, 12, 1),
Block.makeCuboidShape(5, 4, 15, 11, 5, 16), Block.makeCuboidShape(5, 4, 0, 11, 5, 1),
Block.makeCuboidShape(4, 4, 15, 5, 12, 16), Block.makeCuboidShape(4, 4, 0, 5, 12, 1),
Block.makeCuboidShape(11, 4, 15, 12, 12, 16), Block.makeCuboidShape(11, 4, 0, 12, 12, 1),
Block.makeCuboidShape(4, 12, 15, 12, 13, 16), Block.makeCuboidShape(4, 12, 0, 12, 13, 1),
Block.makeCuboidShape(4, 3, 15, 12, 4, 16), Block.makeCuboidShape(4, 3, 0, 12, 4, 1),
Block.makeCuboidShape(3, 3, 15, 4, 13, 16), Block.makeCuboidShape(3, 3, 0, 4, 13, 1),
Block.makeCuboidShape(12, 3, 15, 13, 13, 16), Block.makeCuboidShape(12, 3, 0, 13, 13, 1),
Block.makeCuboidShape(4, 13, 4, 12, 14, 12), Block.makeCuboidShape(11, 14, 11, 12, 15, 12),
Block.makeCuboidShape(11, 14, 4, 12, 15, 5), Block.makeCuboidShape(4, 14, 4, 5, 15, 5),
Block.makeCuboidShape(4, 14, 11, 5, 15, 12), Block.makeCuboidShape(2, 14, 2, 14, 15, 4),
Block.makeCuboidShape(12, 14, 4, 14, 15, 12), Block.makeCuboidShape(2, 14, 4, 4, 15, 12),
Block.makeCuboidShape(2, 14, 12, 14, 15, 14), Block.makeCuboidShape(2, 0, 2, 14, 1, 14),
Block.makeCuboidShape(2, 0, 1, 14, 15, 2), Block.makeCuboidShape(2, 0, 14, 14, 15, 15),
Block.makeCuboidShape(1, 0, 1, 2, 15, 15), Block.makeCuboidShape(14, 0, 1, 15, 15, 15),
Block.makeCuboidShape(9, 8, 0, 10, 9, 1), Block.makeCuboidShape(9, 8, 15, 10, 9, 16),
Block.makeCuboidShape(8, 9, 0, 9, 10, 1), Block.makeCuboidShape(8, 9, 15, 9, 10, 16),
Block.makeCuboidShape(6, 6, 0, 7, 7, 1), Block.makeCuboidShape(6, 6, 15, 7, 7, 16)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
private static final VoxelShape SHAPE_S = Stream.of(
Block.makeCuboidShape(0, 1, 0, 1, 15, 1), Block.makeCuboidShape(15, 0, 0, 16, 1, 16),
Block.makeCuboidShape(1, 0, 0, 15, 1, 1), Block.makeCuboidShape(0, 0, 0, 1, 1, 16),
Block.makeCuboidShape(1, 0, 15, 15, 1, 16), Block.makeCuboidShape(15, 15, 0, 16, 16, 16),
Block.makeCuboidShape(0, 15, 0, 1, 16, 16), Block.makeCuboidShape(1, 15, 15, 15, 16, 16),
Block.makeCuboidShape(1, 15, 0, 15, 16, 1), Block.makeCuboidShape(15, 1, 0, 16, 15, 1),
Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(15, 1, 15, 16, 15, 16),
Block.makeCuboidShape(0, 11, 5, 1, 12, 11), Block.makeCuboidShape(15, 11, 5, 16, 12, 11),
Block.makeCuboidShape(0, 4, 5, 1, 5, 11), Block.makeCuboidShape(15, 4, 5, 16, 5, 11),
Block.makeCuboidShape(0, 4, 4, 1, 12, 5), Block.makeCuboidShape(15, 4, 4, 16, 12, 5),
Block.makeCuboidShape(0, 4, 11, 1, 12, 12), Block.makeCuboidShape(15, 4, 11, 16, 12, 12),
Block.makeCuboidShape(0, 12, 4, 1, 13, 12), Block.makeCuboidShape(15, 12, 4, 16, 13, 12),
Block.makeCuboidShape(0, 3, 4, 1, 4, 12), Block.makeCuboidShape(15, 3, 4, 16, 4, 12),
Block.makeCuboidShape(0, 3, 3, 1, 13, 4), Block.makeCuboidShape(15, 3, 3, 16, 13, 4),
Block.makeCuboidShape(0, 3, 12, 1, 13, 13), Block.makeCuboidShape(15, 3, 12, 16, 13, 13),
Block.makeCuboidShape(4, 13, 4, 12, 14, 12), Block.makeCuboidShape(4, 14, 11, 5, 15, 12),
Block.makeCuboidShape(11, 14, 11, 12, 15, 12), Block.makeCuboidShape(11, 14, 4, 12, 15, 5),
Block.makeCuboidShape(4, 14, 4, 5, 15, 5), Block.makeCuboidShape(12, 14, 2, 14, 15, 14),
Block.makeCuboidShape(4, 14, 12, 12, 15, 14), Block.makeCuboidShape(4, 14, 2, 12, 15, 4),
Block.makeCuboidShape(2, 14, 2, 4, 15, 14), Block.makeCuboidShape(2, 0, 2, 14, 1, 14),
Block.makeCuboidShape(14, 0, 2, 15, 15, 14), Block.makeCuboidShape(1, 0, 2, 2, 15, 14),
Block.makeCuboidShape(1, 0, 1, 15, 15, 2), Block.makeCuboidShape(1, 0, 14, 15, 15, 15),
Block.makeCuboidShape(15, 8, 9, 16, 9, 10), Block.makeCuboidShape(0, 8, 9, 1, 9, 10),
Block.makeCuboidShape(15, 9, 8, 16, 10, 9), Block.makeCuboidShape(0, 9, 8, 1, 10, 9),
Block.makeCuboidShape(15, 6, 6, 16, 7, 7), Block.makeCuboidShape(0, 6, 6, 1, 7, 7)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
private static final VoxelShape SHAPE_W = Stream.of(
Block.makeCuboidShape(15, 1, 0, 16, 15, 1), Block.makeCuboidShape(0, 0, 15, 16, 1, 16),
Block.makeCuboidShape(15, 0, 1, 16, 1, 15), Block.makeCuboidShape(0, 0, 0, 16, 1, 1),
Block.makeCuboidShape(0, 0, 1, 1, 1, 15), Block.makeCuboidShape(0, 15, 15, 16, 16, 16),
Block.makeCuboidShape(0, 15, 0, 16, 16, 1), Block.makeCuboidShape(0, 15, 1, 1, 16, 15),
Block.makeCuboidShape(15, 15, 1, 16, 16, 15), Block.makeCuboidShape(15, 1, 15, 16, 15, 16),
Block.makeCuboidShape(0, 1, 0, 1, 15, 1), Block.makeCuboidShape(0, 1, 15, 1, 15, 16),
Block.makeCuboidShape(5, 11, 0, 11, 12, 1), Block.makeCuboidShape(5, 11, 15, 11, 12, 16),
Block.makeCuboidShape(5, 4, 0, 11, 5, 1), Block.makeCuboidShape(5, 4, 15, 11, 5, 16),
Block.makeCuboidShape(11, 4, 0, 12, 12, 1), Block.makeCuboidShape(11, 4, 15, 12, 12, 16),
Block.makeCuboidShape(4, 4, 0, 5, 12, 1), Block.makeCuboidShape(4, 4, 15, 5, 12, 16),
Block.makeCuboidShape(4, 12, 0, 12, 13, 1), Block.makeCuboidShape(4, 12, 15, 12, 13, 16),
Block.makeCuboidShape(4, 3, 0, 12, 4, 1), Block.makeCuboidShape(4, 3, 15, 12, 4, 16),
Block.makeCuboidShape(12, 3, 0, 13, 13, 1), Block.makeCuboidShape(12, 3, 15, 13, 13, 16),
Block.makeCuboidShape(3, 3, 0, 4, 13, 1), Block.makeCuboidShape(3, 3, 15, 4, 13, 16),
Block.makeCuboidShape(4, 13, 4, 12, 14, 12), Block.makeCuboidShape(4, 14, 4, 5, 15, 5),
Block.makeCuboidShape(4, 14, 11, 5, 15, 12), Block.makeCuboidShape(11, 14, 11, 12, 15, 12),
Block.makeCuboidShape(11, 14, 4, 12, 15, 5), Block.makeCuboidShape(2, 14, 12, 14, 15, 14),
Block.makeCuboidShape(2, 14, 4, 4, 15, 12), Block.makeCuboidShape(12, 14, 4, 14, 15, 12),
Block.makeCuboidShape(2, 14, 2, 14, 15, 4), Block.makeCuboidShape(2, 0, 2, 14, 1, 14),
Block.makeCuboidShape(2, 0, 14, 14, 15, 15), Block.makeCuboidShape(2, 0, 1, 14, 15, 2),
Block.makeCuboidShape(14, 0, 1, 15, 15, 15), Block.makeCuboidShape(1, 0, 1, 2, 15, 15),
Block.makeCuboidShape(6, 8, 15, 7, 9, 16), Block.makeCuboidShape(6, 8, 0, 7, 9, 1),
Block.makeCuboidShape(7, 9, 15, 8, 10, 16), Block.makeCuboidShape(7, 9, 0, 8, 10, 1),
Block.makeCuboidShape(9, 6, 15, 10, 7, 16), Block.makeCuboidShape(9, 6, 0, 10, 7, 1)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
switch (state.get(FACING)) { switch (state.get(FACING)) {
case NORTH: case NORTH:
return SHAPE_N; return BlockShapes.BioReactorShape.SHAPE_N;
case EAST: case EAST:
return SHAPE_E; return BlockShapes.BioReactorShape.SHAPE_E;
case SOUTH: case SOUTH:
return SHAPE_S; return BlockShapes.BioReactorShape.SHAPE_S;
case WEST: case WEST:
return SHAPE_W; return BlockShapes.BioReactorShape.SHAPE_W;
default: default:
return SHAPE_N; return BlockShapes.BioReactorShape.SHAPE_N;
} }
} }
} }

View file

@ -1,36 +1,21 @@
package de.ellpeck.actuallyadditions.common.blocks.functional; package de.ellpeck.actuallyadditions.common.blocks.functional;
import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlock; import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlock;
import net.minecraft.block.Block; import de.ellpeck.actuallyadditions.common.blocks.BlockShapes;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import java.util.stream.Stream;
public class XPSolidifierBlock extends ActuallyBlock { public class XPSolidifierBlock extends ActuallyBlock {
public XPSolidifierBlock() { public XPSolidifierBlock() {
super(Properties.create(Material.ROCK)); super(Properties.create(Material.ROCK));
} }
private static final VoxelShape SOLIDIFIER_SHAPE = Stream.of(
Block.makeCuboidShape(15, 0, 1, 16, 1, 15), Block.makeCuboidShape(1, 1, 1, 15, 15, 15),
Block.makeCuboidShape(0, 0, 0, 16, 1, 1), Block.makeCuboidShape(0, 0, 15, 16, 1, 16),
Block.makeCuboidShape(0, 15, 0, 16, 16, 1), Block.makeCuboidShape(0, 15, 15, 16, 16, 16),
Block.makeCuboidShape(0, 0, 1, 1, 1, 15), Block.makeCuboidShape(0, 15, 1, 1, 16, 15),
Block.makeCuboidShape(15, 15, 1, 16, 16, 15), Block.makeCuboidShape(0, 1, 0, 1, 15, 1),
Block.makeCuboidShape(0, 1, 15, 1, 15, 16), Block.makeCuboidShape(15, 1, 15, 16, 15, 16),
Block.makeCuboidShape(15, 1, 0, 16, 15, 1)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return SOLIDIFIER_SHAPE; return BlockShapes.SOLIDIFIER_SHAPE;
} }
} }