Giter Site home page Giter Site logo

Enchantment API about betterstorage HOT 10 CLOSED

copygirl avatar copygirl commented on August 27, 2024
Enchantment API

from betterstorage.

Comments (10)

copygirl avatar copygirl commented on August 27, 2024

I'd really like to expose the enchantments so other mods can use them, and not just my own locks. I know I could have an API function for the items, like getLevelSecurity, but if someone wanted to make their own locks and make then enchantable I'm not sure how they'd do it.

Maybe you know a good way to do it?

from betterstorage.

copygirl avatar copygirl commented on August 27, 2024

I guess I'll just use a class with a bunch of public static Enchantment xyz; fields, and set them when the mod starts. It's simple and everything, so it should be good.

from betterstorage.

cadyyan avatar cadyyan commented on August 27, 2024

Just sat down to start looking at the code. I'm thinking it would be pretty nice if the enchantment didn't matter to the chest. Like the lock knows what effect it has on the chest and when the lock is attached it applies the effect to the chest. I'm hoping that's possible but it'll take some digging.

from betterstorage.

cadyyan avatar cadyyan commented on August 27, 2024

What about making your base enchantment class part of the API and then adding a method to that class that takes a container as a parameter and it allows the enchantment to apply some effect to the chest? The lock would need to get the list of enchantments it has and call this new method when the lock is added to a chest. A corresponding action would need to be done when the lock is removed as well. This way the lock has to know how to handle the enchantments, not the chest, AND the exact enchantment doesn't matter so much. This also means that someone else can implement their own enchantment that affects locks.

from betterstorage.

cadyyan avatar cadyyan commented on August 27, 2024

I might try and create a fork that has what I'm talking about a bit later.

from betterstorage.

copygirl avatar copygirl commented on August 27, 2024

Yeah, I have an now idea how I'd do it, thanks to your input.
I won't be getting at the API until I've fixed some of the more serious problems.

About the fork, I do have to say I'm very picky about other people's contributions.

from betterstorage.

cadyyan avatar cadyyan commented on August 27, 2024

Yeah fixing core functionality is a bit more important.

I totally get it. I'm trying to stick to the style of your code and trying not to change anything. It's your mod and I don't want to change/add stuff that makes it less your mod.

from betterstorage.

copygirl avatar copygirl commented on August 27, 2024

Added what I thought would be alright for the enchantment API.
Tell me if you'd like to suggest any changes or if it's fine, so I can close up the issue.

from betterstorage.

cadyyan avatar cadyyan commented on August 27, 2024

I think that should be sufficient. Only thing I can think to change is make the names more generic. So instead of shock make it just damage. That way someone could say add an enchantment that does burn damage or something. Then maybe also have the map of names to enchantments be a name to multiple enchantments and all the damage enchantments would be called.

from betterstorage.

copygirl avatar copygirl commented on August 27, 2024

That wouldn't really make sense, as the locks are what decide what happens when the chest is being opened. You could have a lock which does something else to the player for the shock enchantment, but the enchantments themselves are just "there" and can't control anything.

I'll mark the issue as closed now, but I'm (obviously) still open for suggestions and the like.

from betterstorage.

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.