Skip to content

Commit

Permalink
Fixes & Improvments
Browse files Browse the repository at this point in the history
Enhanced stun flash effect
Fixed OpenGL Errors when dropping a gun
  • Loading branch information
Protoxy22 committed Aug 15, 2021
1 parent 4d6e962 commit 9192cd7
Show file tree
Hide file tree
Showing 10 changed files with 249 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ item.prototype.tactical_vest_lv1_tan.name=Tactical Vest Lv.1
item.prototype.tactical_vest_lv2_black.name=Tactical Vest Lv.2
item.prototype.tactical_vest_lv2_green.name=Tactical Vest Lv.2
item.prototype.tactical_vest_lv2_tan.name=Tactical Vest Lv.2
item.prototype.uniform_chest.name=Uniform Chest
item.prototype.uniform_feet.name=Uniform Boots
item.prototype.uniform_legs.name=Uniform Pants
item.prototype.uniform_feet.name=Uniform Boots
item.prototype.uniform_chest.name=Uniform Chest
item.prototype.vest.name=Vest
item.prototype.12gauge.name=12 Gauge Shell
item.prototype.12sluggauge.name=12 Slug Gauge Shot
Expand Down
33 changes: 17 additions & 16 deletions src/main/java/com/modularwarfare/client/ClientEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.modularwarfare.ModConfig;
import com.modularwarfare.ModularWarfare;
import com.modularwarfare.client.hud.FlashSystem;
import com.modularwarfare.client.model.InstantBulletRenderer;
import com.modularwarfare.common.init.ModSounds;
import com.modularwarfare.common.network.PacketOpenGui;
Expand Down Expand Up @@ -48,8 +49,8 @@ public void onPlaySound(PlaySoundEvent event) {
Minecraft mc = Minecraft.getMinecraft();
final ResourceLocation currentSound = event.getSound().getSoundLocation();

if (ClientRenderHooks.flashValue > 0 && !event.getSound().getSoundLocation().toString().contains("stun") && !event.getSound().getSoundLocation().toString().contains("flashed")) {
event.setResultSound(new PositionedSoundRecord(currentSound, event.getSound().getCategory(), 0.05f, 1.0f - ((float) ClientRenderHooks.flashValue / 50), false, 0, ISound.AttenuationType.LINEAR, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()) {{
if (FlashSystem.flashValue > 0 && !event.getSound().getSoundLocation().toString().contains("stun") && !event.getSound().getSoundLocation().toString().contains("flashed")) {
event.setResultSound(new PositionedSoundRecord(currentSound, event.getSound().getCategory(), 0.05f, 1.0f - ((float) FlashSystem.flashValue / 50), false, 0, ISound.AttenuationType.LINEAR, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()) {{
}});
}

Expand All @@ -58,45 +59,45 @@ public void onPlaySound(PlaySoundEvent event) {
}
if (currentSound.toString().equals("minecraft:block.grass.step")) {
if (mc.player.isSprinting()) {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_GRASS_SPRINT, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_GRASS_SPRINT, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
} else {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_GRASS_WALK, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_GRASS_WALK, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
}
} else if (currentSound.toString().equals("minecraft:block.stone.step")) {
if (mc.player.isSprinting()) {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_STONE_SPRINT, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_STONE_SPRINT, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
} else {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_STONE_WALK, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_STONE_WALK, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
}
} else if (currentSound.toString().equals("minecraft:block.gravel.step")) {
if (mc.player.isSprinting()) {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_GRAVEL_SPRINT, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_GRAVEL_SPRINT, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
} else {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_GRAVEL_WALK, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_GRAVEL_WALK, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
}
} else if (currentSound.toString().equals("minecraft:block.metal.step")) {
if (mc.player.isSprinting()) {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_METAL_SPRINT, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_METAL_SPRINT, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
} else {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_METAL_WALK, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_METAL_WALK, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
}
} else if (currentSound.toString().equals("minecraft:block.wood.step")) {
if (mc.player.isSprinting()) {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_WOOD_SPRINT, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_WOOD_SPRINT, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
} else {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_WOOD_WALK, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_WOOD_WALK, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
}
} else if (currentSound.toString().equals("minecraft:block.sand.step")) {
if (mc.player.isSprinting()) {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_SAND_SPRINT, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_SAND_SPRINT, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
} else {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_SAND_WALK, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_SAND_WALK, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
}
} else if (currentSound.toString().equals("minecraft:block.snow.step")) {
if (mc.player.isSprinting()) {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_SNOW_SPRINT, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_SNOW_SPRINT, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
} else {
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_SNOW_WALK, SoundCategory.BLOCKS, (ClientRenderHooks.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (ClientRenderHooks.flashValue > 0) ? 1.0f - ((float) ClientRenderHooks.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
event.setResultSound(new PositionedSoundRecord(ModSounds.STEP_SNOW_WALK, SoundCategory.BLOCKS, (FlashSystem.flashValue > 0) ? soundVolume * 0.05f : soundVolume, (FlashSystem.flashValue > 0) ? 1.0f - ((float) FlashSystem.flashValue / 50) : 1.0f, event.getSound().getXPosF(), event.getSound().getYPosF(), event.getSound().getZPosF()));
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/modularwarfare/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.modularwarfare.client.export.ItemModelExport;
import com.modularwarfare.client.handler.*;
import com.modularwarfare.client.hud.AttachmentUI;
import com.modularwarfare.client.hud.FlashSystem;
import com.modularwarfare.client.hud.GunUI;
import com.modularwarfare.client.killchat.KillFeedManager;
import com.modularwarfare.client.killchat.KillFeedRender;
Expand Down Expand Up @@ -108,6 +109,8 @@ public class ClientProxy extends CommonProxy {
public static HashMap<String, SoundEvent> modSounds = new HashMap<String, SoundEvent>();

public static ScopeUtils scopeUtils;
public static FlashSystem flashImage;

public static ItemLight itemLight = new ItemLight("light");

public static ClientRenderHooks renderHooks;
Expand Down Expand Up @@ -309,6 +312,9 @@ public void load() {
this.scopeUtils = new ScopeUtils();
MinecraftForge.EVENT_BUS.register(this.scopeUtils);

this.flashImage = new FlashSystem();
MinecraftForge.EVENT_BUS.register(this.flashImage);

this.attachmentUI = new AttachmentUI();
MinecraftForge.EVENT_BUS.register(this.attachmentUI);

Expand Down
11 changes: 0 additions & 11 deletions src/main/java/com/modularwarfare/client/ClientRenderHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ public class ClientRenderHooks extends ForgeEvent {
private Minecraft mc;
private float equippedProgress = 1f, prevEquippedProgress = 1f;

public static int flashValue;

public static final ResourceLocation grenade_smoke = new ResourceLocation("modularwarfare", "textures/particles/smoke.png");

public ClientRenderHooks() {
Expand Down Expand Up @@ -135,15 +133,6 @@ public void onWorldRenderLast(RenderWorldLastEvent event) {
}
}

@SubscribeEvent
public void onRenderPost(RenderGameOverlayEvent.Post event) {
Minecraft mc = Minecraft.getMinecraft();
if(event.getType() == RenderGameOverlayEvent.ElementType.ALL) {
if (flashValue != 0) {
RenderHelperMW.renderRectAlphaComp(0, 0, mc.displayWidth, mc.displayHeight, 0xFFFFFF, ClientRenderHooks.flashValue);
}
}
}

@SubscribeEvent
public void renderHeldItem(RenderSpecificHandEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.modularwarfare.client.ClientRenderHooks;
import com.modularwarfare.client.anim.AnimStateMachine;
import com.modularwarfare.client.anim.StateEntry;
import com.modularwarfare.client.hud.FlashSystem;
import com.modularwarfare.client.model.InstantBulletRenderer;
import com.modularwarfare.client.model.ModelGun;
import com.modularwarfare.client.model.renders.RenderParameters;
Expand Down Expand Up @@ -211,10 +212,10 @@ public void onClientTickStart(Minecraft minecraft) {
ClientProxy.gunUI.bulletSnapFade -= 0.01F;
}
//Client Flash Grenade
if (ClientRenderHooks.flashValue > 0) {
ClientRenderHooks.flashValue -= 2;
} else if (ClientRenderHooks.flashValue < 0) {
ClientRenderHooks.flashValue = 0;
if (FlashSystem.flashValue > 0) {
FlashSystem.flashValue -= 2;
} else if (FlashSystem.flashValue < 0) {
FlashSystem.flashValue = 0;
}
}

Expand Down
Loading

0 comments on commit 9192cd7

Please sign in to comment.