Skip to content

Commit

Permalink
Fix Prospector/ModMenu compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
js6pak committed Jan 12, 2020
1 parent 139a2ab commit 7a08d00
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 46 deletions.
55 changes: 16 additions & 39 deletions src/main/java/net/wurstclient/mixin/GameMenuScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,21 @@
*/
package net.wurstclient.mixin;

import java.util.Iterator;

import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.GameMenuScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.wurstclient.WurstClient;
import net.wurstclient.options.WurstOptionsScreen;
import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(GameMenuScreen.class)
public abstract class GameMenuScreenMixin extends Screen
Expand All @@ -45,32 +43,20 @@ private void onInitWidgets(CallbackInfo ci)
addWurstOptionsButton();
removeFeedbackAndBugReportButtons();
}


private ButtonWidget wurstOptionsButton;

private void addWurstOptionsButton()
{
addButton(new ButtonWidget(width / 2 - 102, height / 4 + 56, 204, 20,
wurstOptionsButton = addButton(new ButtonWidget(width / 2 - 102, height / 4 + 56, 204, 20,
" Options",
b -> minecraft.openScreen(new WurstOptionsScreen(this))));
}

private void removeFeedbackAndBugReportButtons()
{
for(Iterator<AbstractButtonWidget> itr = buttons.iterator(); itr
.hasNext();)
{
AbstractButtonWidget button = itr.next();

if(isFeedbackOrBugReportButton(button))
itr.remove();
}

for(Iterator<Element> itr = children.iterator(); itr.hasNext();)
{
Element element = itr.next();

if(isFeedbackOrBugReportButton(element))
itr.remove();
}
buttons.removeIf(this::isFeedbackOrBugReportButton);
children.removeIf(this::isFeedbackOrBugReportButton);
}

private boolean isFeedbackOrBugReportButton(Element element)
Expand All @@ -79,17 +65,8 @@ private boolean isFeedbackOrBugReportButton(Element element)
return false;

AbstractButtonWidget button = (AbstractButtonWidget)element;

if(button.y != height / 4 + 72 + -16)
return false;

if(button.x != width / 2 - 102 && button.x != width / 2 + 4)
return false;

if(button.getWidth() != 98)
return false;

return true;

return button.getMessage().equals(I18n.translate("menu.sendFeedback")) || button.getMessage().equals(I18n.translate("menu.reportBugs"));
}

@Inject(at = {@At("TAIL")}, method = {"render(IIF)V"})
Expand All @@ -109,8 +86,8 @@ private void onRender(int mouseX, int mouseY, float partialTicks,

minecraft.getTextureManager().bindTexture(wurstTexture);

int x = width / 2 - 68;
int y = height / 4 + 73 - 15;
int x = wurstOptionsButton.x + 34;
int y = wurstOptionsButton.y + 2;
int w = 63;
int h = 16;
int fw = 63;
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/net/wurstclient/mixin/TitleScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package net.wurstclient.mixin;

import net.minecraft.client.resource.language.I18n;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -29,17 +30,15 @@ private TitleScreenMixin(WurstClient wurst, Text text_1)
}

@Inject(at = {@At("RETURN")}, method = {"initWidgetsNormal(II)V"})
private void onInitWidgetsNormal(int int_1, int int_2, CallbackInfo ci)
private void onInitWidgetsNormal(int y, int spacingY, CallbackInfo ci)
{
addButton(new ButtonWidget(width / 2 + 2, int_1 + int_2 * 2, 98, 20,
addButton(new ButtonWidget(width / 2 + 2, y + spacingY * 2, 98, 20,
"Alt Manager", b -> minecraft.openScreen(new AltManagerScreen(this,
WurstClient.INSTANCE.getAltManager()))));

for(AbstractButtonWidget button : buttons)
{
if(button.x != width / 2 - 100)
continue;
if(button.y != int_1 + int_2 * 2)
if(!button.getMessage().equals(I18n.translate("menu.online")))
continue;

button.setWidth(98);
Expand Down
Binary file removed src/main/resources/assets/modid/icon.png
Binary file not shown.
Binary file added src/main/resources/assets/wurst/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "wurst",
"version": "${version}",
"version": "$version",

"name": "Wurst Client",
"description": "Wurst Wurst Wurst!",
Expand All @@ -14,7 +14,7 @@
},

"license": "GPL-3.0-or-later",
"icon": "assets/modid/icon.png",
"icon": "assets/wurst/icon.png",

"environment": "client",
"entrypoints": {
Expand Down

0 comments on commit 7a08d00

Please sign in to comment.