#[Fabric 1.21] Advanced Item
10 messages · Page 1 of 1 (latest)
The block handle the redstone signal while it was added or got neighbor update.
To give the block redstone signal, you have to do two things.
First, give the block an update. Second, change the result in world.isReceivingRedstonePower(pos) in every block that can receive redstone power.
I think the second one is difficult.
If you want to add affect to every block, i suggest you to write a non-box block. Use this block to replace the block you want to effect nearby, give an redstone power and update, remove it and set the original blockstate. (It may works but I'm not sure)
If you can only apply to limited block, it's better to just Inject their onUseWithItem method.
if (item.isOf(ModItems.ADVANCED_ITEM)) {
// copy all code in the isReceivingRedstonePower check
}
Thank you! :D this really helps! You don’t have to of course but is it ok if you explain what each thing does, if that makes sense? Of course I get what isRecievingRedstonePower means but what the ‘world’ means or why im referencing it
first you have to know what the object is. Maybe you have to learn some of Object-Oriented Programming.
some object like Entity has a parameter of world, it record which world the entity is.
some method can only be called in some object instance. isRecievingRedstonePower is a method in the class World's interface and it's non-static, so that you can only call it in a world instance.
The block never get a redstone signal, that's what it look like, not actually happended.
The real thing is that a block get a neighborUpdate, then check itself is recieving redstone power or not.
You can't give a neighborUpdate that only use a item touch it. so i suggest you to try to add a shadow block to give redstone power and remove it.
if you can give the block a redstone power and do not update it, it will be in a unstable state until it recieve a neighbor update. That's what the TNT duping works in JAVA edition.
Ohhh ok thank you :D
do u think itll be easier for me to have an actual block that i have to use the item on? like a lever but the only way to activate it is with the item
custom block i mean
in line 9 i dont understand why you need to get the block pos
i guess it was so i can check if the block clicked is a block that can recieve a redstone signal 😭