Skip to content

Commit

Permalink
Fix #8
Browse files Browse the repository at this point in the history
  • Loading branch information
kotmatross28729 committed Dec 23, 2024
1 parent 641d303 commit 50c0ad9
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 20 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 1.3.146

### Fixed
* Crash with new version of Hbm's NTM
* Bug with playing gas mask breathing sound for some players (Requires Hbm's NTM loaded)


### Added
* When mining enviromine coal, Hbm's NTM coal dust will be released.



---
# 1.3.144
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static int PulseWave(OverlayHandler overlay)
{
int alpha;

alpha = (int)(Math.sin( Math.toRadians(overlay.phase) ) * overlay.amplitude );
alpha = (int)(Math.sin(Math.toRadians(overlay.phase)) * overlay.amplitude);
alpha = (255 / overlay.amplitude) * alpha;

if(alpha >= 254) alpha = 254;
Expand Down
28 changes: 13 additions & 15 deletions src/main/java/enviromine/client/gui/hud/items/GasMaskHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@
import enviromine.client.gui.UI_Settings;
import enviromine.client.gui.hud.OverlayHandler;
import enviromine.core.EM_Settings;
import enviromine.core.EnviroMine;
import enviromine.handlers.ObjectHandler;
import enviromine.utils.RenderAssist;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.ISound;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;

@SideOnly(Side.CLIENT)
public class GasMaskHud
{
public static OverlayHandler maskBreathing = new OverlayHandler(1, true).setPulseVar(111, 200, 0, 2, 4);
public static OverlayHandler maskBreathing = new OverlayHandler(1, true).setPulseVar(111, 200, 0, 1, 1);

public static final ResourceLocation gasMaskResource = new ResourceLocation("enviromine", "textures/misc/maskblur2.png");
public static final ResourceLocation breathMaskResource = new ResourceLocation("enviromine", "textures/misc/breath.png");
Expand All @@ -35,9 +34,11 @@ public static void renderGasMask(Minecraft mc)
{
if(itemstack.getItem() == ObjectHandler.gasMask)
{

Renderbreath(scaledresolution.getScaledWidth(), scaledresolution.getScaledHeight(), mc, itemstack);

//Not sync with sound, because sound on server, not client
if(!EnviroMine.isHbmLoaded()) {
Renderbreath(scaledresolution.getScaledWidth(), scaledresolution.getScaledHeight(), mc, itemstack);
}

if(mc.gameSettings.thirdPersonView == 0)
{
mc.renderEngine.bindTexture(gasMaskResource);
Expand All @@ -49,25 +50,22 @@ public static void renderGasMask(Minecraft mc)


}
private static final ISound sound = PositionedSoundRecord.func_147674_a(new ResourceLocation("enviromine", "gasmask"), 1.0F);

public static void Renderbreath(int screenWidth, int screenHeight, Minecraft mc, ItemStack itemstack)
{
mc.renderEngine.bindTexture(breathMaskResource);

if(itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey(EM_Settings.GAS_MASK_FILL_TAG_KEY))
{
alpha = OverlayHandler.PulseWave(maskBreathing);

if(itemstack.getTagCompound().getInteger(EM_Settings.GAS_MASK_FILL_TAG_KEY) <= 20 && mc.gameSettings.thirdPersonView == 0)
if(itemstack.getTagCompound().getInteger(EM_Settings.GAS_MASK_FILL_TAG_KEY) <= 25 && mc.gameSettings.thirdPersonView == 0)
{
RenderAssist.drawScreenOverlay(screenWidth, screenHeight, maskBreathing.getRGBA(alpha));
}

if(maskBreathing.phase == 0 && !mc.isGamePaused() && UI_Settings.breathSound)
{
mc.thePlayer.playSound("enviromine:gasmask", UI_Settings.breathVolume, 1.0F);
}

if (maskBreathing.phase == 0 && !mc.isGamePaused() && UI_Settings.breathSound) {
mc.thePlayer.playSound("enviromine:gasmask", UI_Settings.breathVolume, 1.0F);
}
}
}
}
38 changes: 36 additions & 2 deletions src/main/java/enviromine/handlers/EM_EventManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package enviromine.handlers;

import com.hbm.blocks.ModBlocks;
import com.hbm.main.MainRegistry;
import com.hbm.sound.AudioWrapper;
import cpw.mods.fml.client.event.ConfigChangedEvent;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
Expand All @@ -12,6 +14,9 @@
import enviromine.EnviroDamageSource;
import enviromine.EnviroPotion;
import enviromine.blocks.tiles.TileEntityGas;
import enviromine.client.gui.UI_Settings;
import enviromine.client.gui.hud.OverlayHandler;
import enviromine.client.gui.hud.items.GasMaskHud;
import enviromine.client.gui.menu.config.EM_ConfigMenu;
import enviromine.core.EM_ConfigHandler;
import enviromine.core.EM_ConfigHandler.EnumLogVerbosity;
Expand Down Expand Up @@ -1300,7 +1305,9 @@ public void onPlayerUseItem(PlayerUseItemEvent.Finish event)
tracker.frostbiteLevel = 0;
}
}


private AudioWrapper audioBreathing;

@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event)
{
Expand Down Expand Up @@ -1339,10 +1346,37 @@ public void onLivingUpdate(LivingUpdateEvent event)
}
return;
}

if(event.entityLiving instanceof EntityPlayer)
{
InventoryPlayer invo = (InventoryPlayer)((EntityPlayer)event.entityLiving).inventory;

//GASMASK SOUND
if(EnviroMine.isHbmLoaded() && UI_Settings.breathSound) {
ItemStack mask = invo.armorItemInSlot(3);
if (mask != null && mask.getItem() != null && mask.getItem() == ObjectHandler.gasMask) {

if(mask.hasTagCompound() && mask.getTagCompound().hasKey(EM_Settings.GAS_MASK_FILL_TAG_KEY)) {
if ((audioBreathing == null || !audioBreathing.isPlaying())) {
audioBreathing = MainRegistry.proxy.getLoopedSound("enviromine:breathing", (float) event.entityLiving.posX, (float) event.entityLiving.posY, (float) event.entityLiving.posZ, 0.1F, 5.0F, 1.0F, 5);
audioBreathing.startSound();
}
audioBreathing.updatePosition((float) event.entityLiving.posX, (float) event.entityLiving.posY, (float) event.entityLiving.posZ);
audioBreathing.keepAlive();
} else {
if(audioBreathing != null) {
audioBreathing.stopSound();
audioBreathing = null;
}
}

} else if(audioBreathing != null) {
audioBreathing.stopSound();
audioBreathing = null;
}

}

AxisAlignedBB boundingBox = AxisAlignedBB.getBoundingBox(event.entityLiving.posX - 0.5D, event.entityLiving.posY - 0.5D, event.entityLiving.posZ - 0.5D, event.entityLiving.posX + 0.5D, event.entityLiving.posY + 0.5D, event.entityLiving.posZ + 0.5D).expand(2D, 2D, 2D);
if(event.entityLiving.worldObj.getEntitiesWithinAABB(TileEntityGas.class, boundingBox).size() <= 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/enviromine/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ options.enviromine.barPos.sanity=Sanity Bar
options.enviromine.barPos.airQuality=Air Quality Bar
options.enviromine.guiSounds=Sound Settings
options.enviromine.physSound=Physics Sounds
options.enviromine.breathVol=Breath Volume
options.enviromine.breathVol=Breath Volume (OUTDATED)
options.enviromine.newsPage=News Feed


Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/assets/enviromine/sounds.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
"gasmask"
]
},

"breathing": {
"category": "player",
"sounds": [
"breathing"
]
},
"thingkill": {
"category": "player",
"sounds": [
Expand Down
Binary file not shown.

0 comments on commit 50c0ad9

Please sign in to comment.