Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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
26 changes: 5 additions & 21 deletions src/main/java/com/paneedah/mwc/asm/Interceptors.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.paneedah.weaponlib.compatibility.CompatibleExposureCapability;
import com.paneedah.weaponlib.config.ModernConfigManager;
import com.paneedah.weaponlib.numerical.LissajousCurve;
import com.paneedah.weaponlib.render.NewScreenshakingManager;
import com.paneedah.weaponlib.render.ScreenshakingManager;
import com.paneedah.weaponlib.render.bgl.PostProcessPipeline;
import com.paneedah.weaponlib.render.cam.NaturalCamera;
import com.paneedah.weaponlib.vehicle.*;
Expand Down Expand Up @@ -52,7 +52,7 @@ public static boolean is3dRenderableItem(Item item) {
return item instanceof ItemBlock;
}

public static NaturalCamera nc = new NaturalCamera();
public static final NaturalCamera NATURAL_CAMERA = new NaturalCamera();

public static void setupCameraTransformAfterHurtCameraEffect(float partialTicks) {
//if(1+1==2) return;
Expand Down Expand Up @@ -328,7 +328,7 @@ public static void setupCameraTransformAfterHurtCameraEffect(float partialTicks)
//nc.update();
}

nsm.applyWorld();
SCREENSHAKING_MANAGER.applyWorld();

/*
if(weaponInstance != null) {
Expand Down Expand Up @@ -371,10 +371,7 @@ public static boolean setupViewBobbing(float partialTicks) {
if (ClientModContext.getContext() != null && ClientModContext.getContext().getMainHeldWeapon() != null) {
PlayerWeaponInstance pwi = ClientModContext.getContext().getMainHeldWeapon();


nc.update();

//System.out.println(ClientModContext.getContext());
NATURAL_CAMERA.update(pwi);
}


Expand Down Expand Up @@ -549,14 +546,6 @@ public static boolean setupViewBobbing(float partialTicks) {
RenderVehicle2.captureCameraTransform(null);
}


nsm.applyHead();
//nsm.update();


// if(true) return false;


if (ModernConfigManager.enableAllShaders && ModernConfigManager.enableScreenShaders) {
GlStateManager.disableLighting();
GlStateManager.disableBlend();
Expand All @@ -568,15 +557,10 @@ public static boolean setupViewBobbing(float partialTicks) {
GlStateManager.enableDepth();
}

// System.out.println("hi");
return false;
}

public static void renderLastEvent() {

}

public static NewScreenshakingManager nsm = new NewScreenshakingManager();
public static final ScreenshakingManager SCREENSHAKING_MANAGER = new ScreenshakingManager();

public static boolean hurtCameraEffect(float partialTicks) {
// if(1+1==2) return false;
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/paneedah/mwc/equipment/Vests.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static void createEquipment(ModContext modContext) {
.withName("m43a_chest_harness")
.withPercentDamageBlocked(0.1)
.withDurability(150)
.withTab(MWC.EQUIPMENT_TAB)
.withCreativeTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.M43AChestHarness", "m43achestharness.png")
// .withCustomEquippedPositioning(() -> {
// GlStateManager.scale(0.8f, 0.8f, 0.8f);
Expand All @@ -34,7 +34,7 @@ public static void createEquipment(ModContext modContext) {
.withName("flyye_field_compact_plate_carrier")
.withPercentDamageBlocked(0.2)
.withDurability(175)
.withTab(MWC.EQUIPMENT_TAB)
.withCreativeTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.MollePlateCarrier", "molleplatecarrier.png")
// .withCustomEquippedPositioning(() -> {
// GlStateManager.scale(0.8f, 0.8f, 0.8f);
Expand All @@ -54,7 +54,7 @@ public static void createEquipment(ModContext modContext) {
.withName("molle_black")
.withPercentDamageBlocked(0.2)
.withDurability(175)
.withTab(MWC.EQUIPMENT_TAB)
.withCreativeTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.MollePlateCarrier", "molleplatecarrier_black.png")
// .withCustomEquippedPositioning(() -> {
// GlStateManager.scale(0.8f, 0.8f, 0.8f);
Expand All @@ -74,7 +74,7 @@ public static void createEquipment(ModContext modContext) {
.withName("molle_green")
.withPercentDamageBlocked(0.2)
.withDurability(175)
.withTab(MWC.EQUIPMENT_TAB)
.withCreativeTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.MollePlateCarrier", "molleplatecarrier_green.png")
// .withCustomEquippedPositioning(() -> {
// GlStateManager.scale(0.8f, 0.8f, 0.8f);
Expand All @@ -94,7 +94,7 @@ public static void createEquipment(ModContext modContext) {
.withName("molle_urban")
.withPercentDamageBlocked(0.2)
.withDurability(175)
.withTab(MWC.EQUIPMENT_TAB)
.withCreativeTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.MollePlateCarrier", "molleplatecarrier_urban.png")
// .withCustomEquippedPositioning(() -> {
// GlStateManager.scale(0.8f, 0.8f, 0.8f);
Expand All @@ -114,7 +114,7 @@ public static void createEquipment(ModContext modContext) {
.withName("swat_vest")
.withPercentDamageBlocked(0.3)
.withDurability(250)
.withTab(MWC.EQUIPMENT_TAB)
.withCreativeTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.UTG547Vest", "utg547vest.png")
.withCustomEquippedPositioning(() -> {
GlStateManager.scale(0.8f, 0.8f, 0.8f);
Expand All @@ -134,7 +134,7 @@ public static void createEquipment(ModContext modContext) {
.withName("usMC_vest")
.withPercentDamageBlocked(0.4)
.withDurability(250)
.withTab(MWC.EQUIPMENT_TAB)
.withCreativeTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.USMCVest", "usMC.png")
// .withModelTextureName("usMC.png")
// .withCustomEquippedPositioning(() -> {
Expand All @@ -160,7 +160,7 @@ public static void createEquipment(ModContext modContext) {
// .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)
.withCreativeTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.USMCVest", "usMCvestblack.png")
// .withModelTextureName("usMC.png")
// .withCustomEquippedPositioning(() -> {
Expand All @@ -186,7 +186,7 @@ public static void createEquipment(ModContext modContext) {
// .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)
.withCreativeTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.USMCVest", "militaryuniformforest.png")
// .withModelTextureName("usMC.png")
// .withCustomEquippedPositioning(() -> {
Expand All @@ -212,7 +212,7 @@ public static void createEquipment(ModContext modContext) {
// .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)
.withCreativeTab(MWC.EQUIPMENT_TAB)
.withProperModel("com.paneedah.mwc.models.USMCVest", "militaryuniformurban.png")
// .withModelTextureName("usMC.png")
// .withCustomEquippedPositioning(() -> {
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/paneedah/mwc/init/MWCDataSerializers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.paneedah.mwc.init;

import com.paneedah.weaponlib.vehicle.network.VehicleDataSerializer;
import com.paneedah.weaponlib.vehicle.network.VehiclePhysSerializer;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.registries.DataSerializerEntry;

import static com.paneedah.mwc.ProjectConstants.ID;

@Mod.EventBusSubscriber(modid = ID)
public class MWCDataSerializers {

@SubscribeEvent
public static void registerSerializers(RegistryEvent.Register<DataSerializerEntry> event) {

event.getRegistry().registerAll(
new DataSerializerEntry(VehicleDataSerializer.SERIALIZER)
.setRegistryName(ID, "vehicle_data"),

new DataSerializerEntry(VehiclePhysSerializer.SERIALIZER)
.setRegistryName(ID, "vehicle_phys")
);
}
}
4 changes: 0 additions & 4 deletions src/main/java/com/paneedah/mwc/proxies/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ public void preInit(final MWC mod) {
// Forcing Item Initialization here, at the very least the variables, before they get registered normally on the init() (@SubscribeEvent) phase.
MWCItems.init();

// Idk? Deprecated too.
DataSerializers.registerSerializer(VehicleDataSerializer.SERIALIZER);
DataSerializers.registerSerializer(VehiclePhysSerializer.SERIALIZER);

// Special object initialization (Magic Mag)
SpecialAttachments.init(MWC.modContext);

Expand Down
13 changes: 2 additions & 11 deletions src/main/java/com/paneedah/weaponlib/ClientEventHandler.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.paneedah.weaponlib;

Check notice on line 1 in src/main/java/com/paneedah/weaponlib/ClientEventHandler.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (next)

โœ… Getting better: Overall Code Complexity

The mean cyclomatic complexity decreases from 5.19 to 5.14, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.

import com.paneedah.mwc.asm.Interceptors;
import com.paneedah.mwc.instancing.PlayerItemInstance;
Expand All @@ -19,7 +19,6 @@
import com.paneedah.weaponlib.perspective.Perspective;
import com.paneedah.weaponlib.render.framebuffer.HDRFramebuffer;
import com.paneedah.weaponlib.render.IHasModel;
import com.paneedah.weaponlib.render.MWCFrameTimer;
import com.paneedah.weaponlib.render.bgl.PostProcessPipeline;
import com.paneedah.weaponlib.render.shells.ShellManager;
import com.paneedah.weaponlib.shader.dynamic.DynamicShaderContext;
Expand Down Expand Up @@ -246,7 +245,7 @@
PlayerUtil.restorePlayerSpeed(player, SLOW_DOWN_WHILE_ZOOMING_ATTRIBUTE_MODIFIER);
}

if (mainHandHeldWeaponInstance != null && mainHandHeldWeaponInstance.getState() == WeaponState.READY && mainHandHeldWeaponInstance.getStateUpdateTimestamp() + DEFAULT_RECONCILE_TIMEOUT_MILLIS < System.currentTimeMillis() && mainHandHeldWeaponInstance.syncStartTimestamp == 0 && mainHandHeldWeaponInstance.getUpdateTimestamp() + DEFAULT_RECONCILE_TIMEOUT_MILLIS < System.currentTimeMillis()) {
if (mainHandHeldWeaponInstance.getState() == WeaponState.READY && mainHandHeldWeaponInstance.getStateUpdateTimestamp() + DEFAULT_RECONCILE_TIMEOUT_MILLIS < System.currentTimeMillis() && mainHandHeldWeaponInstance.syncStartTimestamp == 0 && mainHandHeldWeaponInstance.getUpdateTimestamp() + DEFAULT_RECONCILE_TIMEOUT_MILLIS < System.currentTimeMillis()) {

Check notice on line 248 in src/main/java/com/paneedah/weaponlib/ClientEventHandler.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (next)

โœ… Getting better: Complex Method

update decreases in cyclomatic complexity from 14 to 13, 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.

Check notice on line 248 in src/main/java/com/paneedah/weaponlib/ClientEventHandler.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (next)

โœ… Getting better: Complex Conditional

update decreases from 1 complex conditionals with 4 branches to 1 complex conditionals with 3 branches, threshold = 2. A complex conditional is an expression inside a branch (e.g. if, for, while) which consists of multiple, logical operators such as AND/OR. The more logical operators in an expression, the more severe the code smell.
mainHandHeldWeaponInstance.reconcile();
}
} else {
Expand Down Expand Up @@ -310,8 +309,6 @@
}
}

public MWCFrameTimer frameTimer = new MWCFrameTimer();

@SubscribeEvent
public void onRenderWorldLastEvent(RenderWorldLastEvent event) {
// Fills the model view matrix & projection matrix. Only used for world rendering.
Expand All @@ -322,14 +319,8 @@
// Replaces the weather renderer.
PostProcessPipeline.setWorldElements();

// Marks the frame-timer
frameTimer.markFrame();

// Todo: Optimize this
Comment thread
Desoroxxx marked this conversation as resolved.
Outdated
Comment thread
Desoroxxx marked this conversation as resolved.
Outdated
// Frame-timer syncs to 120
double divisor = 120 / frameTimer.getFramerate() * 0.05;
divisor = Math.min(0.08, divisor);
Interceptors.nsm.update();
Interceptors.SCREENSHAKING_MANAGER.update(event.getPartialTicks());

BULLET_HOLE_RENDERER.render();

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/paneedah/weaponlib/ClientModContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.paneedah.weaponlib.melee.MeleeRenderer;
import com.paneedah.weaponlib.melee.PlayerMeleeInstance;
import com.paneedah.weaponlib.perspective.PerspectiveManager;
import com.paneedah.weaponlib.render.bgl.GLCompatible;
import lombok.Getter;
import net.minecraft.client.shader.Framebuffer;
import net.minecraft.entity.Entity;
Expand Down Expand Up @@ -93,6 +94,8 @@ public void preInit(Object mod) {
public void init(Object mod) {
super.init(mod);

GLCompatible.init();

rendererRegistry.registerEntityRenderingHandler(WeaponSpawnEntity.class, new SpawnEntityRenderer());
rendererRegistry.registerEntityRenderingHandler(EntityWirelessCamera.class, new WirelessCameraRenderer());
rendererRegistry.registerEntityRenderingHandler(EntityShellCasing.class, new ShellCasingRenderer());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/paneedah/weaponlib/ItemScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.paneedah.weaponlib.electronics.ScopePerspective;
import com.paneedah.weaponlib.perspective.ReflexScreen;
import com.paneedah.weaponlib.render.scopes.CyclicList;
import com.paneedah.weaponlib.numerical.CyclicList;
import com.paneedah.weaponlib.render.scopes.Reticle;
import net.minecraft.client.renderer.GlStateManager;

Expand Down
24 changes: 2 additions & 22 deletions src/main/java/com/paneedah/weaponlib/ItemVest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import com.paneedah.mwc.renderer.ModelSourceTransforms;
import com.paneedah.mwc.renderer.StaticModelSourceRenderer;
import com.paneedah.mwc.rendering.Transform;
import com.paneedah.mwc.weapons.AbstractItemBuilder;
import com.paneedah.weaponlib.crafting.CraftingEntry;
import com.paneedah.weaponlib.crafting.CraftingGroup;
import com.paneedah.weaponlib.crafting.CraftingRegistry;
import com.paneedah.weaponlib.crafting.ICraftingRecipe;
import com.paneedah.weaponlib.render.IHasModel;
import com.paneedah.weaponlib.render.modelrepo.ServerGearModelHookRegistry;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.util.ITooltipFlag;
Expand All @@ -35,11 +35,8 @@
public class ItemVest extends Item implements ISpecialArmor, ModelSource, ICraftingRecipe, IHasModel {


public static class Builder {
public static class Builder extends AbstractItemBuilder<Builder> {

private String name;
private CreativeTabs tab;
private ModelBase model;
private String textureName;
private final ModelSourceTransforms transforms = ModelSourceTransforms.builder()
.entityPositioning(() -> new Transform()
Expand All @@ -60,11 +57,6 @@ public static class Builder {
private int damageReduceAmount;
private double percentDamageBlocked;

public Builder withName(String name) {
this.name = name;
return this;
}

public Builder withDamageReduceAmount(int damageReduceAmount) {
this.damageReduceAmount = damageReduceAmount;
return this;
Expand All @@ -80,12 +72,6 @@ public Builder withDurability(int durability) {
return this;
}

public Builder withTab(CreativeTabs tab) {
this.tab = tab;
return this;
}


public Builder withProperModel(String elModel, String properTextureName) {

modelFileString = elModel;
Expand All @@ -95,11 +81,6 @@ public Builder withProperModel(String elModel, String properTextureName) {
return this;
}

public Builder withModel(ModelBase model) {
this.model = model;
return this;
}

// public Builder withGuiTextureName(String guiTextureName) {
// this.guiTextureName = guiTextureName;
// return this;
Expand Down Expand Up @@ -174,7 +155,6 @@ public ItemVest build(ModContext modContext) {
ItemVest item = new ItemVest(modContext, percentDamageBlocked, durability);

// Register model and texture for the item
ServerGearModelHookRegistry.modelArray.add(this.modelFileString);
item.modelFileString = this.modelFileString;
item.textureName = this.properTextureName;
item.setTranslationKey(ID + "_" + name);
Expand Down
20 changes: 0 additions & 20 deletions src/main/java/com/paneedah/weaponlib/Weapon.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.paneedah.weaponlib;

Check notice on line 1 in src/main/java/com/paneedah/weaponlib/Weapon.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (next)

โœ… No longer an issue: Lines of Code in a Single File

The lines of code in this module is no longer above the threshold

Check notice on line 1 in src/main/java/com/paneedah/weaponlib/Weapon.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (next)

โœ… No longer an issue: Number of Functions in a Single Module

The number of functions in this module is no longer above the threshold

Check notice on line 1 in src/main/java/com/paneedah/weaponlib/Weapon.java

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (next)

โœ… Getting better: Primitive Obsession

The ratio of primitive types in function arguments decreases from 44.79% to 44.72%, threshold = 30.0%. The functions in this file have too many primitive types (e.g. int, double, float) in their function argument lists. Using many primitive types lead to the code smell Primitive Obsession. Avoid adding more primitive arguments.

import com.paneedah.mwc.instancing.PlayerItemInstanceFactory;
import com.paneedah.mwc.instancing.PlayerWeaponInstance;
Expand All @@ -23,7 +23,6 @@
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -63,19 +62,6 @@

public enum ShellCasingEjectDirection {LEFT, RIGHT}

public static class ScreenShaking {

private final float zRotationCoefficient;

public ScreenShaking(float zRotationCoefficient) {
this.zRotationCoefficient = zRotationCoefficient;
}

public float getZRotationCoefficient() {
return zRotationCoefficient;
}
}

public static class Builder extends AbstractItemBuilder<Builder> {

public static int noRecipe = 0;
Expand Down Expand Up @@ -433,12 +419,6 @@
return this;
}

public Builder withCreativeTab(CreativeTabs creativeTab) {
this.tab = creativeTab;
return this;
}


public Builder withSpawnEntityRocketParticles() {
this.spawnEntityRocketParticles = true;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ public static void fireWeapon(PlayerWeaponInstance pwi) {
double power = params.getWeaponPower();

if (GUN_POW.getCurrentValue() < INITIAL_GUN_POWER_CUTOFF) {
Interceptors.nsm.impulse(screenShakeParam.getFirst());
Interceptors.SCREENSHAKING_MANAGER.impulse(screenShakeParam.getFirst());
power *= INITIAL_GUN_POWER_MULTIPLIER;
} else if (GUN_POW.getCurrentValue() > params.getStockLength()) {
power *= GUN_POWER_PAST_STOCK_DIVISOR;
Interceptors.nsm.impulse(screenShakeParam.getFirst() * GUN_POWER_PAST_STOCK_DIVISOR);
Interceptors.SCREENSHAKING_MANAGER.impulse(screenShakeParam.getFirst() * GUN_POWER_PAST_STOCK_DIVISOR);
} else {
Interceptors.nsm.impulse(screenShakeParam.getFirst());
Interceptors.SCREENSHAKING_MANAGER.impulse(screenShakeParam.getFirst());
}

weaponRecovery.velocity += power * WEAPON_RECOVERY_VELOCITY_POWER;
Expand Down
Loading
Loading