Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strubiums weaponlib cleanup #504

Merged
merged 19 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.paneedah.mwc.init.MWCBlocks;
import com.paneedah.weaponlib.config.ModernConfigManager;
import lombok.NoArgsConstructor;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -12,11 +13,9 @@

import java.util.Random;

public class WorldGeneratorEventHandler implements IWorldGenerator {
@NoArgsConstructor
public class ModernWorldGenerator implements IWorldGenerator {

public WorldGeneratorEventHandler() {

}

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/paneedah/mwc/UniversalSoundRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
* Creates a sound registry for WeaponLib to access in order to play
* reloading noises.
*
* Example: UniversalSoundLookup.registerSoundToLookup("test_sound");
*
* @author Jim Holden, 2022
*/
public class UniversalSoundRegistry {

public static void init() {
// Example: UniversalSoundLookup.registerSoundToLookup("test_sound");
UniversalSoundLookup.registerSoundToLookup("bolt_press");
UniversalSoundLookup.registerSoundToLookup("bolt_slap");
UniversalSoundLookup.registerSoundToLookup("chargehandle_back");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/paneedah/mwc/equipment/Armors.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
static ArmorMaterial Juggernaut = EnumHelper.addArmorMaterial("Juggernaut", "Juggernaut", 20, new int[]{5, 6, 2, 5}, 20, null, 0);
static ArmorMaterial Marine = EnumHelper.addArmorMaterial("Marine", "Marine", 60, new int[]{2, 3, 3, 3}, 15, null, 0);

public static void init(Object mod, ModContext modContext) {
public static void createEquipment(ModContext modContext) {

Check notice on line 68 in src/main/java/com/paneedah/mwc/equipment/Armors.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (next)

โœ… No longer an issue: Large Method

init is no longer above the threshold for lines of code. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.

Check notice on line 68 in src/main/java/com/paneedah/mwc/equipment/Armors.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (next)

โ„น New issue: Large Method

createEquipment has 137 lines, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
Builder marineArmorBuilder = new CustomArmor.Builder()
.withMaterial(Armors.Marine)
.withUnlocalizedName("Marine")
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/paneedah/mwc/equipment/Backpacks.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.paneedah.mwc.equipment;

import com.paneedah.mwc.items.equipment.carryable.ItemBackpack;
import com.paneedah.weaponlib.ModContext;
import com.paneedah.weaponlib.animation.Transform;
import net.minecraft.item.Item;

Expand All @@ -22,7 +23,7 @@

public static Item duffleBag;

public static void init() {
public static void createEquipment(ModContext modContext) {

Check notice on line 26 in src/main/java/com/paneedah/mwc/equipment/Backpacks.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (next)

โœ… No longer an issue: Large Method

init is no longer above the threshold for lines of code. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.

Check notice on line 26 in src/main/java/com/paneedah/mwc/equipment/Backpacks.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (next)

โ„น New issue: Large Method

createEquipment has 97 lines, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.

combatSustainmentBackpackTan = new ItemBackpack.Builder()
.withName("combat_sustainment_backpack_tan")
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/paneedah/mwc/equipment/Belts.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.paneedah.mwc.equipment;

import com.paneedah.weaponlib.ModContext;
import net.minecraft.item.Item;

public class Belts {

public static Item magazineBelt;

public static void init() {

public static void createEquipment(ModContext modContext) {
// TODO: Finish implementing belts
// magazineBelt = new ItemBelt.Builder()
// .withName("magazine_belt")
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/com/paneedah/mwc/equipment/Electronics.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.paneedah.mwc.MWC;
import com.paneedah.mwc.models.GasDetector;
import com.paneedah.weaponlib.ItemAttachment;
import com.paneedah.weaponlib.ModContext;
import com.paneedah.weaponlib.electronics.ItemHandheld;
import com.paneedah.weaponlib.electronics.ItemTablet;
import com.paneedah.weaponlib.electronics.ItemWirelessCamera;
Expand All @@ -15,134 +16,134 @@

public static ItemAttachment<Object> Tablet;

public static void init() {
public static void createEquipment(ModContext modContext) {
Tablet = new ItemTablet.Builder<>()
.withViewfinderPositioning(() -> {
float scale = 5.9f;
GL11.glScalef(scale, scale / MWC.modContext.getAspectRatio(), scale);
GL11.glScalef(scale, scale / modContext.getAspectRatio(), scale);
GL11.glTranslatef(-0.12f, 0.56f, 0.01f);
})
.withCreativeTab(MWC.EQUIPMENT_TAB)
.withCrosshair("HP")
.withModel(new TabletModel(), "IPad.png")
//.withModel(new com.paneedah.mwc.models.LPscope(), "HP2.png")
.withFirstPersonPositioning(() -> {
GL11.glRotatef(25.000000f, 1f, 0f, 0f);
GL11.glRotatef(50.000000f, 0f, 1f, 0f);
GL11.glRotatef(-20.000000f, 0f, 0f, 1f);
GL11.glTranslatef(1.000000f, 0.100000f, -4.399998f);
GL11.glScaled(5F, 5F, 5F);
})
.withThirdPersonModelPositioning(model -> {
if (model instanceof TabletModel) {
GL11.glTranslatef(-0.8F, -0.5F, 0.8F);
GL11.glRotatef(-45F, 0f, 1f, 0f);
GL11.glRotatef(80F, 1f, 0f, 0f);
GL11.glScaled(1F, 1F, 1F);
}
}).withInventoryModelPositioning(model -> {
if (model instanceof com.paneedah.mwc.models.HP) {
GL11.glTranslatef(-0.6F, -0.6F, 0.6F);
GL11.glRotatef(10F, 1f, 0f, 0f);
GL11.glRotatef(-190F, 0f, 1f, 0f);
GL11.glRotatef(0F, 0f, 0f, 1f);
GL11.glScaled(0.65F, 0.65F, 0.65f);
} else if (model instanceof com.paneedah.mwc.models.LPscope) {
GL11.glScaled(0F, 0F, 0F);
}
}).withEntityModelPositioning(model -> {
if (model instanceof com.paneedah.mwc.models.HP) {
GL11.glTranslatef(0.1F, 0.2F, 0.4F);
GL11.glRotatef(90F, 0f, 0f, 1f);
GL11.glScaled(0.4F, 0.4F, 0.4F);
} else if (model instanceof com.paneedah.mwc.models.LPscope) {
GL11.glScaled(0F, 0F, 0F);
}
})
.withFirstPersonHandPositioning(
() -> {
GL11.glScaled(2F, 2F, 2F);
GL11.glRotatef(-145.000000f, 1f, 0f, 0f);
GL11.glRotatef(-35.000000f, 0f, 1f, 0f);
GL11.glRotatef(20.000000f, 0f, 0f, 1f);
GL11.glTranslatef(-0.025000f, -1.149999f, -0.100000f);
},
() -> {
GL11.glScaled(2F, 2F, 2F);
GL11.glRotatef(-135.000000f, 1f, 0f, 0f);
GL11.glRotatef(40.000000f, 0f, 1f, 0f);
GL11.glRotatef(-35.000000f, 0f, 0f, 1f);
GL11.glTranslatef(0.040000f, -0.575000f, 0.125000f);
})
.withName("tablet")

.withTextureName("Dummy.png")
.build(MWC.modContext);
.build(modContext);

new ItemWirelessCamera.Builder()

.withName("wcam")
.withCreativeTab(MWC.EQUIPMENT_TAB)
.withModel(new CameraModel(), "gun")
.withFirstPersonPositioning(() -> {
// GL11.glTranslatef(0.5F, -1.5F, -0.7F);
GL11.glRotatef(55F, 0f, 1f, 0f);
// GL11.glRotatef(2F, 1f, 0f, 0f);
GL11.glTranslatef(-0.1F, -1.6F, 1F);
GL11.glScaled(1F, 1F, 1F);
})
.withThirdPersonModelPositioning(model -> {
if (model instanceof CameraModel) {
GL11.glTranslatef(-0.9F, -0.8F, 0.5F);
GL11.glRotatef(-50F, 0f, 1f, 0f);
GL11.glRotatef(80F, 1f, 0f, 0f);
GL11.glScaled(0.5F, 0.5F, 0.5F);
}
}).withInventoryModelPositioning(model -> {
if (model instanceof com.paneedah.mwc.models.HP) {
GL11.glTranslatef(-0.6F, -0.6F, 0.6F);
GL11.glRotatef(10F, 1f, 0f, 0f);
GL11.glRotatef(-190F, 0f, 1f, 0f);
GL11.glRotatef(0F, 0f, 0f, 1f);
GL11.glScaled(0.65F, 0.65F, 0.65f);
} else if (model instanceof com.paneedah.mwc.models.LPscope) {
GL11.glScaled(0F, 0F, 0F);
}
}).withEntityModelPositioning(model -> {
if (model instanceof com.paneedah.mwc.models.HP) {
GL11.glTranslatef(0.1F, 0.2F, 0.4F);
GL11.glRotatef(90F, 0f, 0f, 1f);
GL11.glScaled(0.4F, 0.4F, 0.4F);
} else if (model instanceof com.paneedah.mwc.models.LPscope) {
GL11.glScaled(0F, 0F, 0F);
}
})

.withFirstPersonHandPositioning(
() -> {
GL11.glScalef(0F, 0F, 0F);
// GL11.glRotatef(190F, 1f, 0f, 0f);
// GL11.glRotatef(10F, 0f, 1f, 0f);
// GL11.glRotatef(30F, 0f, 0f, 1f);
// GL11.glTranslatef(0.1F, -1.75F, 0F);
},
() -> {
GL11.glScalef(0F, 0F, 0F);
// GL11.glRotatef(190F, 1f, 0f, 0f);

Check notice on line 132 in src/main/java/com/paneedah/mwc/equipment/Electronics.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Commented out code

Commented out code (4 lines)
// GL11.glRotatef(0F, 0f, 1f, 0f);
// GL11.glRotatef(-10F, 0f, 0f, 1f);
// GL11.glTranslatef(-0.15F, -0.4F, 0.4F);
}
)

.build(MWC.modContext);
.build(modContext);


new ItemHandheld.Builder<>()
.withScreenPerspectiveType(GasDetectorScreenPerspective.class)
.withScreenPositioning(() -> {
float scale = 1.9f;
GL11.glScalef(scale, scale / MWC.modContext.getAspectRatio(), scale);
GL11.glScalef(scale, scale / modContext.getAspectRatio(), scale);
GL11.glTranslatef(0.017f, 0.16f, 0.17f);
})
.withCreativeTab(MWC.EQUIPMENT_TAB)
Expand Down Expand Up @@ -205,6 +206,6 @@
.withName("gas-detector")

.withTextureName("Dummy.png")
.build(MWC.modContext);
.build(modContext);

Check notice on line 209 in src/main/java/com/paneedah/mwc/equipment/Electronics.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (next)

โœ… No longer an issue: Complex Method

init is no longer above the threshold for cyclomatic complexity. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check notice on line 209 in src/main/java/com/paneedah/mwc/equipment/Electronics.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (next)

โ„น New issue: Complex Method

createEquipment has a cyclomatic complexity of 16, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
}
}
21 changes: 11 additions & 10 deletions src/main/java/com/paneedah/mwc/equipment/Vests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,234 +2,235 @@

import com.paneedah.mwc.MWC;
import com.paneedah.weaponlib.ItemVest;
import com.paneedah.weaponlib.ModContext;
import com.paneedah.weaponlib.animation.Transform;
import org.lwjgl.opengl.GL11;

public class Vests {

public static void init(Object mod) {
public static void createEquipment(ModContext modContext) {

new ItemVest.Builder()
.withName("m43a_chest_harness")
.withPercentDamageBlocked(0.1)
.withDurability(150)
.withTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.M43AChestHarness", "m43achestharness.png")
// .withCustomEquippedPositioning(() -> {
// GL11.glScalef(0.8f, 0.8f, 0.8f);
// GL11.glTranslatef(0f, 0f, 0f);
// GL11.glRotatef(0F, 0f, 0f, 1f);
// })
.withInventoryPositioning(() -> {
new Transform()
.withPosition(-0.15, -4, -0.25)
.withRotation(-15, 150, 0)
.withScale(3, 3, 3)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

new ItemVest.Builder()
.withName("flyye_field_compact_plate_carrier")
.withPercentDamageBlocked(0.2)
.withDurability(175)
.withTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.MollePlateCarrier", "molleplatecarrier.png")
// .withCustomEquippedPositioning(() -> {
// GL11.glScalef(0.8f, 0.8f, 0.8f);
// GL11.glTranslatef(0f, 0f, 0f);
// GL11.glRotatef(0F, 0f, 0f, 1f);
// })
.withInventoryPositioning(() -> {
new Transform()
.withPosition(-0.15, -3.9, -0.25)
.withRotation(-15, 150, 0)
.withScale(3, 3, 3)
.doGLDirect();
})
.build(MWC.modContext);

new ItemVest.Builder()
.withName("molle_black")
.withPercentDamageBlocked(0.2)
.withDurability(175)
.withTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.MollePlateCarrier", "molleplatecarrier_black.png")
// .withCustomEquippedPositioning(() -> {
// GL11.glScalef(0.8f, 0.8f, 0.8f);
// GL11.glTranslatef(0f, 0f, 0f);
// GL11.glRotatef(0F, 0f, 0f, 1f);
// })
.withInventoryPositioning(() -> {
new Transform()
.withPosition(-0.15, -3.9, -0.25)
.withRotation(-15, 150, 0)
.withScale(3, 3, 3)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

new ItemVest.Builder()
.withName("molle_green")
.withPercentDamageBlocked(0.2)
.withDurability(175)
.withTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.MollePlateCarrier", "molleplatecarrier_green.png")
// .withCustomEquippedPositioning(() -> {
// GL11.glScalef(0.8f, 0.8f, 0.8f);
// GL11.glTranslatef(0f, 0f, 0f);
// GL11.glRotatef(0F, 0f, 0f, 1f);
// })
.withInventoryPositioning(() -> {
new Transform()
.withPosition(-0.15, -3.9, -0.25)
.withRotation(-15, 150, 0)
.withScale(3, 3, 3)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

new ItemVest.Builder()
.withName("molle_urban")
.withPercentDamageBlocked(0.2)
.withDurability(175)
.withTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.MollePlateCarrier", "molleplatecarrier_urban.png")
// .withCustomEquippedPositioning(() -> {
// GL11.glScalef(0.8f, 0.8f, 0.8f);
// GL11.glTranslatef(0f, 0f, 0f);
// GL11.glRotatef(0F, 0f, 0f, 1f);
// })
.withInventoryPositioning(() -> {
new Transform()
.withPosition(-0.15, -3.9, -0.25)
.withRotation(-15, 150, 0)
.withScale(3, 3, 3)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

new ItemVest.Builder()
.withName("swat_vest")
.withPercentDamageBlocked(0.3)
.withDurability(250)
.withTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.UTG547Vest", "utg547vest.png")
.withCustomEquippedPositioning(() -> {
GL11.glScalef(0.8f, 0.8f, 0.8f);
GL11.glTranslatef(0f, 0f, 0f);
GL11.glRotatef(0F, 0f, 0f, 1f);
})
.withInventoryPositioning(() -> {
new Transform()
.withPosition(-0.15, -3.9, -0.25)
.withRotation(-15, 150, 0)
.withScale(3, 3, 3)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

new ItemVest.Builder()
.withName("usMC_vest")
.withPercentDamageBlocked(0.4)
.withDurability(250)
.withTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.USMCVest", "usMC.png")
// .withModelTextureName("usMC.png")
// .withCustomEquippedPositioning(() -> {
// GL11.glScalef(0.8f, 0.8f, 0.8f);
// GL11.glTranslatef(0f, 0f, 0f);
// GL11.glRotatef(0F, 0f, 0f, 1f);
// })
.withEntityPositioning(() -> new Transform()
.withPosition(-0.5F, -1.9F, 0.5F)
.withScale(1, 1, 1)
.doGLDirect())
.withInventoryPositioning(() -> {
new Transform()
.withPosition(-0.15, -3.6, -0.25)
.withRotation(-15, 150, 0)
.withScale(2.6, 2.6, 2.6)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

new ItemVest.Builder()
.withName("usMC_vest_black")
// .withDamageReduceAmount(8) // use numbers from 1 to 8
.withPercentDamageBlocked(0.4)
.withDurability(250) // works the same way as shield's max capacity
.withTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.USMCVest", "usMCvestblack.png")
// .withModelTextureName("usMC.png")
// .withCustomEquippedPositioning(() -> {
// GL11.glScalef(0.8f, 0.8f, 0.8f);
// GL11.glTranslatef(0f, 0f, 0f);
// GL11.glRotatef(0F, 0f, 0f, 1f);
// })
.withEntityPositioning(() -> new Transform()
.withPosition(-0.5F, -1.9F, 0.5F)
.withScale(1, 1, 1)
.doGLDirect())
.withInventoryPositioning(() -> {
new Transform()
.withPosition(-0.15, -3.6, -0.25)
.withRotation(-15, 150, 0)
.withScale(2.6, 2.6, 2.6)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

new ItemVest.Builder()
.withName("usMC_vest_green")
// .withDamageReduceAmount(8) // use numbers from 1 to 8
.withPercentDamageBlocked(0.4)
.withDurability(250) // works the same way as shield's max capacity
.withTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.USMCVest", "militaryuniformforest.png")
// .withModelTextureName("usMC.png")
// .withCustomEquippedPositioning(() -> {
// GL11.glScalef(0.8f, 0.8f, 0.8f);
// GL11.glTranslatef(0f, 0f, 0f);
// GL11.glRotatef(0F, 0f, 0f, 1f);
// })
.withEntityPositioning(() -> new Transform()
.withPosition(-0.5F, -1.9F, 0.5F)
.withScale(1, 1, 1)
.doGLDirect())
.withInventoryPositioning(() -> {
new Transform()
.withPosition(-0.15, -3.6, -0.25)
.withRotation(-15, 150, 0)
.withScale(2.6, 2.6, 2.6)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

new ItemVest.Builder()
.withName("usMC_vest_urban")
// .withDamageReduceAmount(8) // use numbers from 1 to 8
.withPercentDamageBlocked(0.4)
.withDurability(250) // works the same way as shield's max capacity
.withTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.USMCVest", "militaryuniformurban.png")
// .withModelTextureName("usMC.png")
// .withCustomEquippedPositioning(() -> {
// GL11.glScalef(0.8f, 0.8f, 0.8f);
// GL11.glTranslatef(0f, 0f, 0f);
// GL11.glRotatef(0F, 0f, 0f, 1f);
// })
.withEntityPositioning(() -> new Transform()
.withPosition(-0.5F, -1.9F, 0.5F)
.withScale(1, 1, 1)
.doGLDirect())
.withInventoryPositioning(() -> {
new Transform()
.withPosition(-0.15, -3.6, -0.25)
.withRotation(-15, 150, 0)
.withScale(2.6, 2.6, 2.6)
.doGLDirect();
})
.build(MWC.modContext);
.build(modContext);

Check notice on line 234 in src/main/java/com/paneedah/mwc/equipment/Vests.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (next)

โœ… No longer an issue: Large Method

init is no longer above the threshold for lines of code. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.

Check notice on line 234 in src/main/java/com/paneedah/mwc/equipment/Vests.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (next)

โ„น New issue: Large Method

createEquipment has 163 lines, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/paneedah/mwc/items/guns/AK47Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import net.minecraft.util.math.Vec3d;
import org.lwjgl.opengl.GL11;

public class AK47Factory {
public class AK47Factory implements GunFactory {

public Item createGun(CommonProxy commonProxy) {
return new Weapon.Builder()
strubium marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -44,9 +44,9 @@
.withCrosshairRunning("Running")
.withCrosshairZoomed("Sight")
.withFlashIntensity(0.6f)
.withFlashScale(() -> 0.5f)

Check warning on line 47 in src/main/java/com/paneedah/mwc/items/guns/AK47Factory.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `0.5f`
.withFlashOffsetX(() -> 0.12f)

Check warning on line 48 in src/main/java/com/paneedah/mwc/items/guns/AK47Factory.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `0.12f`
.withFlashOffsetY(() -> 0.16f)

Check warning on line 49 in src/main/java/com/paneedah/mwc/items/guns/AK47Factory.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `0.16f`
.withCreativeTab(MWC.WEAPONS_TAB)
.useNewSystem()
.withRecoilParam(new RecoilParam(
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/com/paneedah/mwc/proxies/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.paneedah.mwc.items.melee.TacticalTomahawkFactory;
import com.paneedah.mwc.skins.GunSkins;
import com.paneedah.mwc.tileentities.TileEntities;
import com.paneedah.mwc.tileentities.TurretBaseFactory;
import com.paneedah.mwc.vehicle.Vehicles;
import com.paneedah.mwc.weapons.*;
import com.paneedah.weaponlib.UniversalSoundLookup;
Expand Down Expand Up @@ -62,20 +63,24 @@ public void preInit(final MWC mod) {

// Special object initialization
SpecialAttachments.init(mod, MWC.modContext);
Backpacks.init();
Belts.init();
Vests.init(mod);
Armors.init(mod, MWC.modContext);

Backpacks.createEquipment(MWC.modContext);
Belts.createEquipment(MWC.modContext);
Vests.createEquipment(MWC.modContext);
Armors.createEquipment(MWC.modContext);

Attachments.init(mod);
AuxiliaryAttachments.init(mod);
GunSkins.init(mod);
Bullets.init(mod);
Magazines.init(mod);
Guns.init(mod, this);
Electronics.init();
Electronics.createEquipment(MWC.modContext);
Grenades.init(mod, this);
CustomSpawnEggs.init(mod, this);
TileEntities.init(this);

TurretBaseFactory.createTileEntity(MWC.modContext);
TileEntities.createTileEntity(MWC.modContext);

new TacticalTomahawkFactory().createMelee(this);
new BaseballBatFactory().createMelee(this);
Expand All @@ -91,7 +96,7 @@ public void init(final MWC mod) {
Entities.init(this);
Vehicles.init(this);

GameRegistry.registerWorldGenerator(new WorldGeneratorEventHandler(), 0);
GameRegistry.registerWorldGenerator(new ModernWorldGenerator(), 0);
}

public void postInit(final MWC mod, final FMLPostInitializationEvent initializationEvent) {
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/paneedah/mwc/tileentities/TileEntities.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.paneedah.mwc.tileentities;

Check notice on line 1 in src/main/java/com/paneedah/mwc/tileentities/TileEntities.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (next)

โœ… Getting better: Lines of Code in a Single File

The lines of code decreases from 1899 to 1898, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.

import com.paneedah.mwc.MWC;
import com.paneedah.mwc.proxies.CommonProxy;
import com.paneedah.weaponlib.ModContext;
import com.paneedah.weaponlib.tile.CustomTileEntityBlock;
import com.paneedah.weaponlib.tile.LootBoxConfiguration;
import net.minecraft.block.material.Material;
Expand All @@ -11,9 +11,7 @@

public class TileEntities {

public static void init(CommonProxy commonProxy) {
new TurretBaseFactory().createTileEntity(MWC.modContext);

public static void createTileEntity(ModContext modContext) {

Check notice on line 14 in src/main/java/com/paneedah/mwc/tileentities/TileEntities.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (next)

โœ… No longer an issue: Complex Method

init is no longer above the threshold for cyclomatic complexity. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check notice on line 14 in src/main/java/com/paneedah/mwc/tileentities/TileEntities.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (next)

โ„น New issue: Complex Method

createTileEntity has a cyclomatic complexity of 121, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
new LootBoxConfiguration()
.withMaterial(Material.ROCK)
.withName("weapons_case")
Expand Down

This file was deleted.

14 changes: 3 additions & 11 deletions src/main/java/com/paneedah/mwc/tileentities/TurretBaseFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
import com.paneedah.weaponlib.ModContext;
import com.paneedah.weaponlib.tile.LootBoxConfiguration;
import net.minecraft.block.material.Material;
import net.minecraftforge.event.LootTableLoadEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.lwjgl.opengl.GL11;

public class TurretBaseFactory implements TileEntityFactory {
public class TurretBaseFactory {

@Override
public void createTileEntity(ModContext modContext) {
public static void createTileEntity(ModContext modContext) {
new LootBoxConfiguration()
.withMaterial(Material.ROCK)
.withName("turret_base")
Expand All @@ -24,11 +21,6 @@ public void createTileEntity(ModContext modContext) {
GL11.glTranslatef(0.5f, 0f, 0.5f);
// GL11.glRotatef(-45F, 0f, 1f, 0f);
})
.build(MWC.modContext);
.build(modContext);
}

@SubscribeEvent
public void lootLoad(LootTableLoadEvent evt) {
}

}
6 changes: 2 additions & 4 deletions src/main/java/com/paneedah/mwc/vehicle/AE86TruenoFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@

public class AE86TruenoFactory implements VehicleFactory {


@Override
public void createVehicle(ModContext modContext) {


StatefulRenderer<VehicleRenderableState> renderer = null;

if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
Expand Down Expand Up @@ -234,7 +232,7 @@
new EntityVehicleConfiguration.Builder()

.withName("ae86trueno")
.withEntityIdSupplier(() -> 10204)

Check warning on line 235 in src/main/java/com/paneedah/mwc/vehicle/AE86TruenoFactory.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `10204`

.withPhysicsConfig(new PhysicsConfiguration(
/* WHEELBASE (m)*/ 2.4003,
Expand Down Expand Up @@ -282,7 +280,7 @@
.withOBBDimensions(3.3, 2.5, 1.75)
.withSeat(new Vec3d(-0.89, -0.2, 0.0))
.withRenderer(renderer)
.build(MWC.modContext);
.build(modContext);
}

}
6 changes: 2 additions & 4 deletions src/main/java/com/paneedah/mwc/vehicle/ATVFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@

public class ATVFactory implements VehicleFactory {


@Override
public void createVehicle(ModContext modContext) {


StatefulRenderer<VehicleRenderableState> renderer = null;

if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
Expand Down Expand Up @@ -215,7 +213,7 @@
new EntityVehicleConfiguration.Builder()

.withName("atv_polaris_sportsman_850_2019")
.withEntityIdSupplier(() -> 10205)

Check warning on line 216 in src/main/java/com/paneedah/mwc/vehicle/ATVFactory.java

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Auto-boxing

Auto-boxing `10205`

.withPhysicsConfig(new PhysicsConfiguration(
/* WHEELBASE (m)*/ 1.2827,
Expand Down Expand Up @@ -263,7 +261,7 @@
.withOBBDimensions(1, 1, 1)
.withSeat(new Vec3d(-0.5, 0.2, -0.3))
.withRenderer(renderer)
.build(MWC.modContext);
.build(modContext);
strubium marked this conversation as resolved.
Show resolved Hide resolved
}

}
Loading
Loading