Skip to content
Open
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
@@ -0,0 +1,24 @@
package fr.dynamx.addons.basics.client;

import fr.dynamx.addons.basics.BasicsAddon;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

@Config(modid = BasicsAddon.ID, category = "sound")
@Mod.EventBusSubscriber(modid = BasicsAddon.ID)
public class BasicsAddonConfig {

@Config.RangeDouble(min = 0.0, max = 1.0)
@Config.Name("Siren Volume")
public static double sirenVolume = 1.0;

@SubscribeEvent
public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
if (event.getModID().equals(BasicsAddon.ID)) {
ConfigManager.sync(BasicsAddon.ID, Config.Type.INSTANCE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public boolean tryStop() {

@Override
public float getVolume() {
return 1.0F;
return (float) (BasicsAddonConfig.sirenVolume * 5.0);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package fr.dynamx.addons.basics.client;

import fr.dynamx.addons.basics.BasicsAddon;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreenOptionsSounds;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.fml.client.config.GuiSlider;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;

@Mod.EventBusSubscriber(modid = BasicsAddon.ID, value = Side.CLIENT)
public class SoundOptionsHandler {

@SubscribeEvent
public static void onGuiInit(GuiScreenEvent.InitGuiEvent.Post event) {
if (!(event.getGui() instanceof GuiScreenOptionsSounds))
return;

GuiButton subtitlesButton = null;
GuiButton doneButton = null;
for (GuiButton button : event.getButtonList()) {
if (button.id == 201) subtitlesButton = button;
if (button.id == 200) doneButton = button;
}

int centerX = event.getGui().width / 2;
int sliderY;

if (subtitlesButton != null) {
sliderY = subtitlesButton.y;
subtitlesButton.y += 24;
} else {
sliderY = event.getGui().height / 6 + 144;
}

if (doneButton != null) {
doneButton.y += 24;
}

GuiSlider sirenSlider = new GuiSlider(
9100, centerX - 155, sliderY, 310, 20,
I18n.format("basadd.sound.siren") + ": ", "%",
0, 100, BasicsAddonConfig.sirenVolume * 100, false, true,
slider -> {
BasicsAddonConfig.sirenVolume = slider.getValue() / 100.0;
ConfigManager.sync(BasicsAddon.ID, Config.Type.INSTANCE);
}
);
event.getButtonList().add(sirenSlider);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityMountEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
Expand Down Expand Up @@ -103,4 +105,20 @@ public static void interactWithCar(VehicleEntityEvent.PlayerInteract event) {
}
}
}

@SubscribeEvent
public static void onPlayerDismount(EntityMountEvent event) {
if (event.isDismounting() && !event.getWorldObj().isRemote) {
if (event.getEntityMounting() instanceof EntityPlayer && event.getEntityBeingMounted() instanceof BaseVehicleEntity) {
BaseVehicleEntity<?> vehicle = (BaseVehicleEntity<?>) event.getEntityBeingMounted();
if (vehicle.getControllingPassenger() == event.getEntityMounting()) {
BasicsAddonModule module = vehicle.getModuleByType(BasicsAddonModule.class);
if (module != null && (module.isSirenOn() || module.isBeaconsOn())) {
module.setSirenOn(false);
module.setBeaconsOn(true);
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public boolean listenEntityUpdates(Side side) {
@Override
public void updateEntity() {
if (playKlaxon() && entity.world.isRemote && hasKlaxon())
ClientProxy.SOUND_HANDLER.playSingleSound(Vector3fPool.get(entity.posX, entity.posY, entity.posZ), infos.klaxonSound, 1, 1);
ClientProxy.SOUND_HANDLER.playSingleSound(Vector3fPool.get(entity.posX, entity.posY, entity.posZ), infos.klaxonSound, (float) (fr.dynamx.addons.basics.client.BasicsAddonConfig.sirenVolume * 35.0), 1);
if (controller != null)
controller.updateSiren();
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/dynamx_basics/lang/de_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ basadd.key.linked.to=Schlüssel von %s
basadd.fuel.jerrycan=Treibstoff im Kanister: %s

item.dynx.dynamx_basics.fuel_jerrycan.name=Treibstoffkanister

basadd.sound.siren=Sirenen Lautst\u00e4rke
4 changes: 3 additions & 1 deletion src/main/resources/assets/dynamx_basics/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ basadd.key.invalid=Invalid key !
basadd.key.linked.to=%s's key
basadd.fuel.jerrycan=Jerrycan's fuel : %s

item.dynx.dynamx_basics.fuel_jerrycan.name=Fuel jerrycan
item.dynx.dynamx_basics.fuel_jerrycan.name=Fuel jerrycan

basadd.sound.siren=Siren Volume
4 changes: 3 additions & 1 deletion src/main/resources/assets/dynamx_basics/lang/fr_fr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ basadd.key.invalid=Clé invalide !
basadd.key.linked.to=Clé de %s
basadd.fuel.jerrycan=Essence dans le bidon : %s

item.dynx.dynamx_basics.fuel_jerrycan.name=Jerrycan d'essence
item.dynx.dynamx_basics.fuel_jerrycan.name=Jerrycan d'essence

basadd.sound.siren=Volume des sir\u00e8nes