-
Notifications
You must be signed in to change notification settings - Fork 10
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
15 changed files
with
213 additions
and
11 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
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,11 +1,15 @@ | ||
package dev.enjarai.trickster; | ||
|
||
import dev.enjarai.trickster.screen.ModHandledScreens; | ||
import dev.enjarai.trickster.screen.owo.GlyphComponent; | ||
import io.wispforest.owo.ui.parsing.UIParsing; | ||
import net.fabricmc.api.ClientModInitializer; | ||
|
||
public class TricksterClient implements ClientModInitializer { | ||
@Override | ||
public void onInitializeClient() { | ||
ModHandledScreens.register(); | ||
|
||
UIParsing.registerFactory(Trickster.id("glyph"), GlyphComponent::parse); | ||
} | ||
} |
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
84 changes: 84 additions & 0 deletions
84
src/client/java/dev/enjarai/trickster/screen/owo/GlyphComponent.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,84 @@ | ||
package dev.enjarai.trickster.screen.owo; | ||
|
||
import dev.enjarai.trickster.spell.tricks.Trick; | ||
import dev.enjarai.trickster.spell.tricks.Tricks; | ||
import io.wispforest.owo.ui.base.BaseComponent; | ||
import io.wispforest.owo.ui.core.OwoUIDrawContext; | ||
import io.wispforest.owo.ui.core.Sizing; | ||
import io.wispforest.owo.ui.parsing.UIParsing; | ||
import org.joml.Vector2f; | ||
import org.w3c.dom.Element; | ||
|
||
import java.util.List; | ||
import java.util.stream.IntStream; | ||
|
||
import static dev.enjarai.trickster.screen.SpellPartWidget.*; | ||
|
||
public class GlyphComponent extends BaseComponent { | ||
protected Trick trick; | ||
protected List<Integer> patternList; | ||
protected int size; | ||
|
||
public GlyphComponent(Trick trick, int size) { | ||
super(); | ||
this.trick = trick; | ||
this.size = size; | ||
this.patternList = trick.getPattern() | ||
.entries().stream() | ||
.flatMapToInt(e -> IntStream.of(e.p1(), e.p2())) | ||
.distinct() | ||
.boxed() | ||
.toList(); | ||
} | ||
|
||
@Override | ||
public void draw(OwoUIDrawContext context, int mouseX, int mouseY, float partialTicks, float delta) { | ||
var patternSize = size / 2; | ||
|
||
for (int i = 0; i < 9; i++) { | ||
var pos = getPatternDotPosition(x + patternSize + 4, y + patternSize + 4, i, patternSize); | ||
|
||
var isLinked = patternList.contains(i); | ||
var dotSize = 1; | ||
|
||
drawFlatPolygon(context, c -> { | ||
c.accept(pos.x - dotSize, pos.y - dotSize); | ||
c.accept(pos.x - dotSize, pos.y + dotSize); | ||
c.accept(pos.x + dotSize, pos.y + dotSize); | ||
c.accept(pos.x + dotSize, pos.y - dotSize); | ||
}, 0, 0, 0, 0, isLinked ? 0.9f : 0.5f); | ||
} | ||
|
||
for (var line : trick.getPattern().entries()) { | ||
var now = getPatternDotPosition(x + patternSize + 4, y + patternSize + 4, line.p1(), patternSize); | ||
var last = getPatternDotPosition(x + patternSize + 4, y + patternSize + 4, line.p2(), patternSize); | ||
drawGlyphLine(context, last, now, 1, false, 0, 0.9f); | ||
} | ||
} | ||
|
||
@Override | ||
protected int determineHorizontalContentSize(Sizing sizing) { | ||
return size + 8; | ||
} | ||
|
||
@Override | ||
protected int determineVerticalContentSize(Sizing sizing) { | ||
return size + 8; | ||
} | ||
|
||
public static GlyphComponent parse(Element element) { | ||
UIParsing.expectAttributes(element, "trick-id"); | ||
UIParsing.expectAttributes(element, "size"); | ||
|
||
var trickId = UIParsing.parseIdentifier(element.getAttributeNode("trick-id")); | ||
var trick = Tricks.REGISTRY.get(trickId); | ||
|
||
if (trick == null) { | ||
throw new IllegalArgumentException("Not a valid trick: " + trickId); | ||
} | ||
|
||
var size = UIParsing.parseUnsignedInt(element.getAttributeNode("size")); | ||
|
||
return new GlyphComponent(trick, size); | ||
} | ||
} |
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
2 changes: 0 additions & 2 deletions
2
src/main/java/dev/enjarai/trickster/screen/ScrollAndQuillScreenHandler.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
3 changes: 3 additions & 0 deletions
3
src/main/resources/assets/trickster/lavender/books/tome_of_tomfoolery.json
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 @@ | ||
{ | ||
"texture": "trickster:textures/gui/white_book.png" | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/resources/assets/trickster/lavender/entries/tome_of_tomfoolery/test.md
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,62 @@ | ||
```json | ||
{ | ||
"title": "Arithmetic", | ||
"icon": "minecraft:copper_bulb" | ||
} | ||
``` | ||
|
||
The following patterns regard basic arithmetic and simple mathematical operations. | ||
|
||
|
||
Many base arithmetical operations, though not all, will work on both single numbers and vectors. | ||
|
||
;;;;; | ||
|
||
<|glyph@trickster:templates|trick-id=trickster:add,title=Summation|> | ||
|
||
number... -> number | | ||
|
||
vec... -> vec | ||
|
||
--- | ||
|
||
Adds up an arbitrary sequence of numbers into a single value. | ||
Works with vectors. | ||
|
||
;;;;; | ||
|
||
<|glyph@trickster:templates|trick-id=trickster:subtract,title=Subtraction|> | ||
|
||
number... -> number | | ||
|
||
vec... -> vec | ||
|
||
--- | ||
|
||
Sequentially subtracts an arbitrary sequence of numbers into a single value. | ||
Works with vectors. | ||
|
||
;;;;; | ||
|
||
<|glyph@trickster:templates|trick-id=trickster:multiply,title=Multiplication|> | ||
|
||
(number | vec)... -> (number | vec) | ||
|
||
--- | ||
|
||
Multiplies many numbers into a single value. | ||
A number and a vector combined will result in a vector. | ||
|
||
;;;;; | ||
|
||
<|glyph@trickster:templates|trick-id=trickster:divide,title=Subtraction|> | ||
|
||
number... -> number | | ||
|
||
vec... -> vec | ||
|
||
--- | ||
|
||
Sequentially subtracts an arbitrary sequence of numbers into a single value. | ||
Works with vectors. | ||
|
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/trickster/models/item/tome_of_tomfoolery.json
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,6 @@ | ||
{ | ||
"parent": "minecraft:item/generated", | ||
"textures": { | ||
"layer0": "trickster:item/tome_of_tomfoolery" | ||
} | ||
} |
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,38 @@ | ||
<owo-ui xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/wisp-forest/owo-lib/1.20/owo-ui.xsd"> | ||
<templates> | ||
<template name="glyph"> | ||
<flow-layout direction="vertical"> | ||
<children> | ||
<label> | ||
<text>{{title}}</text> | ||
</label> | ||
<label> | ||
<text>{{trick-id}}</text> | ||
</label> | ||
<!-- <label>--> | ||
<!-- <text>{{title}}</text>--> | ||
<!-- <color>dark-gray</color>--> | ||
|
||
<!-- <horizontal-text-alignment>center</horizontal-text-alignment>--> | ||
|
||
<!-- <margins>--> | ||
<!-- <top>2</top>--> | ||
<!-- <bottom>2</bottom>--> | ||
<!-- </margins>--> | ||
<!-- <sizing>--> | ||
<!-- <horizontal method="fill">100</horizontal>--> | ||
<!-- </sizing>--> | ||
<!-- </label>--> | ||
|
||
<!-- <trickster.glyph trick-id="{{trick-id}}" size="50">--> | ||
<!-- </trickster.glyph>--> | ||
</children> | ||
<horizontal-alignment>center</horizontal-alignment> | ||
<sizing> | ||
<horizontal method="fill">100</horizontal> | ||
</sizing> | ||
</flow-layout> | ||
</template> | ||
</templates> | ||
</owo-ui> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+298 Bytes
src/main/resources/assets/trickster/textures/item/tome_of_tomfoolery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+193 Bytes
src/main/resources/assets/trickster/textures/item/written_scroll.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.