This commit is contained in:
simibubi 2019-12-12 07:38:51 +01:00
commit c0b47c124f
39 changed files with 545 additions and 721 deletions

View file

@ -0,0 +1,138 @@
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.Vec3d;
import net.minecraft.util.math.shapes.IBooleanFunction;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import java.util.Arrays;
import static net.minecraft.block.Block.makeCuboidShape;
public class AllShapes {
public static final VoxelShaper
SHORT_CASING_14_VOXEL = VoxelShaper.forDirectional(makeCuboidShape(0, 0, 0, 16, 14, 16), Direction.UP),
SHORT_CASING_12_VOXEL = VoxelShaper.forDirectional(makeCuboidShape(0, 0, 0, 16, 12, 16), Direction.UP),
SHORT_CASING_11_VOXEL = VoxelShaper.forDirectional(makeCuboidShape(0, 0, 0, 16, 11, 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_12_VOXEL.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)),
SCHEMATICS_TABLE_SLOPE_SOUTH = VoxelShapes.or(
makeCuboidShape(0, 10, 16, 16, 14, 11),
makeCuboidShape(0, 12, 11, 16, 16, 6),
makeCuboidShape(0, 14, 6, 16, 18, 1)),
GAUGE_SHAPE_UP = VoxelShapes.or(
makeCuboidShape(1, 0, 0, 15, 2, 16),//plate
makeCuboidShape(2, 2, 1, 14, 14, 15))//log
;
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 can be improved when someone finds the time :D
CRUSHING_WHEEL_COLLISION_SHAPE = makeCuboidShape(0, 0, 0, 16, 22, 16),
MECHANICAL_PROCESSOR_SHAPE = VoxelShapes.combineAndSimplify(
VoxelShapes.fullCube(),
makeCuboidShape(4, 0, 4, 12, 16, 12),
IBooleanFunction.ONLY_FIRST),
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,
BELT_COLLISION_MASK = makeCuboidShape(0, 0, 0, 16, 19, 16),
SCHEMATICANNON_SHAPE = VoxelShapes.or(
makeCuboidShape(1, 0, 1, 15, 8, 15),
makeCuboidShape(0.5, 8, 0.5, 15.5, 11, 15.5))
;
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_12_VOXEL,
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),
SCHEMATICS_TABLE = VoxelShaper.forDirectional(VoxelShapes.or(TABLE_POLE_SHAPE, SCHEMATICS_TABLE_SLOPE_SOUTH), Direction.SOUTH)
;
public static final GaugeShaper GAUGE = GaugeShaper.make();
public static class GaugeShaper extends VoxelShaper {
private VoxelShaper axisFalse, axisTrue;
private static GaugeShaper make(){
GaugeShaper shaper = new GaugeShaper();
shaper.axisFalse = forDirectional(AllShapes.GAUGE_SHAPE_UP, Direction.UP);
shaper.axisTrue = forDirectional(rotatedCopy(AllShapes.GAUGE_SHAPE_UP, new Vec3d(0, 90, 0)), Direction.UP);
//shapes for X axis need to be swapped
Arrays.asList(Direction.EAST, Direction.WEST).forEach(direction -> {
VoxelShape mem = shaper.axisFalse.get(direction);
shaper.axisFalse.withShape(shaper.axisTrue.get(direction), direction);
shaper.axisTrue.withShape(mem, direction);
});
return shaper;
}
public VoxelShape get(Direction direction, boolean axisAlong) {
return (axisAlong ? axisTrue : axisFalse).get(direction);
}
}
}

View file

@ -1,7 +1,9 @@
package com.simibubi.create.foundation.utility; package com.simibubi.create.foundation.utility;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Function;
import org.apache.commons.lang3.mutable.MutableObject; import org.apache.commons.lang3.mutable.MutableObject;
@ -25,68 +27,83 @@ public class VoxelShaper {
return shapes.get(axisAsFace(axis)); return shapes.get(axisAsFace(axis));
} }
public static VoxelShaper forHorizontal(VoxelShape southShape) { public static VoxelShaper forHorizontal(VoxelShape shape, Direction facing){
VoxelShaper voxelShaper = new VoxelShaper(); return forDirectionsWithRotation(shape, facing, Direction.Plane.HORIZONTAL, new HorizontalRotationValues());
for (Direction facing : Direction.values()) {
if (facing.getAxis().isVertical())
continue;
voxelShaper.shapes.put(facing, rotatedCopy(southShape, 0, (int) -facing.getHorizontalAngle()));
}
return voxelShaper;
} }
public static VoxelShaper forHorizontalAxis(VoxelShape zShape) { public static VoxelShaper forHorizontalAxis(VoxelShape shape, Direction facing){
VoxelShaper voxelShaper = new VoxelShaper(); return forDirectionsWithRotation(shape, facing, Arrays.asList(Direction.SOUTH, Direction.EAST), new HorizontalRotationValues());
for (Axis axis : Axis.values()) {
if (axis.isVertical())
continue;
Direction facing = axisAsFace(axis);
voxelShaper.shapes.put(facing, rotatedCopy(zShape, 0, (int) -facing.getHorizontalAngle()));
}
return voxelShaper;
} }
public static VoxelShaper forRotatedPillar(VoxelShape zShape) { public static VoxelShaper forRotatedPillar(VoxelShape zShape) {//todo dunno what this was intended for
VoxelShaper voxelShaper = new VoxelShaper(); VoxelShaper voxelShaper = new VoxelShaper();
for (Axis axis : Axis.values()) { for (Axis axis : Axis.values()) {
Direction facing = axisAsFace(axis); Direction facing = axisAsFace(axis);
voxelShaper.shapes.put(facing, rotatedCopy(zShape, 0, (int) -facing.getHorizontalAngle())); voxelShaper.shapes.put(facing, rotatedCopy(zShape, new Vec3d(0, (int) -facing.getHorizontalAngle(),0)));
} }
return voxelShaper; return voxelShaper;
} }
public static VoxelShaper forDirectional(VoxelShape southShape) { public static VoxelShaper forDirectional(VoxelShape shape, Direction facing){
VoxelShaper voxelShaper = new VoxelShaper(); return forDirectionsWithRotation(shape, facing, Arrays.asList(Direction.values()), new DefaultRotationValues());
for (Direction facing : Direction.values()) { }
int rotX = facing.getAxis().isVertical() ? (facing == Direction.UP ? 270 : 90) : 0;
int rotY = facing.getAxis().isVertical() ? 0 : (int) -facing.getHorizontalAngle(); public static VoxelShaper forDirectionalAxis(VoxelShape shape, Axis along){
voxelShaper.shapes.put(facing, rotatedCopy(southShape, rotX, rotY)); return forDirectionsWithRotation(shape, axisAsFace(along), Arrays.asList(Direction.SOUTH, Direction.EAST, Direction.UP), new DefaultRotationValues());
}
return voxelShaper;
} }
public VoxelShaper withVerticalShapes(VoxelShape upShape) { public VoxelShaper withVerticalShapes(VoxelShape upShape) {
shapes.put(Direction.UP, upShape); shapes.put(Direction.UP, upShape);
shapes.put(Direction.DOWN, rotatedCopy(upShape, 180, 0)); shapes.put(Direction.DOWN, rotatedCopy(upShape, new Vec3d(180, 0, 0)));
return this; return this;
} }
private static Direction axisAsFace(Axis axis) { public VoxelShaper withShape(VoxelShape shape, Direction facing){
shapes.put(facing, shape);
return this;
}
public static Direction axisAsFace(Axis axis) {
return Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis); return Direction.getFacingFromAxis(AxisDirection.POSITIVE, axis);
} }
private static VoxelShape rotatedCopy(VoxelShape shape, int rotX, int rotY) { protected static float horizontalAngleFromDirection(Direction direction){
return (float)((Math.max(direction.getHorizontalIndex(), 0) & 3) * 90);
}
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));
}
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()); MutableObject<VoxelShape> result = new MutableObject<>(VoxelShapes.empty());
Vec3d center = new Vec3d(8, 8, 8);
shape.forEachBox((x1, y1, z1, x2, y2, z2) -> { shape.forEachBox((x1, y1, z1, x2, y2, z2) -> {
Vec3d center = new Vec3d(8, 8, 8);
Vec3d v1 = new Vec3d(x1, y1, z1).scale(16).subtract(center); Vec3d v1 = new Vec3d(x1, y1, z1).scale(16).subtract(center);
Vec3d v2 = new Vec3d(x2, y2, z2).scale(16).subtract(center); Vec3d v2 = new Vec3d(x2, y2, z2).scale(16).subtract(center);
v1 = VecHelper.rotate(v1, rotX, Axis.X); v1 = VecHelper.rotate(v1, (float) rotation.x, Axis.X);
v1 = VecHelper.rotate(v1, rotY, Axis.Y).add(center); v1 = VecHelper.rotate(v1, (float) rotation.y, Axis.Y);
v2 = VecHelper.rotate(v2, rotX, Axis.X); v1 = VecHelper.rotate(v1, (float) rotation.z, Axis.Z).add(center);
v2 = VecHelper.rotate(v2, rotY, Axis.Y).add(center);
v2 = VecHelper.rotate(v2, (float) rotation.x, Axis.X);
v2 = VecHelper.rotate(v2, (float) rotation.y, Axis.Y);
v2 = VecHelper.rotate(v2, (float) rotation.z, Axis.Z).add(center);
VoxelShape rotated = Block.makeCuboidShape(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z); VoxelShape rotated = Block.makeCuboidShape(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z);
result.setValue(VoxelShapes.or(result.getValue(), rotated)); result.setValue(VoxelShapes.or(result.getValue(), rotated));
@ -95,4 +112,27 @@ public class VoxelShaper {
return result.getValue(); return result.getValue();
} }
protected static class DefaultRotationValues implements Function<Direction, Vec3d> {
//assume facing up as the default rotation
@Override
public Vec3d apply(Direction direction) {
return new Vec3d(
direction == Direction.UP ? 0 : (Direction.Plane.VERTICAL.test(direction) ? 180 : 90),
-horizontalAngleFromDirection(direction),
0
);
}
}
protected static class HorizontalRotationValues implements Function<Direction, Vec3d> {
@Override
public Vec3d apply(Direction direction) {
return new Vec3d(
0,
-horizontalAngleFromDirection(direction),
0
);
}
}
} }

View file

@ -1,10 +0,0 @@
package com.simibubi.create.foundation.utility;
import net.minecraft.block.Block;
public class VoxelShapers {
public static final VoxelShaper SHORT_CASING = VoxelShaper
.forDirectional(Block.makeCuboidShape(0, 0, 0, 16, 16, 12));
}

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.IBlockWithScrollableValue;
import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock; import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -19,11 +20,7 @@ import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
import net.minecraft.world.World; import net.minecraft.world.World;
public class MotorBlock extends HorizontalKineticBlock public class MotorBlock extends HorizontalKineticBlock implements IWithTileEntity<MotorTileEntity>, IBlockWithScrollableValue {
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);
private static final Vec3d valuePos = new Vec3d(15 / 16f, 5 / 16f, 5 / 16f); private static final Vec3d valuePos = new Vec3d(15 / 16f, 5 / 16f, 5 / 16f);
@ -33,7 +30,7 @@ public class MotorBlock extends HorizontalKineticBlock
@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 state.get(HORIZONTAL_FACING).getAxis() == Axis.X ? MOTOR_X : MOTOR_Z; return AllShapes.MOTOR_BLOCK.get(state.get(HORIZONTAL_FACING));
} }
@Override @Override

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.receivers;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -25,8 +26,6 @@ import net.minecraftforge.items.ItemStackHandler;
public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity> { public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity> {
public static final VoxelShape SHAPE = makeCuboidShape(0, 0, 0, 16, 13, 16);
public BasinBlock() { public BasinBlock() {
super(Properties.from(Blocks.ANDESITE)); super(Properties.from(Blocks.ANDESITE));
} }
@ -85,7 +84,7 @@ public class BasinBlock extends Block implements IWithTileEntity<BasinTileEntity
@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 SHAPE; return AllShapes.BASIN_BLOCK_SHAPE;
} }
@Override @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 static com.simibubi.create.modules.contraptions.receivers.CrushingWheelControllerBlock.VALID;
import com.simibubi.create.AllBlocks; 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.KineticTileEntity;
import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock;
@ -23,8 +24,6 @@ import net.minecraft.world.World;
public class CrushingWheelBlock extends RotatedPillarKineticBlock { public class CrushingWheelBlock extends RotatedPillarKineticBlock {
public static final VoxelShape COLLISION_SHAPE = makeCuboidShape(0, 0, 0, 16, 22, 16);
public CrushingWheelBlock() { public CrushingWheelBlock() {
super(Properties.from(Blocks.DIORITE)); super(Properties.from(Blocks.DIORITE));
} }
@ -42,7 +41,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock {
@Override @Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
ISelectionContext context) { ISelectionContext context) {
return COLLISION_SHAPE; return AllShapes.CRUSHING_WHEEL_COLLISION_SHAPE;
} }
@Override @Override

View file

@ -5,7 +5,7 @@ import java.util.List;
import com.simibubi.create.foundation.block.IRenderUtilityBlock; import com.simibubi.create.foundation.block.IRenderUtilityBlock;
import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.SuperByteBuffer; 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.base.DirectionalKineticBlock;
import com.simibubi.create.modules.contraptions.receivers.constructs.IHaveMovementBehavior; import com.simibubi.create.modules.contraptions.receivers.constructs.IHaveMovementBehavior;
@ -49,7 +49,7 @@ public class DrillBlock extends DirectionalKineticBlock
@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 VoxelShapers.SHORT_CASING.get(state.get(FACING)); return AllShapes.SHORT_CASING_12_VOXEL.get(state.get(FACING));
} }
@Override @Override

View file

@ -5,7 +5,7 @@ import java.util.List;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IRenderUtilityBlock; import com.simibubi.create.foundation.block.IRenderUtilityBlock;
import com.simibubi.create.foundation.utility.SuperByteBuffer; import com.simibubi.create.foundation.utility.SuperByteBuffer;
import com.simibubi.create.foundation.utility.VoxelShaper; import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.receivers.constructs.IHaveMovementBehavior; import com.simibubi.create.modules.contraptions.receivers.constructs.IHaveMovementBehavior;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -39,8 +39,6 @@ import net.minecraftforge.common.IPlantable;
public class HarvesterBlock extends HorizontalBlock implements IHaveMovementBehavior { public class HarvesterBlock extends HorizontalBlock implements IHaveMovementBehavior {
private static VoxelShaper SHAPER = VoxelShaper.forHorizontal(Block.makeCuboidShape(0, 2, 0, 16, 14, 3));
public HarvesterBlock() { public HarvesterBlock() {
super(Properties.from(Blocks.IRON_BLOCK)); super(Properties.from(Blocks.IRON_BLOCK));
} }
@ -63,7 +61,7 @@ public class HarvesterBlock extends HorizontalBlock implements IHaveMovementBeha
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction direction = state.get(HORIZONTAL_FACING); Direction direction = state.get(HORIZONTAL_FACING);
return SHAPER.get(direction); return AllShapes.HARVESTER_BASE.get(direction);
} }
@Override @Override

View file

@ -3,11 +3,13 @@ package com.simibubi.create.modules.contraptions.receivers;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IBlockWithScrollableValue; import com.simibubi.create.foundation.block.IBlockWithScrollableValue;
import com.simibubi.create.foundation.block.IWithTileEntity; 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.foundation.utility.Lang;
import com.simibubi.create.modules.contraptions.base.KineticBlock; import com.simibubi.create.modules.contraptions.base.KineticBlock;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -44,7 +46,10 @@ public class MechanicalMixerBlock extends KineticBlock
@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 MechanicalPressBlock.SHAPE; if (context.getEntity() instanceof PlayerEntity)
return AllShapes.SHORT_CASING_14_VOXEL.get(Direction.DOWN);
return AllShapes.MECHANICAL_PROCESSOR_SHAPE;
} }
@Override @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.IRenderUtilityBlock;
import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.block.SyncedTileEntity; import com.simibubi.create.foundation.block.SyncedTileEntity;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.item.ItemHelper;
import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock; import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock;
import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.BeltAttachmentState; import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.BeltAttachmentState;
@ -21,6 +22,7 @@ import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.HorizontalBlock; import net.minecraft.block.HorizontalBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.StateContainer.Builder;
@ -37,15 +39,16 @@ import net.minecraft.world.World;
public class MechanicalPressBlock extends HorizontalKineticBlock public class MechanicalPressBlock extends HorizontalKineticBlock
implements IWithTileEntity<MechanicalPressTileEntity>, IBeltAttachment { implements IWithTileEntity<MechanicalPressTileEntity>, IBeltAttachment {
public static VoxelShape SHAPE = makeCuboidShape(0, 0, 0, 16, 16, 16);
public MechanicalPressBlock() { public MechanicalPressBlock() {
super(Properties.from(Blocks.PISTON)); super(Properties.from(Blocks.PISTON));
} }
@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 SHAPE; if (context.getEntity() instanceof PlayerEntity)
return AllShapes.SHORT_CASING_14_VOXEL.get(Direction.DOWN);
return AllShapes.MECHANICAL_PROCESSOR_SHAPE;
} }
@Override @Override

View file

@ -1,7 +1,7 @@
package com.simibubi.create.modules.contraptions.receivers; package com.simibubi.create.modules.contraptions.receivers;
import com.simibubi.create.foundation.block.IWithTileEntity; 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.base.DirectionalAxisKineticBlock;
import com.simibubi.create.modules.contraptions.receivers.constructs.IHaveMovementBehavior; import com.simibubi.create.modules.contraptions.receivers.constructs.IHaveMovementBehavior;
import com.simibubi.create.modules.logistics.block.IBlockWithFilter; import com.simibubi.create.modules.logistics.block.IBlockWithFilter;
@ -82,7 +82,7 @@ public class SawBlock extends DirectionalAxisKineticBlock
@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 VoxelShapers.SHORT_CASING.get(state.get(FACING)); return AllShapes.SHORT_CASING_12_VOXEL.get(state.get(FACING));
} }
@Override @Override

View file

@ -1,5 +1,6 @@
package com.simibubi.create.modules.contraptions.receivers; 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.foundation.utility.VecHelper;
import com.simibubi.create.modules.contraptions.base.KineticBlock; import com.simibubi.create.modules.contraptions.base.KineticBlock;
import com.simibubi.create.modules.contraptions.base.KineticTileEntity; import com.simibubi.create.modules.contraptions.base.KineticTileEntity;
@ -23,10 +24,6 @@ import net.minecraft.world.World;
public class TurntableBlock extends KineticBlock { 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() { public TurntableBlock() {
super(Properties.from(Blocks.STRIPPED_SPRUCE_LOG)); super(Properties.from(Blocks.STRIPPED_SPRUCE_LOG));
} }
@ -38,7 +35,7 @@ public class TurntableBlock extends KineticBlock {
@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 SHAPE; return AllShapes.TURNTABLE_SHAPE;
} }
@Override @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.AllBlocks;
import com.simibubi.create.foundation.block.RenderUtilityBlock; import com.simibubi.create.foundation.block.RenderUtilityBlock;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.AbstractRailBlock; import net.minecraft.block.AbstractRailBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -17,6 +18,7 @@ import net.minecraft.state.IProperty;
import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.StateContainer.Builder;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.RailShape; import net.minecraft.state.properties.RailShape;
import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.ISelectionContext;
@ -31,9 +33,6 @@ public class CartAssemblerBlock extends AbstractRailBlock {
RailShape.NORTH_SOUTH); RailShape.NORTH_SOUTH);
public static BooleanProperty POWERED = BlockStateProperties.POWERED; 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() { public CartAssemblerBlock() {
super(true, Properties.from(Blocks.PISTON)); super(true, Properties.from(Blocks.PISTON));
setDefaultState(getDefaultState().with(POWERED, false)); setDefaultState(getDefaultState().with(POWERED, false));
@ -118,7 +117,7 @@ public class CartAssemblerBlock extends AbstractRailBlock {
@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 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 @Override
@ -126,7 +125,7 @@ public class CartAssemblerBlock extends AbstractRailBlock {
ISelectionContext context) { ISelectionContext context) {
if (context.getEntity() instanceof AbstractMinecartEntity) if (context.getEntity() instanceof AbstractMinecartEntity)
return VoxelShapes.empty(); return VoxelShapes.empty();
return VoxelShapes.fullCube(); return getShape(state, worldIn, pos, context);
} }
@Override @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.AllBlocks;
import com.simibubi.create.CreateConfig; import com.simibubi.create.CreateConfig;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock; 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); 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; protected boolean isSticky;
public MechanicalPistonBlock(boolean sticky) { public MechanicalPistonBlock(boolean sticky) {
@ -155,36 +142,10 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock {
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
if (state.get(STATE) == PistonState.EXTENDED) if (state.get(STATE) == PistonState.EXTENDED)
switch (state.get(FACING)) { return AllShapes.MECHANICAL_PISTON_EXTENDED.get(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;
}
if (state.get(STATE) == PistonState.MOVING) if (state.get(STATE) == PistonState.MOVING)
switch (state.get(FACING)) { return AllShapes.MECHANICAL_PISTON.get(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 VoxelShapes.fullCube(); return VoxelShapes.fullCube();
} }

View file

@ -4,6 +4,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateConfig; import com.simibubi.create.CreateConfig;
import com.simibubi.create.foundation.block.IWithoutBlockItem; import com.simibubi.create.foundation.block.IWithoutBlockItem;
import com.simibubi.create.foundation.block.ProperDirectionalBlock; 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 com.simibubi.create.modules.contraptions.receivers.constructs.piston.MechanicalPistonBlock.PistonState;
import net.minecraft.block.Block; 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 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() { public MechanicalPistonHeadBlock() {
super(Properties.from(Blocks.PISTON_HEAD)); super(Properties.from(Blocks.PISTON_HEAD));
} }
@ -95,22 +80,6 @@ public class MechanicalPistonHeadBlock extends ProperDirectionalBlock implements
@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 AllShapes.MECHANICAL_PISTON_HEAD.get(state.get(FACING));
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();
} }
} }

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.contraptions.receivers.constructs.piston;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.CreateConfig; import com.simibubi.create.CreateConfig;
import com.simibubi.create.foundation.block.ProperDirectionalBlock; 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 com.simibubi.create.modules.contraptions.receivers.constructs.piston.MechanicalPistonBlock.PistonState;
import net.minecraft.block.BlockState; 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.BlockPos;
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 net.minecraft.world.World; import net.minecraft.world.World;
@ -73,17 +73,7 @@ public class PistonPoleBlock extends ProperDirectionalBlock {
@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 AllShapes.FOUR_VOXEL_POLE.get(state.get(FACING).getAxis());
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();
} }
@Override @Override

View file

@ -1,6 +1,7 @@
package com.simibubi.create.modules.contraptions.relays; package com.simibubi.create.modules.contraptions.relays;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.base.IRotate; import com.simibubi.create.modules.contraptions.base.IRotate;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -21,14 +22,6 @@ public class CogWheelBlock extends ShaftBlock {
private boolean isLarge; 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) { public CogWheelBlock(boolean large) {
super(Properties.from(Blocks.GRANITE)); super(Properties.from(Blocks.GRANITE));
isLarge = large; isLarge = large;
@ -36,7 +29,7 @@ public class CogWheelBlock extends ShaftBlock {
@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 VoxelShapes.or(super.getShape(state, worldIn, pos, context), getGearShape(state)); return (isLarge ? AllShapes.LARGE_GEAR : AllShapes.SMALL_GEAR).get(state.get(AXIS));
} }
@Override @Override
@ -65,15 +58,6 @@ public class CogWheelBlock extends ShaftBlock {
return getDefaultState().with(AXIS, ((IRotate) block).getRotationAxis(placedAgainst)); 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 @Override
public float getParticleTargetRadius() { public float getParticleTargetRadius() {
return isLarge ? 1.125f : .65f; return isLarge ? 1.125f : .65f;

View file

@ -1,5 +1,6 @@
package com.simibubi.create.modules.contraptions.relays; package com.simibubi.create.modules.contraptions.relays;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock; import com.simibubi.create.modules.contraptions.base.RotatedPillarKineticBlock;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
@ -14,10 +15,6 @@ import net.minecraft.world.World;
public class ShaftBlock extends RotatedPillarKineticBlock { 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) { public ShaftBlock(Properties properties) {
super(properties); super(properties);
} }
@ -34,7 +31,7 @@ public class ShaftBlock extends RotatedPillarKineticBlock {
@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 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 @Override

View file

@ -8,6 +8,7 @@ import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.block.IWithoutBlockItem; import com.simibubi.create.foundation.block.IWithoutBlockItem;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock; import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock;
import com.simibubi.create.modules.contraptions.relays.belt.BeltMovementHandler.TransportedEntityInfo; import com.simibubi.create.modules.contraptions.relays.belt.BeltMovementHandler.TransportedEntityInfo;
@ -55,7 +56,6 @@ public class BeltBlock extends HorizontalKineticBlock implements IWithoutBlockIt
public static final IProperty<Slope> SLOPE = EnumProperty.create("slope", Slope.class); 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 IProperty<Part> PART = EnumProperty.create("part", Part.class);
public static final BooleanProperty CASING = BooleanProperty.create("casing"); public static final BooleanProperty CASING = BooleanProperty.create("casing");
private final VoxelShape collisionMask = makeCuboidShape(0, 0, 0, 16, 19, 16);
public BeltBlock() { public BeltBlock() {
super(Properties.from(Blocks.BROWN_WOOL)); super(Properties.from(Blocks.BROWN_WOOL));
@ -288,7 +288,7 @@ public class BeltBlock extends HorizontalKineticBlock implements IWithoutBlockIt
if (controller == null) if (controller == null)
return shape; return shape;
if (controller.passengers == null || !controller.passengers.containsKey(context.getEntity())) { if (controller.passengers == null || !controller.passengers.containsKey(context.getEntity())) {
return VoxelShapes.combine(collisionMask, shape, IBooleanFunction.AND); return VoxelShapes.combine(AllShapes.BELT_COLLISION_MASK, shape, IBooleanFunction.AND);
} }
return shape; return shape;

View file

@ -2,6 +2,7 @@ package com.simibubi.create.modules.contraptions.relays.belt;
import static net.minecraft.block.Block.makeCuboidShape; import static net.minecraft.block.Block.makeCuboidShape;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.VoxelShaper; import com.simibubi.create.foundation.utility.VoxelShaper;
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Part; import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Part;
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Slope; import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Slope;
@ -9,53 +10,163 @@ import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock.Slope;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.Axis;
import net.minecraft.util.math.Vec3i; import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.shapes.IBooleanFunction; 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;
public class BeltShapes { public class BeltShapes {
private static final VoxelShape SLOPE_BUILDING_BLOCK_X = makeCuboidShape(5, 5, 1, 11, 11, 15), /*
SLOPE_BUILDING_BLOCK_Z = makeCuboidShape(1, 5, 5, 15, 11, 11), * | hi. i made these comments mostly to help me with creating the shapes. but they should also be able to help you understand what i'm doing here if that's why you came here. cheers
CASING_HORIZONTAL = makeCuboidShape(0, 0, 0, 16, 11, 16); * |
* | belt shape slope south descending
* | generated by makeSlopePart
* | z
* | y 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 | | | |
* | | | | | | |
* | +5 | # | | belt shape flat south ending | belt shape flat south full |
* | +4 | # # | | generated by makeFlatEnding | generated by makeFlatFull |
* | +3 | # # # | z |z |z |
* | +2 | # # # # | 15 14 ... | 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 | 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 |
* | +1 | # # # # # | | | | | | | | |
* | 15 ------+ - - - - - - - - - # # # # # #-- | --+---------- | --+ - - - - - - - - - - - - - - +-- | --+ - - - - - - - - - - - - - - +--- |
* | 14 | # # # # # # # | | | | | | | | |
* | 13 | # # # # # # # # | | | | | | | | |
* | 12 | # # # # # # # # # | | | | # # # # # # # # # # # # # # | | # # # # # # # # # # # # # # # # |
* | 11 | # # # # # # # # # # | | | # # # # # # # # # # # # # # # # | # # # # # # # # # # # # # # # # |
* | 10 | # # # # # # # # # # # | # | # # # # # # # # # # # # # # # # | # # # # # # # # # # # # # # # # |
* | 9 | # # # # # # # # # # # | | # | # # # # # # # # # # # # # # # # | # # # # # # # # # # # # # # # # |
* | 8 | # # # # # # # # # # # | | # | # # # # # # # # # # # # # # # # | # # # # # # # # # # # # # # # # |
* | 7 | # # # # # # # # # # # | | # | # # # # # # # # # # # # # # # # | # # # # # # # # # # # # # # # # |
* | 6 | # # # # # # # # # # # | | # | # # # # # # # # # # # # # # # # | # # # # # # # # # # # # # # # # |
* | 5 # # # # # # # # # # # | | # | # # # # # # # # # # # # # # # # | # # # # # # # # # # # # # # # # |
* | 4 # # # # # # # # # # | | # | # # # # # # # # # # # # # # # # | # # # # # # # # # # # # # # # # |
* | 3 # # # # # # # # # | | # | | # # # # # # # # # # # # # # | | # # # # # # # # # # # # # # # # |
* | 2 # # # # # # # # | | # | | | | | | |
* | 1 # # # # # # # | | # | | | | | | |
* | 0 -------# # # # # # - - - - - - - - - +-- | --#---------- | --+ - - - - - - - - - - - - - - +-- | --+ - - - - - - - - - - - - - - +--- |
* |-1 # # # # # | | | | | | | | | |
* |-2 # # # # | | | | | | | | | |
* |-3 # # # | slice used | | |
* |-4 # # | to create | | |
* |-5 # | the stairs | | |
* | x 1 to 14 | | | |
*/
private static final VoxelShaper SLOPE_END = VoxelShaper.forHorizontal(makeCuboidShape(1, 3, 0, 15, 13, 10)), /*
SLOPE_TOP_END = VoxelShaper.forHorizontal( * |Belt shapes always consist of 2 halves depending on state. This class generated all shapes for belts facing SOUTH and then uses VoxelShapers to fill the remaining 3 Directions
VoxelShapes.or(SLOPE_END.get(Direction.SOUTH), createHalfSlope(Direction.SOUTH, false))), * |Middle shapes use the same building part in both halved and don't need to be composed
SLOPE_BOTTOM_END = VoxelShaper.forHorizontal( * |some of these shapes could be skipped and easily achieved by rotating other shapes but i left them in for clarity's sake
VoxelShapes.or(SLOPE_END.get(Direction.SOUTH), createHalfSlope(Direction.SOUTH, true))), * | Flat Belts: Sloped Belts: (DESC) (ASC)
FLAT_STRAIGHT = VoxelShaper.forHorizontalAxis(makeCuboidShape(0, 3, 1, 16, 13, 15)), * | south half north half south half north half south half north half
VERTICAL_STRAIGHT = VoxelShaper.forHorizontalAxis(makeCuboidShape(1, 0, 3, 15, 16, 13)), * |
SLOPE_STRAIGHT = VoxelShaper.forHorizontal(createSlope(Direction.SOUTH)), * | Middle flat full flat full Middle slope desc slope desc slope asc slope asc
CASING_TOP_END = VoxelShaper.forHorizontal(makeCuboidShape(0, 0, 0, 16, 11, 11)); * | End flat end flat full End flat end slope desc flat end slope asc
* | Start flat full flat end Start slope desc flat end slope asc flat end
*/
//Building parts for the shapes
private static final VoxelShape
SLOPE_DESC_PART = makeSlopePart(false),
SLOPE_ASC_PART = makeSlopePart(true),
FLAT_FULL_PART = makeFlatFull(),
FLAT_END_PART = makeFlatEnding();
private static final VoxelShape SOUTH_MASK = makeCuboidShape(0,-5,8,16,16+5,16);
private static final VoxelShape NORTH_MASK = makeCuboidShape(0,-5,0,16,16+5,8);
//Vertical Shapes
private static final VoxelShaper
VERTICAL_FULL = VerticalBeltShaper.make(FLAT_FULL_PART),
VERTICAL_END = VerticalBeltShaper.make(compose(FLAT_END_PART, FLAT_FULL_PART)),
VERTICAL_START = VerticalBeltShaper.make(compose(FLAT_FULL_PART, FLAT_END_PART));
//Flat Shapes
private static final VoxelShaper
FLAT_FULL = VoxelShaper.forHorizontalAxis(FLAT_FULL_PART, Direction.SOUTH),
FLAT_END = VoxelShaper.forHorizontal(compose(FLAT_END_PART, FLAT_FULL_PART), Direction.SOUTH),
FLAT_START = VoxelShaper.forHorizontal(compose(FLAT_FULL_PART, FLAT_END_PART), Direction.SOUTH);
//Sloped Shapes
private static final VoxelShaper
SLOPE_DESC = VoxelShaper.forHorizontal(SLOPE_DESC_PART, Direction.SOUTH),
SLOPE_ASC = VoxelShaper.forHorizontal(SLOPE_ASC_PART, Direction.SOUTH),
SLOPE_DESC_END = VoxelShaper.forHorizontal(compose(FLAT_END_PART, SLOPE_DESC_PART), Direction.SOUTH),
SLOPE_DESC_START = VoxelShaper.forHorizontal(compose(SLOPE_DESC_PART, FLAT_END_PART), Direction.SOUTH),
SLOPE_ASC_END = VoxelShaper.forHorizontal(compose(FLAT_END_PART, SLOPE_ASC_PART), Direction.SOUTH),
SLOPE_ASC_START = VoxelShaper.forHorizontal(compose(SLOPE_ASC_PART, FLAT_END_PART), Direction.SOUTH);
private static final VoxelShaper
PARTIAL_CASING = VoxelShaper.forHorizontal(makeCuboidShape(0, 0, 5, 16, 11, 16), Direction.SOUTH);
private static VoxelShape compose(VoxelShape southPart, VoxelShape northPart){
return VoxelShapes.or(
VoxelShapes.combine(SOUTH_MASK, southPart, IBooleanFunction.AND),
VoxelShapes.combine(NORTH_MASK, northPart, IBooleanFunction.AND)
);
}
private static VoxelShape makeSlopePart(boolean ascendingInstead) {
VoxelShape slice = makeCuboidShape(1, 0, 16, 15, 11, 15);
VoxelShape result = VoxelShapes.empty();
for (int i = 0; i < 16; i++) {
int yOffset = ascendingInstead ? 10 - i : i - 5;
result = VoxelShapes.or(
result,//move slice i voxels "right" and i-5 voxels "down"
slice.withOffset(0, yOffset / 16f, -i / 16f));
}
return result;
}
private static VoxelShape makeFlatEnding(){
return VoxelShapes.or(
makeCuboidShape(1,4,0,15,12,16),
makeCuboidShape(1,3,1,15,13,15)
);
}
private static VoxelShape makeFlatFull(){
return makeCuboidShape(1,3,0,15,13,16);
}
public static VoxelShape getShape(BlockState state) { public static VoxelShape getShape(BlockState state) {
Direction facing = state.get(BeltBlock.HORIZONTAL_FACING); Direction facing = state.get(BeltBlock.HORIZONTAL_FACING);
Axis axis = facing.getAxis(); Axis axis = facing.getAxis();
Axis perpendicularAxis = facing.rotateY().getAxis();
Part part = state.get(BeltBlock.PART); Part part = state.get(BeltBlock.PART);
Slope slope = state.get(BeltBlock.SLOPE); Slope slope = state.get(BeltBlock.SLOPE);
if (slope == Slope.HORIZONTAL) //vertical
return FLAT_STRAIGHT.get(perpendicularAxis); if (slope == Slope.VERTICAL) {
if (slope == Slope.VERTICAL) if (part == Part.MIDDLE || part == Part.PULLEY)
return VERTICAL_STRAIGHT.get(axis); return VERTICAL_FULL.get(axis);
//vertical ending
if (part != Part.MIDDLE && part != Part.PULLEY) { return (part == Part.START ? VERTICAL_START : VERTICAL_END).get(facing);
boolean upward = slope == Slope.UPWARD;
if (part == Part.START)
upward = !upward;
else
facing = facing.getOpposite();
return upward ? SLOPE_TOP_END.get(facing) : SLOPE_BOTTOM_END.get(facing);
} }
if (slope == Slope.DOWNWARD) //flat part
facing = facing.getOpposite(); if (slope == Slope.HORIZONTAL) {
if (part == Part.MIDDLE || part == Part.PULLEY)
return FLAT_FULL.get(axis);
//flat ending
return (part == Part.START ? FLAT_START : FLAT_END).get(facing);
}
//slope
if (part == Part.MIDDLE || part == Part.PULLEY)
return (slope == Slope.DOWNWARD ? SLOPE_DESC : SLOPE_ASC).get(facing);
//sloped ending
if (part == Part.START)
return (slope == Slope.DOWNWARD ? SLOPE_DESC_START : SLOPE_ASC_START).get(facing);
if (part == Part.END)
return (slope == Slope.DOWNWARD ? SLOPE_DESC_END : SLOPE_ASC_END).get(facing);
//bad state
return VoxelShapes.empty();
return SLOPE_STRAIGHT.get(facing);
} }
public static VoxelShape getCasingShape(BlockState state) { public static VoxelShape getCasingShape(BlockState state) {
@ -66,54 +177,37 @@ public class BeltShapes {
Part part = state.get(BeltBlock.PART); Part part = state.get(BeltBlock.PART);
Slope slope = state.get(BeltBlock.SLOPE); Slope slope = state.get(BeltBlock.SLOPE);
if (slope == Slope.HORIZONTAL)
return CASING_HORIZONTAL;
if (slope == Slope.VERTICAL) if (slope == Slope.VERTICAL)
return VoxelShapes.empty(); return VoxelShapes.empty();
if (part != Part.MIDDLE) { if (slope == Slope.HORIZONTAL) {
boolean upward = slope == Slope.UPWARD; return AllShapes.SHORT_CASING_11_VOXEL.get(Direction.UP);
if (part == Part.START)
upward = !upward;
else
facing = facing.getOpposite();
return upward ? CASING_TOP_END.get(facing) : CASING_HORIZONTAL;
} }
if (slope == Slope.DOWNWARD) if (part == Part.MIDDLE || part == Part.PULLEY)
facing = facing.getOpposite(); return PARTIAL_CASING.get(slope == Slope.UPWARD ? facing : facing.getOpposite());
return CASING_TOP_END.get(facing.getOpposite()); if (part == Part.START)
return slope == Slope.UPWARD ? AllShapes.SHORT_CASING_11_VOXEL.get(Direction.UP) : PARTIAL_CASING.get(facing.getOpposite());
if (part == Part.END)
return slope == Slope.DOWNWARD ? AllShapes.SHORT_CASING_11_VOXEL.get(Direction.UP) : PARTIAL_CASING.get(facing);
//something went wrong
return VoxelShapes.fullCube();
} }
protected static VoxelShape createSlope(Direction facing) { private static class VerticalBeltShaper extends VoxelShaper {
return VoxelShapes.or(createHalfSlope(facing.getOpposite(), false), createHalfSlope(facing, true));
}
protected static VoxelShape createHalfSlope(Direction facing, boolean upward) { public static VoxelShaper make(VoxelShape southBeltShape){
VoxelShape shape = VoxelShapes.empty(); return forDirectionsWithRotation(
VoxelShape buildingBlock = facing.getAxis() == Axis.X ? SLOPE_BUILDING_BLOCK_X : SLOPE_BUILDING_BLOCK_Z; rotatedCopy(southBeltShape, new Vec3d(-90,0,0)),
Vec3i directionVec = facing.getDirectionVec(); Direction.SOUTH,
Direction.Plane.HORIZONTAL,//idk, this can probably be improved :S
int x = directionVec.getX(); direction -> new Vec3d(
int y = upward ? 1 : -1; direction.getAxisDirection() == Direction.AxisDirection.POSITIVE ? 0 : 180,
int z = directionVec.getZ(); -direction.getHorizontalAngle(),
0));
for (int segment = 0; segment < 6; segment++) }
shape = VoxelShapes.or(shape,
buildingBlock.withOffset(x * segment / 16f, y * segment / 16f, z * segment / 16f));
if (!upward)
return shape;
VoxelShape mask = makeCuboidShape(0, -8, 0, 16, 24, 16);
for (int segment = 6; segment < 11; segment++)
shape = VoxelShapes.or(shape,
VoxelShapes.combine(mask,
buildingBlock.withOffset(x * segment / 16f, y * segment / 16f, z * segment / 16f),
IBooleanFunction.AND));
return shape;
} }
} }

View file

@ -58,13 +58,7 @@ public class BeltTunnelBlock extends Block implements IWithTileEntity<BeltTunnel
@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 BeltTunnelShapes.getFilledShape(state); return BeltTunnelShapes.getShape(state);
}
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos,
ISelectionContext context) {
return BeltTunnelShapes.getFrameShape(state);
} }
@Override @Override

View file

@ -1,54 +1,75 @@
package com.simibubi.create.modules.contraptions.relays.belt; package com.simibubi.create.modules.contraptions.relays.belt;
import static com.simibubi.create.foundation.utility.VoxelShaper.forHorizontalAxis;
import static net.minecraft.block.Block.makeCuboidShape;
import static net.minecraft.util.math.shapes.VoxelShapes.or;
import com.simibubi.create.foundation.utility.VoxelShaper; import com.simibubi.create.foundation.utility.VoxelShaper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
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 static net.minecraft.block.Block.makeCuboidShape;
public class BeltTunnelShapes { public class BeltTunnelShapes {
private static final VoxelShape TOP = makeCuboidShape(0, 8, 0, 16, 16, 16), private static VoxelShape block = makeCuboidShape(0, -5, 0, 16, 16, 16);
INNER = makeCuboidShape(2, -5, 2, 14, 16, 14);
private static final VoxelShaper WALL = VoxelShaper.forHorizontal(makeCuboidShape(0, -5, 14, 16, 16, 16)), private static VoxelShaper opening = VoxelShaper.forHorizontal( makeCuboidShape(2, -5, 14, 14, 8, 16), Direction.SOUTH);
POLES = VoxelShaper private static VoxelShaper notch = VoxelShaper.forHorizontal(makeCuboidShape(2, 14, 14, 14, 16, 16), Direction.SOUTH);
.forHorizontal(or(makeCuboidShape(0, -5, 14, 2, 16, 16), makeCuboidShape(14, -5, 14, 16, 16, 16)));
private static final VoxelShaper STRAIGHT = forHorizontalAxis( private static final VoxelShaper
VoxelShapes.or(TOP, WALL.get(Direction.EAST), WALL.get(Direction.WEST))), STRAIGHT = VoxelShaper.forHorizontalAxis(
T_LEFT = forHorizontalAxis(VoxelShapes.or(TOP, WALL.get(Direction.EAST), POLES.get(Direction.WEST))), VoxelShapes.combineAndSimplify(
T_RIGHT = forHorizontalAxis(VoxelShapes.or(TOP, POLES.get(Direction.EAST), WALL.get(Direction.WEST))), block,
CROSS = forHorizontalAxis(VoxelShapes.or(TOP, POLES.get(Direction.EAST), POLES.get(Direction.WEST))); VoxelShapes.or(
opening.get(Direction.SOUTH),
opening.get(Direction.NORTH),
notch.get(Direction.WEST),
notch.get(Direction.EAST)
),
IBooleanFunction.NOT_SAME),
Direction.SOUTH),
public static VoxelShape getFrameShape(BlockState state) { TEE = VoxelShaper.forHorizontal(
VoxelShaper shaper = null; VoxelShapes.combineAndSimplify(
switch (state.get(BeltTunnelBlock.SHAPE)) { block,
case CROSS: VoxelShapes.or(
shaper = CROSS; notch.get(Direction.SOUTH),
break; opening.get(Direction.NORTH),
case T_LEFT: opening.get(Direction.WEST),
shaper = T_LEFT; opening.get(Direction.EAST)
break; ),
case T_RIGHT: IBooleanFunction.NOT_SAME),
shaper = T_RIGHT; Direction.SOUTH);
break;
case STRAIGHT: private static final VoxelShape
case WINDOW: CROSS = VoxelShapes.combineAndSimplify(
default: block,
shaper = STRAIGHT; VoxelShapes.or(
break; opening.get(Direction.SOUTH),
} opening.get(Direction.NORTH),
return shaper.get(state.get(BeltTunnelBlock.HORIZONTAL_AXIS)); opening.get(Direction.WEST),
opening.get(Direction.EAST)
),
IBooleanFunction.NOT_SAME);
public static VoxelShape getShape(BlockState state) {
BeltTunnelBlock.Shape shape = state.get(BeltTunnelBlock.SHAPE);
Direction.Axis axis = state.get(BeltTunnelBlock.HORIZONTAL_AXIS);
if (shape == BeltTunnelBlock.Shape.CROSS)
return CROSS;
if (shape == BeltTunnelBlock.Shape.STRAIGHT || shape == BeltTunnelBlock.Shape.WINDOW)
return STRAIGHT.get(axis);
if (shape == BeltTunnelBlock.Shape.T_LEFT)
return TEE.get(axis == Direction.Axis.Z ? Direction.EAST : Direction.NORTH);
if (shape == BeltTunnelBlock.Shape.T_RIGHT)
return TEE.get(axis == Direction.Axis.Z ? Direction.WEST : Direction.SOUTH);
//something went wrong
return VoxelShapes.fullCube();
} }
public static VoxelShape getFilledShape(BlockState state) {
return or(getFrameShape(state), INNER);
}
} }

View file

@ -1,14 +1,11 @@
package com.simibubi.create.modules.contraptions.relays.gauge; package com.simibubi.create.modules.contraptions.relays.gauge;
import java.util.Random;
import com.simibubi.create.foundation.block.RenderUtilityBlock; import com.simibubi.create.foundation.block.RenderUtilityBlock;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.ColorHelper; import com.simibubi.create.foundation.utility.ColorHelper;
import com.simibubi.create.foundation.utility.Lang; import com.simibubi.create.foundation.utility.Lang;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.foundation.utility.VoxelShaper;
import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock; import com.simibubi.create.modules.contraptions.base.DirectionalAxisKineticBlock;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -28,25 +25,16 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
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 net.minecraft.world.IWorldReader; import net.minecraft.world.IWorldReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.Random;
public class GaugeBlock extends DirectionalAxisKineticBlock { public class GaugeBlock extends DirectionalAxisKineticBlock {
protected Type type; protected Type type;
protected VoxelShape LOG = makeCuboidShape(1, 2, 2, 15, 14, 14);
protected VoxelShaper PLATE = VoxelShaper.forDirectional(makeCuboidShape(0, 1, 0, 16, 15, 2));
protected VoxelShaper ON_WALL_HORIZONTAL = VoxelShaper
.forHorizontal(VoxelShapes.or(PLATE.get(Direction.SOUTH), LOG));
protected VoxelShaper ON_WALL_VERTICAL = VoxelShaper
.forHorizontal(VoxelShapes.or(makeCuboidShape(1, 0, 0, 15, 16, 2), makeCuboidShape(2, 1, 2, 14, 15, 14)));
protected VoxelShaper ON_GROUND = VoxelShaper.forHorizontalAxis(VoxelShapes.or(PLATE.get(Direction.UP), LOG));
protected VoxelShaper ON_CEILING = VoxelShaper.forHorizontalAxis(VoxelShapes.or(PLATE.get(Direction.DOWN), LOG));
public enum Type implements IStringSerializable { public enum Type implements IStringSerializable {
SPEED, STRESS; SPEED, STRESS;
@ -169,21 +157,7 @@ public class GaugeBlock extends DirectionalAxisKineticBlock {
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(FACING); return AllShapes.GAUGE.get(state.get(FACING), state.get(AXIS_ALONG_FIRST_COORDINATE));
Axis axis = getRotationAxis(state);
if (facing.getAxis().isHorizontal()) {
if (axis.isHorizontal())
return ON_WALL_HORIZONTAL.get(facing);
return ON_WALL_VERTICAL.get(facing);
}
axis = axis == Axis.X ? Axis.Z : Axis.X;
if (facing == Direction.UP)
return ON_GROUND.get(axis);
if (facing == Direction.DOWN)
return ON_CEILING.get(axis);
return VoxelShapes.empty();
} }
public static class Head extends RenderUtilityBlock { public static class Head extends RenderUtilityBlock {

View file

@ -1,101 +0,0 @@
package com.simibubi.create.modules.economy;
import com.simibubi.create.foundation.block.IWithoutBlockItem;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.item.ItemStack;
import net.minecraft.state.StateContainer.Builder;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
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.world.IBlockReader;
import net.minecraft.world.World;
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 BODY_SOUTH_SHAPE = makeCuboidShape(0, 0, 0, 16, 14, 14);
public static final VoxelShape BODY_NORTH_SHAPE = makeCuboidShape(0, 0, 2, 16, 14, 16);
public static final VoxelShape BODY_EAST_SHAPE = makeCuboidShape(0, 0, 0, 14, 14, 16);
public static final VoxelShape BODY_WEST_SHAPE = makeCuboidShape(2, 0, 0, 16, 14, 16);
public ShopShelfBlock() {
super(Properties.from(Blocks.SPRUCE_PLANKS));
}
@Override
public boolean hasTileEntity(BlockState state) {
return true;
}
@Override
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
return new ShopShelfTileEntity();
}
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) {
ShopShelfTileEntity te = (ShopShelfTileEntity) worldIn.getTileEntity(pos);
te.setOwner(placer.getUniqueID());
worldIn.notifyBlockUpdate(pos, state, state, 2);
}
@Override
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
BlockRayTraceResult hit) {
ShopShelfTileEntity te = (ShopShelfTileEntity) worldIn.getTileEntity(pos);
if (te == null)
return false;
if (!worldIn.isRemote)
NetworkHooks.openGui((ServerPlayerEntity) player, te, te::sendToContainer);
return true;
}
@Override
protected void fillStateContainer(Builder<Block, BlockState> builder) {
builder.add(HORIZONTAL_FACING);
super.fillStateContainer(builder);
}
@Override
public BlockState getStateForPlacement(BlockItemUseContext context) {
return getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
VoxelShape body = VoxelShapes.empty();
switch (state.get(HORIZONTAL_FACING)) {
case EAST:
body = BODY_EAST_SHAPE;
break;
case NORTH:
body = BODY_NORTH_SHAPE;
break;
case SOUTH:
body = BODY_SOUTH_SHAPE;
break;
case WEST:
body = BODY_WEST_SHAPE;
break;
default:
break;
}
return VoxelShapes.or(TOP_SHAPE, body);
}
}

View file

@ -1,25 +0,0 @@
package com.simibubi.create.modules.economy;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.network.PacketBuffer;
public class ShopShelfContainer extends Container {
public ShopShelfContainer(int id, PlayerInventory inv, ShopShelfTileEntity te) {
// super(AllContainers.SHOP_SHELF.type, id);
super(null, id);
}
public ShopShelfContainer(int id, PlayerInventory inv, PacketBuffer extraData) {
// super(AllContainers.SHOP_SHELF.type, id);
super(null, id);
}
@Override
public boolean canInteractWith(PlayerEntity playerIn) {
return true;
}
}

View file

@ -1,19 +0,0 @@
package com.simibubi.create.modules.economy;
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
public class ShopShelfScreen extends AbstractSimiContainerScreen<ShopShelfContainer> {
public ShopShelfScreen(ShopShelfContainer container, PlayerInventory inv, ITextComponent title) {
super(container, inv, title);
}
@Override
protected void renderWindow(int mouseX, int mouseY, float partialTicks) {
renderTooltip("Hi", mouseX, mouseY);
}
}

View file

@ -1,62 +0,0 @@
package com.simibubi.create.modules.economy;
import java.util.UUID;
import com.simibubi.create.foundation.block.SyncedTileEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
public class ShopShelfTileEntity extends SyncedTileEntity implements INamedContainerProvider {
private UUID owner;
public ShopShelfTileEntity() {
super(null);
// super(AllTileEntities.SHOP_SHELF.type);
}
@Override
public void read(CompoundNBT compound) {
if (compound.contains("Owner"))
setOwner(NBTUtil.readUniqueId(compound.getCompound("Owner")));
super.read(compound);
}
@Override
public CompoundNBT write(CompoundNBT compound) {
if (getOwner() != null)
compound.put("Owner", NBTUtil.writeUniqueId(getOwner()));
return super.write(compound);
}
public UUID getOwner() {
return owner;
}
public void setOwner(UUID owner) {
this.owner = owner;
}
public void sendToContainer(PacketBuffer buffer) {
buffer.writeUniqueId(getOwner());
}
@Override
public Container createMenu(int id, PlayerInventory inventory, PlayerEntity player) {
return new ShopShelfContainer(id, inventory, this);
}
@Override
public ITextComponent getDisplayName() {
return new StringTextComponent(getType().getRegistryName().toString());
}
}

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.logistics.block;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.foundation.utility.AllShapes;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import com.simibubi.create.foundation.block.ProperDirectionalBlock; 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"); public static final BooleanProperty RECEIVER = BooleanProperty.create("receiver");
private static final List<Pair<Vec3d, Vec3d>> itemPositions = new ArrayList<>(Direction.values().length); 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() { public RedstoneBridgeBlock() {
super(Properties.from(Blocks.DARK_OAK_LOG)); super(Properties.from(Blocks.DARK_OAK_LOG));
cacheItemPositions(); cacheItemPositions();
@ -174,22 +168,7 @@ public class RedstoneBridgeBlock extends ProperDirectionalBlock implements IBloc
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(FACING); return AllShapes.REDSTONE_BRIDGE.get(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();
} }
private void cacheItemPositions() { private void cacheItemPositions() {

View file

@ -6,6 +6,7 @@ import java.util.List;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IWithTileEntity; 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.foundation.utility.VecHelper;
import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.BeltAttachmentState; import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.BeltAttachmentState;
import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.IBeltAttachment; 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.IWorldReader;
import net.minecraft.world.World; import net.minecraft.world.World;
public class BeltFunnelBlock extends HorizontalBlock public class BeltFunnelBlock extends HorizontalBlock implements IBeltAttachment, IWithTileEntity<BeltFunnelTileEntity>, IBlockWithFilter {
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 BeltFunnelBlock() { public BeltFunnelBlock() {
super(Properties.from(Blocks.ANDESITE)); super(Properties.from(Blocks.ANDESITE));
@ -105,18 +101,7 @@ public class BeltFunnelBlock extends HorizontalBlock
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(HORIZONTAL_FACING); return AllShapes.BELT_FUNNEL.get(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();
} }
@Override @Override

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.utility.AllShapes;
import com.simibubi.create.foundation.utility.VecHelper; import com.simibubi.create.foundation.utility.VecHelper;
import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock; import com.simibubi.create.modules.contraptions.relays.belt.BeltBlock;
import com.simibubi.create.modules.logistics.block.IBlockWithFilter; 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 class ExtractorBlock extends HorizontalBlock implements IBlockWithFilter {
public static BooleanProperty POWERED = BlockStateProperties.POWERED; 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); private static final List<Vec3d> itemPositions = new ArrayList<>(Direction.values().length);
public ExtractorBlock() { public ExtractorBlock() {
@ -150,18 +148,7 @@ public class ExtractorBlock extends HorizontalBlock implements IBlockWithFilter
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(HORIZONTAL_FACING); return AllShapes.BELT_EXTRACTOR.get(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();
} }
private void cacheItemPositions() { private void cacheItemPositions() {

View file

@ -1,5 +1,6 @@
package com.simibubi.create.modules.logistics.block.inventories; package com.simibubi.create.modules.logistics.block.inventories;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -18,15 +19,13 @@ import net.minecraftforge.fml.network.NetworkHooks;
public class FlexcrateBlock extends Block { public class FlexcrateBlock extends Block {
public static final VoxelShape SHAPE = makeCuboidShape(1, 0, 1, 15, 14, 15);
public FlexcrateBlock() { public FlexcrateBlock() {
super(Properties.from(Blocks.ANDESITE)); super(Properties.from(Blocks.ANDESITE));
} }
@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 SHAPE; return AllShapes.CRATE_BLOCK_SHAPE;
} }
@Override @Override

View file

@ -11,6 +11,8 @@ import java.util.Set;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.VoxelShaper;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -31,7 +33,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.BlockRayTraceResult;
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.util.text.StringTextComponent; import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
@ -48,9 +49,6 @@ public class LogisticalCasingBlock extends Block implements IWithTileEntity<Logi
public static final IProperty<Part> PART = EnumProperty.create("part", Part.class); public static final IProperty<Part> PART = EnumProperty.create("part", Part.class);
public static final BooleanProperty ACTIVE = BooleanProperty.create("active"); public static final BooleanProperty ACTIVE = BooleanProperty.create("active");
public static final VoxelShape 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));
public LogisticalCasingBlock() { public LogisticalCasingBlock() {
super(Properties.from(Blocks.DARK_OAK_PLANKS)); super(Properties.from(Blocks.DARK_OAK_PLANKS));
setDefaultState(getDefaultState().with(PART, Part.NONE).with(AXIS, Axis.Y).with(ACTIVE, false)); setDefaultState(getDefaultState().with(PART, Part.NONE).with(AXIS, Axis.Y).with(ACTIVE, false));
@ -115,7 +113,20 @@ public class LogisticalCasingBlock extends Block implements IWithTileEntity<Logi
@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 state.get(PART) == Part.NONE ? SINGLE_SHAPE : VoxelShapes.fullCube(); Part part = state.get(PART);
if (part == Part.NONE)
return AllShapes.LOGISTICAL_CASING_SINGLE_SHAPE;
if (part == Part.MIDDLE)
return AllShapes.LOGISTICAL_CASING_MIDDLE.get(state.get(AXIS));
Direction facing = VoxelShaper.axisAsFace(state.get(AXIS));
if (part == Part.END)
facing = facing.getOpposite();
return AllShapes.LOGISTICAL_CASING_CAP.get(facing);
//return state.get(PART) == Part.NONE ? VoxelShapers.LOGISTICAL_CASING_SINGLE_SHAPE : VoxelShapes.fullCube();
} }
@Override @Override

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.IWithTileEntity;
import com.simibubi.create.foundation.block.IWithoutBlockItem; import com.simibubi.create.foundation.block.IWithoutBlockItem;
import com.simibubi.create.foundation.block.RenderUtilityBlock; 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.base.LogisticalCasingBlock.Part;
import com.simibubi.create.modules.logistics.management.controller.CalculationTileEntity; import com.simibubi.create.modules.logistics.management.controller.CalculationTileEntity;
import com.simibubi.create.modules.logistics.management.controller.LogisticalInventoryControllerTileEntity; 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.RayTraceResult;
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 net.minecraft.world.IWorldReader; import net.minecraft.world.IWorldReader;
import net.minecraft.world.World; 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 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() { public LogisticalControllerBlock() {
super(Properties.from(Blocks.PISTON)); super(Properties.from(Blocks.PISTON));
} }
@ -271,22 +266,7 @@ public class LogisticalControllerBlock extends DirectionalBlock
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(FACING); return AllShapes.LOGISTICAL_CONTROLLER.get(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();
} }
public static class LogisticalControllerIndicatorBlock extends RenderUtilityBlock { 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.IBlockWithColorHandler;
import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -29,12 +30,7 @@ import net.minecraft.world.IWorldReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.fml.network.NetworkHooks;
public class LogisticalIndexBlock extends HorizontalBlock public class LogisticalIndexBlock extends HorizontalBlock implements IBlockWithColorHandler, IWithTileEntity<LogisticalIndexTileEntity> {
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 LogisticalIndexBlock() { public LogisticalIndexBlock() {
super(Properties.from(Blocks.GRANITE)); super(Properties.from(Blocks.GRANITE));
@ -126,18 +122,7 @@ public class LogisticalIndexBlock extends HorizontalBlock
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(HORIZONTAL_FACING); return AllShapes.LOGISTICAL_INDEX.get(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();
} }
@Override @Override

View file

@ -5,6 +5,7 @@ import java.util.Random;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -33,29 +34,6 @@ import net.minecraft.world.World;
public class LogisticiansTableBlock extends HorizontalBlock implements IWithTileEntity<LogisticiansTableTileEntity> { 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() { public LogisticiansTableBlock() {
super(Properties.from(Blocks.SPRUCE_LOG)); super(Properties.from(Blocks.SPRUCE_LOG));
} }
@ -95,10 +73,6 @@ public class LogisticiansTableBlock extends HorizontalBlock implements IWithTile
super.fillStateContainer(builder); super.fillStateContainer(builder);
} }
public VoxelShape getRenderShape(BlockState state, IBlockReader worldIn, BlockPos pos) {
return RENDER_SHAPE;
}
public boolean func_220074_n(BlockState state) { public boolean func_220074_n(BlockState state) {
return true; return true;
} }
@ -123,24 +97,12 @@ public class LogisticiansTableBlock extends HorizontalBlock implements IWithTile
return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite()); return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
} }
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
ISelectionContext context) { return AllShapes.LOGISTICS_TABLE_BASE;
return COLLISION_SHAPE;
} }
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(HORIZONTAL_FACING)) { return AllShapes.LOGISTICS_TABLE.get(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;
}
} }
} }

View file

@ -3,6 +3,7 @@ package com.simibubi.create.modules.logistics.transport.villager;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.IWithTileEntity;
import com.simibubi.create.foundation.block.ProperDirectionalBlock; 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.ILogisticalCasingAttachment;
import com.simibubi.create.modules.logistics.management.base.LogisticalCasingTileEntity; import com.simibubi.create.modules.logistics.management.base.LogisticalCasingTileEntity;
import com.simibubi.create.modules.logistics.transport.CardboardBoxEntity; 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.IWorldReader;
import net.minecraft.world.World; import net.minecraft.world.World;
public class PackageFunnelBlock extends ProperDirectionalBlock public class PackageFunnelBlock extends ProperDirectionalBlock implements IWithTileEntity<PackageFunnelTileEntity>, ILogisticalCasingAttachment {
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 PackageFunnelBlock() { public PackageFunnelBlock() {
super(Properties.from(Blocks.PISTON)); super(Properties.from(Blocks.PISTON));
@ -82,22 +77,7 @@ public class PackageFunnelBlock extends ProperDirectionalBlock
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
Direction facing = state.get(FACING); return AllShapes.PACKAGE_FUNNEL.get(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();
} }
@Override @Override

View file

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

View file

@ -1,5 +1,6 @@
package com.simibubi.create.modules.schematics.block; package com.simibubi.create.modules.schematics.block;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -13,6 +14,8 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.network.NetworkHooks; import net.minecraftforge.fml.network.NetworkHooks;
@ -39,6 +42,16 @@ public class SchematicTableBlock extends HorizontalBlock {
return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite()); return this.getDefaultState().with(HORIZONTAL_FACING, context.getPlacementHorizontalFacing().getOpposite());
} }
@Override
public VoxelShape getCollisionShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.LOGISTICS_TABLE_BASE;
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.SCHEMATICS_TABLE.get(state.get(HORIZONTAL_FACING));
}
@Override @Override
public boolean hasTileEntity(BlockState state) { public boolean hasTileEntity(BlockState state) {
return true; return true;

View file

@ -2,6 +2,7 @@ package com.simibubi.create.modules.schematics.block;
import com.simibubi.create.AllItems; import com.simibubi.create.AllItems;
import com.simibubi.create.foundation.utility.AllShapes;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -14,6 +15,8 @@ import net.minecraft.util.Direction;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.world.IBlockReader; import net.minecraft.world.IBlockReader;
import net.minecraft.world.IWorld; import net.minecraft.world.IWorld;
import net.minecraft.world.IWorldReader; import net.minecraft.world.IWorldReader;
@ -48,6 +51,11 @@ public class SchematicannonBlock extends Block {
return false; return false;
} }
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
return AllShapes.SCHEMATICANNON_SHAPE;
}
@Override @Override
public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) { public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) {
((SchematicannonTileEntity) world.getTileEntity(pos)).findInventories(); ((SchematicannonTileEntity) world.getTileEntity(pos)).findInventories();