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

Hi there :D

 

I'm currently working on a block that acts kind of like a barrel, where the player can store some items. If the player is holding valid items to store in his hand when he activates the barrel, it will automatically take as much as needed to fill the barrel (64 items) from the stack that is on the player's hand. The problem is that the barrel has different models for its different "fullness states", and I can get it to show that state only using the barrel. I have to feed it with items and then force it to update breaking or placing nearby blocks. I can reference all the code you need, but here is what I tried to use to update the block whenever the player interacts with it.

 

public void updateBlock(World worldIn, IBlockState state) {
         this.markDirty();
         worldIn.notifyBlockUpdate(this.getPos(), state, BlockBarrel.changeStateOverFullness(this, worldIn, state, pos), 0x3 );

         //Todo remove this, just for testing purposes
        world.setBlockState(pos, state);
    }

 

1 hour ago, Fireruner said:

 


public void updateBlock(World worldIn, IBlockState state) {
         this.markDirty();
         worldIn.notifyBlockUpdate(this.getPos(), state, BlockBarrel.changeStateOverFullness(this, worldIn, state, pos), 0x3 );

         //Todo remove this, just for testing purposes
        world.setBlockState(pos, state);
    }

Try


// All state variables should be the same.
world.notifyBlockUpdate(message.getPos(), state, state, 3);
world.markBlockRangeForRenderUpdate(pos, pos);
world.scheduleBlockUpdate(pos, state.getBlock(), 0, 0);

 

 

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Make sure that you've overridden getActualState to get the fullness level from the TE

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

@Animefan8888 

23 hours ago, Animefan8888 said:

// All state variables should be the same.
world.notifyBlockUpdate(message.getPos(), state, state, 3);
world.markBlockRangeForRenderUpdate(pos, pos);
world.scheduleBlockUpdate(pos, state.getBlock(), 0, 0);

not working :C I dont really know what I am doing wrong, and peole who knows a lot of modding sent me here because they didnt neither. Do u want the full files so you can take a look at them? I dont know what to do

  • Author
19 hours ago, Draco18s said:

Make sure that you've overridden getActualState to get the fullness level from the TE

It its overriden, but still not working. The problem is that getActualState gets called only when Minecraft wants to call it, so when the player interacts with the block I dont know how to force Minecraft to check the state of the block. Its kinda confusing because when you use it, and change blocks arround it gets updated to the correct state. But only if you force Minecraft to update it changing blocks arround it. Its strange :C

  • Author
7 minutes ago, diesieben07 said:

What does this do?

 

If you store the fullness in the TE, you need to make sure it is synced to the client properly.

That method asks the TE how full is the block and if it is processing the content or has finished processing it. Thats not the problem I think, because when getActualState gets called, it runs perfectly. My problem is that I need to tell Minecraft to call getActualState after the player interacts with the block. I have a log on getActualState so I can see when it gets called, and when it gets called by Minecraft it updates the block just perfect, but when the player uses the block it doesnt get called. 

  • Author
36 minutes ago, diesieben07 said:

Why is it returning an IBlockState? Why are you passing that block state to notifyBlockUpdate?

Just testing if the 2 states recieved there should be different or something, tested with the same states on both parametters, and still nothing. It returns a IBlockState because is an auxiliar method for the getActualState of the block that gets the values from the TE and process them. Not really usefull here, but I was testing.

 

38 minutes ago, diesieben07 said:

notifyBlockUpdate should call getActualState. Make sure you do it on the client though, after the new TE data is received.

Yeah, right? That's what I thought, but is not doing it. I think that this code runs both on server and on client, but lemme double check

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.