Skip to content

Commit 30055c2

Browse files
committed
fixing explosions
1 parent a9e5275 commit 30055c2

File tree

6 files changed

+92
-5
lines changed

6 files changed

+92
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ public final class Keys {
10201020
* determined randomly at the time of the explosion or computed from the
10211021
* context in which the {@link Explosive} explodes.</p>
10221022
*/
1023-
public static final Key<Value<Integer>> EXPLOSION_RADIUS = Keys.key(ResourceKey.sponge("explosion_radius"), Integer.class);
1023+
public static final Key<Value<Float>> EXPLOSION_RADIUS = Keys.key(ResourceKey.sponge("explosion_radius"), Float.class);
10241024

10251025
/**
10261026
* The eye height of an {@link Entity}.

src/main/java/org/spongepowered/api/entity/explosive/Explosive.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public interface Explosive extends Entity {
4040
*
4141
* @return The explosion radius
4242
*/
43-
default Optional<Value.Mutable<Integer>> explosionRadius() {
43+
default Optional<Value.Mutable<Float>> explosionRadius() {
4444
return this.getValue(Keys.EXPLOSION_RADIUS).map(Value::asMutable);
4545
}
4646

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
import org.spongepowered.api.world.biome.climate.TemperatureModifier;
163163
import org.spongepowered.api.world.chunk.ChunkState;
164164
import org.spongepowered.api.world.difficulty.Difficulty;
165+
import org.spongepowered.api.world.explosion.ExplosionBlockInteraction;
165166
import org.spongepowered.api.world.gamerule.GameRule;
166167
import org.spongepowered.api.world.generation.carver.Carver;
167168
import org.spongepowered.api.world.generation.carver.CarverType;
@@ -357,6 +358,8 @@ public final class RegistryTypes {
357358

358359
public static final DefaultedRegistryType<EquipmentType> EQUIPMENT_TYPE = RegistryTypes.spongeKeyInGame("equipment_type");
359360

361+
public static final RegistryType<ExplosionBlockInteraction> EXPLOSION_BLOCK_INTERACTION = RegistryTypes.spongeKeyInGame("explosion_block_interaction");
362+
360363
public static final DefaultedRegistryType<FireworkShape> FIREWORK_SHAPE = RegistryTypes.spongeKeyInGame("firework_shape");
361364

362365
public static final DefaultedRegistryType<FlatGeneratorConfig> FLAT_GENERATOR_CONFIG = RegistryTypes.spongeKeyInGame("flat_generator_config");

src/main/java/org/spongepowered/api/world/explosion/Explosion.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ interface Builder extends org.spongepowered.api.util.Builder<Explosion, Builder>
184184
Builder shouldPlaySmoke(boolean smoke);
185185

186186
/**
187-
* Sets whether the affected blocks should be destroyed on explosion.
187+
* Sets the desired block interaction.
188188
*
189-
* @param destroy Whether the affected blocks should be destroyed
189+
* @param interaction the desired block interaction
190190
* @return The builder, for chaining
191191
*/
192-
Builder shouldBreakBlocks(boolean destroy);
192+
Builder blockInteraction(ExplosionBlockInteraction interaction);
193193

194194
/**
195195
* Sets the resolution of the explosion.
@@ -244,4 +244,5 @@ default Builder knockback(double knockback) {
244244
Explosion build() throws IllegalArgumentException;
245245

246246
}
247+
247248
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.explosion;
26+
27+
import org.spongepowered.api.util.annotation.CatalogedBy;
28+
29+
@CatalogedBy(ExplosionBlockInteractions.class)
30+
public interface ExplosionBlockInteraction {
31+
// TODO mixin
32+
33+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.explosion;
26+
27+
import org.spongepowered.api.ResourceKey;
28+
import org.spongepowered.api.Sponge;
29+
import org.spongepowered.api.registry.DefaultedRegistryReference;
30+
import org.spongepowered.api.registry.Registry;
31+
import org.spongepowered.api.registry.RegistryKey;
32+
import org.spongepowered.api.registry.RegistryTypes;
33+
34+
public final class ExplosionBlockInteractions {
35+
public static final DefaultedRegistryReference<ExplosionBlockInteraction> KEEP = ExplosionBlockInteractions.key(ResourceKey.sponge("keep"));
36+
public static final DefaultedRegistryReference<ExplosionBlockInteraction> DESTROY = ExplosionBlockInteractions.key(ResourceKey.sponge("destroy"));
37+
public static final DefaultedRegistryReference<ExplosionBlockInteraction> DESTROY_WITH_DECAY = ExplosionBlockInteractions.key(ResourceKey.sponge("destroy_with_decay"));
38+
public static final DefaultedRegistryReference<ExplosionBlockInteraction> TRIGGER_BLOCK = ExplosionBlockInteractions.key(ResourceKey.sponge("trigger_block"));
39+
40+
private ExplosionBlockInteractions() {
41+
}
42+
43+
public static Registry<ExplosionBlockInteraction> registry() {
44+
return Sponge.game().registry(RegistryTypes.EXPLOSION_BLOCK_INTERACTION);
45+
}
46+
47+
private static DefaultedRegistryReference<ExplosionBlockInteraction> key(final ResourceKey location) {
48+
return RegistryKey.of(RegistryTypes.EXPLOSION_BLOCK_INTERACTION, location).asDefaultedReference(Sponge::game);
49+
}
50+
}

0 commit comments

Comments
 (0)