-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add button to refresh the sounds (#436)
- Loading branch information
Showing
4 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/com/mitchej123/hodgepodge/client/handlers/ReloadSoundsGui.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.mitchej123.hodgepodge.client.handlers; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiButton; | ||
import net.minecraft.client.gui.GuiScreenOptionsSounds; | ||
import net.minecraft.util.StatCollector; | ||
import net.minecraftforge.client.event.GuiScreenEvent; | ||
|
||
import com.mitchej123.hodgepodge.config.TweaksConfig; | ||
|
||
import cpw.mods.fml.common.eventhandler.SubscribeEvent; | ||
|
||
public class ReloadSoundsGui { | ||
|
||
private static final int BUTTON_ID = 51861; | ||
|
||
@SubscribeEvent | ||
public void onInitGui(GuiScreenEvent.InitGuiEvent.Post event) { | ||
if (TweaksConfig.reloadSoundsButton && event.gui instanceof GuiScreenOptionsSounds) { | ||
int posX = event.gui.width / 2 - 100; | ||
int posY = 0; | ||
for (Object o : event.buttonList) { | ||
if (o instanceof GuiButton guiButton | ||
&& o.getClass().getName().endsWith("GuiScreenOptionsSounds$Button")) { | ||
posY = Math.max(posY, guiButton.yPosition); | ||
} | ||
} | ||
if (posY == 0) { | ||
posY = event.gui.height / 6 + 168 - (20 + 4) * 2; | ||
} | ||
posY += 20 + 4; | ||
event.buttonList.add( | ||
new GuiButton( | ||
BUTTON_ID, | ||
posX, | ||
posY, | ||
StatCollector.translateToLocal("hodgepodge.soundsmenu.refreshsounds"))); | ||
} | ||
} | ||
|
||
@SubscribeEvent | ||
public void onClick(GuiScreenEvent.ActionPerformedEvent.Post event) { | ||
if (TweaksConfig.reloadSoundsButton && event.gui instanceof GuiScreenOptionsSounds) { | ||
if (event.button.id == BUTTON_ID) { | ||
Minecraft mc = Minecraft.getMinecraft(); | ||
mc.getSoundHandler().onResourceManagerReload(mc.getResourceManager()); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters