I'm working on creating an easy-to-use system for modded blocks that don't have the proper mirror and rotate methods overridden, so I can use them in structures. What I have so far that somewhat works for my purposes is a custom block that uses the model of the "real" block, overriding the mirror and rotate methods, based on an issue posted on the KubeJS GitHub.
event.create('ulszsurvival:replacesink', "cardinal").material('wood')
.hardness(0.4)
.soundType("ladder")
.textureAll('surv:block/decayed_ladder')
.defaultCutout()
.property(BlockProperties.WATERLOGGED)
.tagBlock("minecraft:climbable")
.model("pfm:block/basic_sink/basic_sink")
.rotateState(ctx => ctx.set(BlockProperties.HORIZONTAL_FACING, ctx.rotate(ctx.get(BlockProperties.HORIZONTAL_FACING))))
.mirrorState(ctx => ctx.set(BlockProperties.HORIZONTAL_FACING, ctx.mirror(ctx.get(BlockProperties.HORIZONTAL_FACING))))
.rightClick(ctx => {
ctx.server.scheduleInTicks(1, () => {
// Get the new block with properties
let newBlock = Block.getBlock("pfm:basic_sink").withPropertiesOf(ctx.block.blockState);
let currentFacing = ctx.block.blockState.getValue(BlockProperties.HORIZONTAL_FACING);
// Determine the flipped facing direction
let flippedFacing;
switch (currentFacing) {
case Direction.NORTH:
flippedFacing = Direction.NORTH;
break;
case Direction.SOUTH:
flippedFacing = Direction.SOUTH;
break;
case Direction.WEST:
flippedFacing = Direction.WEST;
break;
case Direction.EAST:
flippedFacing = Direction.EAST;
break;
default:
flippedFacing = currentFacing;
break;
}
// Create a new block state with the flipped facing direction
newBlock = newBlock.setValue(BlockProperties.HORIZONTAL_FACING, flippedFacing);
// Schedule the block placement to avoid immediate execution issues
ctx.getLevel().setBlock(ctx.block.pos, newBlock, 3);
});
})
.displayName("Placeholder Sink")
The custom block transforms into a correctly mirrored "real" block upon right-clicking. My issue is that it's cumbersome for players to have to right-click on these blocks while exploring my structures to access the modded block's functionality. Is there any clever way to automate this process, possibly using Forge events or another method? I couldn't find any relevant information in the documentation, but I might have missed something.