diff --git a/build.gradle b/build.gradle index b0c1384..ce00a36 100644 --- a/build.gradle +++ b/build.gradle @@ -31,6 +31,18 @@ repositories { } maven { url = "https://mvn.devos.one/snapshots/" } + + exclusiveContent { + forRepository { + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + } + } + filter { + includeGroup "maven.modrinth" + } + } } fabricApi { @@ -52,6 +64,7 @@ dependencies { modImplementation("dev.emi:trinkets:${project.trinkets_version}") modImplementation("foundry.veil:veil-fabric-${project.minecraft_version}:${project.veil_version}") { exclude group: "maven.modrinth" } // modImplementation(include("com.tterrag.registrate_fabric:Registrate:${project.registrate_version}")) + modRuntimeOnly(modCompileOnly("maven.modrinth:marksman:${project.marksman_version}")) } processResources { @@ -98,4 +111,4 @@ publishing { // The repositories here will be used for publishing your artifact, not for // retrieving dependencies. } -} \ No newline at end of file +} diff --git a/gradle.properties b/gradle.properties index 8aad579..3f8813e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.parallel=true # check these on https://fabricmc.net/develop minecraft_version=1.21.1 yarn_mappings=1.21.1+build.3 -loader_version=0.16.9 +loader_version=0.16.10 # Mod Properties mod_version=1.0.0 @@ -17,4 +17,5 @@ archives_base_name=clean_cut fabric_version=0.110.0+1.21.1 veil_version=1.0.0.6 trinkets_version=3.10.0 -#registrate_version=1.3.0 \ No newline at end of file +#registrate_version=1.3.0 +marksman_version=1.2.0 diff --git a/src/main/java/net/dustley/clean_cut/CleanCutMixinConfigPlugin.java b/src/main/java/net/dustley/clean_cut/CleanCutMixinConfigPlugin.java new file mode 100644 index 0000000..e88f1d4 --- /dev/null +++ b/src/main/java/net/dustley/clean_cut/CleanCutMixinConfigPlugin.java @@ -0,0 +1,49 @@ +package net.dustley.clean_cut; + +import net.fabricmc.loader.api.FabricLoader; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.util.List; +import java.util.Set; + +public class CleanCutMixinConfigPlugin implements IMixinConfigPlugin { + @Override + public void onLoad(String mixinPackage) { + + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + // If more compat is added this should be replaced with a switch statement + if (mixinClassName.equals("net.dustley.clean_cut.mixin.MarksmanCleaverProjectileEntityMixin")) + return FabricLoader.getInstance().isModLoaded("marksman"); + return true; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { + + } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + + } +} diff --git a/src/main/java/net/dustley/clean_cut/mixin/MarksmanCleaverProjectileEntityMixin.java b/src/main/java/net/dustley/clean_cut/mixin/MarksmanCleaverProjectileEntityMixin.java new file mode 100644 index 0000000..90793e8 --- /dev/null +++ b/src/main/java/net/dustley/clean_cut/mixin/MarksmanCleaverProjectileEntityMixin.java @@ -0,0 +1,37 @@ +package net.dustley.clean_cut.mixin; + +import archives.tater.marksman.Marksman; +import archives.tater.marksman.Ricoshottable; +import net.dustley.clean_cut.entity.cleaver.CleaverProjectileEntity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.ProjectileDeflection; +import net.minecraft.entity.projectile.PersistentProjectileEntity; +import net.minecraft.entity.projectile.ProjectileEntity; +import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; + +@Mixin(CleaverProjectileEntity.class) +public abstract class MarksmanCleaverProjectileEntityMixin extends PersistentProjectileEntity implements Ricoshottable { + @Unique + private boolean marksman$ricoshotted = false; + + protected MarksmanCleaverProjectileEntityMixin(EntityType entityType, World world) { + super(entityType, world); + } + + @Override + public ProjectileDeflection getProjectileDeflection(ProjectileEntity projectile) { + return marksman$canBeRicoshotted() ? Marksman.AIM_AT_TARGET : super.getProjectileDeflection(projectile); + } + + @Override + public boolean marksman$canBeRicoshotted() { + return !marksman$ricoshotted && age > 6 && !isOnGround(); + } + + @Override + public void marksman$setRicoshotted() { + marksman$ricoshotted = true; + } +} diff --git a/src/main/resources/clean_cut.mixins.json b/src/main/resources/clean_cut.mixins.json index cba07fc..d18f36d 100644 --- a/src/main/resources/clean_cut.mixins.json +++ b/src/main/resources/clean_cut.mixins.json @@ -2,7 +2,10 @@ "required": true, "package": "net.dustley.clean_cut.mixin", "compatibilityLevel": "JAVA_21", - "mixins": [ ], + "mixins": [ + "MarksmanCleaverProjectileEntityMixin" + ], + "plugin": "net.dustley.clean_cut.CleanCutMixinConfigPlugin", "injectors": { "defaultRequire": 1 }, @@ -10,4 +13,4 @@ "client.ItemRendererMixin", "client.ModelLoaderMixin" ] -} \ No newline at end of file +}