Skip to content

Commit 25cd22a

Browse files
Documentation update, add section for using LevelPollution
1 parent a2158ef commit 25cd22a

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

docs/extending.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
The content here assumes you have read the custom resolvers section of [how_to.md](how_to.md#custom-registries-and-resolvers)
44
and have a passing knowledge of writing mixins.
55

6+
**This document is incomplete and not extensive, I'm trying my best to make this make sense**
7+
68
## Adding destruction methods
79

810
The general idea of how to add a new cause of pollution is as simple as a single mixin, throw it in where it will be

docs/how_to.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ so references to an `X_REGISTRY_KEY` can be replaced with the `getRegistryKey()`
101101

102102
## Events
103103

104+
### Catching
105+
104106
There is a single event provided by this api, that being [`PollutionEvent`](../src/main/java/io/github/real_septicake/compressed_pollution/events/PollutionEvent.java).
105107
This is a generic fired whenever pollution is about to be applied to a `Level` that can be filtered to when a specific
106108
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.
121123
There are two main ways to fire off this event. The first was mentioned previously, being the `fireEvent()` methods on the
122124
resolver classes, which creates the event based on the arguments passed to it as well as the data of the resolver itself.
123125

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
125127
of causing the event, allowing explicit assignment of each value in the event. This static function passes off
126128
the parameters to the event batcher, which deduplicates and merges pollution objects that would cause the same event to
127129
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
142+
allowing for any modification before-hand.

0 commit comments

Comments
 (0)