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.

Dandrel

Members
  • Joined

  • Last visited

  1. Thanks Elyon, my code is much more cleaner and easier to understand and works much better! As for the removeBlockByPlayer, I have never used this method before. Is this method called just like destroyedByPlayer as in it is called once it is destroyed?
  2. This is what the run code is Random rnd = new Random(); int num = rnd.nextInt(4); if(num ==0){ world.setBlock(x,y+1,z,this,0,3); } if(num == 1){ world.setBlock(x, y, z +1, this, 0, 3); } if(num ==2){ world.setBlock(x, y, z -1, this, 0, 3); } if(num ==3){ world.setBlock(x+1, y, z , this, 0, 3); } if(num ==4){ world.setBlock(x-1, y, z , this, 0, 3); } //Second block Random rnd2 = new Random(); int num2 = rnd.nextInt(4); while (num2==num){ num2 = rnd.nextInt(4); } if(num2 ==0){ world.setBlock(x,y+1,z,this,0,3); } if(num2 == 1){ world.setBlock(x, y, z +1, this, 0, 3); } if(num2 ==2){ world.setBlock(x, y, z -1, this, 0, 3); } if(num2 ==3){ world.setBlock(x+1, y, z , this, 0, 3); } if(num2 ==4){ world.setBlock(x-1, y, z , this, 0, 3); }
  3. Basically, I have code in the onBlockDestroyedByPlayer that I want to run each time the block is destroyed. However, I want the code to be in an if statement for example if("toolusedtodestroyblock" != DiamondPickaxe) { Run Code } So what i need is to get whatever tool is used to destroy the block. I am assuming I need access to the player class
  4. Hi Does anybody know how I would go about gaining access the instance of entity player that destroyed a block? My overall aim is to detect what tool was used to destroy the block in the onBlockDestroyedByPlayer Thanks

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.