Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline Patterns !! (and also a small little pattern rendering rework) #708

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2f5d64c
add Inline as a dependency
SamsTheNerd Jun 24, 2024
8b96a33
add hex pattern codec for inline to use
SamsTheNerd Jun 26, 2024
57fbe72
depend on forge inline in common because vanillagradle is stupid and …
SamsTheNerd Jun 26, 2024
d1dce0d
add inline pattern data
SamsTheNerd Jun 26, 2024
74c24a1
move worldly pattern renderers out of PatternTextureManager
SamsTheNerd Jun 29, 2024
597ffd6
attempt/start (perhaps poorly) to clean up worldly pattern rendering
SamsTheNerd Jun 29, 2024
5a07f34
add pattern matcher and renderer skeleton
SamsTheNerd Jul 1, 2024
5624440
inline patterns mostly working + general pattern render function started
SamsTheNerd Jul 2, 2024
280270b
horrible half broken code. Texture stuff is on the operating table, w…
SamsTheNerd Jul 4, 2024
50899de
inline-ify pattern's Display call for showing in the stack and whatnot
SamsTheNerd Jul 4, 2024
f791a11
idk why that folder exists but let's git ignore it!
SamsTheNerd Jul 8, 2024
7b35534
still very very broken code. making progress, texture renderer is tap…
SamsTheNerd Jul 8, 2024
e371e96
slates are looking good !
SamsTheNerd Jul 8, 2024
df9a7c3
some progress on cleaning up inline patterns - hitting an issue with …
SamsTheNerd Jul 9, 2024
8bf0031
make patterns white in lists
SamsTheNerd Jul 9, 2024
3b31e2d
add slate and scroll pattern labels for hotbar viewing
SamsTheNerd Jul 9, 2024
5555044
working on getting renderlib drawlineseq to accept other shaders/form…
SamsTheNerd Jul 12, 2024
a748879
add chat feedback to texture debug commands
SamsTheNerd Jul 12, 2024
df420f3
texture and dynamic renderers are almost identical. dynamic has weird…
SamsTheNerd Jul 12, 2024
85d7a84
make entity iota display inline - it's kinda icky rn though
SamsTheNerd Jul 16, 2024
221a2a5
fix-ish the z fighting, move some more logic into points class
SamsTheNerd Jul 16, 2024
1c339fc
add dot colors
SamsTheNerd Jul 16, 2024
e5f9325
make dots work!
SamsTheNerd Jul 16, 2024
95a44b8
add cloth config to forge runtime so inline is happy and datagen is f…
SamsTheNerd Jul 18, 2024
0307f11
consolidate vc helper-y stuff
SamsTheNerd Jul 18, 2024
b65434a
remove some dead code
SamsTheNerd Jul 18, 2024
4ba222b
clean up worldly renderers - get rid of icky ps transformer stuff
SamsTheNerd Jul 18, 2024
414d140
delete old render code from bookshelves and scrolls
SamsTheNerd Jul 18, 2024
9bfb48e
make tooltips use the new system. make circles purple. tweaks with no…
SamsTheNerd Jul 19, 2024
a9be061
refactor pattern settings to be a bit more modular and easy to use
SamsTheNerd Jul 22, 2024
3eb283c
clean up pattern color stuff a little
SamsTheNerd Jul 22, 2024
705f60f
switch patchi renders over to new system
SamsTheNerd Jul 23, 2024
a4b6f63
re-add stroke gradient
SamsTheNerd Jul 23, 2024
bf0ed92
switch emi/jei pattern tab icons over to new system
SamsTheNerd Jul 28, 2024
0a7fd12
fix akashic bookshelf lighting (fix #587)
SamsTheNerd Jul 28, 2024
1400256
hopefully fix placement flickering (#567) and also remove resolution …
SamsTheNerd Jul 28, 2024
33e5b24
restore non hex-grid/pattern rendering. start lore doc
SamsTheNerd Jul 30, 2024
3004075
actually implement alignment options properly
SamsTheNerd Jul 30, 2024
179c3d4
joyous - i think it's done
SamsTheNerd Jul 30, 2024
5817f80
add inline pattern matcher lang
SamsTheNerd Aug 1, 2024
fa3d126
make inline patterns not have shortened end bit - personal choice, up…
SamsTheNerd Aug 1, 2024
cbe821b
Merge remote-tracking branch 'origin/main' into inlinepatterns
SamsTheNerd Aug 2, 2024
051c52f
Merge branch 'main' into inlinepatterns
SamsTheNerd Aug 16, 2024
005b91e
update to inline 1.0.0
SamsTheNerd Sep 29, 2024
e7c3e8f
fix scroll normals
SamsTheNerd Sep 29, 2024
0b284d7
make inline patterns glow nice on signs
SamsTheNerd Sep 29, 2024
26bf80a
make pattern renders size-changable
SamsTheNerd Sep 29, 2024
9d3d4f5
give pattern inlines click events again
SamsTheNerd Sep 29, 2024
8c00eeb
bleh inline broken again, gotta go fix that
SamsTheNerd Sep 29, 2024
d7814e5
update to inline 1.0.1 and add player/entity renders on entity iotas
SamsTheNerd Sep 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ eclipse
run
.DS_Store

# Idk what prompted gradle to create this folder
Fabric/Fabric


# MacOS moment
.DS_Store

Expand Down
4 changes: 4 additions & 0 deletions Common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ repositories {
url = "https://modmaven.dev"
}

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

}

dependencies {
Expand All @@ -37,6 +39,8 @@ dependencies {
compileOnly "at.petra-k.paucal:paucal-common-$minecraftVersion:$paucalVersion"
compileOnly "vazkii.patchouli:Patchouli-xplat:$minecraftVersion-$patchouliVersion-SNAPSHOT"

compileOnly "com.samsthenerd.inline:inline-forge:$minecraftVersion-$inlineVersion"

compileOnly "org.jetbrains:annotations:$jetbrainsAnnotationsVersion"
testCompileOnly "org.jetbrains:annotations:$jetbrainsAnnotationsVersion"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import com.samsthenerd.inline.api.InlineAPI;
import com.samsthenerd.inline.api.data.EntityInlineData;
import com.samsthenerd.inline.api.data.PlayerHeadData;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -38,13 +43,29 @@ public boolean isTruthy() {
Tag serialize() {
var out = new CompoundTag();
out.putUUID("uuid", this.getEntity().getUUID());
out.putString("name", Component.Serializer.toJson(this.getEntity().getName()));
out.putString("name", Component.Serializer.toJson(getEntityNameWithInline(true)));
return out;
}

@Override
public Component display() {
return this.getEntity().getName().copy().withStyle(ChatFormatting.AQUA);
return getEntityNameWithInline(false).copy().withStyle(ChatFormatting.AQUA);
}

private Component getEntityNameWithInline(boolean fearSerializer){
MutableComponent baseName = this.getEntity().getName().copy();
Component inlineEnt = null;
if(this.getEntity() instanceof Player player){
inlineEnt = new PlayerHeadData(player.getGameProfile()).asText(!fearSerializer);
inlineEnt = inlineEnt.plainCopy().withStyle(InlineAPI.INSTANCE.withSizeModifier(inlineEnt.getStyle(), 1.5));
} else{
if(fearSerializer){ // we don't want to have to serialize an entity just to display it
inlineEnt = EntityInlineData.fromType(this.getEntity().getType()).asText(!fearSerializer);
} else {
inlineEnt = EntityInlineData.fromEntity(this.getEntity()).asText(!fearSerializer);
}
}
return baseName.append(Component.literal(": ")).append(inlineEnt);
}

public static IotaType<EntityIota> TYPE = new IotaType<>() {
Expand Down Expand Up @@ -73,6 +94,7 @@ public Component display(Tag tag) {
return Component.translatable("hexcasting.spelldata.entity.whoknows");
}
var nameJson = ctag.getString("name");
// return Component.literal(nameJson);
return Component.Serializer.fromJsonLenient(nameJson).withStyle(ChatFormatting.AQUA);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ public Component display(Tag tag) {

out.append(IotaType.getDisplay(csub));

if (i < list.size() - 1) {
// only add a comma between 2 non-patterns (commas don't look good with Inline patterns)
// TODO: maybe add a config? maybe add a method on IotaType to allow it to opt out of commas
if (i < list.size() - 1 && (IotaType.getTypeFromTag(csub) != PatternIota.TYPE
|| IotaType.getTypeFromTag(HexUtils.downcast(list.get(i+1), CompoundTag.TYPE)) != PatternIota.TYPE)) {
out.append(", ");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
import at.petrak.hexcasting.api.casting.mishaps.MishapEvalTooMuch;
import at.petrak.hexcasting.api.casting.mishaps.MishapInvalidPattern;
import at.petrak.hexcasting.api.casting.mishaps.MishapUnenlightened;
import at.petrak.hexcasting.api.mod.HexConfig;
import at.petrak.hexcasting.api.mod.HexTags;
import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.casting.PatternRegistryManifest;
import at.petrak.hexcasting.common.lib.hex.HexEvalSounds;
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import at.petrak.hexcasting.interop.inline.InlinePatternData;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerLevel;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -163,6 +164,12 @@ public static PatternIota deserialize(Tag tag) throws IllegalArgumentException {
}

public static Component display(HexPattern pat) {
Component text = (new InlinePatternData(pat)).asText(true);
return text.copy().withStyle(text.getStyle().applyTo(Style.EMPTY.withColor(ChatFormatting.WHITE)));
}

// keep around just in case it's needed.
public static Component displayNonInline(HexPattern pat){
var bob = new StringBuilder();
bob.append(pat.getStartDir());

Expand All @@ -172,7 +179,7 @@ public static Component display(HexPattern pat) {
bob.append(sig);
}
return Component.translatable("hexcasting.tooltip.pattern_iota",
Component.literal(bob.toString()).withStyle(ChatFormatting.WHITE))
.withStyle(ChatFormatting.GOLD);
Component.literal(bob.toString()).withStyle(ChatFormatting.WHITE))
.withStyle(ChatFormatting.GOLD);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package at.petrak.hexcasting.api.casting.math

import at.petrak.hexcasting.api.utils.getSafe
import com.mojang.serialization.Codec

enum class HexDir {
NORTH_EAST, EAST, SOUTH_EAST, SOUTH_WEST, WEST, NORTH_WEST;
Expand All @@ -26,6 +27,11 @@ enum class HexDir {
}

companion object {
val CODEC: Codec<HexDir> = Codec.STRING.xmap(
HexDir::fromString,
HexDir::name
)

@JvmStatic
fun fromString(key: String): HexDir {
return values().getSafe(key, WEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import at.petrak.hexcasting.api.utils.NBTBuilder
import at.petrak.hexcasting.api.utils.coordToPx
import at.petrak.hexcasting.api.utils.findCenter
import at.petrak.hexcasting.api.utils.getSafe
import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.nbt.CompoundTag
import net.minecraft.nbt.Tag
import net.minecraft.world.phys.Vec2
Expand Down Expand Up @@ -127,6 +129,13 @@ data class HexPattern(val startDir: HexDir, val angles: MutableList<HexAngle> =
const val TAG_START_DIR = "start_dir"
const val TAG_ANGLES = "angles"

@JvmField
val CODEC: Codec<HexPattern> = RecordCodecBuilder.create({instance -> instance.group(
Codec.STRING.fieldOf(TAG_START_DIR).forGetter(HexPattern::anglesSignature),
HexDir.CODEC.fieldOf(TAG_ANGLES).forGetter(HexPattern::startDir)
).apply(instance, HexPattern::fromAngles)
})

@JvmStatic
fun isPattern(tag: CompoundTag): Boolean {
return tag.contains(TAG_START_DIR, Tag.TAG_ANY_NUMERIC.toInt())
Expand Down
Loading