Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
19 changes: 3 additions & 16 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 @@ -328,7 +328,7 @@ public static void setupCameraTransformAfterHurtCameraEffect(float partialTicks)
//nc.update();
}

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

/*
if(weaponInstance != null) {
Expand Down Expand Up @@ -549,14 +549,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 +560,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
24 changes: 24 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,24 @@
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;

@Mod.EventBusSubscriber
public class MWCDataSerializers {
Comment thread
strubium marked this conversation as resolved.
Outdated

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

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

new DataSerializerEntry(VehiclePhysSerializer.SERIALIZER)
.setRegistryName("mwc", "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
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
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
1 change: 0 additions & 1 deletion src/main/java/com/paneedah/weaponlib/melee/MeleeState.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.paneedah.weaponlib.melee;

import com.paneedah.mwc.network.TypeRegistry;
import com.paneedah.weaponlib.state.ManagedState;
import io.netty.buffer.ByteBuf;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.paneedah.weaponlib.render.scopes;
package com.paneedah.weaponlib.numerical;

import java.util.LinkedList;

/**
* A {@link LinkedList} that allows cycling through its elements indefinitely.
*
* <p>Each call to {@link #next()} advances the position by one. When
* the end of the list is reached, the position wraps around to the beginning.</p>
*
* @param <K> the type of elements in this list
*/
public class CyclicList<K> extends LinkedList<K> {

/**
*
*/
private static final long serialVersionUID = 1L;

private int position = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @since October 23rd, 2022
*/
@Getter @Setter
public class SpringValue {
public class SpringValue implements ISimulator {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

fd 'ISimulator.java' --type f

Repository: Cubed-Development/Modern-Warfare-Cubed

Length of output: 144


🏁 Script executed:

cat -n src/main/java/com/paneedah/weaponlib/numerical/ISimulator.java

Repository: Cubed-Development/Modern-Warfare-Cubed

Length of output: 243


🏁 Script executed:

cat -n src/main/java/com/paneedah/weaponlib/numerical/SpringValue.java

Repository: Cubed-Development/Modern-Warfare-Cubed

Length of output: 4140


Fix unused parameter in getLerpedPosition(double mu).

The method at lines 108-111 accepts a mu parameter but never uses it, instead calling MC.getRenderPartialTicks(). Either use the parameter or remove it from the signature.

🤖 Prompt for AI Agents
In `@src/main/java/com/paneedah/weaponlib/numerical/SpringValue.java` at line 18,
In SpringValue (class SpringValue) the method getLerpedPosition(double mu)
ignores its mu parameter and instead calls MC.getRenderPartialTicks(); change
the implementation to use the passed-in mu value wherever
MC.getRenderPartialTicks() is currently used so the method actually lerps by the
provided mu, and keep the signature as getLerpedPosition(double mu); if there
are call sites that relied on the old behavior, ensure they pass the desired
partial tick value into getLerpedPosition instead of relying on
MC.getRenderPartialTicks().


/**
* Integration Series:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.paneedah.weaponlib.config.ModernConfigManager;
import com.paneedah.weaponlib.model.ScreenModel;
import com.paneedah.weaponlib.render.Shaders;
import com.paneedah.weaponlib.render.scopes.CyclicList;
import com.paneedah.weaponlib.numerical.CyclicList;
import com.paneedah.weaponlib.render.scopes.Reticle;
import com.paneedah.weaponlib.shader.Shader;
import net.minecraft.client.model.ModelBase;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/paneedah/weaponlib/render/Bloom.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static boolean shouldRecreateFBOs() {

}

public static boolean bloomNotAvaliable() {
public static boolean bloomNotAvailable() {
return data == null;
}

Expand All @@ -90,7 +90,7 @@ public static void bindBloomBuffer() {
* if(data == null) { width = mc.displayWidth; height = mc.displayHeight;
* recreateFramebuffers(); }
*/
if (bloomNotAvaliable()) {
if (bloomNotAvailable()) {
return;
}

Expand Down
115 changes: 0 additions & 115 deletions src/main/java/com/paneedah/weaponlib/render/InstancedRender.java

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/java/com/paneedah/weaponlib/render/MWCFrameTimer.java

This file was deleted.

Loading