diff --git a/If-you-want-to-contribute-to-Forge.md b/If-you-want-to-contribute-to-Forge.md index 98c868d..bd753b4 100644 --- a/If-you-want-to-contribute-to-Forge.md +++ b/If-you-want-to-contribute-to-Forge.md @@ -23,7 +23,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 this.setBeenAttacked(); this.health = (int)((float)this.health - p_70097_2_); @@ -38,8 +38,8 @@ return false; ``` 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: -``` - +```java +//snip this.setBeenAttacked(); ++ + if(isCondition) return false; @@ -52,11 +52,11 @@ if (this.health <= 0) } return false; - +//snip ``` But do: -``` - +```java +//snip this.setBeenAttacked(); ++ if(isCondition) return false; this.health = (int)((float)this.health - p_70097_2_); @@ -67,12 +67,12 @@ if (this.health <= 0) } return false; - +//snip ``` - In spirit of the previous point: prevent to add more lines than necessary. If you can reduce your statement to one single line, please do so. Example here is an `if`-statement that could be written as follows to improve readability: -``` +```java if((float)this.field_70291_e - p_70097_2_ <= 0.0F) { if(net.minecraftforge.common.ForgeHooks.onItemDeath(this, p_70097_1_)) @@ -82,18 +82,18 @@ if((float)this.field_70291_e - p_70097_2_ <= 0.0F) } ``` However, to keep changes to `.java.patch`-files as minimal as possible. Try to write that statement to one single line: -``` +```java if((float)this.field_70291_e - p_70097_2_ <= 0.0F && net.minecraftforge.common.ForgeHooks.onItemDeath(this, p_70097_1_)) return false; ``` - Prevent using imports and try using full qualifications in the code. Using imports will generate extra lines in patch-files which can be prevented. Imports that are already in the file are not your concern. Example below: -``` - +```java +//snip import net.minecraft.otherimports import net.minecraftforge.event.GenericEvent import net.minecraftforge.otherimports - +//snip if (isCondition) MinecraftForge.EVENT_BUS.post(new GenericEvent()); - +//snip ``` Instead try to code it as: ```