Jump to content

[1.8] Registering commands good practices


DJD

Recommended Posts

If I have a lot of commands (some with variable parameters), what is the most efficient way of registering them ?

 

In other words, say I've got a base command Do (its dumb but its simple like me :D). It can have variable parameters associated with it such as:

 

Do

Do Something

Do Something ToSomethingElse

Do Help

 

Or in other words, is there I way I can register just the single "Do" command and pass it parameters for which "Do" to "do" ?

 

What is the best way to implement this ?

 

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Link to comment
Share on other sites

Thank you !

 

That helps a lot knowing I can encapsulate my commands for my mod with one register.

 

Or should I break each command out seperately ?

 

e.g I say i've got a Do command and a Go command. Register them seperately or as one "mega command" (e.g. say "mod"

and handle the Do and Go commands in there ?)

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Link to comment
Share on other sites

So if I have say 40 commands I should register each one individually ? Seems kind of archaic.....

 

Each command does only one thing.

 

My thinking is I have a base command (telling to use my mod) followed by a space followed by the command and any parameters I can create a centralized command handling system that won't mung up anyone else's mod commands....

 

mod Do something

mod Do something toSomething

mod Help

 

etc...

 

I register mod (or whatever I will call it) as a single command but handle the 1st parameter as the command and anything else entered as a parameter.  Is this a bad thing (e.g. will the engine balk at this) or am I overthinking this whole thing ?

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Link to comment
Share on other sites

I guess its also a question of if when you register a command with MC,

 

A) does it have to re-instantiate itself whenever a command is executed or

B) does it reside out there when registered to be waiting to be used until MC shuts down.

 

If A then a bunch a smaller footprint (individual commands) would be better

 

If B then a central command handler seems would be fine (and it simplifies error trapping, messaging etc etc).....

 

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Link to comment
Share on other sites

Think Diablo 3 and how it handles its "randomness".  it only has a few sections it uses over and over again with a few things changed to create a sense randomness.

 

I've got the design for storage handling, buffering etc down, so without getting into more boring details, my thoughts are like this:

 

The mod allows the generation of geomorphic sections with variations amongst the internal elements of each geomorph (e.g. a length of corridor with mostly cobblestone but sometimes will generate with a cracked cobblestone or whatever)....

 

To do so requires 3 types of files:

Structures: which blocks go where),

Themes: groups of blocks with similar properties (e.g. cobblestone dungeon)

Plans: The "how to" place the geomorphs so that they make sense (corridors things connect etc) and the randomness of it all.

 

These files are editable by hand, but some of the things that would be better to do inside Minecraft to ease the design burden.

(such as grab a section of blocks and save to a buffer for later output)....

 

A buffered structure (there can be more than one) can be "placed" and individual blocks "modified" and saved to the buffer. Which of course can be saved off (and hand edited later if desired instead of clunking around typing commands when one sees what needs to be done).

 

So there will be commands for:

Getting/Setting structures

Getting/Setting plans

Managing the buffer a little (e.g. structures and plans currently loaded) without having to save the whole thing, edit it in a text file and bring it back in.

 

All of this is done in creative mode.

 

For generation and actually playing, the Plans files are used to generate random geomorphic things (can be dungeon, town or whatever).

 

So... maybe that wasn't so short after all :D

 

It would be nice to handle the commands centrally (e.g. for error trapping and messaging purposes (e.g. output to player's chat)) rather than have a bunch of commands that each have to have their own error handling/messaging/IO etc.....

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Link to comment
Share on other sites

I'll probably go with the central idea first, because the way this thing has been created it would be easier to split it up later than try to put it all in one. Would be a good test anyway :D

I don't keep an open mind lest someone try to fill it with garbage - Mark Twain

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Try deliting feur builder  It caused this issue in my modpack
    • I am not using hardcoded recipes, I'm using Vanilla's already existing code for leather armor dying. (via extending and implementing DyeableArmorItem / DyeableLeatherItem respectively) I have actually figured out that it's something to do with registering item colors to the ItemColors instance, but I'm trying to figure out where exactly in my mod's code I would be placing a call to the required event handler. Unfortunately the tutorial is criminally undescriptive. The most I've found is that it has to be done during client initialization. I'm currently trying to do the necessary setup via hijacking the item registry since trying to modify the item classes directly (via using SubscribeEvent in the item's constructor didn't work. Class so far: // mrrp mrow - mcmod item painter v1.0 - catzrule ch package catzadvitems.init; import net.minecraft.client.color.item.ItemColors; import net.minecraft.world.item.Item; import net.minecraftforge.registries.ObjectHolder; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.client.event.ColorHandlerEvent; import catzadvitems.item.DyeableWoolArmorItem; @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class Painter { @ObjectHolder("cai:dyeable_wool_chestplate") public static final Item W_CHEST = null; @ObjectHolder("cai:dyeable_wool_leggings") public static final Item W_LEGS = null; @ObjectHolder("cai:dyeable_wool_boots") public static final Item W_SOCKS = null; public Painter() { // left blank, idk if forge throws a fit if constructors are missing, not taking the chance of it happening. } @SubscribeEvent public static void init(FMLClientSetupEvent event) { new Painter(); } @Mod.EventBusSubscriber private static class ForgeBusEvents { @SubscribeEvent public static void registerItemColors(ColorHandlerEvent.Item event) { ItemColors col = event.getItemColors(); col.register(DyeableUnderArmorItem::getItemDyedColor, W_CHEST, W_LEGS, W_SOCKS); //placeholder for other dye-able items here later.. } } } (for those wondering, i couldn't think of a creative wool helmet name)
    • nvm found out it was because i had create h and not f
    • Maybe there's something happening in the 'leather armor + dye' recipe itself that would be updating the held item texture?
    • @SubscribeEvent public static void onRenderPlayer(RenderPlayerEvent.Pre e) { e.setCanceled(true); model.renderToBuffer(e.getPoseStack(), pBuffer, e.getPackedLight(), 0f, 0f, 0f, 0f, 0f); //ToaPlayerRenderer.render(); } Since getting the render method from a separate class is proving to be bit of a brick wall for me (but seems to be the solution in older versions of minecraft/forge) I've decided to try and pursue using the renderToBuffer method directly from the model itself. I've tried this route before but can't figure out what variables to feed it for the vertexConsumer and still can't seem to figure it out; if this is even a path to pursue.  The vanilla model files do not include any form of render methods, and seem to be fully constructed from their layer definitions? Their renderer files seem to take their layers which are used by the render method in the vanilla MobRenderer class. But for modded entities we @Override this function and don't have to feed the method variables because of that? I assume that the render method in the extended renderer takes the layer definitions from the renderer classes which take those from the model files. Or maybe instead of trying to use a render method I should be calling the super from the renderer like   new ToaPlayerRenderer(context, false); Except I'm not sure what I would provide for context? There's a context method in the vanilla EntityRendererProvider class which doesn't look especially helpful. I've been trying something like <e.getEntity(), model<e.getEntity()>> since that generally seems to be what is provided to the renderers for context, but I don't know if it's THE context I'm looking for? Especially since the method being called doesn't want to take this or variations of this.   In short; I feel like I'm super super close but I have to be missing something obvious? Maybe this insane inane ramble post will provide some insight into this puzzle?
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.