Skript icon indicating copy to clipboard operation
Skript copied to clipboard

Cow Variants

Open Absolutionism opened this issue 7 months ago • 8 comments

Description

This PR aims to add support for cow variants to Skript. A bit of reflect was needed in order to set and get the variant.


Target Minecraft Versions: any Requirements: none Related Issues: none

Absolutionism avatar May 15 '25 07:05 Absolutionism

Rather than all the reflection, that will be removed in a couple years, why not just only register the CowData class if the variant exists? (same for simple data, if the class doesn't exist, register a simple cow)

ShaneBeee avatar May 15 '25 18:05 ShaneBeee

Rather than all the reflection, that will be removed in a couple years, why not just only register the CowData class if the variant exists? (same for simple data, if the class doesn't exist, register a simple cow)

Even if I made it where CowData would only be registered on 1.21.5+ it would still require the reflection.

Absolutionism avatar May 15 '25 18:05 Absolutionism

why would it require reflection?

ShaneBeee avatar May 15 '25 18:05 ShaneBeee

why would it require reflection?

I'm not entirely sure of how it works. But for some reason Cow.class was returning/redirecting to AbstractCow.class and within #set(Cow cow) it was throwing a NoSuchMethod for the #setVariant, because for some reason cow was an AbstractCow. I asked in Paper discord couple hours ago, and it has something to do with the api-version in plugin.yml.

Before making the PR, I had changed the api-version to 1.21.5 and it worked perfectly, but since it needed to be 1.19, then that wasn't a viable option.

Absolutionism avatar May 15 '25 18:05 Absolutionism

convo continued on Discord. Due to some silly API stuff in Paper, I guess the reflection is necessary.

ShaneBeee avatar May 15 '25 19:05 ShaneBeee

Can we get a short summary of why in a comment/in the PR description? I'm curious about it too

sovdeeth avatar May 15 '25 19:05 sovdeeth

Can we get a short summary of why in a comment/in the PR description? I'm curious about it too

Basically as Smurfy already said. By not having api-version: "1.21.5" ... Paper is forcing the Cow class to return as AbstractCow. So when doing Cow#setVariant its forcing AbstractCow#setVariant (which doesn't exist)

ShaneBeee avatar May 15 '25 19:05 ShaneBeee

Can we get a short summary of why in a comment/in the PR description? I'm curious about it too

Basically as Smurfy already said. By not having api-version: "1.21.5" ... Paper is forcing the Cow class to return as AbstractCow. So when doing Cow#setVariant its forcing AbstractCow#setVariant (which doesn't exist)

Wacky, thanks

sovdeeth avatar May 15 '25 19:05 sovdeeth