diff --git a/arrow.webp b/arrow.webp new file mode 100644 index 0000000..1bd04a0 Binary files /dev/null and b/arrow.webp differ diff --git a/common/src/main/java/dev/newty/projectileding/mixin/client/PersistentProjectileEntityMixin.java b/common/src/main/java/dev/newty/projectileding/mixin/PersistentProjectileEntityMixin.java similarity index 51% rename from common/src/main/java/dev/newty/projectileding/mixin/client/PersistentProjectileEntityMixin.java rename to common/src/main/java/dev/newty/projectileding/mixin/PersistentProjectileEntityMixin.java index 96b0b57..cba1020 100644 --- a/common/src/main/java/dev/newty/projectileding/mixin/client/PersistentProjectileEntityMixin.java +++ b/common/src/main/java/dev/newty/projectileding/mixin/PersistentProjectileEntityMixin.java @@ -1,43 +1,38 @@ -package dev.newty.projectileding.mixin.client; +package dev.newty.projectileding.mixin; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayerEntity; -import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.projectile.PersistentProjectileEntity; -import net.minecraft.entity.projectile.ProjectileEntity; import net.minecraft.sound.SoundEvent; import net.minecraft.sound.SoundEvents; import net.minecraft.util.hit.EntityHitResult; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(PersistentProjectileEntity.class) public abstract class PersistentProjectileEntityMixin { + @Unique private boolean projectileDing$targetAlive; + @Shadow public abstract void setSound(SoundEvent sound); @Inject(method = "onEntityHit", at = @At("HEAD")) private void changeSound(EntityHitResult entityHitResult, CallbackInfo ci) { - Entity target = entityHitResult.getEntity(); + projectileDing$targetAlive = entityHitResult.getEntity() instanceof LivingEntity; - // ensure that the target is alive - if (target instanceof LivingEntity) { - ClientPlayerEntity player = MinecraftClient.getInstance().player; - ProjectileEntity projectile = (ProjectileEntity) (Object) this; - - if (player != null && player.equals(projectile.getOwner())) { - // change the sound to the custom sound - this.setSound(SoundEvents.ENTITY_ARROW_HIT_PLAYER); - } + // if the arrow hits a living target, change the sound to the custom sound + if (projectileDing$targetAlive) { + this.setSound(SoundEvents.ENTITY_ARROW_HIT_PLAYER); } } @Inject(method = "onEntityHit", at = @At("TAIL")) private void revertSound(EntityHitResult entityHitResult, CallbackInfo ci) { - // revert the sound back to default, even if it hasn't been changed - this.setSound(SoundEvents.ENTITY_ARROW_HIT); + // if the arrow hit a living target, revert the sound back to the default + if (projectileDing$targetAlive) { + this.setSound(SoundEvents.ENTITY_ARROW_HIT); + } } } diff --git a/common/src/main/resources/projectileding.mixins.json b/common/src/main/resources/projectileding.mixins.json index 5202abb..9927242 100644 --- a/common/src/main/resources/projectileding.mixins.json +++ b/common/src/main/resources/projectileding.mixins.json @@ -3,10 +3,8 @@ "package": "dev.newty.projectileding.mixin", "compatibilityLevel": "JAVA_21", "minVersion": "0.8", - "client": [ - "client.PersistentProjectileEntityMixin" - ], "mixins": [ + "PersistentProjectileEntityMixin" ], "injectors": { "defaultRequire": 1 diff --git a/fabric-like/build.gradle b/fabric-like/build.gradle deleted file mode 100644 index eeb4364..0000000 --- a/fabric-like/build.gradle +++ /dev/null @@ -1,13 +0,0 @@ -architectury { - common rootProject.enabled_platforms.split(',') -} - -dependencies { - modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version" - modImplementation "net.fabricmc.fabric-api:fabric-api:$rootProject.fabric_api_version" - - // Architectury API. This is optional, and you can comment it out if you don't need it. - modImplementation "dev.architectury:architectury-fabric:$rootProject.architectury_api_version" - - compileOnly(project(path: ':common', configuration: 'namedElements')) { transitive false } -} diff --git a/fabric-like/src/main/java/dev/newty/projectileding/fabriclike/ProjectileDingFabricLike.java b/fabric-like/src/main/java/dev/newty/projectileding/fabriclike/ProjectileDingFabricLike.java deleted file mode 100644 index 04cbe22..0000000 --- a/fabric-like/src/main/java/dev/newty/projectileding/fabriclike/ProjectileDingFabricLike.java +++ /dev/null @@ -1,10 +0,0 @@ -package dev.newty.projectileding.fabriclike; - -import dev.newty.projectileding.ProjectileDing; - -public final class ProjectileDingFabricLike { - public static void init() { - // Run our common setup. - ProjectileDing.init(); - } -} diff --git a/fabric/build.gradle b/fabric/build.gradle index b5dc249..4119e23 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -27,16 +27,8 @@ configurations { dependencies { modImplementation "net.fabricmc:fabric-loader:$rootProject.fabric_loader_version" - // Fabric API. This is technically optional, but you probably want it anyway. - modImplementation "net.fabricmc.fabric-api:fabric-api:$rootProject.fabric_api_version" - - // Architectury API. This is optional, and you can comment it out if you don't need it. - modImplementation "dev.architectury:architectury-fabric:$rootProject.architectury_api_version" - common(project(path: ':common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':common', configuration: 'transformProductionFabric') - common(project(path: ':fabric-like', configuration: 'namedElements')) { transitive false } - shadowBundle project(path: ':fabric-like', configuration: 'transformProductionFabric') } processResources { diff --git a/fabric/src/main/java/dev/newty/projectileding/fabric/ProjectileDingFabric.java b/fabric/src/main/java/dev/newty/projectileding/fabric/ProjectileDingFabric.java index e977abd..d331a54 100644 --- a/fabric/src/main/java/dev/newty/projectileding/fabric/ProjectileDingFabric.java +++ b/fabric/src/main/java/dev/newty/projectileding/fabric/ProjectileDingFabric.java @@ -1,17 +1,12 @@ package dev.newty.projectileding.fabric; +import dev.newty.projectileding.ProjectileDing; import net.fabricmc.api.ModInitializer; -import dev.newty.projectileding.fabriclike.ProjectileDingFabricLike; - public final class ProjectileDingFabric implements ModInitializer { @Override public void onInitialize() { - // This code runs as soon as Minecraft is in a mod-load-ready state. - // However, some things (like resources) may still be uninitialized. - // Proceed with mild caution. - - // Run the Fabric-like setup. - ProjectileDingFabricLike.init(); + // Run our common setup. + ProjectileDing.init(); } } diff --git a/fabric/src/main/java/dev/newty/projectileding/fabric/client/ProjectileDingFabricClient.java b/fabric/src/main/java/dev/newty/projectileding/fabric/client/ProjectileDingFabricClient.java deleted file mode 100644 index 1aee5b5..0000000 --- a/fabric/src/main/java/dev/newty/projectileding/fabric/client/ProjectileDingFabricClient.java +++ /dev/null @@ -1,10 +0,0 @@ -package dev.newty.projectileding.fabric.client; - -import net.fabricmc.api.ClientModInitializer; - -public final class ProjectileDingFabricClient implements ClientModInitializer { - @Override - public void onInitializeClient() { - // This entrypoint is suitable for setting up client-specific logic, such as rendering. - } -} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index a3ee51f..12f3da3 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -17,9 +17,6 @@ "entrypoints": { "main": [ "dev.newty.projectileding.fabric.ProjectileDingFabric" - ], - "client": [ - "dev.newty.projectileding.fabric.client.ProjectileDingFabricClient" ] }, "mixins": [ @@ -28,9 +25,7 @@ "depends": { "fabricloader": ">=0.16.3", "minecraft": "~1.21", - "java": ">=21", - "architectury": ">=13.0.2", - "fabric-api": "*" + "java": ">=21" }, "suggests": { "another-mod": "*" diff --git a/gradle.properties b/gradle.properties index 32dcea0..5a75dd7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.parallel=true mod_version = 1.0.0 maven_group = dev.newty archives_name = projectileding -enabled_platforms = fabric,neoforge,quilt +enabled_platforms = fabric,neoforge # Minecraft properties minecraft_version = 1.21 @@ -15,8 +15,5 @@ yarn_mappings = 1.21+build.1 # Dependencies architectury_api_version = 13.0.2 fabric_loader_version = 0.16.3 -fabric_api_version = 0.102.0+1.21 neoforge_version = 21.0.42-beta yarn_mappings_patch_neoforge_version = 1.21+build.4 -quilt_loader_version = 0.26.4-beta.5 -quilted_fabric_api_version = 11.0.0-alpha.3+0.100.7-1.21 diff --git a/neoforge/build.gradle b/neoforge/build.gradle index 471864e..08f6354 100644 --- a/neoforge/build.gradle +++ b/neoforge/build.gradle @@ -34,9 +34,6 @@ repositories { dependencies { neoForge "net.neoforged:neoforge:$rootProject.neoforge_version" - // Architectury API. This is optional, and you can comment it out if you don't need it. - modImplementation "dev.architectury:architectury-neoforge:$rootProject.architectury_api_version" - common(project(path: ':common', configuration: 'namedElements')) { transitive false } shadowBundle project(path: ':common', configuration: 'transformProductionNeoForge') } diff --git a/quilt/build.gradle b/quilt/build.gradle deleted file mode 100644 index 345c0ca..0000000 --- a/quilt/build.gradle +++ /dev/null @@ -1,66 +0,0 @@ -plugins { - id 'com.github.johnrengelman.shadow' -} - -repositories { - maven { url 'https://maven.quiltmc.org/repository/release/' } -} - -architectury { - platformSetupLoomIde() - loader('quilt') -} - -configurations { - common { - canBeResolved = true - canBeConsumed = false - } - compileClasspath.extendsFrom common - runtimeClasspath.extendsFrom common - developmentQuilt.extendsFrom common - - // Files in this configuration will be bundled into your mod using the Shadow plugin. - // Don't use the `shadow` configuration from the plugin itself as it's meant for excluding files. - shadowBundle { - canBeResolved = true - canBeConsumed = false - } -} - -dependencies { - modImplementation "org.quiltmc:quilt-loader:$rootProject.quilt_loader_version" - - // Quilt Standard Libraries and QSL. - modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:$rootProject.quilted_fabric_api_version" - - // Architectury API. This is optional, and you can comment it out if you don't need it. - modImplementation("dev.architectury:architectury-fabric:$rootProject.architectury_api_version") { - // We must not pull Fabric Loader and Fabric API from Architectury Fabric. - exclude group: 'net.fabricmc' - exclude group: 'net.fabricmc.fabric-api' - } - - common(project(path: ':common', configuration: 'namedElements')) { transitive false } - shadowBundle project(path: ':common', configuration: 'transformProductionQuilt') - common(project(path: ':fabric-like', configuration: 'namedElements')) { transitive false } - shadowBundle project(path: ':fabric-like', configuration: 'transformProductionQuilt') -} - -processResources { - inputs.property 'group', project.group - inputs.property 'version', project.version - - filesMatching('quilt.mod.json') { - expand group: project.group, version: project.version - } -} - -shadowJar { - configurations = [project.configurations.shadowBundle] - archiveClassifier = 'dev-shadow' -} - -remapJar { - input.set shadowJar.archiveFile -} diff --git a/quilt/gradle.properties b/quilt/gradle.properties deleted file mode 100644 index 56fe802..0000000 --- a/quilt/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -loom.platform = quilt diff --git a/quilt/src/main/java/dev/newty/projectileding/quilt/ProjectileDingQuilt.java b/quilt/src/main/java/dev/newty/projectileding/quilt/ProjectileDingQuilt.java deleted file mode 100644 index 8c445fa..0000000 --- a/quilt/src/main/java/dev/newty/projectileding/quilt/ProjectileDingQuilt.java +++ /dev/null @@ -1,14 +0,0 @@ -package dev.newty.projectileding.quilt; - -import org.quiltmc.loader.api.ModContainer; -import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; - -import dev.newty.projectileding.fabriclike.ProjectileDingFabricLike; - -public final class ProjectileDingQuilt implements ModInitializer { - @Override - public void onInitialize(ModContainer mod) { - // Run the Fabric-like setup. - ProjectileDingFabricLike.init(); - } -} diff --git a/quilt/src/main/resources/quilt.mod.json b/quilt/src/main/resources/quilt.mod.json deleted file mode 100644 index 5d3fb53..0000000 --- a/quilt/src/main/resources/quilt.mod.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "schema_version": 1, - "quilt_loader": { - "group": "${group}", - "id": "projectileding", - "version": "${version}", - "metadata": { - "name": "ProjectileDing", - "description": "This is an example description! Tell everyone what your mod is about!", - "contributors": { - "Me!": "Author" - }, - "icon": "assets/projectileding/icon.png" - }, - "intermediate_mappings": "net.fabricmc:intermediary", - "entrypoints": { - "init": [ - "dev.newty.quilt.ExampleModQuilt" - ] - }, - "depends": [ - { - "id": "quilt_loader", - "version": "*" - }, - { - "id": "quilt_base", - "version": "*" - }, - { - "id": "minecraft", - "version": ">=1.21" - }, - { - "id": "architectury", - "version": ">=13.0.2" - } - ] - }, - "mixin": [ - "projectileding.mixins.json" - ] -} diff --git a/readme.md b/readme.md index 2081b16..3f072ab 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,20 @@
-

DrinkableXP

+ +

ProjectileDing

+[![Modrinth Downloads](https://img.shields.io/modrinth/dt/INLXGXFI?style=for-the-badge&logo=modrinth&color=a79aff)](https://modrinth.com/mod/projectile-ding) + +Plays the ENTITY_ARROW_HIT_PLAYER sound effect whenever you hit a living entity with an arrow. You can find a +demonstration of the mod in action on YouTube [here](https://www.youtube.com/watch?v=WpB4vh8CIRk). + +### Supported versions of Minecraft + +- 1.21.1 + +### Supported mod loaders + +- [Fabric](https://fabricmc.net/)/[Quilt](https://quiltmc.org/en/) +- [NeoForge](https://neoforged.net/) + This project is licensed with the Opinionated Queer License v1.2 - you can view it here. \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index df05047..5aeac91 100644 --- a/settings.gradle +++ b/settings.gradle @@ -11,6 +11,4 @@ rootProject.name = 'projectileding' include 'common' include 'fabric' -include 'fabric-like' include 'neoforge' -include 'quilt'