moved most shapes to central AllShapes class

also some more changes to voxelshaper :)

Signed-off-by: Zelophed <zefren1@googlemail.com>
This commit is contained in:
zelophed 2019-12-10 02:23:34 +01:00 committed by Zelophed
parent 70eafb997d
commit 7166aeeb52
31 changed files with 198 additions and 388 deletions

View file

@ -0,0 +1,94 @@
package com.simibubi.create.foundation.utility;
import net.minecraft.block.Blocks;
import net.minecraft.block.DirectionalBlock;
import net.minecraft.block.PistonHeadBlock;
import net.minecraft.util.Direction;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import static net.minecraft.block.Block.makeCuboidShape;
public class AllShapes {
public static final VoxelShaper
SHORT_CASING = VoxelShaper.forDirectional(makeCuboidShape(0, 0, 0, 16, 12, 16), Direction.UP),
HARVESTER_BASE = VoxelShaper.forHorizontal(makeCuboidShape(0, 2, 0, 16, 14, 3), Direction.SOUTH),
MOTOR_BLOCK = VoxelShaper.forHorizontal(makeCuboidShape(0, 3, 3, 16, 13, 13), Direction.EAST),
FOUR_VOXEL_POLE = VoxelShaper.forDirectionalAxis(makeCuboidShape(6, 0, 6, 10, 16, 10), Direction.Axis.Y),
SIX_VOXEL_POLE = VoxelShaper.forDirectionalAxis(makeCuboidShape(5, 0, 5, 11, 16, 11), Direction.Axis.Y),
BELT_FUNNEL = VoxelShaper.forHorizontal(makeCuboidShape(3, -4, 11, 13, 8, 17), Direction.SOUTH),
BELT_EXTRACTOR = VoxelShaper.forHorizontal(makeCuboidShape(4, 2, 11, 12, 10, 17), Direction.SOUTH)
;
private static final VoxelShape
LOGISTICAL_CASING_MIDDLE_SHAPE = VoxelShapes.or(
makeCuboidShape(1,0,1,15,16,15),
makeCuboidShape(0,0,0,2,16,2),
makeCuboidShape(14,0,0,16,16,2),
makeCuboidShape(0,0,14,2,16,16),
makeCuboidShape(14,0,14,16,16,16)),
LOGISTICAL_CASING_CAP_SHAPE = VoxelShapes.or(
LOGISTICAL_CASING_MIDDLE_SHAPE,
makeCuboidShape(0,0,0,16,2,16)),
CART_ASSEMBLER_SHAPE = VoxelShapes.or(
VoxelShapes.fullCube(),
makeCuboidShape(-2, 0, 1, 18, 13, 15)),
MECHANICAL_PISTON_HEAD_SHAPE_UP = Blocks.PISTON_HEAD.getShape(Blocks.PISTON_HEAD.getStateContainer().getBaseState().with(DirectionalBlock.FACING, Direction.UP).with(PistonHeadBlock.SHORT, true), null, null, null),
MECHANICAL_PISTON_EXTENDED_SHAPE_UP = VoxelShapes.or(
SHORT_CASING.get(Direction.UP),
FOUR_VOXEL_POLE.get(Direction.Axis.Y)),
SMALL_GEAR_SHAPE = makeCuboidShape(2, 6, 2, 14, 10, 14),
LARGE_GEAR_SHAPE = makeCuboidShape(0, 6, 0, 16, 10, 16),
VERTICAL_TABLET_SHAPE_SOUTH = makeCuboidShape(3, 1, -1, 13, 15, 3),
SQUARE_TABLET_SHAPE_SOUTH = makeCuboidShape(2, 2, -1, 14, 14, 3),
PACKAGE_FUNNEL_SHAPE_UP = makeCuboidShape(1, -1, 1, 15, 3, 15),
TABLE_POLE_SHAPE = VoxelShapes.or(
makeCuboidShape(4, 0, 4, 12, 2, 12),
makeCuboidShape(5, 2, 5, 11, 14, 11)),
LOGISTICS_TABLE_SLOPE_SOUTH = VoxelShapes.or(
makeCuboidShape(0, 10D, 15, 16, 14, 10.667),
makeCuboidShape(0, 12, 10.667, 16, 16, 6.333),
makeCuboidShape(0, 14, 6.333, 16, 18, 2))
;
public static final VoxelShape
LOGISTICAL_CASING_SINGLE_SHAPE = VoxelShapes.or(
makeCuboidShape(0, 0, 0, 16, 2, 16),
makeCuboidShape(1, 1, 1, 15, 15, 15),
makeCuboidShape(0, 14, 0, 16, 16, 16)),
BASIN_BLOCK_SHAPE = makeCuboidShape(0, 0, 0, 16, 13, 16),//todo maybe
CRUSHING_WHEEL_COLLISION_SHAPE = makeCuboidShape(0, 0, 0, 16, 22, 16),
MECHANICAL_PRESS_SHAPE = VoxelShapes.fullCube(),//todo maybe
TURNTABLE_SHAPE = VoxelShapes.or(
makeCuboidShape(1, 6, 1, 15, 8, 15),
makeCuboidShape(5, 0, 5, 11, 6, 11)),
CRATE_BLOCK_SHAPE = makeCuboidShape(1, 0, 1, 15, 14, 15),
LOGISTICS_TABLE_BASE = TABLE_POLE_SHAPE
;
public static final VoxelShaper
LOGISTICAL_CASING_MIDDLE = VoxelShaper.forDirectional(LOGISTICAL_CASING_MIDDLE_SHAPE, Direction.UP),
LOGISTICAL_CASING_CAP = VoxelShaper.forDirectional(LOGISTICAL_CASING_CAP_SHAPE, Direction.UP),
CART_ASSEMBLER = VoxelShaper.forHorizontalAxis(CART_ASSEMBLER_SHAPE, Direction.SOUTH),
MECHANICAL_PISTON_HEAD = VoxelShaper.forDirectional(MECHANICAL_PISTON_HEAD_SHAPE_UP, Direction.UP),
MECHANICAL_PISTON = SHORT_CASING,
MECHANICAL_PISTON_EXTENDED = VoxelShaper.forDirectional(MECHANICAL_PISTON_EXTENDED_SHAPE_UP, Direction.UP),
SMALL_GEAR = VoxelShaper.forDirectionalAxis(VoxelShapes.or(SMALL_GEAR_SHAPE, SIX_VOXEL_POLE.get(Direction.Axis.Y)), Direction.Axis.Y),
LARGE_GEAR = VoxelShaper.forDirectionalAxis(VoxelShapes.or(LARGE_GEAR_SHAPE, SIX_VOXEL_POLE.get(Direction.Axis.Y)), Direction.Axis.Y),
LOGISTICAL_CONTROLLER = VoxelShaper.forDirectional(SQUARE_TABLET_SHAPE_SOUTH, Direction.SOUTH),
REDSTONE_BRIDGE = VoxelShaper.forHorizontal(VERTICAL_TABLET_SHAPE_SOUTH, Direction.SOUTH).withVerticalShapes(LOGISTICAL_CONTROLLER.get(Direction.UP)),
LOGISTICAL_INDEX = REDSTONE_BRIDGE,
PACKAGE_FUNNEL = VoxelShaper.forDirectional(PACKAGE_FUNNEL_SHAPE_UP, Direction.UP),
LOGISTICS_TABLE = VoxelShaper.forHorizontal(VoxelShapes.or(TABLE_POLE_SHAPE, LOGISTICS_TABLE_SLOPE_SOUTH), Direction.SOUTH)
;
}

View file

@ -28,13 +28,11 @@ public class VoxelShaper {
}
public static VoxelShaper forHorizontal(VoxelShape shape, Direction facing){
shape = rotateUp(shape, facing);
return forDirectionsWithRotation(shape, Direction.Plane.HORIZONTAL, new DefaultRotationValues());
return forDirectionsWithRotation(shape, facing, Direction.Plane.HORIZONTAL, new HorizontalRotationValues());
}
public static VoxelShaper forHorizontalAxis(VoxelShape shape, Direction facing){
shape = rotateUp(shape, facing);
return forDirectionsWithRotation(shape, Arrays.asList(Direction.SOUTH, Direction.EAST), new DefaultRotationValues());
return forDirectionsWithRotation(shape, facing, Arrays.asList(Direction.SOUTH, Direction.EAST), new HorizontalRotationValues());
}
public static VoxelShaper forRotatedPillar(VoxelShape zShape) {//dunno what this was intended for
@ -47,21 +45,16 @@ public class VoxelShaper {
}
public static VoxelShaper forDirectional(VoxelShape shape, Direction facing){
shape = rotateUp(shape, facing);
return forDirectionsWithRotation(shape, Arrays.asList(Direction.values()), new DefaultRotationValues());
return forDirectionsWithRotation(shape, facing, Arrays.asList(Direction.values()), new DefaultRotationValues());
}
protected static VoxelShaper forDirectionsWithRotation(VoxelShape shape, Iterable<Direction> directions, Function<Direction, Vec3d> rotationValues){
VoxelShaper voxelShaper = new VoxelShaper();
for (Direction dir : directions) {
voxelShaper.shapes.put(dir, rotatedCopy(shape, rotationValues.apply(dir)));
}
return voxelShaper;
public static VoxelShaper forDirectionalAxis(VoxelShape shape, Axis along){
return forDirectionsWithRotation(shape, axisAsFace(along), Arrays.asList(Direction.SOUTH, Direction.EAST, Direction.UP), new DefaultRotationValues());
}
public VoxelShaper withVerticalShapes(VoxelShape upShape) {
shapes.put(Direction.UP, upShape);
shapes.put(Direction.DOWN, rotatedCopy(upShape, new Vec3d(0, 180, 0)));
shapes.put(Direction.DOWN, rotatedCopy(upShape, new Vec3d(180, 0, 0)));
return this;
}
@ -74,15 +67,26 @@ public class VoxelShaper {
return Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis);
}
private static VoxelShape rotateUp(VoxelShape shape, Direction facing){
if (facing != Direction.UP) {
Vec3d rot = new DefaultRotationValues().apply(facing);
shape = rotatedCopy(shape, new Vec3d(360, 360,360).subtract(rot));
protected static VoxelShaper forDirectionsWithRotation(VoxelShape shape, Direction facing, Iterable<Direction> directions, Function<Direction, Vec3d> rotationValues){
VoxelShaper voxelShaper = new VoxelShaper();
for (Direction dir : directions) {
voxelShaper.shapes.put(dir, rotate(shape, facing, dir, rotationValues));
//voxelShaper.shapes.put(dir, rotatedCopy(shape, rotationValues.apply(dir)));
}
return shape;
return voxelShaper;
}
protected static VoxelShape rotate(VoxelShape shape, Direction from, Direction to, Function<Direction, Vec3d> usingValues){
if (from == to)
return shape;
return rotatedCopy(shape, usingValues.apply(from).inverse().add(usingValues.apply(to)));
}
protected static VoxelShape rotatedCopy(VoxelShape shape, Vec3d rotation){
if (rotation.equals(Vec3d.ZERO))
return shape;
MutableObject<VoxelShape> result = new MutableObject<>(VoxelShapes.empty());
Vec3d center = new Vec3d(8, 8, 8);
@ -106,7 +110,6 @@ public class VoxelShaper {
}
protected static class DefaultRotationValues implements Function<Direction, Vec3d> {
//assume facing up as the default rotation
@Override
public Vec3d apply(Direction direction) {
@ -118,4 +121,15 @@ public class VoxelShaper {
}
}
protected static class HorizontalRotationValues implements Function<Direction, Vec3d> {
@Override
public Vec3d apply(Direction direction) {
return new Vec3d(
0,
-direction.getHorizontalAngle(),
0
);
}
}
}

View file

@ -1,45 +0,0 @@
package com.simibubi.create.foundation.utility;
import net.minecraft.util.Direction;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import static net.minecraft.block.Block.makeCuboidShape;
public class VoxelShapers {
public static final VoxelShape
LOGISTICAL_CASING_SINGLE_SHAPE = VoxelShapes.or(
makeCuboidShape(0, 0, 0, 16, 2, 16),
makeCuboidShape(1, 1, 1, 15, 15, 15),
makeCuboidShape(0, 14, 0, 16, 16, 16))
;
private static final VoxelShape
LOGISTICAL_CASING_MIDDLE_SHAPE = VoxelShapes.or(
makeCuboidShape(1,0,1,15,16,15),
makeCuboidShape(0,0,0,2,16,2),
makeCuboidShape(14,0,0,16,16,2),
makeCuboidShape(0,0,14,2,16,16),
makeCuboidShape(14,0,14,16,16,16)),
LOGISTICAL_CASING_CAP_SHAPE = VoxelShapes.or(
LOGISTICAL_CASING_MIDDLE_SHAPE,
makeCuboidShape(0,0,0,16,2,16))
;
public static final VoxelShaper
SHORT_CASING = VoxelShaper.forDirectional(makeCuboidShape(0, 0, 0, 16, 12, 16), Direction.UP),
LOGISTICAL_CASING_MIDDLE = VoxelShaper.forDirectional(LOGISTICAL_CASING_MIDDLE_SHAPE, Direction.UP),
LOGISTICAL_CASING_CAP = VoxelShaper.forDirectional(LOGISTICAL_CASING_CAP_SHAPE, Direction.UP),
HARVESTER_BASE = VoxelShaper.forHorizontal(makeCuboidShape(0, 2, 0, 16, 14, 3), Direction.SOUTH)
;
}

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.generators;
import com.simibubi.create.foundation.block.IBlockWithScrollableValue;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock;
import net.minecraft.block.BlockState;
@ -19,11 +20,7 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld;
import net.minecraft.world.World;
public class MotorBlock extends HorizontalKineticBlock
implements IWithTileEntity<MotorTileEntity>, IBlockWithScrollableValue {
protected static final VoxelShape MOTOR_X = makeCuboidShape(0, 3, 3, 16, 13, 13);
protected static final VoxelShape MOTOR_Z = makeCuboidShape(3, 3, 0, 13, 13, 16);
public class MotorBlock extends HorizontalKineticBlock implements IWithTileEntity<MotorTileEntity>, IBlockWithScrollableValue {
private static final Vec3d valuePos = new Vec3d(15 / 16f, 5 / 16f, 5 / 16f);
@ -33,7 +30,7 @@ public class MotorBlock extends HorizontalKineticBlock
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return state.get(HORIZONTAL_FACING).getAxis() == Axis.X ? MOTOR_X : MOTOR_Z;
return AllShapes.MOTOR_BLOCK.get(state.get(HORIZONTAL_FACING));
}
@Override

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.receivers;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -25,8 +26,6 @@ import net.minecraftforge.items.ItemStackHandler;
public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity> {
public static final VoxelShape SHAPE = makeCuboidShape(0, 0, 0, 16, 13, 16);
public BasinBlock() {
super(Properties.from(Blocks.ANDESITE));
}
@ -85,7 +84,7 @@ public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
return AllShapes.BASIN_BLOCK_SHAPE;
}
@Override

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.receivers;
import static com.simibubi.create.modules.contraptions.receivers.CrushingWheelControllerBlock.VALID;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock;
@ -23,8 +24,6 @@ import net.minecraft.world.World;
public class CrushingWheelBlock extends RotatedPillarKineticBlock {
public static final VoxelShape COLLISION_SHAPE = makeCuboidShape(0, 0, 0, 16, 22, 16);
public CrushingWheelBlock() {
super(Properties.from(Blocks.DIORITE));
}
@ -42,7 +41,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock {
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
ISelectionContext context) {
return COLLISION_SHAPE;
return AllShapes.CRUSHING_WHEEL_COLLISION_SHAPE;
}
@Override

View file

@ -5,7 +5,7 @@ import java.util.List;
import com.simibubi.create.foundation.block.IRenderUtilityBlock;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.SuperByteBuffer;
import com.simibubi.create.foundation.utility.VoxelShapers;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.base.DirectionalKineticBlock;
import com.simibubi.create.modules.contraptions.receivers.constructs.IHaveMovementBehavior;
@ -49,7 +49,7 @@ public class DrillBlock extends DirectionalKineticBlock
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return VoxelShapers.SHORT_CASING.get(state.get(FACING));
return AllShapes.SHORT_CASING.get(state.get(FACING));
}
@Override

View file

@ -5,7 +5,7 @@ import java.util.List;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IRenderUtilityBlock;
import com.simibubi.create.foundation.utility.SuperByteBuffer;
import com.simibubi.create.foundation.utility.VoxelShapers;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.receivers.constructs.IHaveMovementBehavior;
import net.minecraft.block.Block;
@ -61,7 +61,7 @@ public class HarvesterBlock extends HorizontalBlock implements IHaveMovementBeha
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction direction = state.get(HORIZONTAL_FACING);
return VoxelShapers.HARVESTER_BASE.get(direction);
return AllShapes.HARVESTER_BASE.get(direction);
}
@Override

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.receivers;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IBlockWithScrollableValue;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.contraptions.base.KineticBlock;
@ -44,7 +45,7 @@ public class MechanicalMixerBlock extends KineticBlock
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return MechanicalPressBlock.SHAPE;
return AllShapes.MECHANICAL_PRESS_SHAPE;
}
@Override

View file

@ -8,6 +8,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IRenderUtilityBlock;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.block.SyncedTileEntity;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.ItemHelper;
import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock;
import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.BeltAttachmentState;
@ -37,15 +38,13 @@ import net.minecraft.world.World;
public class MechanicalPressBlock extends HorizontalKineticBlock
implements IWithTileEntity<MechanicalPressTileEntity>, IBeltAttachment {
public static VoxelShape SHAPE = makeCuboidShape(0, 0, 0, 16, 16, 16);
public MechanicalPressBlock() {
super(Properties.from(Blocks.PISTON));
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
return AllShapes.MECHANICAL_PRESS_SHAPE;
}
@Override

View file

@ -1,7 +1,7 @@
package com.simibubi.create.modules.contraptions.receivers;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.VoxelShapers;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock;
import com.simibubi.create.modules.contraptions.receivers.constructs.IHaveMovementBehavior;
import com.simibubi.create.modules.logistics.block.IBlockWithFilter;
@ -82,7 +82,7 @@ public class SawBlock extends DirectionalAxisKineticBlock
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return VoxelShapers.SHORT_CASING.get(state.get(FACING));
return AllShapes.SHORT_CASING.get(state.get(FACING));
}
@Override

View file

@ -1,5 +1,6 @@
package com.simibubi.create.modules.contraptions.receivers;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.modules.contraptions.base.KineticBlock;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
@ -23,10 +24,6 @@ import net.minecraft.world.World;
public class TurntableBlock extends KineticBlock {
protected static final VoxelShape SHAPE = VoxelShapes.or(
Block.makeCuboidShape(1.0D, 6.0D, 1.0D, 15.0D, 8.0D, 15.0D),
Block.makeCuboidShape(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D));
public TurntableBlock() {
super(Properties.from(Blocks.STRIPPED_SPRUCE_LOG));
}
@ -38,7 +35,7 @@ public class TurntableBlock extends KineticBlock {
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
return AllShapes.TURNTABLE_SHAPE;
}
@Override

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.receivers.constructs.mounted;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.RenderUtilityBlock;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.AbstractRailBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@ -17,6 +18,7 @@ import net.minecraft.state.IProperty;
import net.minecraft.state.StateContainer.Builder;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.RailShape;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
@ -31,9 +33,6 @@ public class CartAssemblerBlock extends AbstractRailBlock {
RailShape.NORTH_SOUTH);
public static BooleanProperty POWERED = BlockStateProperties.POWERED;
public static VoxelShape X_SHAPE = VoxelShapes.or(VoxelShapes.fullCube(), makeCuboidShape(1, 0, -2, 15, 13, 18));
public static VoxelShape Z_SHAPE = VoxelShapes.or(VoxelShapes.fullCube(), makeCuboidShape(-2, 0, 1, 18, 13, 15));
public CartAssemblerBlock() {
super(true, Properties.from(Blocks.PISTON));
setDefaultState(getDefaultState().with(POWERED, false));
@ -118,7 +117,7 @@ public class CartAssemblerBlock extends AbstractRailBlock {
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return state.get(RAIL_SHAPE) == RailShape.EAST_WEST ? X_SHAPE : Z_SHAPE;
return AllShapes.CART_ASSEMBLER.get(state.get(RAIL_SHAPE) == RailShape.NORTH_SOUTH ? Direction.Axis.Z : Direction.Axis.X);
}
@Override
@ -126,7 +125,7 @@ public class CartAssemblerBlock extends AbstractRailBlock {
ISelectionContext context) {
if (context.getEntity() instanceof AbstractMinecartEntity)
return VoxelShapes.empty();
return VoxelShapes.fullCube();
return getShape(state, worldIn, pos, context);
}
@Override

View file

@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.receivers.constructs.piston;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateConfig;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock;
@ -33,20 +34,6 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock {
public static final EnumProperty<PistonState> STATE = EnumProperty.create("state", PistonState.class);
protected static final VoxelShape BASE_SHAPE_UP = makeCuboidShape(0, 0, 0, 16, 12, 16),
BASE_SHAPE_DOWN = makeCuboidShape(0, 4, 0, 16, 16, 16),
BASE_SHAPE_EAST = makeCuboidShape(0, 0, 0, 12, 16, 16),
BASE_SHAPE_WEST = makeCuboidShape(4, 0, 0, 16, 16, 16),
BASE_SHAPE_SOUTH = makeCuboidShape(0, 0, 0, 16, 16, 12),
BASE_SHAPE_NORTH = makeCuboidShape(0, 0, 4, 16, 16, 16),
EXTENDED_SHAPE_UP = VoxelShapes.or(BASE_SHAPE_UP, MechanicalPistonHeadBlock.AXIS_SHAPE_Y),
EXTENDED_SHAPE_DOWN = VoxelShapes.or(BASE_SHAPE_DOWN, MechanicalPistonHeadBlock.AXIS_SHAPE_Y),
EXTENDED_SHAPE_EAST = VoxelShapes.or(BASE_SHAPE_EAST, MechanicalPistonHeadBlock.AXIS_SHAPE_X),
EXTENDED_SHAPE_WEST = VoxelShapes.or(BASE_SHAPE_WEST, MechanicalPistonHeadBlock.AXIS_SHAPE_X),
EXTENDED_SHAPE_SOUTH = VoxelShapes.or(BASE_SHAPE_SOUTH, MechanicalPistonHeadBlock.AXIS_SHAPE_Z),
EXTENDED_SHAPE_NORTH = VoxelShapes.or(BASE_SHAPE_NORTH, MechanicalPistonHeadBlock.AXIS_SHAPE_Z);
protected boolean isSticky;
public MechanicalPistonBlock(boolean sticky) {
@ -155,36 +142,10 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock {
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
if (state.get(STATE) == PistonState.EXTENDED)
switch (state.get(FACING)) {
case DOWN:
return EXTENDED_SHAPE_DOWN;
case EAST:
return EXTENDED_SHAPE_EAST;
case NORTH:
return EXTENDED_SHAPE_NORTH;
case SOUTH:
return EXTENDED_SHAPE_SOUTH;
case UP:
return EXTENDED_SHAPE_UP;
case WEST:
return EXTENDED_SHAPE_WEST;
}
return AllShapes.MECHANICAL_PISTON_EXTENDED.get(state.get(FACING));
if (state.get(STATE) == PistonState.MOVING)
switch (state.get(FACING)) {
case DOWN:
return BASE_SHAPE_DOWN;
case EAST:
return BASE_SHAPE_EAST;
case NORTH:
return BASE_SHAPE_NORTH;
case SOUTH:
return BASE_SHAPE_SOUTH;
case UP:
return BASE_SHAPE_UP;
case WEST:
return BASE_SHAPE_WEST;
}
return AllShapes.MECHANICAL_PISTON.get(state.get(FACING));
return VoxelShapes.fullCube();
}

View file

@ -4,6 +4,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateConfig;
import com.simibubi.create.foundation.block.IWithoutBlockItem;
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.receivers.constructs.piston.MechanicalPistonBlock.PistonState;
import net.minecraft.block.Block;
@ -28,22 +29,6 @@ public class MechanicalPistonHeadBlock extends ProperDirectionalBlock implements
public static final EnumProperty<PistonType> TYPE = BlockStateProperties.PISTON_TYPE;
public static final VoxelShape AXIS_SHAPE_X = makeCuboidShape(0, 6, 6, 16, 10, 10),
AXIS_SHAPE_Y = makeCuboidShape(6, 0, 6, 10, 16, 10), AXIS_SHAPE_Z = makeCuboidShape(6, 6, 0, 10, 10, 16),
TOP_SHAPE_UP = makeCuboidShape(0, 12, 0, 16, 16, 16), TOP_SHAPE_DOWN = makeCuboidShape(0, 0, 0, 16, 4, 16),
TOP_SHAPE_EAST = makeCuboidShape(12, 0, 0, 16, 16, 16),
TOP_SHAPE_WEST = makeCuboidShape(0, 0, 0, 4, 16, 16),
TOP_SHAPE_SOUTH = makeCuboidShape(0, 0, 12, 16, 16, 16),
TOP_SHAPE_NORTH = makeCuboidShape(0, 0, 0, 16, 16, 4),
EXTENSION_SHAPE_UP = VoxelShapes.or(AXIS_SHAPE_Y, TOP_SHAPE_UP),
EXTENSION_SHAPE_DOWN = VoxelShapes.or(AXIS_SHAPE_Y, TOP_SHAPE_DOWN),
EXTENSION_SHAPE_EAST = VoxelShapes.or(AXIS_SHAPE_X, TOP_SHAPE_EAST),
EXTENSION_SHAPE_WEST = VoxelShapes.or(AXIS_SHAPE_X, TOP_SHAPE_WEST),
EXTENSION_SHAPE_SOUTH = VoxelShapes.or(AXIS_SHAPE_Z, TOP_SHAPE_SOUTH),
EXTENSION_SHAPE_NORTH = VoxelShapes.or(AXIS_SHAPE_Z, TOP_SHAPE_NORTH);
public MechanicalPistonHeadBlock() {
super(Properties.from(Blocks.PISTON_HEAD));
}
@ -95,22 +80,6 @@ public class MechanicalPistonHeadBlock extends ProperDirectionalBlock implements
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
switch (state.get(FACING)) {
case DOWN:
return EXTENSION_SHAPE_DOWN;
case EAST:
return EXTENSION_SHAPE_EAST;
case NORTH:
return EXTENSION_SHAPE_NORTH;
case SOUTH:
return EXTENSION_SHAPE_SOUTH;
case UP:
return EXTENSION_SHAPE_UP;
case WEST:
return EXTENSION_SHAPE_WEST;
}
return VoxelShapes.empty();
return AllShapes.MECHANICAL_PISTON_HEAD.get(state.get(FACING));
}
}

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.receivers.constructs.piston;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateConfig;
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.receivers.constructs.piston.MechanicalPistonBlock.PistonState;
import net.minecraft.block.BlockState;
@ -16,7 +17,6 @@ import net.minecraft.util.Direction.AxisDirection;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
@ -73,17 +73,7 @@ public class PistonPoleBlock extends ProperDirectionalBlock {
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
switch (state.get(FACING).getAxis()) {
case X:
return MechanicalPistonHeadBlock.AXIS_SHAPE_X;
case Y:
return MechanicalPistonHeadBlock.AXIS_SHAPE_Y;
case Z:
return MechanicalPistonHeadBlock.AXIS_SHAPE_Z;
}
return VoxelShapes.empty();
return AllShapes.FOUR_VOXEL_POLE.get(state.get(FACING).getAxis());
}
@Override

View file

@ -1,6 +1,7 @@
package com.simibubi.create.modules.contraptions.relays;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.base.IRotate;
import net.minecraft.block.Block;
@ -21,14 +22,6 @@ public class CogWheelBlock extends ShaftBlock {
private boolean isLarge;
protected static final VoxelShape GEAR_X = makeCuboidShape(6, 2, 2, 10, 14, 14);
protected static final VoxelShape GEAR_Y = makeCuboidShape(2, 6, 2, 14, 10, 14);
protected static final VoxelShape GEAR_Z = makeCuboidShape(2, 2, 6, 14, 14, 10);
protected static final VoxelShape LARGE_GEAR_X = makeCuboidShape(6, 0, 0, 10, 16, 16);
protected static final VoxelShape LARGE_GEAR_Y = makeCuboidShape(0, 6, 0, 16, 10, 16);
protected static final VoxelShape LARGE_GEAR_Z = makeCuboidShape(0, 0, 6, 16, 16, 10);
public CogWheelBlock(boolean large) {
super(Properties.from(Blocks.GRANITE));
isLarge = large;
@ -36,7 +29,7 @@ public class CogWheelBlock extends ShaftBlock {
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return VoxelShapes.or(super.getShape(state, worldIn, pos, context), getGearShape(state));
return (isLarge ? AllShapes.LARGE_GEAR : AllShapes.SMALL_GEAR).get(state.get(AXIS));
}
@Override
@ -65,15 +58,6 @@ public class CogWheelBlock extends ShaftBlock {
return getDefaultState().with(AXIS, ((IRotate) block).getRotationAxis(placedAgainst));
}
private VoxelShape getGearShape(BlockState state) {
if (state.get(AXIS) == Axis.X)
return isLarge ? LARGE_GEAR_X : GEAR_X;
if (state.get(AXIS) == Axis.Z)
return isLarge ? LARGE_GEAR_Z : GEAR_Z;
return isLarge ? LARGE_GEAR_Y : GEAR_Y;
}
@Override
public float getParticleTargetRadius() {
return isLarge ? 1.125f : .65f;

View file

@ -1,5 +1,6 @@
package com.simibubi.create.modules.contraptions.relays;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock;
import net.minecraft.block.BlockState;
@ -14,10 +15,6 @@ import net.minecraft.world.World;
public class ShaftBlock extends RotatedPillarKineticBlock {
public static final VoxelShape AXIS_X = makeCuboidShape(0, 5, 5, 16, 11, 11);
public static final VoxelShape AXIS_Y = makeCuboidShape(5, 0, 5, 11, 16, 11);
public static final VoxelShape AXIS_Z = makeCuboidShape(5, 5, 0, 11, 11, 16);
public ShaftBlock(Properties properties) {
super(properties);
}
@ -34,7 +31,7 @@ public class ShaftBlock extends RotatedPillarKineticBlock {
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return state.get(AXIS) == Axis.X ? AXIS_X : state.get(AXIS) == Axis.Z ? AXIS_Z : AXIS_Y;
return AllShapes.SIX_VOXEL_POLE.get(state.get(AXIS));
}
@Override

View file

@ -55,7 +55,7 @@ public class BeltBlock extends HorizontalKineticBlock implements IWithoutBlockIt
public static final IProperty<Slope> SLOPE = EnumProperty.create("slope", Slope.class);
public static final IProperty<Part> PART = EnumProperty.create("part", Part.class);
public static final BooleanProperty CASING = BooleanProperty.create("casing");
private final VoxelShape collisionMask = makeCuboidShape(0, 0, 0, 16, 19, 16);
private final VoxelShape collisionMask = makeCuboidShape(0, 0, 0, 16, 19, 16);//todo review
public BeltBlock() {
super(Properties.from(Blocks.BROWN_WOOL));

View file

@ -202,8 +202,14 @@ public class BeltShapes {
private static class VerticalBeltShaper extends VoxelShaper {
public static VoxelShaper make(VoxelShape southBeltShape){
return forDirectionsWithRotation(southBeltShape, Direction.Plane.HORIZONTAL,//idk, this can probably be improved :S
direction -> new Vec3d(direction.getAxisDirection() == Direction.AxisDirection.NEGATIVE ? 90 : 270, -direction.getHorizontalAngle(), 0));
return forDirectionsWithRotation(
rotatedCopy(southBeltShape, new Vec3d(-90,0,0)),
Direction.SOUTH,
Direction.Plane.HORIZONTAL,//idk, this can probably be improved :S
direction -> new Vec3d(
direction.getAxisDirection() == Direction.AxisDirection.POSITIVE ? 0 : 180,
-direction.getHorizontalAngle(),
0));
}
}

View file

@ -25,7 +25,7 @@ import net.minecraftforge.fml.network.NetworkHooks;
public class ShopShelfBlock extends HorizontalBlock implements IWithoutBlockItem {
public static final VoxelShape TOP_SHAPE = makeCuboidShape(0, 14, 0, 16, 16, 16);
public static final VoxelShape TOP_SHAPE = makeCuboidShape(0, 14, 0, 16, 16, 16);//todo review
public static final VoxelShape BODY_SOUTH_SHAPE = makeCuboidShape(0, 0, 0, 16, 14, 14);
public static final VoxelShape BODY_NORTH_SHAPE = makeCuboidShape(0, 0, 2, 16, 14, 16);

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.logistics.block;
import java.util.ArrayList;
import java.util.List;
import com.simibubi.create.foundation.utility.AllShapes;
import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
@ -37,13 +38,6 @@ public class RedstoneBridgeBlock extends ProperDirectionalBlock implements IBloc
public static final BooleanProperty RECEIVER = BooleanProperty.create("receiver");
private static final List<Pair<Vec3d, Vec3d>> itemPositions = new ArrayList<>(Direction.values().length);
public static final VoxelShape UP_SHAPE = makeCuboidShape(2, 0, 2, 14, 3, 14),
DOWN_SHAPE = makeCuboidShape(2, 13, 2, 14, 16, 14);
public static final VoxelShape SOUTH_SHAPE = makeCuboidShape(3, 1, -1, 13, 15, 3),
NORTH_SHAPE = makeCuboidShape(3, 1, 13, 13, 15, 17), EAST_SHAPE = makeCuboidShape(-1, 1, 3, 3, 15, 13),
WEST_SHAPE = makeCuboidShape(13, 1, 3, 17, 15, 13);
public RedstoneBridgeBlock() {
super(Properties.from(Blocks.DARK_OAK_LOG));
cacheItemPositions();
@ -174,22 +168,7 @@ public class RedstoneBridgeBlock extends ProperDirectionalBlock implements IBloc
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(FACING);
if (facing == Direction.UP)
return UP_SHAPE;
if (facing == Direction.DOWN)
return DOWN_SHAPE;
if (facing == Direction.EAST)
return EAST_SHAPE;
if (facing == Direction.WEST)
return WEST_SHAPE;
if (facing == Direction.NORTH)
return NORTH_SHAPE;
if (facing == Direction.SOUTH)
return SOUTH_SHAPE;
return VoxelShapes.empty();
return AllShapes.REDSTONE_BRIDGE.get(state.get(FACING));
}
private void cacheItemPositions() {

View file

@ -6,6 +6,7 @@ import java.util.List;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.BeltAttachmentState;
import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.IBeltAttachment;
@ -38,12 +39,7 @@ import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
public class BeltFunnelBlock extends HorizontalBlock
implements IBeltAttachment, IWithTileEntity<BeltFunnelTileEntity>, IBlockWithFilter {
public static final VoxelShape SHAPE_NORTH = makeCuboidShape(3, -4, -1, 13, 8, 5),
SHAPE_SOUTH = makeCuboidShape(3, -4, 11, 13, 8, 17), SHAPE_WEST = makeCuboidShape(-1, -4, 3, 5, 8, 13),
SHAPE_EAST = makeCuboidShape(11, -4, 3, 17, 8, 13);
public class BeltFunnelBlock extends HorizontalBlock implements IBeltAttachment, IWithTileEntity<BeltFunnelTileEntity>, IBlockWithFilter {
public BeltFunnelBlock() {
super(Properties.from(Blocks.ANDESITE));
@ -105,18 +101,7 @@ public class BeltFunnelBlock extends HorizontalBlock
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(HORIZONTAL_FACING);
if (facing == Direction.EAST)
return SHAPE_EAST;
if (facing == Direction.WEST)
return SHAPE_WEST;
if (facing == Direction.SOUTH)
return SHAPE_SOUTH;
if (facing == Direction.NORTH)
return SHAPE_NORTH;
return VoxelShapes.empty();
return AllShapes.BELT_FUNNEL.get(state.get(HORIZONTAL_FACING));
}
@Override

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock;
import com.simibubi.create.modules.logistics.block.IBlockWithFilter;
@ -35,9 +36,6 @@ import net.minecraft.world.World;
public class ExtractorBlock extends HorizontalBlock implements IBlockWithFilter {
public static BooleanProperty POWERED = BlockStateProperties.POWERED;
public static final VoxelShape SHAPE_NORTH = makeCuboidShape(4, 2, -1, 12, 10, 5),
SHAPE_SOUTH = makeCuboidShape(4, 2, 11, 12, 10, 17), SHAPE_WEST = makeCuboidShape(-1, 2, 4, 5, 10, 12),
SHAPE_EAST = makeCuboidShape(11, 2, 4, 17, 10, 12);
private static final List<Vec3d> itemPositions = new ArrayList<>(Direction.values().length);
public ExtractorBlock() {
@ -150,18 +148,7 @@ public class ExtractorBlock extends HorizontalBlock implements IBlockWithFilter
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(HORIZONTAL_FACING);
if (facing == Direction.EAST)
return SHAPE_EAST;
if (facing == Direction.WEST)
return SHAPE_WEST;
if (facing == Direction.SOUTH)
return SHAPE_SOUTH;
if (facing == Direction.NORTH)
return SHAPE_NORTH;
return VoxelShapes.empty();
return AllShapes.BELT_EXTRACTOR.get(state.get(HORIZONTAL_FACING));
}
private void cacheItemPositions() {

View file

@ -1,5 +1,6 @@
package com.simibubi.create.modules.logistics.block.inventories;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -18,15 +19,13 @@ import net.minecraftforge.fml.network.NetworkHooks;
public class FlexcrateBlock extends Block {
public static final VoxelShape SHAPE = makeCuboidShape(1, 0, 1, 15, 14, 15);
public FlexcrateBlock() {
super(Properties.from(Blocks.ANDESITE));
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return SHAPE;
return AllShapes.CRATE_BLOCK_SHAPE;
}
@Override

View file

@ -12,7 +12,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.VoxelShaper;
import com.simibubi.create.foundation.utility.VoxelShapers;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -33,7 +33,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockReader;
@ -117,16 +116,16 @@ public class LogisticalCasingBlock extends Block implements IWithTileEntity<Logi
Part part = state.get(PART);
if (part == Part.NONE)
return VoxelShapers.LOGISTICAL_CASING_SINGLE_SHAPE;
return AllShapes.LOGISTICAL_CASING_SINGLE_SHAPE;
if (part == Part.MIDDLE)
return VoxelShapers.LOGISTICAL_CASING_MIDDLE.get(state.get(AXIS));
return AllShapes.LOGISTICAL_CASING_MIDDLE.get(state.get(AXIS));
Direction facing = VoxelShaper.axisAsFace(state.get(AXIS));
if (part == Part.END)
facing = facing.getOpposite();
return VoxelShapers.LOGISTICAL_CASING_CAP.get(facing);
return AllShapes.LOGISTICAL_CASING_CAP.get(facing);
//return state.get(PART) == Part.NONE ? VoxelShapers.LOGISTICAL_CASING_SINGLE_SHAPE : VoxelShapes.fullCube();
}

View file

@ -22,6 +22,7 @@ import com.simibubi.create.foundation.block.IWithContainer;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.block.IWithoutBlockItem;
import com.simibubi.create.foundation.block.RenderUtilityBlock;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.logistics.management.base.LogisticalCasingBlock.Part;
import com.simibubi.create.modules.logistics.management.controller.CalculationTileEntity;
import com.simibubi.create.modules.logistics.management.controller.LogisticalInventoryControllerTileEntity;
@ -52,7 +53,6 @@ import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
@ -63,11 +63,6 @@ public class LogisticalControllerBlock extends DirectionalBlock
public static final IProperty<Type> TYPE = EnumProperty.create("type", Type.class);
public static final VoxelShape UP_SHAPE = makeCuboidShape(2, -1, 2, 14, 3, 14),
DOWN_SHAPE = makeCuboidShape(2, 13, 2, 14, 17, 14), SOUTH_SHAPE = makeCuboidShape(2, 2, -1, 14, 14, 3),
NORTH_SHAPE = makeCuboidShape(2, 2, 13, 14, 14, 17), EAST_SHAPE = makeCuboidShape(-1, 2, 2, 3, 14, 14),
WEST_SHAPE = makeCuboidShape(13, 2, 2, 17, 14, 14);
public LogisticalControllerBlock() {
super(Properties.from(Blocks.PISTON));
}
@ -271,22 +266,7 @@ public class LogisticalControllerBlock extends DirectionalBlock
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(FACING);
if (facing == Direction.UP)
return UP_SHAPE;
if (facing == Direction.DOWN)
return DOWN_SHAPE;
if (facing == Direction.EAST)
return EAST_SHAPE;
if (facing == Direction.WEST)
return WEST_SHAPE;
if (facing == Direction.NORTH)
return NORTH_SHAPE;
if (facing == Direction.SOUTH)
return SOUTH_SHAPE;
return VoxelShapes.empty();
return AllShapes.LOGISTICAL_CONTROLLER.get(state.get(FACING));
}
public static class LogisticalControllerIndicatorBlock extends RenderUtilityBlock {

View file

@ -4,6 +4,7 @@ import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.block.IBlockWithColorHandler;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -29,12 +30,7 @@ import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks;
public class LogisticalIndexBlock extends HorizontalBlock
implements IBlockWithColorHandler, IWithTileEntity<LogisticalIndexTileEntity> {
public static final VoxelShape SOUTH_SHAPE = makeCuboidShape(3, 1, -1, 13, 15, 3),
NORTH_SHAPE = makeCuboidShape(3, 1, 13, 13, 15, 17), EAST_SHAPE = makeCuboidShape(-1, 1, 3, 3, 15, 13),
WEST_SHAPE = makeCuboidShape(13, 1, 3, 17, 15, 13);
public class LogisticalIndexBlock extends HorizontalBlock implements IBlockWithColorHandler, IWithTileEntity<LogisticalIndexTileEntity> {
public LogisticalIndexBlock() {
super(Properties.from(Blocks.GRANITE));
@ -126,18 +122,7 @@ public class LogisticalIndexBlock extends HorizontalBlock
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(HORIZONTAL_FACING);
if (facing == Direction.EAST)
return EAST_SHAPE;
if (facing == Direction.WEST)
return WEST_SHAPE;
if (facing == Direction.NORTH)
return NORTH_SHAPE;
if (facing == Direction.SOUTH)
return SOUTH_SHAPE;
return VoxelShapes.empty();
return AllShapes.LOGISTICAL_INDEX.get(state.get(HORIZONTAL_FACING));
}
@Override

View file

@ -5,6 +5,7 @@ import java.util.Random;
import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -33,29 +34,6 @@ import net.minecraft.world.World;
public class LogisticiansTableBlock extends HorizontalBlock implements IWithTileEntity<LogisticiansTableTileEntity> {
private static final VoxelShape BASE_SHAPE = Block.makeCuboidShape(4.0D, 0.0D, 4.0D, 12.0D, 2.0D, 12.0D);
private static final VoxelShape POLE_SHAPE = Block.makeCuboidShape(5.0D, 2.0D, 5.0D, 11.0D, 14.0D, 11.0D);
private static final VoxelShape RENDER_SHAPE = VoxelShapes.or(BASE_SHAPE, POLE_SHAPE);
private static final VoxelShape TOP_COLLISION_SHAPE = Block.makeCuboidShape(0.0D, 15.0D, 0.0D, 16.0D, 15.0D, 16.0D);
private static final VoxelShape COLLISION_SHAPE = VoxelShapes.or(RENDER_SHAPE, TOP_COLLISION_SHAPE);
private static final VoxelShape WEST_SHAPE = VoxelShapes.or(
Block.makeCuboidShape(1.0D, 10.0D, 0.0D, 5.333333D, 14.0D, 16.0D),
Block.makeCuboidShape(5.333333D, 12.0D, 0.0D, 9.666667D, 16.0D, 16.0D),
Block.makeCuboidShape(9.666667D, 14.0D, 0.0D, 14.0D, 18.0D, 16.0D), RENDER_SHAPE);
private static final VoxelShape NORTH_SHAPE = VoxelShapes.or(
Block.makeCuboidShape(0.0D, 10.0D, 1.0D, 16.0D, 14.0D, 5.333333D),
Block.makeCuboidShape(0.0D, 12.0D, 5.333333D, 16.0D, 16.0D, 9.666667D),
Block.makeCuboidShape(0.0D, 14.0D, 9.666667D, 16.0D, 18.0D, 14.0D), RENDER_SHAPE);
private static final VoxelShape EAST_SHAPE = VoxelShapes.or(
Block.makeCuboidShape(15.0D, 10.0D, 0.0D, 10.666667D, 14.0D, 16.0D),
Block.makeCuboidShape(10.666667D, 12.0D, 0.0D, 6.333333D, 16.0D, 16.0D),
Block.makeCuboidShape(6.333333D, 14.0D, 0.0D, 2.0D, 18.0D, 16.0D), RENDER_SHAPE);
private static final VoxelShape SOUTH_SHAPE = VoxelShapes.or(
Block.makeCuboidShape(0.0D, 10.0D, 15.0D, 16.0D, 14.0D, 10.666667D),
Block.makeCuboidShape(0.0D, 12.0D, 10.666667D, 16.0D, 16.0D, 6.333333D),
Block.makeCuboidShape(0.0D, 14.0D, 6.333333D, 16.0D, 18.0D, 2.0D), RENDER_SHAPE);
public LogisticiansTableBlock() {
super(Properties.from(Blocks.SPRUCE_LOG));
}
@ -95,10 +73,6 @@ public class LogisticiansTableBlock extends HorizontalBlock implements IWithTile
super.fillStateContainer(builder);
}
public VoxelShape getRenderShape(BlockState state, IBlockReader worldIn, BlockPos pos) {
return RENDER_SHAPE;
}
public boolean func_220074_n(BlockState state) {
return true;
}
@ -123,24 +97,12 @@ public class LogisticiansTableBlock extends HorizontalBlock implements IWithTile
return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
}
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
ISelectionContext context) {
return COLLISION_SHAPE;
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.LOGISTICS_TABLE_BASE;
}
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
switch (state.get(HORIZONTAL_FACING)) {
case NORTH:
return NORTH_SHAPE;
case SOUTH:
return SOUTH_SHAPE;
case EAST:
return EAST_SHAPE;
case WEST:
return WEST_SHAPE;
default:
return RENDER_SHAPE;
}
return AllShapes.LOGISTICS_TABLE.get(state.get(HORIZONTAL_FACING));
}
}

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.logistics.transport.villager;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.logistics.management.base.ILogisticalCasingAttachment;
import com.simibubi.create.modules.logistics.management.base.LogisticalCasingTileEntity;
import com.simibubi.create.modules.logistics.transport.CardboardBoxEntity;
@ -22,13 +23,7 @@ import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader;
import net.minecraft.world.World;
public class PackageFunnelBlock extends ProperDirectionalBlock
implements IWithTileEntity<PackageFunnelTileEntity>, ILogisticalCasingAttachment {
public static final VoxelShape UP_SHAPE = makeCuboidShape(1, -1, 1, 15, 3, 15),
DOWN_SHAPE = makeCuboidShape(1, 13, 1, 15, 17, 15), SOUTH_SHAPE = makeCuboidShape(1, 1, -1, 15, 15, 3),
NORTH_SHAPE = makeCuboidShape(1, 1, 13, 15, 15, 17), EAST_SHAPE = makeCuboidShape(-1, 1, 1, 3, 15, 15),
WEST_SHAPE = makeCuboidShape(13, 1, 1, 17, 15, 15);
public class PackageFunnelBlock extends ProperDirectionalBlock implements IWithTileEntity<PackageFunnelTileEntity>, ILogisticalCasingAttachment {
public PackageFunnelBlock() {
super(Properties.from(Blocks.PISTON));
@ -82,22 +77,7 @@ public class PackageFunnelBlock extends ProperDirectionalBlock
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(FACING);
if (facing == Direction.UP)
return UP_SHAPE;
if (facing == Direction.DOWN)
return DOWN_SHAPE;
if (facing == Direction.EAST)
return EAST_SHAPE;
if (facing == Direction.WEST)
return WEST_SHAPE;
if (facing == Direction.NORTH)
return NORTH_SHAPE;
if (facing == Direction.SOUTH)
return SOUTH_SHAPE;
return VoxelShapes.empty();
return AllShapes.PACKAGE_FUNNEL.get(state.get(FACING));
}
@Override

View file

@ -1,5 +1,6 @@
package com.simibubi.create.modules.schematics.block;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.material.Material;
@ -10,8 +11,6 @@ import net.minecraft.world.IBlockReader;
public class CreativeCrateBlock extends Block {
protected static final VoxelShape shape = makeCuboidShape(1, 0, 1, 15, 14, 15);
public CreativeCrateBlock() {
super(Properties.create(Material.WOOD));
}
@ -23,13 +22,7 @@ public class CreativeCrateBlock extends Block {
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return shape;
}
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
ISelectionContext context) {
return shape;
return AllShapes.CRATE_BLOCK_SHAPE;
}
}