Redstone related functions


#1

Heya!

I would like to make a suggestion, as I feel that it’s extremely hard to do anything related to redstone (currently, it would request us to make custom properties and complex functions to reproduce what’s already included in the base minecraft)
I know there are a few properties for redstone stuff, but they are far from being enough. For instance, I can’t even know if a dispenser is powered or not.

What I’m thinking is to add properties to blocks affected by redstone. This would be great so we can add custom functions related to redstone systems.


#2

PoweredProperty works for that specific reason already. Blockstates do not stored whether a TileEntity is powered, it’s an environmental property you can call on in the instant you’re checking.

What properties are you looking for? There’s several intended for this sort of case.


#3

Well… I maybe missed something, since I’m still quite a rooky with sponge plugins…
I use NotifyNeighborBlockEvent to check whenever a redstore wire is powered or not next to a dispenser, and once I get a dispenser with event.getNeighbors(), checked all properties related to redstone (including PoweredProperty), seeing all of them returned an empty Optional, I did getProperties() and listed them, but I find the PoweredProperty key nowhere. Maybe I made a mistake? What is supposed to hold PoweredProperty?

Thank you for your reply.

EDIT: Oh, and to reply your question… I simply would like to get the current power the dispenser is getting to make a special function with it (for both when it get powered and not)


#4

The PoweredProperty should be part of the Location: location.getProperty(PoweredProperty.class).get().


#5

Damn, wouldn’t have thought about checking the location instead of any kind of class block… Thank you very much, I finally did what I wanted to do.
Otherwise, since we are in the same topic, I have a last question… When I was doing my researches, I noticed a topic 2 years ago.

PoweredProperty was supposed to return a int, giving the intensity of the redstone received. Isn’t it the case anymore? I thought it was a very interesting addition, but I’m not sure about the reasons it’s a boolean again now.

Anyway, thank you for your help. I have to admit it wasn’t much intuitive to check to the locations for the redstone power :x


#6

It’s just one of those things you learn. Sponge’s Location<> is used both as an actual location and to access the block at that location. BlockState is a separate concept - a combination of BlockType and Keys which produce a data value.