Skip to content

Commit e48e624

Browse files
committed
added a Style Guide, updated CONTRIBUTING.md to refer to it (and to add some additional tips and guidelines)
1 parent 6015658 commit e48e624

3 files changed

Lines changed: 160 additions & 36 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Contributing to BloodMagic
2+
3+
First off, thank you for taking the time to contribute!
4+
5+
## Issues
6+
7+
First, make sure the issue has not been already reported. Have a look through the open issues on GitHub tagged with the version of Minecraft that you're playing with. (Also check the closed issues if you aren't playing with the latest version of the mod - your issue may have already been resolved in an update.)
8+
9+
If it has not been reported, follow the provided issue template (created when you click "New Issue"). Please be sure to fill in your Blood Magic version! If you're playing with other mods, see if you can re-create the issue with just Blood Magic and its dependencies. If not, see if you can figure out exactly which mods are required to trigger the issue, and list them too.
10+
11+
If it has been reported, provide any additional information you can to the current active issue.
12+
13+
## Pull Requests
14+
15+
With the ~~1.8~~ 1.21 rewrite comes a need to keep the code *clean*. Pull Requests will be looked over a bit stricter from now on.
16+
17+
When you wish to contribute, please keep these points in mind:
18+
19+
1) This guide assumes you are familiar with the basics of Java, Git, NeoForge, and modding minecraft in general. If not, there are plenty of tutorials out there, tailored to every level of expertise and method of learning; familiarise yourself with these tools before continuing.
20+
2) Before anything else, talk to us! Either open a PR with the basis of your idea or, for a more informal chat, come join our [Discord](https://discord.gg/VtNrGrs). The #dev-environment channel (and the threads in there) are the best place for this. That way we can discuss alternatives, bring up balance concerns, talk about whether it sounds like it'd make more sense as an addon-mod, etc.
21+
3) Once we've hammered out a decent and well-balanced design (or at least 'good enough for now'), then you can start making PRs (See below). After that we can refine, test, balance, refractor etc.
22+
4) Keep in mind that this process may not be fast - we all have lives outside of Blood Magic and sometimes things can take us away from the mod. If you ignore this and start coding before discussing it, you may find yourself having to throw away a lot of work.
23+
24+
### Making PRs
25+
1) Fork this repository and clone your fork locally.
26+
2) Open the project in your favourite IDE or Text Editor and make sure to sync the gradle project.
27+
3) Add this repository as upstream by running `git remote add upstream git@github.com:WayofTime/BloodMagic.git` and make sure your local clone knows about all the branches of it by running `git fetch upstream` after.
28+
4) Create a new local branch based on the upstream branch you wish to target (eg `git checkout -b <your branch name> upstream/1.21.1`)
29+
5) Make your changes in your new branch.
30+
6) Test your changes both on client only and client - server setups. We'll still test it ourselves, for completeness' sake.
31+
7) Now you can commit your changes, push them to your fork (`git push --set-upstream <your branch name>`) and open a pull request.
32+
8) We will review and test your changes and may ask you to change some things. If we do, change them on your local branch, commit and push it again (--set-upstream not needed anymore) and let us know you've done so, so we can repeat as needed.
33+
34+
### Do:
35+
* Try and make each commit represent a meaningful change to the code.
36+
* Squash extra commits if it's reasonable to do so.
37+
* Use meaningful names for classes, functions and parameters.
38+
* Code should be self documenting and the intents should be immediately clear. If in doubt, elaborate in a comment.
39+
* Describe each and every change you make in your Pull Request.
40+
* This lets everybody know exactly what is going on for easy discussion.
41+
* Make short yet descriptive commit titles.
42+
* Feel free to give a very basic overview of the commit in the message, then use the description to go into detail.
43+
* Keep your formatting the same as the project.
44+
* see [STYLE_GUIDE.MD](/STYLE_GUIDE.md) for more details
45+
46+
### Do not:
47+
* Make unnecessary changes to files.
48+
* If you don't need to touch it, don't touch it.
49+
* This includes: *renaming args*, *renaming files*, *editing formatting*, etc.
50+
51+
52+
## Human-Driven Development
53+
Blood Magic is a labour of love and has been hand-coded for over a decade, and we want to keep it that way. No-one on the dev team has any interest in agentic programming or AI-Driven development, and reading Claude code is frankly exhausting.
54+
55+
As such, we politely request that any PRs should be written by *you*, not merely prompted into existence. If code is written strangely or doesn't fit in with the rest of the mod's style, we will have questions.
56+
57+
This also applies to artwork - There are plenty of talented artists looking for gigs and if we decide to get more imagery for the mod, we'll commission them.
58+
59+
## If in doubt, ask. If dangerously certain, ask anyway.
60+
If a little cursory research on GitHub and discord haven't provided a conclusive answer, then there's no harm in asking. We'd much rather answer a few up-front questions than deny a 500-line PR, so please, always get clarification if there's the slightest seed of doubt. Similarly, push your code often and ask people to double-check it - many eyes make light work. (this also makes our jobs easier!)

STYLE_GUIDE.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
Here's a quick-and-dirty style-guide for contributing code to the mod. Thank you for your interest!
2+
3+
Make use of newlines when lines get long, like with builder style code
4+
If you have to scroll to see what's going on, you are probably better off splitting it, e.g:
5+
```
6+
return BlockBehaviour.Properties.of()
7+
.forceSolidOn()
8+
.noOcclusion()
9+
.strength(1.5F)
10+
.pushReaction(PushReaction.DESTROY)
11+
.mapColor(color)
12+
.sound(type)
13+
.lightLevel(state -> light);
14+
```
15+
A sort-of exception to this is registering stuff. we get what its doing and if we really need to know the specifics we can go look at them still. Besides, 50% of it is boilerplate anyway. e.g:
16+
```
17+
public static final DeferredHolder<Block, WhateverThingBlock> SOME_BLOCK_VAR_NAME = BLOCKS.register(...
18+
```
19+
As you can see above, we prefer tabs over spaces - please configure your IDE accordingly.
20+
21+
Prefer early return rather than putting everything inside an if. Do this even for a single condition.
22+
23+
This:
24+
```
25+
if (!conditionA) {
26+
return;
27+
}
28+
if (!conditionB) {
29+
return;
30+
}
31+
doStuff();
32+
```
33+
Not this:
34+
```
35+
if (conditionA) {
36+
if (conditionB) {
37+
doStuff();
38+
}
39+
}
40+
```
41+
Comments should not describe what the code does, but rather why it does that. Unless it's really complicated and *also* needs explaining what it does (but if you think your code is too complicated, try and simplify it! -wrince). If you need an essay, link it to a GitHub issue.
42+
43+
If there is something that needs to be looked at later for whatever reason
44+
`// TODO {whatever it is}` goes above the line (or at the end if its short)
45+
46+
47+
Example rundown of a class:
48+
```
49+
package whatever;
50+
51+
// All imports are grouped together (and usually sorted in alphabetical order)
52+
import a;
53+
import b;
54+
55+
// ... Except java internal stuff, which should be a separate group below
56+
import java.whatever;
57+
58+
// Class names (and record, enums etc count too) in PascalCase
59+
// Begin interfaces with I if they are for a capability. leave it be if its not
60+
// Enums dont *require* Enum in their name either, but it can be helpful in some cases.
61+
public class Name {
62+
63+
// Class wide variables used all over the place go on top and should
64+
// be grouped in some way that makes sense
65+
// Public static final's (constants) ARE_ALL_CAPS_WITH_UNDERSCORE
66+
public static final int CONSTANT_VAR = 5;
67+
public static final int CONSTANT_OTHER = 7;
68+
69+
// Static vars can either be snake_case or camelCase
70+
// Registry Keys, Resource Locations, Translation keys and all other sorts of strings that refer to something in code should be snake_case.
71+
private static String some_text = "blah";
72+
73+
// Booleans start with "is" or "has" or "do", or something similar
74+
// This should hint at its true/false nature in context
75+
private boolean isGreen = false;
76+
77+
public Name() {
78+
...
79+
}
80+
81+
// If there's a variable that mostly just interacts with one method
82+
// it can be declared just before that method (putting it with
83+
// the rest on top is also fine)
84+
private int fieldVar = 24;
85+
private void doSomething() {
86+
if (condition) {
87+
doStuff();
88+
} else { // Else has both braces on the same line.
89+
// there is nothing gained by doing this in 2 or 3 lines
90+
doSomethingElse();
91+
}
92+
doMore(fieldVar);
93+
}
94+
95+
// Setters and getters are named like this and go near where its relevant, or at the bottom
96+
public void setFieldVar(int fieldVar) {
97+
this.fieldVar = fieldVar;
98+
}
99+
}
100+
```

0 commit comments

Comments
 (0)