generated from QuiltMC/quilt-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
149 additions
and
18 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
5 changes: 3 additions & 2 deletions
5
...s/kitten-heart/src/main/java/net/pixaurora/kitten_cube/impl/ui/widget/text/TextField.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
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
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
29 changes: 29 additions & 0 deletions
29
...ten-square/r1.21.2/src/main/java/net/pixaurora/kitten_square/impl/mixin/EditBoxMixin.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,29 @@ | ||
package net.pixaurora.kitten_square.impl.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyReceiver; | ||
|
||
import net.minecraft.client.gui.components.EditBox; | ||
import net.minecraft.client.gui.components.WidgetSprites; | ||
import net.pixaurora.kitten_square.impl.ui.widget.TextFieldImpl; | ||
|
||
@Mixin(EditBox.class) | ||
public class EditBoxMixin { | ||
/** | ||
* Because the field for the background is both private and static, the only way to modify it in our subclass is when it is used. | ||
*/ | ||
@ModifyReceiver( | ||
method = "renderWidget", | ||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/WidgetSprites;get(ZZ)Lnet/minecraft/resources/ResourceLocation;") | ||
) | ||
private WidgetSprites replaceBackground(WidgetSprites receiver, boolean a, boolean b) { | ||
EditBox instance = (EditBox) (Object) this; | ||
if (instance instanceof TextFieldImpl) { | ||
return ((TextFieldImpl) instance).background(); | ||
} else { | ||
return receiver; | ||
} | ||
} | ||
} |
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
50 changes: 50 additions & 0 deletions
50
...quare/r1.21.2/src/main/java/net/pixaurora/kitten_square/impl/ui/widget/TextFieldImpl.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,50 @@ | ||
package net.pixaurora.kitten_square.impl.ui.widget; | ||
|
||
import net.minecraft.client.gui.Font; | ||
import net.minecraft.client.gui.components.EditBox; | ||
import net.minecraft.client.gui.components.WidgetSprites; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.pixaurora.kitten_cube.impl.math.Size; | ||
import net.pixaurora.kitten_cube.impl.text.Component; | ||
import net.pixaurora.kitten_cube.impl.ui.texture.GuiTexture; | ||
import net.pixaurora.kitten_cube.impl.ui.widget.text.TextField; | ||
import net.pixaurora.kitten_cube.impl.ui.widget.text.TextFieldBackground; | ||
import net.pixaurora.kitten_square.impl.service.UICompatImpl; | ||
|
||
public class TextFieldImpl extends EditBox implements TextField { | ||
private final WidgetSprites background; | ||
private final Size size; | ||
|
||
public TextFieldImpl(Font font, TextFieldBackground<GuiTexture> background, Component defaultText, int maxLength) { | ||
super(font, background.normal().size().width(), background.normal().size().height(), | ||
UICompatImpl.internalToMinecraftType(defaultText)); | ||
|
||
TextFieldBackground<ResourceLocation> background0 = background.map(texture -> UICompatImpl.internalToMinecraftType(texture.path())); | ||
this.background = new WidgetSprites(background0.normal(), background0.highlighted()); | ||
|
||
this.size = background.normal().size(); | ||
|
||
this.setMaxLength(maxLength); | ||
} | ||
|
||
@Override | ||
public Size size() { | ||
return this.size; | ||
} | ||
|
||
@Override | ||
public String input() { | ||
return this.getValue(); | ||
} | ||
|
||
@Override | ||
public void setPos(int x, int y) { | ||
this.setX(x); | ||
this.setY(y); | ||
} | ||
|
||
// For the Mixin class associated with EditBox | ||
public WidgetSprites background() { | ||
return this.background; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
projects/kitten-square/r1.21.2/src/main/resources/kitten_square.accesswidener
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,3 @@ | ||
accessWidener v2 named | ||
|
||
accessible method net/minecraft/client/gui/screens/Screen addRenderableWidget (Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener; |
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
Binary file added
BIN
+98 Bytes
...sources/assets/kit_tunes/textures/gui/sprites/widget/text_field/highlighted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
.../resources/assets/kit_tunes/textures/gui/sprites/widget/text_field/highlighted.png.mcmeta
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,10 @@ | ||
{ | ||
"gui": { | ||
"scaling": { | ||
"type": "nine_slice", | ||
"width": 200, | ||
"height": 20, | ||
"border": 1 | ||
} | ||
} | ||
} |
Binary file added
BIN
+98 Bytes
...in/resources/assets/kit_tunes/textures/gui/sprites/widget/text_field/normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
src/main/resources/assets/kit_tunes/textures/gui/sprites/widget/text_field/normal.png.mcmeta
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,10 @@ | ||
{ | ||
"gui": { | ||
"scaling": { | ||
"type": "nine_slice", | ||
"width": 200, | ||
"height": 20, | ||
"border": 1 | ||
} | ||
} | ||
} |