Posted August 8, 201510 yr I need to be able to 1) get a block from the world (done). 2) rotate that block to the player's direction (done- but messy atm). 3) place the block back in the world (done). I was wondering what the best way to rotate a block in this instance (right now I am manipulating the property "FACING" (if it exists) in its IBlockState) to face the correct direction. Is there a way to change ANY block's facing without having to manipulate the properties directly ? Let me add a little more info as well: a) I get a block from the world, save all its data to a file and bring it back. (this works) b) I have to be able to bring the block back into existence and using the properties I've saved (this works) c) Its when bringing back the block into the world and having to change the facing (because its not facing the original direction that it was selected from) that I am dealing with (works, but messy and has to deal directly with the FACING property). I don't keep an open mind lest someone try to fill it with garbage - Mark Twain
August 8, 201510 yr Hi What's your concern with manipulating FACING? That's for sure the most portable and robust way to do it. Back in the bad old days of 1.7.10 you had to know the metadata encoding of every block... You might find this class useful https://gist.github.com/TheGreyGhost/d3e89af8f4121bd63acc -TGG
August 8, 201510 yr Author Thanks, I'll give it a look see I've got a cut/paste thing (multiple blocks) going for my mod and would prefer a better way to perform the paste portion with a rotation without having to directly manipulate the properties (which is messy).... I did something similiar to your class (although not as well thought out as yours for facing, but it seems messy.... I'm looking for a way to maybe use the block.rotateBlock instead as this will handle any other changes besides facing that have to be handled.... I don't keep an open mind lest someone try to fill it with garbage - Mark Twain
August 8, 201510 yr Hi From memory, the block.rotateBlock() was a Forge addition and it only works rotating the block in place (i.e. a block which is already placed into the world). You could use that if you're willing to place the block then rotate it. -TGG
August 8, 201510 yr Author Suppose I could do that after I re-create the block. I would hope that any attachments (fences etc) are updated when the block is rotated as well. If not then it could get VERY ugly code It does not seem to work- I set the BlockProperties correctly and it places the block, but when I attempt the rotate after that (passing block.rotateBlock(((EntityPlayer) sender).worldObj, pos, rot) it returns true but doesn't seem to update the world. If its an older part of Forge, maybe its not working correctly since 1.8 ? Or is there another process to correctly using rotateBlock ? For the record for now I've settled on a direction re-map function (I know the direction the block was "grabbed" and the player direction) and just re-map the grabbed direction based on the player direction (simple enough but it would be nice not to have to manipulate the facing property directly).... I don't keep an open mind lest someone try to fill it with garbage - Mark Twain
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.