Skip to content

Commit ae8534d

Browse files
committed
add SignalAwareVolume
1 parent de5564d commit ae8534d

File tree

5 files changed

+436
-0
lines changed

5 files changed

+436
-0
lines changed

src/main/java/org/spongepowered/api/registry/RegistryTypes.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
import org.spongepowered.api.world.ChunkRegenerateFlag;
162162
import org.spongepowered.api.world.HeightType;
163163
import org.spongepowered.api.world.LightType;
164+
import org.spongepowered.api.world.SignalType;
164165
import org.spongepowered.api.world.WorldType;
165166
import org.spongepowered.api.world.biome.Biome;
166167
import org.spongepowered.api.world.biome.climate.GrassColorModifier;
@@ -491,6 +492,8 @@ public final class RegistryTypes {
491492

492493
public static final DefaultedRegistryType<SelectorType> SELECTOR_TYPE = RegistryTypes.spongeKeyInGame("selector_type");
493494

495+
public static final DefaultedRegistryType<SignalType> SIGNAL_TYPE = RegistryTypes.spongeKeyInGame("signal_type");
496+
494497
public static final DefaultedRegistryType<SkinPart> SKIN_PART = RegistryTypes.spongeKeyInGame("skin_part");
495498

496499
public static final DefaultedRegistryType<SlabPortion> SLAB_PORTION = RegistryTypes.spongeKeyInGame("slab_portion");
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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.world;
26+
27+
import org.spongepowered.api.registry.DefaultedRegistryValue;
28+
import org.spongepowered.api.util.annotation.CatalogedBy;
29+
import org.spongepowered.api.world.volume.game.SignalAwareVolume;
30+
31+
/**
32+
* Represents a type of the signal in the {@link SignalAwareVolume}.
33+
*/
34+
@CatalogedBy(SignalTypes.class)
35+
public interface SignalType extends DefaultedRegistryValue {
36+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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.world;
26+
27+
import org.spongepowered.api.ResourceKey;
28+
import org.spongepowered.api.Sponge;
29+
import org.spongepowered.api.block.BlockTypes;
30+
import org.spongepowered.api.registry.DefaultedRegistryReference;
31+
import org.spongepowered.api.registry.Registry;
32+
import org.spongepowered.api.registry.RegistryKey;
33+
import org.spongepowered.api.registry.RegistryScope;
34+
import org.spongepowered.api.registry.RegistryScopes;
35+
import org.spongepowered.api.registry.RegistryTypes;
36+
import org.spongepowered.api.world.volume.game.SignalAwareVolume;
37+
38+
@RegistryScopes(scopes = RegistryScope.GAME)
39+
public final class SignalTypes {
40+
41+
/**
42+
* Powers neighbours.
43+
*/
44+
public static final DefaultedRegistryReference<SignalType> WEAK = SignalTypes.key(ResourceKey.sponge("weak"));
45+
46+
/**
47+
* Powers neighbours and goes through them powering their neighbours.
48+
*/
49+
public static final DefaultedRegistryReference<SignalType> STRONG = SignalTypes.key(ResourceKey.sponge("strong"));
50+
51+
/**
52+
* The combination of {@link #WEAK} and {@link #STRONG} signals.<br>
53+
* Usually depends on block properties to choose between these two signals
54+
* (e.g. if the block {@link SignalAwareVolume#canConductSignal(int, int, int)}).
55+
*/
56+
public static final DefaultedRegistryReference<SignalType> COMPOSITE = SignalTypes.key(ResourceKey.sponge("composite"));
57+
58+
/**
59+
* Doesn't directly power anything but can be extracted
60+
* by some blocks (e.g. {@link BlockTypes#COMPARATOR}).
61+
*/
62+
public static final DefaultedRegistryReference<SignalType> ANALOG = SignalTypes.key(ResourceKey.sponge("analog"));
63+
64+
private SignalTypes() {
65+
}
66+
67+
public static Registry<SignalType> registry() {
68+
return Sponge.game().registry(RegistryTypes.SIGNAL_TYPE);
69+
}
70+
71+
private static DefaultedRegistryReference<SignalType> key(final ResourceKey location) {
72+
return RegistryKey.of(RegistryTypes.SIGNAL_TYPE, location).asDefaultedReference(Sponge::game);
73+
}
74+
}

src/main/java/org/spongepowered/api/world/volume/game/Region.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
public interface Region<R extends Region<R>> extends
4242
EnvironmentalVolume,
43+
SignalAwareVolume,
4344
BiomeVolume.Streamable<R>,
4445
BlockVolume.Streamable<R>,
4546
BlockEntityVolume.Streamable<R>,

0 commit comments

Comments
 (0)