diff --git a/src/main/java/org/spongepowered/api/data/Keys.java b/src/main/java/org/spongepowered/api/data/Keys.java index 0d6a38083c..454d9f681e 100644 --- a/src/main/java/org/spongepowered/api/data/Keys.java +++ b/src/main/java/org/spongepowered/api/data/Keys.java @@ -1020,7 +1020,7 @@ public final class Keys { * determined randomly at the time of the explosion or computed from the * context in which the {@link Explosive} explodes.

*/ - public static final Key> EXPLOSION_RADIUS = Keys.key(ResourceKey.sponge("explosion_radius"), Integer.class); + public static final Key> EXPLOSION_RADIUS = Keys.key(ResourceKey.sponge("explosion_radius"), Float.class); /** * The eye height of an {@link Entity}. diff --git a/src/main/java/org/spongepowered/api/entity/explosive/Explosive.java b/src/main/java/org/spongepowered/api/entity/explosive/Explosive.java index ab0cff20ac..23e3a18a65 100644 --- a/src/main/java/org/spongepowered/api/entity/explosive/Explosive.java +++ b/src/main/java/org/spongepowered/api/entity/explosive/Explosive.java @@ -40,7 +40,7 @@ public interface Explosive extends Entity { * * @return The explosion radius */ - default Optional> explosionRadius() { + default Optional> explosionRadius() { return this.getValue(Keys.EXPLOSION_RADIUS).map(Value::asMutable); } diff --git a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java index a108e65405..119f59aeb8 100644 --- a/src/main/java/org/spongepowered/api/registry/RegistryTypes.java +++ b/src/main/java/org/spongepowered/api/registry/RegistryTypes.java @@ -162,6 +162,7 @@ import org.spongepowered.api.world.biome.climate.TemperatureModifier; import org.spongepowered.api.world.chunk.ChunkState; import org.spongepowered.api.world.difficulty.Difficulty; +import org.spongepowered.api.world.explosion.ExplosionBlockInteraction; import org.spongepowered.api.world.gamerule.GameRule; import org.spongepowered.api.world.generation.carver.Carver; import org.spongepowered.api.world.generation.carver.CarverType; @@ -357,6 +358,8 @@ public final class RegistryTypes { public static final DefaultedRegistryType EQUIPMENT_TYPE = RegistryTypes.spongeKeyInGame("equipment_type"); + public static final RegistryType EXPLOSION_BLOCK_INTERACTION = RegistryTypes.spongeKeyInGame("explosion_block_interaction"); + public static final DefaultedRegistryType FIREWORK_SHAPE = RegistryTypes.spongeKeyInGame("firework_shape"); public static final DefaultedRegistryType FLAT_GENERATOR_CONFIG = RegistryTypes.spongeKeyInGame("flat_generator_config"); diff --git a/src/main/java/org/spongepowered/api/world/explosion/Explosion.java b/src/main/java/org/spongepowered/api/world/explosion/Explosion.java index 0701c0c2d1..4f157b8b7a 100644 --- a/src/main/java/org/spongepowered/api/world/explosion/Explosion.java +++ b/src/main/java/org/spongepowered/api/world/explosion/Explosion.java @@ -184,12 +184,12 @@ interface Builder extends org.spongepowered.api.util.Builder Builder shouldPlaySmoke(boolean smoke); /** - * Sets whether the affected blocks should be destroyed on explosion. + * Sets the desired block interaction. * - * @param destroy Whether the affected blocks should be destroyed + * @param interaction the desired block interaction * @return The builder, for chaining */ - Builder shouldBreakBlocks(boolean destroy); + Builder blockInteraction(ExplosionBlockInteraction interaction); /** * Sets the resolution of the explosion. @@ -244,4 +244,5 @@ default Builder knockback(double knockback) { Explosion build() throws IllegalArgumentException; } + } diff --git a/src/main/java/org/spongepowered/api/world/explosion/ExplosionBlockInteraction.java b/src/main/java/org/spongepowered/api/world/explosion/ExplosionBlockInteraction.java new file mode 100644 index 0000000000..ac030daaae --- /dev/null +++ b/src/main/java/org/spongepowered/api/world/explosion/ExplosionBlockInteraction.java @@ -0,0 +1,33 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.world.explosion; + +import org.spongepowered.api.util.annotation.CatalogedBy; + +@CatalogedBy(ExplosionBlockInteractions.class) +public interface ExplosionBlockInteraction { + // TODO mixin + +} diff --git a/src/main/java/org/spongepowered/api/world/explosion/ExplosionBlockInteractions.java b/src/main/java/org/spongepowered/api/world/explosion/ExplosionBlockInteractions.java new file mode 100644 index 0000000000..83f79020d3 --- /dev/null +++ b/src/main/java/org/spongepowered/api/world/explosion/ExplosionBlockInteractions.java @@ -0,0 +1,50 @@ +/* + * This file is part of SpongeAPI, licensed under the MIT License (MIT). + * + * Copyright (c) SpongePowered + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package org.spongepowered.api.world.explosion; + +import org.spongepowered.api.ResourceKey; +import org.spongepowered.api.Sponge; +import org.spongepowered.api.registry.DefaultedRegistryReference; +import org.spongepowered.api.registry.Registry; +import org.spongepowered.api.registry.RegistryKey; +import org.spongepowered.api.registry.RegistryTypes; + +public final class ExplosionBlockInteractions { + public static final DefaultedRegistryReference KEEP = ExplosionBlockInteractions.key(ResourceKey.sponge("keep")); + public static final DefaultedRegistryReference DESTROY = ExplosionBlockInteractions.key(ResourceKey.sponge("destroy")); + public static final DefaultedRegistryReference DESTROY_WITH_DECAY = ExplosionBlockInteractions.key(ResourceKey.sponge("destroy_with_decay")); + public static final DefaultedRegistryReference TRIGGER_BLOCK = ExplosionBlockInteractions.key(ResourceKey.sponge("trigger_block")); + + private ExplosionBlockInteractions() { + } + + public static Registry registry() { + return Sponge.game().registry(RegistryTypes.EXPLOSION_BLOCK_INTERACTION); + } + + private static DefaultedRegistryReference key(final ResourceKey location) { + return RegistryKey.of(RegistryTypes.EXPLOSION_BLOCK_INTERACTION, location).asDefaultedReference(Sponge::game); + } +}