adrianrv1999 0 Report post Posted June 19, 2018 (edited) Hello, i'm really new at minecraft modding but i know some java, i created a block chair and i want it to rotate when i place it, i mean, like stairs do in vanilla, i don't know how to look into vanilla code and i don't fing nothing searching, thanks for the help and sorry for probably sh*tt* question Edited June 19, 2018 by adrianrv1999 Share this post Link to post Share on other sites
diesieben07 6104 Report post Posted June 19, 2018 Forge and vanilla code is attached as a library in your IDE. Find it and open it to browse the code. 1 Share this post Link to post Share on other sites
adrianrv1999 0 Report post Posted June 19, 2018 1 minute ago, diesieben07 said: Forge and vanilla code is attached as a library in your IDE. Find it and open it to browse the code. Where i can find it in eclipse Share this post Link to post Share on other sites
diesieben07 6104 Report post Posted June 19, 2018 Just now, adrianrv1999 said: Where i can find it in eclipse This is not an Eclipse support forum. If I remember correctly, Eclipse will list libraries under "Referenced Libraries". 1 Share this post Link to post Share on other sites
adrianrv1999 0 Report post Posted June 19, 2018 (edited) 1 hour ago, diesieben07 said: This is not an Eclipse support forum. If I remember correctly, Eclipse will list libraries under "Referenced Libraries". finded it, thanks ❤️ but still haven't idea to rotate blocks Edited June 19, 2018 by adrianrv1999 Share this post Link to post Share on other sites
aw_wolfe 13 Report post Posted June 20, 2018 if you are looking for simple rotation, then stairs may not be the best example. Stairs rotate, but also can be placed upside down and their bounding boxes change. 1) add property facing to your block public static final PropertyDirection FACING = BlockHorizontal.FACING; 2) set default blockstate in the block constructor this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); 3) create the proper blockstatecontainer @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] { FACING}); } 4) meta-> blockstate and blockstate->meta. a meta value is store with each blockstate. you have to convert this to and from the blockstate property value (below is taken from one of my blocks with other properties removed manually without testing, but think it is ok) @Override public IBlockState getStateFromMeta(int meta) { EnumFacing enumfacing = EnumFacing.getFront(meta); if (enumfacing.getAxis() == EnumFacing.Axis.Y) { enumfacing = EnumFacing.NORTH; } return this.getDefaultState().withProperty(FACING, enumfacing); } @Override public int getMetaFromState(IBlockState state) { EnumFacing facing=state.getValue(FACING); int meta=((EnumFacing)state.getValue(FACING)).getIndex(); return meta; } 5)set the property values in the blockstate json. (the "mod" is your modid, the "model" is your model json which should be located in assets/[mod]/models/block. If you wanted different models for different directions, just change here. { "variants": { "facing=north": { "model": "mod:model" }, "facing=east": { "model": "mod:model", "y": 90 }, "facing=south": { "model": "mod:model", "y": 180 }, "facing=west": { "model": "mod:model", "y": 270 }, } } I think that is all you need. Good luck. Don't get discouraged modding, once you get used to looking into the minecraft code, it gets easier. 1 Share this post Link to post Share on other sites
diesieben07 6104 Report post Posted June 20, 2018 36 minutes ago, aw_wolfe said: Don't get discouraged modding, once you get used to looking into the minecraft code, it gets easier. Yes, and "just copy this" posts like yours don't help... Share this post Link to post Share on other sites
adrianrv1999 0 Report post Posted June 20, 2018 1 hour ago, aw_wolfe said: Don't get discouraged modding, once you get used to looking into the minecraft code, it gets easier. i'm so lost in minecraft code, always i don't know really what does what Share this post Link to post Share on other sites
aw_wolfe 13 Report post Posted June 20, 2018 There are tutorials out there. Just put some time into your problem before posting here. People (often the same people) have answered the same questions over and over and over again. If your issue looks like you thought it through and did some research, people will be more helpful (in general). https://shadowfacts.net/tutorials/forge-modding-112/ http://jabelarminecraft.blogspot.com/p/minecraft-modding-containers.html https://github.com/TheGreyGhost/MinecraftByExample 1 Share this post Link to post Share on other sites
Draco18s 1928 Report post Posted June 20, 2018 4 hours ago, aw_wolfe said: @Override public IBlockState getStateFromMeta(int meta) { EnumFacing enumfacing = EnumFacing.getFront(meta); if (enumfacing.getAxis() == EnumFacing.Axis.Y) { enumfacing = EnumFacing.NORTH; } return this.getDefaultState().withProperty(FACING, enumfacing); } This is over-engineered. The check for the Axis being Y and setting the facing to North isn't really needed. The only way this could ever happen is if you used external tools to force the block metadata to be something other than what the allowable states are. Use EnumFacing.getHorizontal(meta) instead. Quote @Override public int getMetaFromState(IBlockState state) { EnumFacing facing=state.getValue(FACING); int meta=((EnumFacing)state.getValue(FACING)).getIndex(); return meta; } This is likewise over-engineered copy paste "I don't know what the fuck I'm doing" garbage. You created a local facing variable and then don't even use it. You even cast the property to an EnumFacing (why?) and use getIndex, which is wrong. No wonder you have to fix things with the getAxis == Y.... return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); Share this post Link to post Share on other sites
Drachenbauer 0 Report post Posted February 10 (edited) On 6/20/2018 at 4:53 PM, Draco18s said: This is over-engineered. The check for the Axis being Y and setting the facing to North isn't really needed. The only way this could ever happen is if you used external tools to force the block metadata to be something other than what the allowable states are. Use EnumFacing.getHorizontal(meta) instead. This is likewise over-engineered copy paste "I don't know what the fuck I'm doing" garbage. You created a local facing variable and then don't even use it. You even cast the property to an EnumFacing (why?) and use getIndex, which is wrong. No wonder you have to fix things with the getAxis == Y.... return state.getValue(BlockHorizontal.FACING).getHorizontalIndex(); As i copyed aw_wolfe´s stuff into my block-class, i get purple, black blocks instead of my model, if I placing it in my Minecraft-test-world. I don´t know, what exactly i have to replace with the lines, you show here as a better choice... Edited February 10 by Drachenbauer Share this post Link to post Share on other sites
Meldexun 3 Report post Posted February 10 (edited) I'm not sure if you should make your own thread. But you should show us what you already have so that we can help you. Edited February 10 by Meldexun Share this post Link to post Share on other sites
Cadiboo 142 Report post Posted February 11 2 hours ago, Meldexun said: make your own thread And 2 hours ago, Meldexun said: show us what you already have so that we can help you. Share this post Link to post Share on other sites