Skip to content

Commit

Permalink
Added code for Shoji blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Qzimyion committed Nov 8, 2023
1 parent 1e97bcd commit c4d29fc
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,15 @@ public BlockState getStateForNeighborUpdate(BlockState state, Direction directio
return getConnection(state, world, pos);
}

public BlockState getConnection(BlockState state, WorldAccess world, BlockPos currentPos){
public BlockState getConnection(BlockState state, WorldAccess world, BlockPos pos){
Direction facing = state.get(FACING);

BlockState top = world.getBlockState(currentPos.offset(facing.rotateYClockwise()));
BlockState bottom = world.getBlockState(currentPos.offset(facing.rotateYCounterclockwise()));
BlockState top = world.getBlockState(pos.offset(facing.rotateClockwise(Direction.Axis.Y)));
BlockState bottom = world.getBlockState(pos.offset(facing.rotateCounterclockwise(Direction.Axis.Y)));

boolean sideU = (top.getBlock() instanceof ShojiBlocks && (top.get(FACING)==facing) || top.get(FACING)==facing.rotateYClockwise());
boolean sideD = (top.getBlock() instanceof ShojiBlocks && (bottom.get(FACING)==facing) || top.get(FACING)==facing.rotateYCounterclockwise());
ShojiShapes shapes = sideU && sideD ?
ShojiShapes.MID
: (sideD ? ShojiShapes.BOTTOM
: (sideU ? ShojiShapes.TOP
: ShojiShapes.NONE));
boolean sideU = (top.getBlock() instanceof ShojiBlocks && (top.get(FACING)==facing) || top.get(FACING)==facing.rotateClockwise(Direction.Axis.Y));
boolean sideD = (top.getBlock() instanceof ShojiBlocks && (bottom.get(FACING)==facing) || top.get(FACING)==facing.rotateCounterclockwise(Direction.Axis.Y));
ShojiShapes shapes = sideU && sideD ? ShojiShapes.MID : (sideD ? ShojiShapes.BOTTOM : (sideU ? ShojiShapes.TOP : ShojiShapes.NONE));
return state.with(SHOJI_SHAPE, shapes);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.qzimyion.cellulose.blocks.customBlocks.ShojiBlocks;

import net.minecraft.util.StringIdentifiable;

public enum ShojiShapes implements StringIdentifiable {
TOP("top"),
MID("mid"),
BOTTOM("bottom"),
NONE("none");

private final String name;
ShojiShapes(String name) {
this.name = name;
}

public String toString() {
return this.name;
}

@Override
public String asString() {
return null;
}
}

0 comments on commit c4d29fc

Please sign in to comment.