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

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.

  • Author

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!

  • Author

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!

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.