Jump to content

[1.12] [Solved] Block not updating it state to others blocks.


AngheloAlf

Recommended Posts

Hi. It's me again.

 

I'm trying to make a block that outputs redstone on and off by a self timer.

The block is on for X ticks, and then is off by X ticks, and repeat (a clock).

It kinda works... The value inside the tile entity changes, but the output signal doesn't changes (neither the texture).

 

Code is here.

The problem is related with `blocks.LogicClock_Block.java` and `blocks.datablock.ClockEntity.java`.

 

I suspect there is a method that I am not overriding, but I don't know what it is...

 

Thanks ?

Edited by AngheloAlf
Link to comment
Share on other sites

When you update the counter in your TE you need to do 2 things:

In order for the texture to change you need to notify the client of the new value of the counter and tell it to re-render the block. TileEntity#markDirty only notifies the chunk that the data has changed and needs to be serialized, it doesn't do anything with the client.

When the state of the lit field changes you need to notify all neighbouring blocks of the change in order for the redstone to update. See BlockLever#onBlockActivated as an example of what to do.

Link to comment
Share on other sites

Thanks a lot! This fixed my problem.

 

What I did was add Block#notifyNeighborsOfStateChange into the update() method of my tile entity, just like this:

@Override
public void update(){
    counter -= lastCount * 4;
    if (counter <= 0) {
        lit = !lit;
        counter = 400;
        markDirty();
        world.notifyNeighborsOfStateChange(getPos(), blockType, false);
    }
}

 

I have one doubt remaining, what is the third argument (the boolean) of Block#notifyNeighborsOfStateChange supposed to mean? I put there a false, but I don't know what will change if I put true there.

 

Oh, and i just noticed that I forgot to put a title to my post. Ups. Is there a way to change it??

 

Thanks a lot again!

Link to comment
Share on other sites

Thanks a lot! This fixed my problem.

 

What I did was add Block#notifyNeighborsOfStateChange into the update() method of my tile entity, just like this:

@Override
public void update(){
    counter -= lastCount * 4;
    if (counter <= 0) {
        lit = !lit;
        counter = 400;
        markDirty();
        world.notifyNeighborsOfStateChange(getPos(), blockType, false);
    }
}

 

I have one doubt remaining, what is the third argument (the boolean) of Block#notifyNeighborsOfStateChange supposed to mean? I put there a false, but I don't know what will change if I put true there.

 

Oh, and i just noticed that I forgot to put a title to my post. Ups. Is there a way to change it??

 

Thanks a lot again!

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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