-
Notifications
You must be signed in to change notification settings - Fork 5
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
Registry (For discussion only) #3
base: master
Are you sure you want to change the base?
Conversation
What are EntityMaterials? 😜 |
well... The stuff which describes the entity... So a tiny creeper or similar... This allows saving of positions of entities when the server is shut down. It could be just an id to name mapping in the end. |
I thought they were called EntityPrefabs... |
it may the prefabs than... Well you need to know the kind of prefab you want to save. And also I want to support changing the prefabs on block, same like with blockMaterial |
The plan with EntityPrefabs was that they are used only to create an entity - do tell what components are attached at the beginning. Later, only the components matter. You can attach or detach them at will. |
well, we would need to take a look than where we would include the Registry in that process than... And yeah... Also take a look at the PR :-P |
@dredhorse I'm having a hard time seeing the actual changes because of all the formatting changes? Can you fix it please? Remembers, spaces not tabs. |
|
||
public boolean saveRegistry() { | ||
if (Flow.getPlatform().isClient()) { | ||
Flow.debug("Won't be saving registry on client platform!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just throw an error. We don't want to even call this on the client.
Also, do !isServer, because Singleplayer is both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will change that... It could be possible that we run into problems afterwards though when we need to code the client and server code handling if we run both in one instance... I wonder what the impact would be to run a server and a client instance.
Also, what are the speed implications of using an Attribute system versus fields? |
you mean because of the generic object I'm using? No idea... We could switch it to something else. I know singleplayer is both, but won't it be 2 instances? Otherwise we should get a both option or isSinglePlayer. |
@dredhorse I'd just like to see some kind of profiling so I/we can judge this on that. SIngleplayer is not two instances. The methods are there only as a shortcut for doing two checks (ex. if Client then you have to check if CLIENT or if SINGLEPLAYER) |
|
||
/** | ||
* Class of the instancing Plugin. | ||
* This is required to make sure that only objects from the instancing game can be used as fallback objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it doesn't !
I mean... maybe it is required in order to , but we don't want to .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need too, fallback material must be something that ALL plugins for that "game" understand, otherwise any plugin can register a fallback material (why honestly???) and other plugins don't understand that and will generate errors... and if your "game" support also an external client that client will either crash or get blocks he can't display.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if we do need it, comparing package name is NOT the way to go.
Also, this should be (able to be) delegated to a class that extends BlockMaterialRegsitry. This is policy. We should separate policy from mechanisms.
Other random notes:
|
Also, one major problem you didn't solve: |
we need this crap in TempPlugin so that other plugins are able to grab the Registries when the want to make changes... Where else do you want to store that information, as discussed there will not be by default a Registry per World approach. Can cut down on the redundant checks. Will check the get.add attribute stuff. What do you exactly mean by the BaseMaterial.getID() returns an ID assigned by the old registry? |
By crap in TempPlugin I mean onClientEnable, setEnabled, etc. Stuff that a plugin would nomally have, but you do NOT NEED it in order to implement the registry. |
public BaseMaterial(String name) { | ||
this.displayName = name; | ||
this.name = getClass().getCanonicalName() + "_" + name.replace(' ', '_'); | ||
this.id = (short) MaterialRegistry.register(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By getID returns ID from old registry I mean exactly this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah… Mistake from my side… Thanks..
On 22.06.2014, at 12:19, Wolf480pl [email protected] 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(' ', '_');
By getID returns ID from old registry I mean exactly this...this.id = (short) MaterialRegistry.register(this);
—
Reply to this email directly or view it on GitHub.
Ah, ok… Well I did just put that stuff in as it was missing atm… I know it will be done it it’s own project. So ignore that atm.. On 22.06.2014, at 12:17, Wolf480pl [email protected] wrote:
|
@Wolf480pl @dredhorse for |
@dredhorse the Attribute system looks similar to the defaulted package in flow-commons? |
Hmm…. Need to check that On 24.06.2014, at 18:59, Jack Huey [email protected] wrote:
|
did you mean the defaultedHashMap? |
@dredhorse yes |
will look into that again... but I guess we can always fallback to normal objects if we have an issue later on. I will go on a 2 week vacation and will try to finish this, and also squash the commits to make it easier to review. We can than decide if we pull it or not. |
@dredhorse What's up with this? :D Also, be sure to rebase. |
Working on it, if you mean when will it be done. BTW: Also found out that we probably need a registry for world generators incl. Versions. On 07.08.2014, at 01:42, Jack Huey [email protected] wrote:
|
1a624be
to
011d9ab
Compare
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?????