generated from QuiltMC/quilt-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* testing susShapes * vague ass blockstate errors are not helpful * more shenanigans * done for the night i guess * done for the night i guess * some more stuff, thanks falk for helping me * more annoying shenanigans * experimental arch blocks * some more stuff * even more stuff * even more stuff x2 * even more stuff x3 * model improvements * more model improvements * Get octagonal columns working * Fix 'Stone Brick Null' again --------- Co-authored-by: Falkreon <[email protected]>
- Loading branch information
1 parent
65df10d
commit 4a1e3c5
Showing
35 changed files
with
1,438 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
src/main/java/io/github/debuggyteam/architecture_extensions/blocks/OctagonalColumnBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package io.github.debuggyteam.architecture_extensions.blocks; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.PillarBlock; | ||
import net.minecraft.block.ShapeContext; | ||
import net.minecraft.block.Waterloggable; | ||
import net.minecraft.fluid.FluidState; | ||
import net.minecraft.fluid.Fluids; | ||
import net.minecraft.item.ItemPlacementContext; | ||
import net.minecraft.state.StateManager; | ||
import net.minecraft.state.property.BooleanProperty; | ||
import net.minecraft.state.property.EnumProperty; | ||
import net.minecraft.state.property.Properties; | ||
import net.minecraft.util.BlockRotation; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.shape.VoxelShape; | ||
import net.minecraft.world.BlockView; | ||
import net.minecraft.world.WorldAccess; | ||
|
||
public class OctagonalColumnBlock extends PillarBlock implements Waterloggable { | ||
public static final BooleanProperty MIN_CAP = BooleanProperty.of("min_cap"); | ||
public static final BooleanProperty MAX_CAP = BooleanProperty.of("max_cap"); | ||
public static final EnumProperty<Direction.Axis> AXIS = Properties.AXIS; | ||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; | ||
|
||
protected static final VoxelShape X_AXIS_BOX = Block.createCuboidShape(0.0, 4.0, 4.0, 16.0, 12.0, 12.0); | ||
protected static final VoxelShape Y_AXIS_BOX = Block.createCuboidShape(4.0, 0.0, 4.0, 12.0, 16.0, 12.0); | ||
protected static final VoxelShape Z_AXIS_BOX = Block.createCuboidShape(4.0, 4.0, 0.0, 12.0, 12.0, 16.0); | ||
|
||
public OctagonalColumnBlock(Settings settings) { | ||
super(settings); | ||
this.setDefaultState( | ||
this.getDefaultState() | ||
.with(WATERLOGGED, false) | ||
.with(AXIS, Direction.Axis.Y) | ||
.with(MIN_CAP, false) | ||
.with(MAX_CAP, false) | ||
); // Thanks LambdAurora! | ||
} | ||
|
||
// The following deals with block rotation | ||
@Override | ||
public BlockState rotate(BlockState state, BlockRotation rotation) { | ||
return changeRotation(state, rotation); | ||
} | ||
|
||
public static BlockState changeRotation(BlockState state, BlockRotation rotation) { | ||
return switch (rotation) { | ||
case COUNTERCLOCKWISE_90, CLOCKWISE_90 -> switch (state.get(AXIS)) { | ||
case X -> state.with(AXIS, Direction.Axis.Z); | ||
case Z -> state.with(AXIS, Direction.Axis.X); | ||
default -> state; | ||
}; | ||
default -> state; | ||
}; | ||
} | ||
|
||
// The following block of code below deals with block collision. | ||
@Override | ||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { | ||
Direction.Axis cardinalDir = state.get(AXIS); | ||
return switch (cardinalDir) { | ||
case X -> X_AXIS_BOX; | ||
case Y -> Y_AXIS_BOX; | ||
case Z -> Z_AXIS_BOX; | ||
}; | ||
} | ||
|
||
// Deals with placing the block properly in accordance to direction. | ||
@Override | ||
public BlockState getPlacementState(ItemPlacementContext context) { | ||
BlockState initialState = this.getDefaultState().with(AXIS, context.getSide().getAxis()); | ||
return getUpdatedState(context.getWorld(), context.getBlockPos(), initialState); | ||
} | ||
|
||
@Override | ||
public FluidState getFluidState(BlockState state) { | ||
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState(); | ||
} | ||
|
||
@Override | ||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { | ||
if (state.get(WATERLOGGED)) world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); | ||
|
||
return getUpdatedState(world, pos, state); | ||
} | ||
|
||
@Override | ||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) { | ||
stateManager.add(AXIS, MIN_CAP, MAX_CAP, WATERLOGGED); | ||
} | ||
|
||
public BlockState getUpdatedState(WorldAccess world, BlockPos pos, BlockState state) { | ||
Direction.Axis selfAxis = state.get(AXIS); | ||
|
||
BlockState minNeighbor = world.getBlockState(pos.offset(selfAxis, -1)); | ||
boolean minCap = !(minNeighbor.getBlock() instanceof OctagonalColumnBlock && | ||
minNeighbor.get(AXIS) == selfAxis); | ||
|
||
BlockState maxNeighbor = world.getBlockState(pos.offset(selfAxis, 1)); | ||
boolean maxCap = !(maxNeighbor.getBlock() instanceof OctagonalColumnBlock && | ||
maxNeighbor.get(AXIS) == selfAxis); | ||
|
||
return state.with(MIN_CAP, minCap).with(MAX_CAP, maxCap); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/io/github/debuggyteam/architecture_extensions/blocks/RoundArchBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package io.github.debuggyteam.architecture_extensions.blocks; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.HorizontalFacingBlock; | ||
import net.minecraft.block.enums.BlockHalf; | ||
import net.minecraft.item.ItemPlacementContext; | ||
import net.minecraft.state.StateManager; | ||
import net.minecraft.state.property.DirectionProperty; | ||
import net.minecraft.state.property.EnumProperty; | ||
import net.minecraft.state.property.Properties; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.shape.VoxelShape; | ||
import net.minecraft.util.shape.VoxelShapes; | ||
import net.minecraft.world.BlockView; | ||
|
||
import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings; | ||
|
||
public class RoundArchBlock extends HorizontalFacingBlock { | ||
public static final DirectionProperty FACING = HorizontalFacingBlock.FACING; | ||
public static final EnumProperty<BlockHalf> HALF = Properties.BLOCK_HALF; | ||
|
||
public RoundArchBlock(QuiltBlockSettings settings) { | ||
super(settings); | ||
} | ||
|
||
@Override | ||
public BlockState getPlacementState(ItemPlacementContext context) { | ||
// Thanks Falkreon | ||
BlockHalf half = switch(context.getSide()) { | ||
case UP -> BlockHalf.BOTTOM; | ||
case DOWN -> BlockHalf.TOP; | ||
default -> { | ||
double sideHitHeight = context.getHitPos().getY() - context.getBlockPos().getY(); | ||
if (sideHitHeight > 0.5) { | ||
yield BlockHalf.TOP; | ||
} else { | ||
yield BlockHalf.BOTTOM; | ||
} | ||
} | ||
}; | ||
|
||
return this.getDefaultState().with(FACING, context.getPlayerFacing()).with(HALF, half); | ||
} | ||
|
||
@Override | ||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) { | ||
super.appendProperties(builder); | ||
builder.add(FACING, HALF); | ||
} | ||
|
||
@Override | ||
public VoxelShape getCullingShape(BlockState state, BlockView world, BlockPos pos) { | ||
return VoxelShapes.empty(); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
src/main/java/io/github/debuggyteam/architecture_extensions/blocks/RoundFencePostBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package io.github.debuggyteam.architecture_extensions.blocks; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.PillarBlock; | ||
import net.minecraft.block.ShapeContext; | ||
import net.minecraft.block.Waterloggable; | ||
import net.minecraft.fluid.FluidState; | ||
import net.minecraft.fluid.Fluids; | ||
import net.minecraft.item.ItemPlacementContext; | ||
import net.minecraft.state.StateManager; | ||
import net.minecraft.state.property.BooleanProperty; | ||
import net.minecraft.state.property.EnumProperty; | ||
import net.minecraft.state.property.Properties; | ||
import net.minecraft.util.BlockRotation; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.Direction; | ||
import net.minecraft.util.shape.VoxelShape; | ||
import net.minecraft.world.BlockView; | ||
import net.minecraft.world.WorldAccess; | ||
|
||
public class RoundFencePostBlock extends PillarBlock implements Waterloggable { | ||
public static final EnumProperty<Direction.Axis> AXIS = Properties.AXIS; | ||
public static final BooleanProperty WATERLOGGED = Properties.WATERLOGGED; | ||
|
||
protected static final VoxelShape X_AXIS_BOX = Block.createCuboidShape(0.0, 5.0, 5.0, 16.0, 11.0, 11.0); | ||
protected static final VoxelShape Y_AXIS_BOX = Block.createCuboidShape(5.0, 0.0, 5.0, 11.0, 16.0, 11.0); | ||
protected static final VoxelShape Z_AXIS_BOX = Block.createCuboidShape(5.0, 5.0, 0.0, 11.0, 11.0, 16.0); | ||
|
||
public RoundFencePostBlock(Settings settings) { | ||
super(settings); | ||
setDefaultState(this.stateManager.getDefaultState().with(AXIS, Direction.Axis.Y)); | ||
} | ||
|
||
// The following deals with block rotation | ||
@Override | ||
public BlockState rotate(BlockState state, BlockRotation rotation) { | ||
return changeRotation(state, rotation); | ||
} | ||
|
||
public static BlockState changeRotation(BlockState state, BlockRotation rotation) { | ||
return switch (rotation) { | ||
case COUNTERCLOCKWISE_90, CLOCKWISE_90 -> switch (state.get(AXIS)) { | ||
case X -> state.with(AXIS, Direction.Axis.Z); | ||
case Z -> state.with(AXIS, Direction.Axis.X); | ||
default -> state; | ||
}; | ||
default -> state; | ||
}; | ||
} | ||
|
||
// Both of the following blocks of code below deals with block collision. | ||
@Override | ||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) { | ||
Direction.Axis cardinalDir = state.get(AXIS); | ||
return switch (cardinalDir) { | ||
case X -> X_AXIS_BOX; | ||
case Y -> Y_AXIS_BOX; | ||
case Z -> Z_AXIS_BOX; | ||
}; | ||
} | ||
|
||
// Deals with placing the block properly in accordance to direction. | ||
@Override | ||
public BlockState getPlacementState(ItemPlacementContext context) { | ||
return this.getDefaultState().with(AXIS, context.getSide().getAxis()).with(WATERLOGGED, context.getWorld().getFluidState(context.getBlockPos()).getFluid() == Fluids.WATER); | ||
} | ||
|
||
@Override | ||
public FluidState getFluidState(BlockState state) { | ||
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : Fluids.EMPTY.getDefaultState(); | ||
} | ||
|
||
@Override | ||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) { | ||
if (state.get(WATERLOGGED)) world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world)); | ||
|
||
return state; | ||
} | ||
|
||
@Override | ||
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) { | ||
stateManager.add(AXIS, WATERLOGGED); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.