Skip to content

Commit

Permalink
Merge pull request #13 from StellarWitch7/master
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai authored Jul 8, 2024
2 parents 70e6673 + 3a676e6 commit 807637f
Show file tree
Hide file tree
Showing 141 changed files with 2,463 additions and 399 deletions.
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ repositories {
name "Terraformers Maven"
url 'https://maven.terraformersmc.com'
}

maven {
url 'https://maven.shedaniel.me/'
}
}

loom {
Expand Down Expand Up @@ -120,6 +124,8 @@ dependencies {

modImplementation "com.terraformersmc:modmenu:${property('deps.modmenu')}"
modClientImplementation "maven.modrinth:sodium:${property('deps.sodium')}"

modImplementation("io.wispforest:accessories-fabric:${property('deps.accessories')}")
}

processResources {
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ deps.cardinal-components-api=6.1.0
deps.modmenu=11.0.1

# Optional
deps.sodium=mc1.21-0.5.11
deps.sodium=mc1.21-0.5.11
deps.accessories=1.0.0-beta.11+1.21
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public abstract class PlayerRendererMixin {

var rot = new Vec3d(-1, -1, player.getRotationVector().y);;

this.trickster$renderer.renderPart(matrices, vertexConsumers, spell, 0, 0, 0.5f, 0, tickDelta, size -> 1f, rot);
this.trickster$renderer.renderPart(matrices, vertexConsumers, spell.get(), 0, 0, 0.5f, 0, tickDelta, size -> 1f, rot);
matrices.pop();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.enjarai.trickster.mixin.client;
package dev.enjarai.trickster.mixin.client.tooltip;

import dev.enjarai.trickster.SpellTooltipData;
import dev.enjarai.trickster.render.SpellTooltipComponent;
Expand All @@ -10,7 +10,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(TooltipComponent.class)
public interface SpellToolTipMixin {
public interface TooltipComponentMixin {

@Inject(method = "of(Lnet/minecraft/item/tooltip/TooltipData;)Lnet/minecraft/client/gui/tooltip/TooltipComponent;", at = @At("HEAD"), cancellable = true)
private static void trickster$getTooltipData(TooltipData data, CallbackInfoReturnable<TooltipComponent> cir) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void render(SpellCircleBlockEntity entity, float tickDelta, MatrixStack m
matrices.push();
matrices.translate(0.5f, 0.5f, 0.5f);
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(90));
this.renderer.renderPart(matrices, vertexConsumers, Optional.of(entity.spell), 0, 0, 0.5f, 0, tickDelta, size -> 1f, new Vec3d(0, 0, -1));
this.renderer.renderPart(matrices, vertexConsumers, entity.spell, 0, 0, 0.5f, 0, tickDelta, size -> 1f, new Vec3d(0, 0, -1));
// matrices.scale(1, -1, 1);
// this.renderer.renderPart(matrices, vertexConsumers, Optional.of(entity.spell), 0, 0, 1, 0, tickDelta, size -> 1f);
matrices.pop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.blaze3d.systems.RenderSystem;
import dev.enjarai.trickster.Trickster;
import dev.enjarai.trickster.spell.Fragment;
import dev.enjarai.trickster.spell.Pattern;
import dev.enjarai.trickster.spell.PatternGlyph;
import dev.enjarai.trickster.spell.SpellPart;
import net.minecraft.client.MinecraftClient;
Expand Down Expand Up @@ -57,54 +58,43 @@ public void setMousePosition(double mouseX, double mouseY) {
this.mouseY = mouseY;
}

public void renderPart(MatrixStack matrices, VertexConsumerProvider vertexConsumers, Optional<SpellPart> entry, float x, float y, float size, double startingAngle, float delta, Function<Float, Float> alphaGetter, Vec3d normal) {
public void renderPart(MatrixStack matrices, VertexConsumerProvider vertexConsumers, SpellPart entry, float x, float y, float size, double startingAngle, float delta, Function<Float, Float> alphaGetter, Vec3d normal) {
var alpha = alphaGetter.apply(size);

if (entry.isPresent()) {
var part = entry.get();

drawTexturedQuad(
matrices, vertexConsumers, CIRCLE_TEXTURE,
x - size, x + size, y - size, y + size,
0,
1f, 1f, 1f, alpha, normal
);
drawGlyph(
matrices, vertexConsumers, part,
x, y, size, startingAngle,
delta, alphaGetter, normal
);
drawTexturedQuad(
matrices, vertexConsumers, CIRCLE_TEXTURE,
x - size, x + size, y - size, y + size,
0,
1f, 1f, 1f, alpha, normal
);
drawGlyph(
matrices, vertexConsumers, entry,
x, y, size, startingAngle,
delta, alphaGetter, normal
);

int partCount = part.getSubParts().size();
int partCount = entry.getSubParts().size();

drawDivider(matrices, vertexConsumers, x, y, startingAngle, size, partCount, alpha);
drawDivider(matrices, vertexConsumers, x, y, startingAngle, size, partCount, alpha);

matrices.push();
if (!inUI) {
matrices.translate(0, 0, -1 / 16f);
}
int i = 0;
for (var child : part.getSubParts()) {
var angle = startingAngle + (2 * Math.PI) / partCount * i - (Math.PI / 2);
matrices.push();
if (!inUI) {
matrices.translate(0, 0, -1 / 16f);
}
int i = 0;
for (var child : entry.getSubParts()) {
var angle = startingAngle + (2 * Math.PI) / partCount * i - (Math.PI / 2);

var nextX = x + (size * Math.cos(angle));
var nextY = y + (size * Math.sin(angle));
var nextX = x + (size * Math.cos(angle));
var nextY = y + (size * Math.sin(angle));

var nextSize = Math.min(size / 2, size / (float) (partCount / 2));
var nextSize = Math.min(size / 2, size / (float) (partCount / 2));

renderPart(matrices, vertexConsumers, child, (float) nextX, (float) nextY, nextSize, angle, delta, alphaGetter, normal);
renderPart(matrices, vertexConsumers, child, (float) nextX, (float) nextY, nextSize, angle, delta, alphaGetter, normal);

i++;
}
matrices.pop();
} else {
drawTexturedQuad(
matrices, vertexConsumers, CIRCLE_TEXTURE_HALF,
x - size / 2, x + size / 2, y - size / 2, y + size / 2,
0,
1f, 1f, 1f, (float) alpha, normal
);
i++;
}
matrices.pop();
}

protected void drawDivider(MatrixStack matrices, VertexConsumerProvider vertexConsumers, float x, float y, double startingAngle, float size, float partCount, float alpha) {
Expand Down Expand Up @@ -137,7 +127,7 @@ protected void drawDivider(MatrixStack matrices, VertexConsumerProvider vertexCo
protected void drawGlyph(MatrixStack matrices, VertexConsumerProvider vertexConsumers, SpellPart parent, float x, float y, float size, double startingAngle, float delta, Function<Float, Float> alphaGetter, Vec3d normal) {
var glyph = parent.getGlyph();
if (glyph instanceof SpellPart part) {
renderPart(matrices, vertexConsumers, Optional.of(part), x, y, size / 3, startingAngle, delta, alphaGetter, normal);
renderPart(matrices, vertexConsumers, part, x, y, size / 3, startingAngle, delta, alphaGetter, normal);
} else {
matrices.push();
drawSide(matrices, vertexConsumers, parent, x, y, size, alphaGetter, glyph);
Expand All @@ -160,12 +150,13 @@ private void drawSide(MatrixStack matrices, VertexConsumerProvider vertexConsume
var pixelSize = patternSize / PART_PIXEL_RADIUS;

var isDrawing = inEditor && drawingPartGetter.get() == parent;
var patternList = isDrawing ? drawingPatternGetter.get() : pattern.orderedPattern();
var drawingPattern = inEditor ? drawingPatternGetter.get() : null;
var patternList = isDrawing ? Pattern.from(drawingPattern) : pattern.pattern();

for (int i = 0; i < 9; i++) {
var pos = getPatternDotPosition(x, y, i, patternSize);

var isLinked = patternList.contains(Integer.valueOf(i).byteValue());
var isLinked = isDrawing ? drawingPattern.contains((byte) i) : patternList.contains(i);
float dotScale = 1;

if (inEditor && isInsideHitbox(pos, pixelSize, mouseX, mouseY) && isCircleClickable(size)) {
Expand All @@ -190,16 +181,14 @@ private void drawSide(MatrixStack matrices, VertexConsumerProvider vertexConsume
}, 0, isDrawing && isLinked ? 0.5f : 1, isDrawing && isLinked ? 0.5f : 1, 1, 0.5f * alpha);
}

Vector2f last = null;
for (var b : patternList) {
var now = getPatternDotPosition(x, y, b, patternSize);
if (last != null) {
drawGlyphLine(matrices, vertexConsumers, last, now, pixelSize, isDrawing, 1, 0.5f * alpha);
}
last = now;
for (var line : patternList.entries()) {
var first = getPatternDotPosition(x, y, line.p1(), patternSize);
var second = getPatternDotPosition(x, y, line.p2(), patternSize);
drawGlyphLine(matrices, vertexConsumers, first, second, pixelSize, isDrawing, 1, 0.5f * alpha);
}

if (inEditor && isDrawing && last != null) {
if (inEditor && isDrawing) {
var last = getPatternDotPosition(x, y, drawingPattern.getLast(), patternSize);
var now = new Vector2f((float) mouseX, (float) mouseY);
drawGlyphLine(matrices, vertexConsumers, last, now, pixelSize, true, 1, 0.5f * alpha);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void drawItems(TextRenderer textRenderer, int x, int y, DrawContext conte
var size = 30f;

matrices.push();
renderer.renderPart(matrices, vertexConsumers, Optional.of(spell), x + (float) getWidth(textRenderer) / 2, y + (float) getHeight() / 2, size,
renderer.renderPart(matrices, vertexConsumers, spell, x + (float) getWidth(textRenderer) / 2, y + (float) getHeight() / 2, size,
0.0, delta, a -> a/size, new Vec3d(0, 0, -1) );
matrices.pop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ protected void drawBackground(DrawContext context, float delta, int mouseX, int
context.drawTexture(TEXTURE, i, j + this.rows * 18 + 17, 0, 126, this.backgroundWidth, 96);
}

@Override
protected void drawForeground(DrawContext context, int mouseX, int mouseY) {
context.drawText(this.textRenderer, this.title, this.titleX, this.titleY, 0xc0c0c0, false);
context.drawText(this.textRenderer, this.playerInventoryTitle, this.playerInventoryTitleX, this.playerInventoryTitleY, 0x404040, false);
}

@Override
protected void drawSlot(DrawContext context, Slot slot) {
super.drawSlot(context, slot);
Expand Down
82 changes: 41 additions & 41 deletions src/client/java/dev/enjarai/trickster/screen/SpellCircleScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,47 @@ public SpellCircleScreen() {

@Override
protected void init() {
var part = new SpellPart(
new PatternGlyph(1, 2, 3, 4),
List.of(
Optional.of(new SpellPart(
new PatternGlyph(2, 3, 6, 7),
List.of()
)),
Optional.of(new SpellPart(
new PatternGlyph(2, 3, 6, 7),
List.of(
Optional.of(new SpellPart(
new PatternGlyph(8, 6, 4),
List.of()
)),
Optional.of(new SpellPart(
new SpellPart(
new PatternGlyph(8, 6, 4),
List.of()
),
List.of(
Optional.of(new SpellPart(
new PatternGlyph(8, 6, 4),
List.of()
))
)
)),
Optional.empty(),
Optional.empty()
)
)),
Optional.of(new SpellPart(
new PatternGlyph(1, 7, 5, 8),
List.of(
Optional.of(new SpellPart(
new PatternGlyph(8, 6, 4),
List.of()
))
)
))
)
);
// var part = new SpellPart(
// new PatternGlyph(1, 2, 3, 4),
// List.of(
// Optional.of(new SpellPart(
// new PatternGlyph(2, 3, 6, 7),
// List.of()
// )),
// Optional.of(new SpellPart(
// new PatternGlyph(2, 3, 6, 7),
// List.of(
// Optional.of(new SpellPart(
// new PatternGlyph(8, 6, 4),
// List.of()
// )),
// Optional.of(new SpellPart(
// new SpellPart(
// new PatternGlyph(8, 6, 4),
// List.of()
// ),
// List.of(
// Optional.of(new SpellPart(
// new PatternGlyph(8, 6, 4),
// List.of()
// ))
// )
// )),
// Optional.empty(),
// Optional.empty()
// )
// )),
// Optional.of(new SpellPart(
// new PatternGlyph(1, 7, 5, 8),
// List.of(
// Optional.of(new SpellPart(
// new PatternGlyph(8, 6, 4),
// List.of()
// ))
// )
// ))
// )
// );

// partWidget = new SpellPartWidget(part, width / 2d, height / 2d, 64, spell -> {});
// addDrawableChild(partWidget);
Expand Down
Loading

0 comments on commit 807637f

Please sign in to comment.