Everything posted by Azathoth YS
-
[1.12] Problem when rotating a rail
I didn't explained what I did very well : I tried all flags from 0 up to 11, and none of them chaged anything.
-
[1.12] Problem when rotating a rail
I tried changing the flag from 0 to 11 and none of them worked (also removing the flag sets it to 3). The problem doesn't seems to be the block update, as in my MCP-modified game, the rail do updates (flag 11). I also tried to delete the block and setting it again with the different state, but that also doesn't work. Even rotating a rail which doesn't have any neighbors doesn't work. I really don't know what else I can try.
-
[1.12] Problem when rotating a rail
Thanks for the answer and for the tip. The thing is that this code works outside of forge, and even a rail which isn't connected to another rail on any side doesn't change. Here is 3 gifs of what is happening : - vanilla coding (no forge) -> what should be happening : http://gph.is/2ueCnHY - forge version : http://gph.is/2vCXDdX - edited forge version (changes both server and client) : http://gph.is/2ue6nUu What I think is happening is that forge sends a block update when I change the state of the rail. But how can I stop that ?
-
[1.12] Problem when rotating a rail
Hello, I'm kinda new to modding, and I'm trying to make a wrench that can cycle though every facing of a block. I came up with a way to do so for every vanilla block (by editing the game code via MCP, without forge), but I had some troubles with the new launcher and so I tried creating a forge mod. What I have now do work for every block in vanilla but I'm experiencing a very weird thing for all rails : it just flaches to it's next possible facing and then back to it's previous state. Also every rail that I place faces the north_south direction, I can't place them to the east/west. My code doesn't change the way rails behave and no other block do the flash thing, I tried multiple ways of doing it and it is the only thing that happen. My code : public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY) { ItemStack itemstack = stack.getHeldItem(pos); if (!stack.canPlayerEdit(worldIn.offset(hand), hand, itemstack)) { return EnumActionResult.FAIL; } else { IBlockState iblockstate = playerIn.getBlockState(worldIn); iblockstate = rotateState(iblockstate, iblockstate.getBlock(), playerIn, worldIn); if (playerIn.getBlockState(worldIn) != iblockstate) { setBlock(itemstack, stack, playerIn, worldIn, iblockstate); System.out.println("Rotation with wrench succeded!"); return EnumActionResult.SUCCESS; } else { System.out.println("Rotation with wrench failed!"); return EnumActionResult.FAIL; } } } public IBlockState rotateState(IBlockState iblockstate, Block block, World world, BlockPos blockPos) { if (!(block instanceof BlockRailBase) && !(block instanceof BlockLever)) { // rotating other blocks ... } else if (block instanceof BlockRailBase) { // here I am using the 'withRotation' method, but 'cycleProperty' outputs the same thing Rotation[] arotation = Rotation.values(); Rotation rotate = arotation[1]; System.out.println("old state :" + iblockstate); iblockstate = block.withRotation(iblockstate, rotate); System.out.println("new state :" + iblockstate); return iblockstate; } else { // rotating a lever... } // by default: return iblockstate; } protected void setBlock(ItemStack stack, EntityPlayer player, World worldIn, BlockPos pos, IBlockState state) { worldIn.playSound(player, pos, SoundEvents.BLOCK_LEVER_CLICK, SoundCategory.BLOCKS, 0.3F, 1.0F); if (!worldIn.isRemote || true) // always true to have both Client and Server feedback on screen, else the rail stays the same on screen and doesn't flash to it's next facing and back again { System.out.println("Set Block result : " + worldIn.setBlockState(pos, state, 11)); if (MathHelper.getInt(worldIn.rand, 0, 4) == 0) { stack.damageItem(1, player); // 1 in 4 chance to damage the wrench. } } } The output on this when is right click a rail is : old state :minecraft:rail[shape=north_south] new state :minecraft:rail[shape=east_west] Set Block result : true Rotation with wrench succeded! On screen, the rail rotates but imediatly after it changes back to how it was before. Since this code works on vanilla but not on forge, is it a problem from forge or in my code ?
IPS spam blocked by CleanTalk.