Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Shifty887

Members
  • Joined

  • Last visited

Everything posted by Shifty887

  1. 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
  2. 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.
  3. Only because thats what the ItemTool class does (the super class).
  4. 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 ?
  5. 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.
  6. 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 ?
  7. 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.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.