#Globally-Ticking fields

5 messages · Page 1 of 1 (latest)

blazing sundial
#

I would like to create a global wind value based on a simplex noise sampler, the value of which could be accessed by any entity such that two entities at the same position would return the same value. At first glance this is easy because simplex noise is deterministic, but I would also like to be able to scroll that simplex sampler over time to provide changing wind direction.

My current thought is that I could create a new superclass of Entity at the lowest level from which all my wind-sensitive subclasses would inherit, but I would have to do some very ugly inheritance shuffling, and it wouldn't really solve the major problem: synchronization of the wind direction noise scrolling factor across all entities. EG: I need an entity I created last week and one I created five minutes ago to give me the same wind value at the same coordinate, even though I've been scrolling the wind noise sampler all along.

Is there a non-stupid way to do this? If nothing else, I figure I could use the inheritance solution and base the scrolling factor on some global variable like uptime, presuming such a thing exists. Advice would be greatly appreciated though.

elfin zodiac
#

I'd attach the wind calculator to the level instead, then just get values from the entity using this.level or similar. You could scroll it using the level's gameTime().

blazing sundial
#

I imagine I'd at least have to mixin the accessor

elfin zodiac
#

I'd create an interface like WindProvider with a method like Vec3 getWindAt(BlockPos pos);, then implement it with a mixin onto Level