-
World.destroyBlock not visible by other players
So I changed to use packets - following your tutorial diesieben07 and it all works. So thanks for that! Secondly I was seeing strange results because I was testing it lazily - ie only firing up the client and/or opening it to LAN. The reason I was doing this is because when I start the test server and connect to it through the test client I can't seem to break any blocks. I've noticed this is only when I have it in offline mode and set the flag on the client to allow invalid credentials. If I have it in online mode and use my account's login details then it works but I can no longer test with multiple clients as I can only be logged in on one client at a time. Also is there any doc showing which methods are called on what side ? If I had known that this method was only called on the client that would have saved some time. I'll continue to look into this / writing some tests to avoid doing it manually. But the original problem I posted about has now been fixed so thanks to all who helped
-
World.destroyBlock not visible by other players
Apologies I meant Item not ItemTool. I'll look into packets to send the update to the server on right click. Seems a bit over complicated though.
-
World.destroyBlock not visible by other players
Only because thats what the ItemTool class does (the super class).
-
World.destroyBlock not visible by other players
Is there a better method than onItemUse then ? A method that does execute on the server that happens on right click or that I can check to see if the player is right clicking ?
-
World.destroyBlock not visible by other players
Here is the code in question as requested: @Override public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if(!world.isRemote) { if (player.isSneaking()) { if (facing != EnumFacing.DOWN) { placeTorch(world, pos.offset(facing), facing); } } else { world.destroyBlock(pos, true); } } return EnumActionResult.PASS; } private void placeTorch(World world, BlockPos pos, EnumFacing facing) { IBlockState torch = Blocks.TORCH.getDefaultState(); world.setBlockState(pos, torch.withProperty(BlockTorch.FACING, facing)); } Basically If I right click then it removes the block, if I shift right click it places a torch. This works from the clients perspective.
-
World.destroyBlock not visible by other players
Ok I suspected as much. What method should I be using then ? Or do I need to send some request to the server to do the deletion from that method ?
-
World.destroyBlock not visible by other players
Hi, Making my first mod so forgive me if this is trivial. I have a pickaxe which mines multiple blocks. I use the onBlockDestroyed method to remove all adjacent blocks in a given direction, effectively the pickaxe now mines 9 blocks at a time. This currently works. The problem is that its now impossible to mine a single block which can cause problems - like mining upwards. So i added a right click to destroy a single block. I did this using the onItemUse method. However this does not work for other players, when a player right clicks they see the block disappear but the other players do not. Leaving this 'ghost' block behind - other players can still mine it themselves. I thought this must be a client/server issue so after a quick search I found world.isRemote. Now I only call world.destroyBlock when !world.isRemote so that it runs on the server. But still the same issue, the player who clicks can see the block disappear but noone else. I've tried looking through the other src files and other peoples mods with no luck. Any help will be greatly appreciated. On a side note what is the best way to test this. I tried launching the server through the IntelliJ run config and then multiple clients. But the only way to get multiple clients is to set offline-mode to false and then suddenly none of the clients can remove blocks, they instantly reappear (seems wrong). Which means I can only test it with 1 client and can't see if I've fixed the issue or not.
IPS spam blocked by CleanTalk.