mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-22 13:09:59 +00:00
Updated If you want to contribute to Forge (markdown)
1 parent
fe08738322
commit
40d5699231
1 file changed
+5
-5
@@ -24,7 +24,7 @@ Whenever a new update of Minecraft is released, these patches are applied to the
|
||||
#### While coding:
|
||||
- Prevent to add extra spaces/line breaks, even when there are already existing ones in the code between statements. Below is an example that comes from `net.minecraft.entity.item.EntityItem#attackEntityFrom(DamageSourc, float)`:
|
||||
```java
|
||||
<snip>
|
||||
//snip
|
||||
this.setBeenAttacked();
|
||||
this.health = (int)((float)this.health - p_70097_2_);
|
||||
|
||||
@@ -34,7 +34,7 @@ if (this.health <= 0)
|
||||
}
|
||||
|
||||
return false;
|
||||
<snip>
|
||||
//<snip
|
||||
```
|
||||
Lets say we add an `if`-statement between `this.setBeenAttacked();` and `this.health = (int)((float)this.health - p_70097_2_);`. It seems that `if`-statements get extra spaces/line breaks in the original code. However, when contributing to a `java.patch`-file you should always try to keep the changes as minimal as possible.
|
||||
So, don't do:
|
||||
@@ -97,12 +97,12 @@ import net.minecraftforge.otherimports
|
||||
```
|
||||
Instead try to code it as:
|
||||
```
|
||||
<snip>
|
||||
//snip
|
||||
import net.minecraft.otherimports
|
||||
import net.minecraftforge.otherimports
|
||||
<snip>
|
||||
//snip
|
||||
if (isCondition) MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.GenericEvent());
|
||||
<snip>
|
||||
//snip
|
||||
```
|
||||
Sidenote: The previous example can be improved further. As FML/Forge is trying to move away from imports try to use `net.minecraftforge.common.MinecraftForge` even when an existing import is already there.
|
||||
An even better way is to add a function in `net.minecraftforge.event.EventFactory` or `net.minecraftforge.common.ForgeHooks` and use the full qualification function names.
|
||||
|
||||
Reference in new issue
Block a user