GithubHelp home page GithubHelp logo

Comments (4)

Moderocky avatar Moderocky commented on June 16, 2024

This is being caused because nearest entity is an Expression returning an array of Entities, being cast to an Expression that wants to return an array of LivingEntities, and an array of Entities is not an array of LivingEntities, so it's failing.

Here at Skript, our policy is to do these unchecked, unverified casts without properly checking and just suppress the warning, which is why this is occurring as a problem.

The easy fix is to just make the charge effect not do that cast, since it isn't necessary, but the larger question is why the %livingentities% input is accepting %entities% without any kind of conversion, since this will run into the same problem elsewhere.

from skript.

sovdeeth avatar sovdeeth commented on June 16, 2024

This is being caused because nearest entity is an Expression returning an array of Entities, being cast to an Expression that wants to return an array of LivingEntities, and an array of Entities is not an array of LivingEntities, so it's failing.

Here at Skript, our policy is to do these unchecked, unverified casts without properly checking and just suppress the warning, which is why this is occurring as a problem.

The easy fix is to just make the charge effect not do that cast, since it isn't necessary, but the larger question is why the %livingentities% input is accepting %entities% without any kind of conversion, since this will run into the same problem elsewhere.

I feel like it might be a bit more complicated than that, since nearest entity works fine, and player's spectator target, which is an Expression<Entity>, also worked fine in tests.

from skript.

Moderocky avatar Moderocky commented on June 16, 2024

I feel like it might be a bit more complicated than that, since nearest entity works fine, and player's spectator target, which is an Expression, also worked fine in tests.

No, it's exactly this, and it happens with a bunch of other syntax -- I'm testing it right now to find the whole list.

Basically, %livingentities% permits Expression<Entity>s and doesn't apply any kind of conversion, and because of the generic <LivingEntity> type, when getArray is called it tries to cast the array to a LivingEntity[] which, clearly, it won't be, since it's an entity expression, so it's throwing the class cast exception.

What probably ought to be happening is that it should sub in some kind of converted Expression that filters out the incorrect elements and returns the array that's been asked for.

from skript.

Moderocky avatar Moderocky commented on June 16, 2024

Having chased this issue down the rabbit hole, we discovered its cause is some expressions wrongly reporting their returntype as being different from the array type they return in get..., so in this issue the charge the nearest creeper fails because the expression promises to return a Creeper (a LivingEntity) but actually returns an array of Entities. This means the parser doesn't convert the expression.

I have a fix for this in the pipeline but I'd also like to find a way to address the more pervasive issue in future.

from skript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.