Jump to content

Recommended Posts

Posted

Hi All

 

I'd like to ask for some help from you experienced modders out there.

 

I'm putting together a sample code project to give simple working examples of the important concepts in Minecraft and Forge, to show new modders how the key parts are put together and give them a base to start experimenting from. 

 

I have made a modest start (https://github.com/TheGreyGhost/MinecraftByExample) and I'd like to make it much more comprehensive, so I am hoping some of you will help out.

 

What I'm looking for:

- ideas for topics / samples

- pointers to good examples which already exist in other projects

- snippets of self-contained code to illustrate a key concept.

- feedback

 

The key features of the samples are that

* they must be self-contained, a handful of short classes at most

* must be well documented in the source code itself

* they must be simple and readable; clarity is much more than important than flexibility, extensibility, or "efficiency"

 

FYI currently I'm planning on adding the following topics over time.  It's a long list and half of it I've got no idea about, so it's going to take forever without help...

Blocks -

  simple block modelling

  more-complicated block modelling

  blocks with properties / metadata

  block with display tick

  block with scheduled update

  animated texture

Items -

  simple item

  item with sub-types

  item with NBT

  how to control rendering in the different views (1st person, 3rd person, inventory, etc)

Recipes

  variety of recipe types

TileEntity

  simple tile entity with NBT, no renderer

  simple TileEntitySpecialRenderer

Containers

  furnace-like

  chest-like

Entities

  basic entity that can be spawned and disappears after a certain time

  missile entity

  entity rendering / techne -based / animation

  entity with basic AI

EntityFX

  simple effect generator

Events

  show some events on different busses

GUI

  customise the standard HUD render elements (crosshairs, etc)

  create a custom GUI

Terrain generation

 

Generate a new dimension

 

Miscellaneous

  best practice error logging (I could sure use some help on that one!)

 

Thoughts, feedback, suggestions very welcome...

 

-TGG

 

 

 

 

  • Like 1
Posted

Hello TGG,

 

Here's a pretty useful snippet of code that lets you move elements in the overlay to arbitrary locations. I think it's a very clean way of modifying the overlay, and it demonstrates how events can be used in very few lines of code.

 

@SubscribeEvent(receiveCanceled=true)
public void onEvent(RenderGameOverlayEvent.Pre event) {
  if (event.type == ElementType.FOOD) {
    /* This call saves the current "state" of transformations. */
    GL11.glPushMatrix();
    
    /* Move the food bar to some location. */
    GL11.glTranslatef(0, -10, 0);
  }
  /* etc. */
}

@SubscribeEvent(receiveCanceled=true)
public void onEvent(RenderGameOverlayEvent.Post event) {
  if (event.type == ElementType.FOOD) {
  
    /* This call reverts to the previous "state" of transformations,
     * effectively undoing anything that you have done above. Do not
     * forget to pop the matrix.
     */
    GL11.glPopMatrix();
  }
  /* etc. */
}

 

In the client side init method, register the above class:

MinecraftForge.EVENT_BUS.register(new SomeEventHandler());

 

Here's an example of what the above code does to the food bar:

 

 

e92b8fba56.jpg

 

Of course, it's possible to do all sorts of crazy things to the overlay.

01a4994a87.jpg

 

(The above images are from an unpublished mod that I worked on in the past, which is why there's a different health bar and an extra gold colored bar. )

 

 

Posted

Hi TGG,

 

This sounds like a great idea! My only concern is that noobs will just copy paste this into their mod and then tweak a minor thing then claim it as their own. I have some nifty tricks and I'll contribute and help ya ;D. Im really glad someone has started something like this.

 

-Asweez

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

Hi

 

This sounds like a great idea! My only concern is that noobs will just copy paste this into their mod and then tweak a minor thing then claim it as their own.

-Asweez

Well to be honest I was noob once (and still am in plenty of areas) so that doesn't really bother me much :P  Best way for a noob to ascend to coder god is to start by imitating the experts, I reckon...

 

I have some nifty tricks and I'll contribute and help ya ;D. Im really glad someone has started something like this.

Awesome, thanks!

 

Any particular areas you're thinking of?

 

-TGG

  • 1 month later...
Posted

Hi TGG,

 

This sounds like a great idea! My only concern is that noobs will just copy paste this into their mod and then tweak a minor thing then claim it as their own. I have some nifty tricks and I'll contribute and help ya ;D. Im really glad someone has started something like this.

 

-Asweez

 

So, what you are saying is that if you give me a blueberry muffin recipe made with regular all-purpose flour and I change the blueberries to cranberries, that the resulting new recipe isn't mine to claim?

  • 3 weeks later...
Posted

Seriously, copying and pasting code isn't that easy.  :P

 

It never works for me.  I always have to learn all the details of how the code was supposed to work, and change some tiny things, before it will work.  But it's a darn good start!  :)

 

-Noob

hw developer in a sw world

Posted

How much level do you planning to introduce on "Generate a new dimension"?

Tutorial like 'Changing Sunlight Strength' can be included? If so, I'd do that using PR.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Posted

Dimensions? Count me in!

 

What exactly do you want?

Server only (multiworld)

Full dimension with custom biomes?

dynamically generated dimensions? (Thats a bit harder, I still haven't got it working 100%)

 

Should we also post little helper classes? (1.8 display title, easier Potions, auto-updater, donator particles (why did I create donator particles if I never publish any of m mods?),...)

 

 

 

I think there is nothing wrong with copying code. I taught myself java by reading the decompiled Minecraft source and changing parts of it. I didn't even realize that I could google some stuff... I was such an idiot.

 

 

EDIT: I can also post 5 to 6 different all-around Teleporter classes. They are always usefull.

Here could be your advertisement!

  • 4 weeks later...
Posted

I have a lot of expertise with items and nbt stuff. I have some with entities and GUIs and almost nothing with blocks. If you ever need anything with those areas mentioned then I will try to help.

Creator of the MyFit, MagiCraft, Tesseract gun, and Papa's Wingeria mod.

Posted

Thanks TGG for continuing to blaze ahead to help the rest of us.

 

In my tutorials I personally have taken the approach of not sharing fully working examples because I feel that a person only learns by struggling through the details of tying the concepts together, plus I expect you'll take on a lot of support requests as people copy and paste.  But I'm also sure an example mod will be greatly appreciated.

 

As an aside, I encourage all modders to develop a default starting code base for their mods, with all their favorite hooks and organization.  When I start a new mod I can just copy my codebase and with a couple quick edits am up and running with working packets, event handling, etc.  What TGG is developing here might work well for a lot of you.

 

Anyway, my suggestions:

- it is probably implied in your other topics, but custom network messages is good topic.

- I personally like configurations.  Not sure how many people use them though.  I've even been getting into providing an in-game options GUI to control the configuration.

- You mentioned terrain generation and dimensions, but specifically biomes, structures, trees, oregen are all pretty popular topics.

- Villages would be interesting topic.

- Achievements and stats.

- Enchantments and potions.

- Entities that are mountable is a popular topic.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

I have a lot of expertise with items and nbt stuff. I have some with entities and GUIs and almost nothing with blocks. If you ever need anything with those areas mentioned then I will try to help.

Hi Asweez

 

Keen, thanks.  If you would be willing to code up an example or two (or more) on Entities, it would be very helpful because the example project currently has nothing on Entities at all.

 

The rough thought I had was for four examples:

Entities

  basic entity that can be spawned and disappears after a certain time

  missile entity (always people trying to code their own guns & bullets, bows & arrows, etc)

  entity rendering / techne -based / animation

  entity with basic AI

 

Perhaps a fifth for mountable entity like Jabelar suggested

 

Any contribution would be very helpful.

The existing project is at https://github.com/TheGreyGhost/MinecraftByExample

If you like, you could fork and PR; alternatively if you want to do a completely separate project that's fine too, I could integrate myself.

It would help a lot if you follow the package structure, class, notes, and commenting style used by the rest of the project because that will save me having to refactor it.

 

Cheers

  TGG

 

PS @Jabelar thanks for the suggestions, I'll add them to the wish list.  Will need to up my skills for some of those :) The project has a fair few examples, including network messages which are a minefield for the unwary.

 

 

 

 

 

 

 

  • 4 weeks later...
Posted

PS @Jabelar thanks for the suggestions, I'll add them to the wish list.  Will need to up my skills for some of those :)

 

One of the reasons I like answering questions and making tutorials is to get me into new topics. Sometimes the simplest question ("why isn't my custom slime entity transparent") can make you really go back and review what you know.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Don't know if you're looking for anything to do with armor, and it's for 1.7.10, but perhaps you can adapt this to your needs.

Thanks dude, sounds interesting, I'll look at it sometime in the next month or so... currently working on ISmartBlockModel...

  • 2 weeks later...
Posted

Do you by any change have a tutorial on ISmartItemModel? Or are you going to do one in the future? I'm making an Item with about 130 different variants, and I would like not having to make 130 model files only to change the texture. Or do you have another solution to this?

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Hi

 

Funnily enough I'm working on this right now... it's very similar to MBE04 - uses ModelBakeEvent to inject itself into the model registry.  I am just figuring out how to generate the BakedQuads algorithmically; based on this code

  https://github.com/MinecraftForge/MinecraftForge/blob/master/src/test/java/net/minecraftforge/debug/ModelBakeEventDebug.java

 

(The test code is a pretty good example to learn from, too)

 

If your 130 variants are made up of a few simple components, ISmartItemModel is probably the best way I reckon.  Alternatively, if you are just (say) changing colours like eggs or potions you could use the item layers instead.

 

-TGG

Posted

If I go the route for the different model files, every model file looks like this:

{
    "parent":"dwarffortress:item/standard_item",
    "textures": {
        "layer0": "minecraft:blocks/stone"
    }
}

The only difference per-JSON is the layer0 line, so only the texture. So I guess the ISmartItemModel is the way go here, right?

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted

Can you update the Camera transforms item, it doesn't actually move the item in your hand any more, I had to go get the code from the separate github page for it to work.

Posted

Can you update the Camera transforms item, it doesn't actually move the item in your hand any more, I had to go get the code from the separate github page for it to work.

Ah that's annoying, a regression bug perhaps...

What version did you try that didn't work?  (where did you get it from?)

Posted

I got the latest version yesterday, the current latest 11.14.1.1402, and I know that I used 11.14.1.1400 or higher. Also half the classes were declared deprecated. The other github repo did work though, but many classes were deprecated. Awsome item btw.

 

EDIT: I got it from the official files.minecraftforge.net

Posted

If I go the route for the different model files, every model file looks like this:

{
    "parent":"dwarffortress:item/standard_item",
    "textures": {
        "layer0": "minecraft:blocks/stone"
    }
}

The only difference per-JSON is the layer0 line, so only the texture. So I guess the ISmartItemModel is the way go here, right?

If your items are all identical except each one has a different texture, then yeah I would use the ISmartItemModel.  Create one model file with 130 defined textures, then your ISmartItemModel tweaks its bakedquad list to choose the correct texture coordinates

 

-TGG

Posted

I got the latest version yesterday, the current latest 11.14.1.1402, and I know that I used 11.14.1.1400 or higher. Also half the classes were declared deprecated. The other github repo did work though, but many classes were deprecated. Awsome item btw.

 

EDIT: I got it from the official files.minecraftforge.net

Oh, you mean- when you use the camera item after updating forge to 11.14.1.1402, it no longer works?  But it did work before?

I updated it with a couple of bugfixes recently but perhaps I broke something.  I will test again...

 

And you're talking about the camera item in MinecraftByExample, not the standalone GitHub ItemTransformHelper (or PlanetMinecraft d/load)?

 

-TGG

 

Posted

Ok so I just started modding 1.8 and I chose to grab the latest forge edition, i was going through your MinecraftByExample tutorial (random parts) and I saw the camera item and decided to try it because one of the biggest push factors for 1.8 modding for me was json models (as great as they are they are a pain) and it didn't actually modify the item translation/scale/rotation so I looked around and found the other repo and took all the code from there, it worked after that. Also as I said before a large number of the classes were deprecated.

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

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
  • Topics

×
×
  • Create New...

Important Information

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