-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mineTomek/1-crash-in-multiplayer-when-pres…
…sing-h Fix #1 - Crash in multiplayer when pressing H
- Loading branch information
Showing
9 changed files
with
204 additions
and
31 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
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 |
---|---|---|
|
@@ -32,6 +32,10 @@ bin/ | |
|
||
run/ | ||
|
||
# server | ||
|
||
server/ | ||
|
||
# java | ||
|
||
hs_err_*.log | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
### Bug fixes: | ||
- Fix #1 (`Crash in multiplayer when pressing H`) | ||
### Features: | ||
- Now the (formerly) "P" and "R" buttons have proper textures ot them | ||
- Change `panoramas_button` texture to `load_panoramas_button` | ||
- Add `remove_panoramas_button` texture | ||
- The two panorama buttons are now available in multiplayer screen (server selection) | ||
### Other Changes: | ||
- Simplified / resolved positioning of buttons | ||
- Removed unused code (unused panoramas options screen) | ||
- The changelog loaded to Modrinth is now named `CHANGELOG_NEWEST.md` and contains only the newest version without the version header (the main `CHANGELOG.md` remains) | ||
- Added links to the mod's GitHub page | ||
- Extend utility static methods to `PanoramaClient` | ||
- Make a few changes to the `main.yml` workflow making it simpler and more automatic | ||
- Disable the remove panorama button when no panorama is applied |
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
115 changes: 115 additions & 0 deletions
115
src/client/java/com/panoramas/mixin/client/MultiplayerScreenMixin.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,115 @@ | ||
package com.panoramas.mixin.client; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import com.panoramas.Panoramas; | ||
import com.panoramas.PanoramasClient; | ||
|
||
import net.minecraft.client.gui.DrawContext; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; | ||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget; | ||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget.Entry; | ||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget.LanServerEntry; | ||
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget.ServerEntry; | ||
import net.minecraft.client.gui.tooltip.Tooltip; | ||
import net.minecraft.client.gui.widget.ButtonWidget; | ||
import net.minecraft.resource.ResourcePackManager; | ||
import net.minecraft.resource.ResourcePackProfile; | ||
import net.minecraft.screen.ScreenTexts; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Identifier; | ||
|
||
@Mixin(MultiplayerScreen.class) | ||
public class MultiplayerScreenMixin extends Screen { | ||
protected MultiplayerScreenMixin(Text title) { | ||
super(title); | ||
} | ||
|
||
private ButtonWidget loadPanoramaButton; | ||
|
||
private ButtonWidget removePanoramaButton; | ||
|
||
@Shadow | ||
protected MultiplayerServerListWidget serverListWidget; | ||
|
||
@Inject(method = "init", at = @At("HEAD")) | ||
private void initInjected(CallbackInfo info) { | ||
loadPanoramaButton = addDrawableChild( | ||
ButtonWidget.builder(ScreenTexts.EMPTY, button -> { | ||
Entry entry = serverListWidget.getSelectedOrNull(); | ||
|
||
String packName = ""; | ||
|
||
if (entry instanceof LanServerEntry) { | ||
packName = ((LanServerEntry) entry).getLanServerEntry().getAddressPort(); | ||
} else if (entry instanceof ServerEntry) { | ||
packName = ((ServerEntry) entry).getServer().address; | ||
} | ||
|
||
client.getResourcePackManager().enable("file/Panorama_" | ||
+ packName); | ||
client.options.refreshResourcePacks(client.getResourcePackManager()); | ||
}).dimensions(this.width / 2 + 158, this.height - 30, 20, 20).build()); | ||
|
||
removePanoramaButton = addDrawableChild(ButtonWidget.builder(ScreenTexts.EMPTY, button -> { | ||
ResourcePackManager manager = client.getResourcePackManager(); | ||
|
||
for (ResourcePackProfile pack : manager.getProfiles()) { | ||
if (PanoramasClient.isPanoramasResourcePack(pack.getName())) { | ||
manager.disable(pack.getName()); | ||
} | ||
} | ||
|
||
client.options.refreshResourcePacks(manager); | ||
}).dimensions(this.width / 2 + 182, this.height - 30, 20, 20).build()); | ||
} | ||
|
||
@Inject(method = "tick", at = @At("TAIL")) | ||
public void tickInjected(CallbackInfo info) { | ||
Entry entry = serverListWidget.getSelectedOrNull(); | ||
if (entry != null) { | ||
String packName = ""; | ||
|
||
if (entry instanceof LanServerEntry) { | ||
packName = ((LanServerEntry) entry).getLanServerEntry().getAddressPort(); | ||
} else if (entry instanceof ServerEntry) { | ||
packName = ((ServerEntry) entry).getServer().address; | ||
} | ||
|
||
if (PanoramasClient.hasPanoramaPack(packName)) { | ||
loadPanoramaButton.active = true; | ||
loadPanoramaButton.setTooltip(Tooltip.of(Text.literal("NO TOOLTIP"))); | ||
} else { | ||
loadPanoramaButton.active = false; | ||
loadPanoramaButton.setTooltip(Tooltip | ||
.of(Text.translatable("panoramas.pack_button.no_panorama", | ||
Text.keybind("key.panoramas.create")))); | ||
} | ||
} else { | ||
loadPanoramaButton.active = false; | ||
loadPanoramaButton.setTooltip(Tooltip.of(Text.translatable("panoramas.pack_button.server_is_lan"))); | ||
} | ||
|
||
removePanoramaButton.active = PanoramasClient.isAnyPanoramasResourcePackLoaded(); | ||
} | ||
|
||
@Inject(method = "render", at = @At("TAIL")) | ||
public void renderInjected(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo info) { | ||
Identifier loadPanoramasButtonTextureLocation = new Identifier(Panoramas.MOD_ID, "load_panoramas_button"); | ||
|
||
context.drawGuiTexture(loadPanoramasButtonTextureLocation, loadPanoramaButton.getX(), | ||
loadPanoramaButton.getY(), loadPanoramaButton.getWidth(), | ||
loadPanoramaButton.getHeight()); | ||
|
||
Identifier removePanoramasButtonTextureLocation = new Identifier(Panoramas.MOD_ID, "remove_panoramas_button"); | ||
|
||
context.drawGuiTexture(removePanoramasButtonTextureLocation, removePanoramaButton.getX(), | ||
removePanoramaButton.getY(), removePanoramaButton.getWidth(), | ||
removePanoramaButton.getHeight()); | ||
} | ||
} |
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