Registry (For discussion only)

Ok, here is my idea for a way to handle BlockMaterials, ItemMaterials, EntityMaterials etc.

Atm only BlockMaterials is done, and I didn't create any abstract classes or interfaces really.

Most code is in api/material, api/material/block and engine/registry

The plugin running the game will create a registry and pass the kind of registry it want's to use (yaml etc) to it. It will than initialize the registry which will normally load it if the registry is already on file and if it is a server.

Loading the registry means that the mapping ID = MaterialName is done, nothing more, after that the materials need to be added still.

Base / Fallback material can only be used from the plugin holding the registry, custom material can come from other plugins.

you can remove a custom blockMaterial in which case we will fallback to an older version or to the base material.

Client handshake will handle this with a specific packet which will send over the registry to the client, after that the client will need to start adding the blockMaterials.

I guess implementing server-client-handshake will require some rework in the init and check init part, we should only init the registry if the yamlregistry for example is already transmitted.

Feedback?????
Ah… Mistake from my side… Thanks..

On 22.06.2014, at 12:19, Wolf480pl <notifications@github.com> wrote:

> In src/main/java/com/flowpowered/api/material/BaseMaterial.java:
> 
> > +	private final String name;
> > +	private String displayName;
> > +	private int maxStackSize = 64;
> > +	private MATERIAL_STATE materialState = MATERIAL_STATE.UNDEFINED;
> > +
> > +	public static enum MATERIAL_STATE {
> > +		SOLID, LIQUID, GAS, UNDEFINED
> > +	}
> > +
> > +	/**
> > +	 * Creates a material with a name
> > +	 */
> > +	public BaseMaterial(String name) {
> > +		this.displayName = name;
> > +		this.name = getClass().getCanonicalName() + "_" + name.replace(' ', '_');
> > +		this.id = (short) MaterialRegistry.register(this);
> By getID returns ID from old registry I mean exactly this...
> 
> —
> Reply to this email directly or view it on GitHub.
>