Posted October 30, 20186 yr Hello guys, I had a little problem, I spend too much hours looking for the best solution. But i didnt find it. Can somebody explain me. I wants something like this: When i placed the block and block should be rotating where I looking. I had some code and the blocks rotating only to two sides. Code:https://pastebin.com/E5erjEYe Thanks for all helps. (sorry for my bad english)
October 30, 20186 yr Quote extends BlockBase BlockBase is an antipattern. You don't need it. Quote public void onBlockPlacedBy Don't set the blockstate in Block#onBlockPlaced or Block#onBlockPlacedBy. Just return the state you want in Block#getStateForPlacement. if(entityFacing == EnumFacing.NORTH) { entityFacing = EnumFacing.NORTH; } else if(entityFacing == EnumFacing.EAST) { entityFacing = EnumFacing.EAST; } else if(entityFacing == EnumFacing.SOUTH) { entityFacing = EnumFacing.SOUTH; } else if(entityFacing == EnumFacing.WEST) { entityFacing = EnumFacing.WEST; } if x is x then set the x to x? Why? This is equivalent to writing if (x == 1) x = 1; It does nothing. As for the rotation - this looks correct to me. See BlockFurnace#getStateForPlacement - it does a very similar thing. So I suspect the issue may be somewhere else. Could your please show your blockstate file?
October 30, 20186 yr Author Yea of course I this finded on this forum:https://pastebin.com/frHzCGwV and then I had 4 models for this but when I wants 1 it will be perfect. 5 minutes ago, V0idWa1k3r said: BlockBase is an antipattern. You don't need it. I know but, its doesnt matter. Its transparent to me. Edited October 30, 20186 yr by XpresS
October 30, 20186 yr That is not how forge's blockstate format works. You are trying to merge vanilla's blockstate format with forge's. Choose one. 7 minutes ago, XpresS said: I had 4 models for this but when I wants 1 it will be perfect. What do you need 4 models for? Just have one and rotate it around the Y axis. In fact you are already rotating them. This might be the cause of your issue.
October 30, 20186 yr Author Thank you very much. 24 minutes ago, V0idWa1k3r said: Don't set the blockstate in Block#onBlockPlaced or Block#onBlockPlacedBy. Just return the state you want in Block#getStateForPlacement. @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand).withProperty(FACING, placer.getHorizontalFacing()); } Maybe this will be then before. When somebody will have same problem as me the solution for this is on following lines: { "forge_marker": 1, "defaults": { "model": "prisonthings:red_chair1" }, "variants": { "facing=north": { "y": 0 }, "facing=east": { "y": 90 }, "facing=south": { "y": 180 }, "facing=west": { "y": 270 }, "inventory": { "model": "prisonthings:red_chair1", "transform": "forge:default-block" } } } Edited October 30, 20186 yr by XpresS
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.