Skip to content

Commit

Permalink
Fix ME Source Jar voxel shape in different orientations
Browse files Browse the repository at this point in the history
  • Loading branch information
62832 committed Jul 5, 2024
1 parent e01c0b1 commit 3c37b0b
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions src/main/java/gripe/_90/arseng/block/MESourceJarBlock.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gripe._90.arseng.block;

import java.util.stream.Stream;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.ParametersAreNonnullByDefault;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -34,24 +35,13 @@
import appeng.api.orientation.IOrientableBlock;
import appeng.api.orientation.IOrientationStrategy;
import appeng.api.orientation.OrientationStrategies;
import appeng.api.orientation.RelativeSide;
import appeng.hooks.WrenchHook;

import gripe._90.arseng.block.entity.MESourceJarBlockEntity;

@ParametersAreNonnullByDefault
public class MESourceJarBlock extends Block implements EntityBlock, SimpleWaterloggedBlock, IOrientableBlock {
private static final VoxelShape SHAPE = Stream.of(
Block.box(4, 13, 4, 12, 14, 12),
Block.box(0, 0, 0, 16, 1, 16),
Block.box(2, 1, 2, 14, 2, 14),
Block.box(3, 2, 3, 13, 13, 13),
Block.box(3, 14, 3, 13, 16, 13),
Block.box(6, 1, 14, 10, 16, 16),
Block.box(6, 14, 13, 10, 16, 16),
Block.box(5, 5, 13, 11, 11, 16))
.reduce((v1, v2) -> Shapes.join(v1, v2, BooleanOp.OR))
.get();

public MESourceJarBlock() {
super(Properties.of()
.strength(2.2f, 11.f)
Expand Down Expand Up @@ -91,7 +81,38 @@ public int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos) {
@NotNull
@Override
public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
return SHAPE;
var boxes = new ArrayList<VoxelShape>();
boxes.add(Block.box(4, 13, 4, 12, 14, 12));
boxes.add(Block.box(0, 0, 0, 16, 1, 16));
boxes.add(Block.box(2, 1, 2, 14, 2, 14));
boxes.add(Block.box(3, 2, 3, 13, 13, 13));
boxes.add(Block.box(3, 14, 3, 13, 16, 13));

var forward = getOrientation(state).getSide(RelativeSide.BACK);
boxes.addAll(
switch (forward) {
case SOUTH -> List.of(
Block.box(6, 1, 14, 10, 16, 16),
Block.box(6, 14, 13, 10, 16, 16),
Block.box(5, 5, 13, 11, 11, 16));
case NORTH -> List.of(
Block.box(6, 1, 0, 10, 16, 2),
Block.box(6, 14, 0, 10, 16, 3),
Block.box(5, 5, 0, 11, 11, 3));
case EAST -> List.of(
Block.box(14, 1, 6, 16, 16, 10),
Block.box(13, 14, 6, 16, 16, 10),
Block.box(13, 5, 5, 16, 11, 11));
case WEST -> List.of(
Block.box(0, 1, 6, 2, 16, 10),
Block.box(0, 14, 6, 3, 16, 10),
Block.box(0, 5, 5, 3, 11, 11));
default -> List.of();
});

return boxes.stream()
.reduce((b1, b2) -> Shapes.join(b1, b2, BooleanOp.OR))
.get();
}

@Override
Expand Down

0 comments on commit 3c37b0b

Please sign in to comment.