forked from ChomeNS/chipmunkmod
Fix some gui stuff
This commit is contained in:
parent
de55b8208e
commit
deeb89bb45
5 changed files with 18 additions and 9 deletions
|
@ -3,6 +3,10 @@ plugins {
|
|||
id 'maven-publish'
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/chipmunkmod.accesswidener")
|
||||
}
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
targetCompatibility = JavaVersion.VERSION_21
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package land.chipmunk.chipmunkmod.testclient.gui;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.Drawable;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
|
@ -23,6 +25,7 @@ public class OptionsScreen extends Screen {
|
|||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
renderBackground(context, mouseX, mouseY, delta);
|
||||
context.fill(40, 40, width-40, height-40, backgroundColor);
|
||||
int textWidth = MinecraftClient.getInstance().textRenderer.getWidth(getTitle());
|
||||
AtomicInteger lineY = new AtomicInteger(70);
|
||||
|
@ -39,7 +42,9 @@ public class OptionsScreen extends Screen {
|
|||
option.widget.setX(width - 50 - option.widget.getWidth());
|
||||
option.widget.setY(textY.get() - ((option.widget.getHeight()-9)/2));
|
||||
}
|
||||
super.render(context, mouseX, mouseY, delta);
|
||||
|
||||
// had to use access widener cause minecraft is silly and wont lemme separate background and foreground manually
|
||||
for (Drawable drawable : this.drawables) {
|
||||
drawable.render(context, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,7 @@ public class BooleanCheckboxOption extends Option<Boolean> {
|
|||
optionValue = !optionValue;
|
||||
onPress.run(optionValue);
|
||||
|
||||
// equivalent of `checked = optionValue`, but checked is private so i have to use this :(
|
||||
try {
|
||||
Field checkedField = CheckboxWidget.class.getDeclaredField("checked");
|
||||
checkedField.setAccessible(true);
|
||||
checkedField.set(this, optionValue);
|
||||
} catch(NoSuchFieldException | IllegalAccessException e) {e.printStackTrace();}
|
||||
checkbox.checked = optionValue;
|
||||
})
|
||||
.build();
|
||||
|
||||
|
|
3
src/main/resources/chipmunkmod.accesswidener
Normal file
3
src/main/resources/chipmunkmod.accesswidener
Normal file
|
@ -0,0 +1,3 @@
|
|||
accessWidener v2 named
|
||||
accessible field net/minecraft/client/gui/screen/Screen drawables Ljava/util/List;
|
||||
accessible field net/minecraft/client/gui/widget/CheckboxWidget checked Z
|
|
@ -3,6 +3,8 @@
|
|||
"id": "chipmunkmod",
|
||||
"version": "${version}",
|
||||
|
||||
"accessWidener" : "chipmunkmod.accesswidener",
|
||||
|
||||
"name": "ChipmunkMod (Blackilykat's fork)",
|
||||
"description": "My fork of ChipmunkMod",
|
||||
"authors": [
|
||||
|
|
Loading…
Reference in a new issue