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.

Featured Replies

Posted

I am using the code

        			worldIn.destroyBlock(pos.add(0, 0, i), false);

(i being a variable) to destroy multiple blocks at once. The blocks are being removed but aren't updating, still showing as what they were before until I relog. How can I force a block update at the location?

  • Author

I am using the code

        			worldIn.destroyBlock(pos.add(0, 0, i), false);

(i being a variable) to destroy multiple blocks at once. The blocks are being removed but aren't updating, still showing as what they were before until I relog. How can I force a block update at the location?

Are you calling this ONLY (!world.isRemote) server side?

1.7.10 is no longer supported by forge, you are on your own.

Are you calling this ONLY (!world.isRemote) server side?

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Are you calling this ONLY (!world.isRemote) server side?

Yes, here is my whole code for the action.

    public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        if (!worldIn.isRemote) {
        	for (int i = 0; i < 2; i++){
        			if (worldIn.getBlockState(pos.add(0, 0, i)).getBlock().equals(Blocks.STONE) && playerIn.canPlayerEdit(pos.add(0, 0, i), facing, stack)){
        			worldIn.destroyBlock(pos.add(0, 0, i), false);
            			//worldIn.getBlockState(pos.add(0,0,i)).getBlock().removedByPlayer(worldIn.getBlockState(pos.add(0,0,i)),
            					//worldIn, pos.add(0,0,i), playerIn, true);
        			worldIn.scheduleBlockUpdate(pos, worldIn.getBlockState(pos.add(0,0,i)).getBlock(), 1, 100);
        			}
        	}
        }

The first block is the only one that actually gets updated and is shown breaking. The second one does not update.

  • Author

Are you calling this ONLY (!world.isRemote) server side?

Yes, here is my whole code for the action.

    public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        if (!worldIn.isRemote) {
        	for (int i = 0; i < 2; i++){
        			if (worldIn.getBlockState(pos.add(0, 0, i)).getBlock().equals(Blocks.STONE) && playerIn.canPlayerEdit(pos.add(0, 0, i), facing, stack)){
        			worldIn.destroyBlock(pos.add(0, 0, i), false);
            			//worldIn.getBlockState(pos.add(0,0,i)).getBlock().removedByPlayer(worldIn.getBlockState(pos.add(0,0,i)),
            					//worldIn, pos.add(0,0,i), playerIn, true);
        			worldIn.scheduleBlockUpdate(pos, worldIn.getBlockState(pos.add(0,0,i)).getBlock(), 1, 100);
        			}
        	}
        }

The first block is the only one that actually gets updated and is shown breaking. The second one does not update.

  • Author

Why are you calling scheduleBlockUpdate?

To attempt to update the block since it is broken but doesn't update until relog. Is there another thing I could use?

  • Author

Why are you calling scheduleBlockUpdate?

To attempt to update the block since it is broken but doesn't update until relog. Is there another thing I could use?

  • Author

Just tried it, works just fine with just

destroyBlock

:

 

Mine's done on right click, if that changes anything.

   
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        if (!worldIn.isRemote) {
        	int dir = MathHelper.floor_double((double)((playerIn.rotationYaw * 4F) / 360F) + 0.5D) & 3;
    		if (dir == 0){
        	for (int i = 0; i < 2; i++){
        			if (worldIn.getBlockState(pos.add(0, 0, i)).getBlock().equals(Blocks.STONE)){
        			worldIn.destroyBlock(pos.add(0, 0, i), false);
        			}
        			if (worldIn.getBlockState(pos.add(1, 0, i)).getBlock().equals(Blocks.STONE)){
        			worldIn.destroyBlock(pos.add(1, 0, i), false);
        			}        			if (worldIn.getBlockState(pos.add(-1, 0, i)).getBlock().equals(Blocks.STONE)){
        			worldIn.destroyBlock(pos.add(-1, 0, i), false);

        			}
        		}
    		}
        }
	return null;
    }

Full code

EDIT: Longer gif

  • Author

Why in god's name are you returning null?

Just changed it to return SUCCESS and it worked. Thank you so much!

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.