Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item JSON parse #1

Open
ci010 opened this issue Sep 7, 2017 · 1 comment
Open

Item JSON parse #1

ci010 opened this issue Sep 7, 2017 · 1 comment
Assignees

Comments

@ci010
Copy link
Collaborator

ci010 commented Sep 7, 2017

Parse Item JSON format and produce a Item object

Item JSON ===some parsing process===> Item Object

JSON format is defined in:
https://infinitystudio.github.io/SimpleAPI/docs/Item.html

Parsing process context: (the thing this module doesn't need to care about)
modid, the modid of the Mod that own this item
ItemTypeHandlerRegistry, the registry of the ItemTypeHandler, which is used to decorate Item with special property
CapabilityInjector, the api that injects the capability to a thing

ItemTypeHandlerRegistry和CapabilityInjector我都没写……没实现也没interface……LG你就定义2个顺手的interface把……modid和这俩你就当方法参数传进来就好了

Parsing process overview:

  1. determine the type of the item
  2. new DelegatedItem()
  3. set forge registry resLocation and unlocalized name (basically, you combine the modid and id property in JSON and generate resLocation and unlocalized name)
  4. inject capability if it requires
  5. get the ItemTypeHandler and feed the JSON (or maybe you store other property in a new map) to this handler. So the Item is decorated with special properties

sample interfaces:

interface ItemTypeHandler {
    void decorate(ItemDelegate item, JsonOrMap data);
}
interface ItemTypeHandlerRegistry {
    ItemTypeHandler getHandler(String type)
}
interface CapabilityInjector{
    void inject(Object obj, CapabilityInfo info);
}

(当然如果那些没实现的你想实现也没问题23333)

@LasmGratel
Copy link
Member

I will make some interfaces and implementations on the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants