You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/how_to.md
+16-2Lines changed: 16 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,6 +101,8 @@ so references to an `X_REGISTRY_KEY` can be replaced with the `getRegistryKey()`
101
101
102
102
## Events
103
103
104
+
### Catching
105
+
104
106
There is a single event provided by this api, that being [`PollutionEvent`](../src/main/java/io/github/real_septicake/compressed_pollution/events/PollutionEvent.java).
105
107
This is a generic fired whenever pollution is about to be applied to a `Level` that can be filtered to when a specific
106
108
class "type" causes it, e.g. a stack of items being dropped in lava fires a `PollutionEvent` for `Item.class`, a fluid
@@ -121,8 +123,20 @@ modified, canceled outright, or simply left alone.
121
123
There are two main ways to fire off this event. The first was mentioned previously, being the `fireEvent()` methods on the
122
124
resolver classes, which creates the event based on the arguments passed to it as well as the data of the resolver itself.
123
125
124
-
The second, which `fireEvent()` is backed by, is `CompressedPollution#handlePollution()`, which is a more direct and way
126
+
The second, which `fireEvent()` is backed by, is `CompressedPollution#handlePollution()`, which is a more direct way
125
127
of causing the event, allowing explicit assignment of each value in the event. This static function passes off
126
128
the parameters to the event batcher, which deduplicates and merges pollution objects that would cause the same event to
127
129
be fired. The events themselves are dispatched at the end of the server's tick, to be passed onto the handlers to cause
128
-
whatever changes or cancellations they end up doing.
130
+
whatever changes or cancellations they end up doing.
131
+
132
+
## Level Pollution
133
+
134
+
There's been a *lot* of talk pollution thus far, more specifically how to create it. But that does leave the question,
135
+
how do you interact with this pollution once it's been created?
136
+
137
+
`LevelPollution` objects are attached to levels, and are where the pollution from the events gets put after they've
138
+
passed through the handlers. Obtaining the object for a level is done via the `getFromLevel()` static function in the
139
+
same class, providing the level you want to get the pollution levels for as the argument. The values of different
140
+
pollutants can be queried through `getPollutant()` and modified via `setPollutant()` and `addPollutant()`. Do note
141
+
that the functions that modify the pollutant values *do not* trigger event handlers, they get applied as-is without
0 commit comments