AlexiyOrlov / trajectory-preview

1 stars 0 forks source link

Plugin does not register #1

Closed SiverDX closed 1 year ago

SiverDX commented 1 year ago

Hey, I tried to create a plugin but it does not register I also cannot find the log message Loaded and prepared {} plugin(s) (debug or latest) even though the Main plugin is loaded / working

The log I added is also not appearing Am I missing something?

@TrajectoryPlugin
public class TrialErrorPlugin implements PreviewProvider {
    public TrialErrorPlugin() {}

    @Override
    public Class<? extends PreviewEntity<? extends Entity>> getPreviewEntityFor(final Player player, final Item shootable) {
        Main.LOG.info("Called `getPreviewEntityFor` with: " + shootable.getDescriptionId() + " " + shootable.getClass());
        if (shootable instanceof SpearItem) {
            return CactemSpearPreview.class;
        }

        return null;
    }
}
public class CactemSpearPreview extends BowArrowPreview implements PreviewEntity<AbstractArrow> {
    public CactemSpearPreview(final Level level) {
        super(level);
    }

    @Override
    public List<AbstractArrow> initializeEntities(final Player player, final ItemStack associatedItem) {
        if (associatedItem.getItem() instanceof SpearItem) {
            int timeLeft = player.getUseItemRemainingTicks();

            if (timeLeft > 0) {
                int maxDuration = player.getMainHandItem().getUseDuration();
                int difference = maxDuration - timeLeft;

                if (difference >= 10) {
                    ThrownCactemSpearEntity cactemSpear = new ThrownCactemSpearEntity(level, player, associatedItem);
                    cactemSpear.shootFromRotation(player, player.getXRot(), player.getYRot(), 0.0F, 2.5F, 0);

                    return Collections.singletonList(cactemSpear);
                }
            }
        }

        return null;
    }

    @Override
    public void simulateShot(final AbstractArrow simulatedEntity) {
        super.simulateShot(simulatedEntity);
    }
}
AlexiyOrlov commented 1 year ago

Strange, Loaded and prepared string should show up even if you haven't added any code. What does your build.gradle look like?

SiverDX commented 1 year ago

I added runtimeOnly fg.deobf("dev.buildtool:trajectory-preview:${trajectory_preview_version}:unobf") just now to see if I need it but it does not change anything

buildscript {
    repositories {
        maven { url 'https://maven.minecraftforge.net' }
        maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
        mavenCentral()
    }

    dependencies {
        classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
        classpath group: 'org.spongepowered', name: 'mixingradle', version: '0.7-SNAPSHOT'
        classpath 'org.parchmentmc:librarian:1.+'
    }
}

tasks.withType(JavaCompile).configureEach {
    options.encoding = 'UTF-8'
}

apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'org.parchmentmc.librarian.forgegradle'
apply plugin: 'org.spongepowered.mixin'

minecraft {
    mappings channel: 'parchment', version: "${parchment_version}-${minecraft_version}"

    runs {
        client {
            workingDirectory project.file('run')
            ideaModule "${rootProject.name}.${project.name}.main"
            taskName 'Client'

            mods {
                modClientRun {
                    source sourceSets.main
                }
            }
        }

        server {
            workingDirectory project.file('run')
            ideaModule "${rootProject.name}.${project.name}.main"
            taskName 'Server'

            mods {
                modServerRun {
                    source sourceSets.main
                }
            }
        }
    }
}

repositories {
    maven { url = "https://www.cursemaven.com" }
    maven { url = "https://mymavenrepo.com/repo/XXNTQu0VdMr93BjoOV1S/" } // Trajectory Preview

    flatDir {
        dirs 'dev'
    }
}

dependencies {
    minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

    implementation fg.deobf("curse.maven:obscure-api-638417:4522272") // 15 : 1.19.2
    implementation fg.deobf("curse.maven:trajectory-preview-289141:4493729") // 4.5.1 : 1.19
    implementation fg.deobf("curse.maven:creatures-and-beasts-414401:4411179") // 1.5.2 : 1.19.2

    implementation("dev.buildtool:trajectory-preview:${trajectory_preview_version}:api")
    runtimeOnly fg.deobf("dev.buildtool:trajectory-preview:${trajectory_preview_version}:unobf")

    if(project.mixin.toBoolean()) annotationProcessor "org.spongepowered:mixin:${mixinVersion}:processor"
}

mixin {
    if (project.mixin.toBoolean()) add sourceSets.main, "${mod_id}.refmap.json"
}

def resourceTargets = ['META-INF/mods.toml', 'pack.mcmeta', "${mod_id}.mixins.json".toString()]
def intoTargets = ["$rootDir/out/production/resources/", "$rootDir/out/production/${project.name}.main/", "$rootDir/bin/main/"]
def replaceProperties = [
        modid       : mod_id,
        version     : version,
        displayName : mod_name,
        author      : mod_author,
        license     : mod_license,
        desc        : mod_description,
        mcVersion   : minecraft_version,
        forgeVersion: forge_version,
        mixins      : mixins,
        clientMixins: client_mixins
]

processResources {
    inputs.properties replaceProperties
    replaceProperties.put 'project', project

    filesMatching(resourceTargets) {
        expand replaceProperties
    }

    intoTargets.each { target ->
        if (file(target).exists()) {
            copy {
                from(sourceSets.main.resources) {
                    include resourceTargets
                    expand replaceProperties
                }
                into target
            }
        }
    }
}

jar {
    manifest {
        attributes(["Specification-Title"     : project.file_name,
                    "Specification-Vendor"    : project.mod_author,
                    "Specification-Version"   : "1.0",
                    "Implementation-Title"    : project.file_name,
                    "Implementation-Version"  : project.version,
                    "Implementation-Vendor"   : project.mod_author,
                    "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
                    "MixinConfigs"            : project.mixin.toBoolean() ? "${mod_id}.mixins.json" : ""
        ])
    }
}

jar.finalizedBy('reobfJar')
SiverDX commented 1 year ago

Removed runtimeOnly fg.deobf("curse.maven:trajectory-preview-289141:4493729")

BowArrowPreview was coming from dev.buildtool.traj.preview.BowArrowPreview instead of dev.buildtool.trajectory.preview.BowArrowPreview

Did not fix the issue though

Looking at the .jar in the mods folder - the path is traj Kinda would have expected an error then

AlexiyOrlov commented 1 year ago

Yeah, you only need

implementation("dev.buildtool:trajectory-preview:${trajectory_preview_version}:api")
runtimeOnly fg.deobf("dev.buildtool:trajectory-preview:${trajectory_preview_version}:unobf"

Don't add jars from curseforge or any other sources

SiverDX commented 1 year ago

So it's probably because the part which loads plugins is not in my .jar (my mod) nor in the .jar from curse Do I need to provide the .jar? Wouldn't it be duplicate then?

Also getting an error with build Not sure why it worked before

    implementation("dev.buildtool:trajectory-preview:${trajectoryPreview_version}:api")
    compileOnly fg.deobf("dev.buildtool:trajectory-preview:${trajectoryPreview_version}:unobf")

(when adding compileOnly fg.deobf("dev.buildtool:trajectory-preview:${trajectoryPreview_version}:unobf"))

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve dev.buildtool:trajectory-preview:{strictly 4.5.1-1.19_mapped_parchment_2022.11.27-1.19.2}.
     Required by:
         project :
      > Cannot find a version of 'dev.buildtool:trajectory-preview' that satisfies the version constraints:
           Dependency path 'de.cadentem.trialanderror:Trial and Error modifications:1.0' --> 'dev.buildtool:trajectory-preview:{strictly 4.5.1-1.19_mapped_parchment_2022.11.27-1.19.2}'
           Dependency path 'de.cadentem.trialanderror:Trial and Error modifications:1.0' --> 'dev.buildtool:trajectory-preview:4.5.1-1.19'

   > Could not resolve dev.buildtool:trajectory-preview:4.5.1-1.19.
     Required by:
         project :
      > Cannot find a version of 'dev.buildtool:trajectory-preview' that satisfies the version constraints:
           Dependency path 'de.cadentem.trialanderror:Trial and Error modifications:1.0' --> 'dev.buildtool:trajectory-preview:{strictly 4.5.1-1.19_mapped_parchment_2022.11.27-1.19.2}'
           Dependency path 'de.cadentem.trialanderror:Trial and Error modifications:1.0' --> 'dev.buildtool:trajectory-preview:4.5.1-1.19'

They're both there though: image

Build works with just implementation fg.deobf("dev.buildtool:trajectory-preview:${trajectoryPreview_version}:unobf") though

SiverDX commented 1 year ago

I think Curse has some old version This is how you load the plugins in there right now:

static Set<PreviewProvider> previewProviders = ImmutableSet.of(new BasicPlugin());

SiverDX commented 1 year ago

Will you upload latest 1.19 Git build to CurseForge? It works with that

AlexiyOrlov commented 1 year ago

I'm sorry, it seems I fucked up and forgot to upload a version with API. Should be sorted out now,

AlexiyOrlov commented 1 year ago

So, have you managed to implement your thing?

SiverDX commented 1 year ago

Tested it again, I think the latest version is no good It's missing all previews now (and the API part is missing)

Seems like an old version as well or sth.? Entry class looks like this: image

Files are from 2023-04-16

AlexiyOrlov commented 1 year ago

Crap, I uploaded a version for 1.19.3. but not for 1.19. I will do it on Monday.

AlexiyOrlov commented 1 year ago

I uploaded it, you can try again.

SiverDX commented 1 year ago

Working now, many thanks