Skip to content

Commit ec48561

Browse files
committed
feat(api): add PotentSulfur block entity representation
Additions: - New BlockEntity interface for the potent sulfur geyser exposing the dormant/erupting countdown - Keys.ERUPTION_COUNTDOWN (sponge-namespaced, Ticks-valued) backs the countdown value; pairs with BlockStateKeys.POTENT_SULFUR_STATE for the visible state flip. See: https://minecraft.wiki/w/Potent_Sulfur
1 parent c1df828 commit ec48561

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) SpongePowered <https://www.spongepowered.org>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package org.spongepowered.api.block.entity;
26+
27+
import org.spongepowered.api.data.BlockStateKeys;
28+
import org.spongepowered.api.data.Keys;
29+
import org.spongepowered.api.data.value.Value;
30+
import org.spongepowered.api.util.Ticks;
31+
32+
/**
33+
* Represents a geyser-like, periodically erupting block that applies a
34+
* nausea effect to nearby living entities while a suitable noxious source
35+
* exists above it, and may launch entities upward during an eruption.
36+
*
37+
* <p>The countdown exposed by {@link #eruptionCountdown()} advances each
38+
* server tick the block entity finds a valid source; when it elapses the
39+
* block toggles between its dormant and erupting block-state forms (see
40+
* {@link BlockStateKeys#POTENT_SULFUR_STATE}).</p>
41+
*
42+
* @see <a href="https://minecraft.wiki/w/Potent_Sulfur">Potent Sulfur</a>
43+
*/
44+
public interface PotentSulfur extends BlockEntity {
45+
46+
/**
47+
* {@link Keys#ERUPTION_COUNTDOWN}
48+
*
49+
* <p>The remaining ticks until the next state flip. When the block
50+
* entity has not yet evaluated its surroundings (or no suitable
51+
* noxious source is present), this value is absent.</p>
52+
*
53+
* @return The mutable eruption countdown.
54+
*/
55+
default Value.Mutable<Ticks> eruptionCountdown() {
56+
return this.requireValue(Keys.ERUPTION_COUNTDOWN).asMutable();
57+
}
58+
59+
/**
60+
* Clears the eruption countdown, forcing the block entity to
61+
* re-evaluate its surroundings on the next server tick.
62+
*/
63+
default void resetCountdown() {
64+
this.remove(Keys.ERUPTION_COUNTDOWN);
65+
}
66+
}

src/main/java/org/spongepowered/api/data/Keys.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,15 @@ public final class Keys {
11011101
*/
11021102
public static final Key<Value<Ticks>> END_GATEWAY_AGE = Keys.key(ResourceKey.sponge("end_gateway_age"), Ticks.class);
11031103

1104+
/**
1105+
* The remaining ticks until a {@link org.spongepowered.api.block.entity.PotentSulfur}
1106+
* block entity toggles between its dormant and erupting states.
1107+
*
1108+
* <p>The value is absent when the block entity has not yet evaluated
1109+
* its surroundings or when no suitable noxious source is present.</p>
1110+
*/
1111+
public static final Key<Value<Ticks>> ERUPTION_COUNTDOWN = Keys.key(ResourceKey.sponge("eruption_countdown"), Ticks.class);
1112+
11041113
/**
11051114
* The {@link EntityType entity type} of a spawn egg, which may be one of
11061115
* several based on {@link ItemTypes#ZOMBIE_SPAWN_EGG}, etc. It is not

0 commit comments

Comments
 (0)