I'm trying to implement a block that rotates like a log would when it is placed. I cannot find any information on this for the latest versions of fabric, and the "rotational block" tutorial on the fabric website made my game crash. here is the code I have currently:
public class LogBlock extends Block{
public static final DirectionProperty DIRECTION = DirectionProperty.of("direction");
public LogBlock(Settings settings) {
super(settings);
setDefaultState(getStateManager().getDefaultState().with(DIRECTION, Direction.UP));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(DIRECTION);
}
}
The easiest way to emulate a vanilla block is to copy its code and make any necessary changes (ID/texture/name/texture, model, blockstate files). For example (this is from 1.6.4 so it is probably completely different; obviously, there are no longer numerical block IDs, instead you use a string, and the texture name (there are two textures, for the inside and the bark) may now be set within the model file. The main thing to note is that logs have special placement and drop mechanics so they almost certainly use a custom class, unless that can be set within the model/blockstate files):
public static final Block wood = (new BlockLog(17)).setHardness(2.0F).setStepSound(soundWoodFootstep).setUnlocalizedName("log").setTextureName("log");
public static final Block customLog = (new BlockLog(200)).setHardness(2.0F).setStepSound(soundWoodFootstep).setUnlocalizedName("customLog").setTextureName("customLog");
// Alternatively, extend the vanilla BlockLog class if you need to add any special overrides to the vanilla
// log behavior
public class BlockCustomLog extends BlockLog ...
// Then register block with whatever method your API uses (the code above is how vanilla 1.6.4 "registers"
// blocks)
Of course, this assumes you even have access to the vanilla source (I have no idea how anybody even develops mods without it; of course, all my modding experience is with MCP, which is simply altering and adding to the vanilla source, but at the very least you still need to know the constructor and method parameters to really do anything with it).
I'm trying to implement a block that rotates like a log would when it is placed. I cannot find any information on this for the latest versions of fabric, and the "rotational block" tutorial on the fabric website made my game crash. here is the code I have currently:
For the blockstate file:
I hope for a solution that isn't too difficult, as it is my first time modding with fabric.
Thanks,
Diskman.
What is the crash message?
The easiest way to emulate a vanilla block is to copy its code and make any necessary changes (ID/texture/name/texture, model, blockstate files). For example (this is from 1.6.4 so it is probably completely different; obviously, there are no longer numerical block IDs, instead you use a string, and the texture name (there are two textures, for the inside and the bark) may now be set within the model file. The main thing to note is that logs have special placement and drop mechanics so they almost certainly use a custom class, unless that can be set within the model/blockstate files):
Of course, this assumes you even have access to the vanilla source (I have no idea how anybody even develops mods without it; of course, all my modding experience is with MCP, which is simply altering and adding to the vanilla source, but at the very least you still need to know the constructor and method parameters to really do anything with it).
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?