Type casting in skript-mirror?

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Xander402

Member
Aug 20, 2019
3
0
1
22
Hello, everyone
I want to destroy (so that it will drop itself and its contents) a minecart with hopper that got under a certain chest.
My code I wrote so far (I'm using the skript-mirror add-on):
Code:
import:
    org.bukkit.event.inventory.InventoryMoveItemEvent
    org.bukkit.event.inventory.InventoryType
on InventoryMoveItemEvent:
    if event.getDestination().getType() is InventoryType.HOPPER:
        ...
        set {_minecart} to event.getDestination().getHolder()
        send "%{_minecart}'s location%" to all players
        {_minecart}.setDamage(50)
only shows the minecart's position (which at least is the sign proving that most of the code works properly) and I know exactly why this happens (or at least I think I do).
The local variable {_minecart} is an instance of org.bukkit.inventory.InventoryHolder, which inherits the getLocation() method from org.bukkit.entity.Entity.
In order to call the setDamage(int) method on that variable, it should be cast to org.bukkit.entity.minecart.HopperMinecart or org.bukkit.entity.Minecart. And this is my question. How can I cast {_minecart} to one of the above-mentioned interfaces? Skript does not recognize either the standard Java way of doing it or the Skipt native parsed as expression. Any ideas?
 
Status
Not open for further replies.