Jump to content

Recommended Posts

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);
    }

 

Posted
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.

Posted

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.

Posted

@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

Posted
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

Posted
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. 

Posted
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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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