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

Hello. I want to use the replaceBlock function, to change the block when it's right clicked with a certain item. I have it @Override onBlockActivated, then check the item in the player's hand. The problem I've run into i getting the other blocks state. I've tried creating a variable in the other block with this.getDefaultState, but when I use it somewhere else, I get an unclassified usage. So I made a new variable, that simply is the same as the other one, only this one is created inside the block being replace's class. However, it says that the variable in the other class needs to be static, but when I make it static, this.getDefaultState doesn't work. How would I get the other blocks state into my block?

Here's my @Override code:

@Override
public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {

    if (player.getHeldItemMainhand().getItem() == RegistryHandler.WRENCH.get()) {

        RightCurvedBelt.replaceBlock(state, NEWSTATE, worldIn, pos, getHarvestLevel(state));
    }

And here's the 2 variables I've tried to make

public static final BlockState RSTATE = this.getDefaultState();
private static final BlockState NEWSTATE = RightCurvedBelt.RSTATE;

 

Edited by MrInfinity

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.