diff --git a/build.gradle b/build.gradle index fae2fd9..e51e2e3 100644 --- a/build.gradle +++ b/build.gradle @@ -120,6 +120,9 @@ dependencies { // iris modImplementation libs.iris + // explosive enhancement + modImplementation libs.explosive.enhancement + // pehkui modCompileOnly libs.pehkui modRuntimeOnly libs.pehkui diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ffc7a7b..5d5bb1d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -23,6 +23,7 @@ lambdynamiclights = "2.3.2+1.20.1" spruceui = "5.0.2+1.20" sodium = "mc1.20.1-0.5.3" iris = "1.6.11+1.20.1" +explosive_enhancement = "1.2.2-1.20.x" [libraries] minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } @@ -50,6 +51,7 @@ lambdynamiclights = { module = "maven.modrinth:lambdynamiclights", version.ref = spruceui = { module = "dev.lambdaurora:spruceui", version.ref = "spruceui" } sodium = { module = "maven.modrinth:sodium", version.ref = "sodium" } iris = { module = "maven.modrinth:iris", version.ref = "iris" } +explosive_enhancement = { module = "maven.modrinth:explosive-enhancement", version.ref = "explosive_enhancement" } # If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example". [bundles] diff --git a/src/main/java/dev/cammiescorner/arcanuscontinuum/client/ArcanusClient.java b/src/main/java/dev/cammiescorner/arcanuscontinuum/client/ArcanusClient.java index fa9b859..5dfd351 100644 --- a/src/main/java/dev/cammiescorner/arcanuscontinuum/client/ArcanusClient.java +++ b/src/main/java/dev/cammiescorner/arcanuscontinuum/client/ArcanusClient.java @@ -136,6 +136,7 @@ public void onInitializeClient(ModContainer mod) { ClientPlayNetworking.registerGlobalReceiver(SyncStaffTemplatePacket.ID, SyncStaffTemplatePacket::handle); ClientPlayNetworking.registerGlobalReceiver(SyncSupporterData.ID, SyncSupporterData::handle); ClientPlayNetworking.registerGlobalReceiver(SyncConfigValuesPacket.ID, SyncConfigValuesPacket::handle); + ClientPlayNetworking.registerGlobalReceiver(SyncExplosionParticlesPacket.ID, SyncExplosionParticlesPacket::handle); ColorProviderRegistry.ITEM.register((stack, tintIndex) -> tintIndex == 0 ? StaffItem.getPrimaryColour(stack) : tintIndex == 1 ? StaffItem.getSecondaryColour(stack) : 0xffffff, ArcanusItems.WOODEN_STAFF.get(), diff --git a/src/main/java/dev/cammiescorner/arcanuscontinuum/common/compat/ExplosiveEnhancementCompat.java b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/compat/ExplosiveEnhancementCompat.java new file mode 100644 index 0000000..5c35b44 --- /dev/null +++ b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/compat/ExplosiveEnhancementCompat.java @@ -0,0 +1,24 @@ +package dev.cammiescorner.arcanuscontinuum.common.compat; + +import net.minecraft.registry.tag.FluidTags; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.superkat.explosiveenhancement.ExplosiveEnhancement; +import net.superkat.explosiveenhancement.ExplosiveEnhancementClient; +import net.superkat.explosiveenhancement.api.ExplosiveApi; + +public class ExplosiveEnhancementCompat { + public static void spawnEnhancedBooms(World world, double x, double y, double z, float power, boolean didDestroyBlocks) { + boolean isUnderWater = false; + BlockPos pos = BlockPos.create(x, y, z); + + if(ExplosiveEnhancementClient.config.underwaterExplosions && world.getFluidState(pos).isIn(FluidTags.WATER)) { + isUnderWater = true; + + if(ExplosiveEnhancementClient.config.debugLogs) + ExplosiveEnhancement.LOGGER.info("particle is underwater!"); + } + + ExplosiveApi.spawnParticles(world, x, y, z, power, isUnderWater, didDestroyBlocks); + } +} diff --git a/src/main/java/dev/cammiescorner/arcanuscontinuum/common/packets/s2c/SyncExplosionParticlesPacket.java b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/packets/s2c/SyncExplosionParticlesPacket.java new file mode 100644 index 0000000..f02fed5 --- /dev/null +++ b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/packets/s2c/SyncExplosionParticlesPacket.java @@ -0,0 +1,48 @@ +package dev.cammiescorner.arcanuscontinuum.common.packets.s2c; + +import dev.cammiescorner.arcanuscontinuum.Arcanus; +import dev.cammiescorner.arcanuscontinuum.common.compat.ExplosiveEnhancementCompat; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.network.PacketByteBuf; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.util.Identifier; +import net.minecraft.world.World; +import org.quiltmc.loader.api.QuiltLoader; +import org.quiltmc.qsl.networking.api.PacketByteBufs; +import org.quiltmc.qsl.networking.api.PacketSender; +import org.quiltmc.qsl.networking.api.ServerPlayNetworking; + +public class SyncExplosionParticlesPacket { + public static final Identifier ID = Arcanus.id("sync_explosion_particles"); + + public static void send(ServerPlayerEntity player, double x, double y, double z, float strength, boolean didDestroyBlocks) { + PacketByteBuf buf = PacketByteBufs.create(); + + buf.writeDouble(x); + buf.writeDouble(y); + buf.writeDouble(z); + buf.writeFloat(strength); + buf.writeBoolean(didDestroyBlocks); + + ServerPlayNetworking.send(player, ID, buf); + } + + public static void handle(MinecraftClient client, ClientPlayNetworkHandler handler, PacketByteBuf buf, PacketSender sender) { + double x = buf.readDouble(); + double y = buf.readDouble(); + double z = buf.readDouble(); + float strength = buf.readFloat(); + boolean didDestroyBlocks = buf.readBoolean(); + + client.execute(() -> { + World world = client.world; + + if(QuiltLoader.isModLoaded("explosiveenhancement")) + ExplosiveEnhancementCompat.spawnEnhancedBooms(world, x, y, z, strength, didDestroyBlocks); + else + world.addParticle(ParticleTypes.EXPLOSION_EMITTER, x, y, z, 1, 1, 1); + }); + } +} diff --git a/src/main/java/dev/cammiescorner/arcanuscontinuum/common/spell_components/shapes/ExplosionSpellShape.java b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/spell_components/shapes/ExplosionSpellShape.java index 5789af5..22e3e3f 100644 --- a/src/main/java/dev/cammiescorner/arcanuscontinuum/common/spell_components/shapes/ExplosionSpellShape.java +++ b/src/main/java/dev/cammiescorner/arcanuscontinuum/common/spell_components/shapes/ExplosionSpellShape.java @@ -6,12 +6,14 @@ import dev.cammiescorner.arcanuscontinuum.api.spells.SpellGroup; import dev.cammiescorner.arcanuscontinuum.api.spells.SpellShape; import dev.cammiescorner.arcanuscontinuum.api.spells.Weight; +import dev.cammiescorner.arcanuscontinuum.common.packets.s2c.SyncExplosionParticlesPacket; +import dev.cammiescorner.arcanuscontinuum.common.registry.ArcanusSpellComponents; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.fluid.FluidState; import net.minecraft.item.ItemStack; -import net.minecraft.particle.ParticleTypes; +import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; @@ -20,6 +22,7 @@ import net.minecraft.util.math.*; import net.minecraft.world.event.GameEvent; import org.jetbrains.annotations.Nullable; +import org.quiltmc.qsl.networking.api.PlayerLookup; import java.util.HashSet; import java.util.List; @@ -100,7 +103,10 @@ public void cast(@Nullable LivingEntity caster, Vec3d castFrom, @Nullable Entity } world.playSound(null, castFrom.getX(), castFrom.getY(), castFrom.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4F, (1F + (world.random.nextFloat() - world.random.nextFloat()) * 0.2F) * 0.7F, 1L); - world.spawnParticles(ParticleTypes.EXPLOSION_EMITTER, castFrom.getX(), castFrom.getY(), castFrom.getZ(), 1, 1, 0, 0, 1); + + for(ServerPlayerEntity player : PlayerLookup.tracking(world, BlockPos.create(castFrom.getX(), castFrom.getY(), castFrom.getZ()))) + SyncExplosionParticlesPacket.send(player, castFrom.getX(), castFrom.getY(), castFrom.getZ(), strength, effects.contains(ArcanusSpellComponents.MINE.get())); + castNext(caster, castFrom, castSource, world, stack, spellGroups, groupIndex, potency); } }