Jump to content

Recommended Posts

Posted

Hi !

I'm creating a custom block that recieves a redstone signal from any face.

A TileEntity implementing ITickable is created by this block.

In the ITickable::update method, I'm getting the current power using World::isBlockIndirectlyGettingPowered.

It works...a bit.

Screenshot

On this screenshot, the block on the right will receive a power of 15 whereas the block on the left will receive a power of 0. I really don't know why.

My Block class :

public class BlockRedstoneReceiver extends BlockRedstoneDevice {

	public BlockRedstoneReceiver(String name, Material mat, CreativeTabs tab, float hardness, float resistance,
			String tool, int harvest, float light) {
		super(name, mat, tab, hardness, resistance, tool, harvest, light, GuiHandler.REDSTONE_RECEIVER_GUI);
	}

	@Override
	public TileEntity createTileEntity(World world, IBlockState state) {
		return new TileEntityRedstoneReceiver();
	}

}

The block superclass overrides Block::canConnectRedstone to return true.

I'm stuck now. Maybe I forgot something on the block class but I'm not sure... if someone can help me !

Posted (edited)

Check how vanilla does it at BlockRedstoneDiode. I believe it has something to do with the fact that Block::canConnectRedstone is actually irrelevant when it comes to recieving weak power and is relevant when it comes to sending it.

Edited by V0idWa1k3r
  • Like 1
Posted

Yeah, that's probably that for the Block::canConnectRedstone.

I looked at  BlockRedstoneDiode::updateTick but it seems that it only checks if it has power or not - and I want to check how much power I have.

Posted
1 minute ago, Franckyi said:

I looked at  BlockRedstoneDiode::updateTick

BlockRedstoneDiode::calculateInputStrength is the method you are looking for, not it's update tick. You can adapt the code from that method to check all faces instead of just the input one.

  • Like 1

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.