Giter VIP home page Giter VIP logo

Comments (6)

gilesknap avatar gilesknap commented on July 23, 2024

My preferred behaviour would be that Item __str__ returns the short form but the constructor could take the long or short form:

In [2]: str(Item.AIR)
Out[2]: 'air'

In [4]: Item("air")
Out[4]: <Item.AIR: 'minecraft:air'>

In [4]: Item("minecraft:air")
Out[4]: <Item.AIR: 'minecraft:air'>

(I believe all commands are OK with the short form?)

from mcipc.

conqp avatar conqp commented on July 23, 2024

Yep. Unintentionally my last change to this Enum caused an unintended change of the previous behavior.
I reverted the changes and also added regression tests.
Fixed in 19a22f9

I made str(item) return the long form, since I think I had problems with the short form on some commands.

from mcipc.

gilesknap avatar gilesknap commented on July 23, 2024

@conqp for some reason this is still breaking the mcwb modules tests.

There is a change in behaviour which is affecting the vaildate function https://github.com/mcipc-tools/mcwb/blob/master/mcwb/functions.py#L88-L101.

When casting an array of Item to a numpy array the numpy array now ends up containing str instead of Item and this breaks the validation. Its not clear to me why this is happening.

Investigating further.

from mcipc.

gilesknap avatar gilesknap commented on July 23, 2024

downgrading mcipc and rcon does fix the issue.

from mcipc.

conqp avatar conqp commented on July 23, 2024

Well, Item had a __str__ method before, returning the long form, so that kind of behaviour should not have changed.
However, Item now is also a subclass of str, which is intentional.

from mcipc.

gilesknap avatar gilesknap commented on July 23, 2024

OK the subclass of str is probably what is doing it. numpy likes to use the base class of its elements as its type, I believe.
It also means that ndarray.toList() is returning a list of str even if you do make a numpy array of Item.

I have worked around this by supplying a dtype of Item to numpy constructors, so mcwb is working again. Now when we save an 'Items' object to a json file it now looks like a list of long form string (because it uses toList), but this works OK and is a bit more legible than the old format. loading of Items objects still supports the old and new json formats.

In short, I think the new behaviour is now fine for mcwb and mciwb. The only problem is if there are any other users relying on the old behaviour.

from mcipc.

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.