-
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
1 parent
62cf3c0
commit 7b74d6f
Showing
14 changed files
with
292 additions
and
9 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
2 changes: 1 addition & 1 deletion
2
...nszelescik/colorize/fabric/JsonUtils.java → ...colorize/common/api/config/JsonUtils.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
loom.platform=fabric |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
plugins { | ||
id "com.github.johnrengelman.shadow" version "7.1.2" | ||
} | ||
|
||
architectury { | ||
platformSetupLoomIde() | ||
loader("quilt") | ||
} | ||
|
||
archivesBaseName = rootProject.archives_base_name + "-" + rootProject.minecraft_version + "-quilt" | ||
|
||
loom { | ||
accessWidenerPath = project(":common").loom.accessWidenerPath | ||
} | ||
|
||
configurations { | ||
common | ||
shadowCommon // Don't use shadow from the shadow plugin since it *excludes* files. | ||
compileClasspath.extendsFrom common | ||
runtimeClasspath.extendsFrom common | ||
developmentFabric.extendsFrom common | ||
} | ||
|
||
repositories { | ||
maven { url "https://maven.quiltmc.org/repository/release/" } | ||
maven { url "https://modmaven.dev" } | ||
} | ||
|
||
dependencies { | ||
modImplementation "org.quiltmc:quilt-loader:${rootProject.quilt_loader_version}" | ||
modApi "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.quilt_fabric_api_version}" | ||
// Remove the next line if you don't want to depend on the API | ||
//modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}" | ||
|
||
modRuntimeOnly "mezz.jei:jei-${jei_minecraft_version}-fabric:${jei_version}" | ||
|
||
common(project(path: ":common", configuration: "namedElements")) { transitive false } | ||
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false } | ||
} | ||
|
||
processResources { | ||
inputs.property "version", project.version | ||
|
||
filesMatching("quilt.mod.json") { | ||
expand "group": rootProject.maven_group, | ||
"version": project.version | ||
} | ||
} | ||
|
||
shadowJar { | ||
exclude "architectury.common.json" | ||
|
||
configurations = [project.configurations.shadowCommon] | ||
archiveClassifier = "dev-shadow" | ||
} | ||
|
||
remapJar { | ||
injectAccessWidener = true | ||
input.set shadowJar.archiveFile | ||
dependsOn shadowJar | ||
} | ||
|
||
sourcesJar { | ||
def commonSources = project(":common").sourcesJar | ||
dependsOn commonSources | ||
from commonSources.archiveFile.map { zipTree(it) } | ||
} | ||
|
||
components.java { | ||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) { | ||
skip() | ||
} | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenFabric(MavenPublication) { | ||
artifactId = rootProject.archives_base_name + "-" + project.name | ||
from components.java | ||
} | ||
} | ||
|
||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing. | ||
repositories { | ||
// Add repositories to publish to here. | ||
} | ||
} |
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 @@ | ||
loom.platform=quilt |
28 changes: 28 additions & 0 deletions
28
quilt/src/main/java/pl/panszelescik/colorize/quilt/ColorizeQuilt.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,28 @@ | ||
package pl.panszelescik.colorize.quilt; | ||
|
||
import net.fabricmc.fabric.api.event.player.UseBlockCallback; | ||
import net.minecraft.world.InteractionResult; | ||
import org.quiltmc.loader.api.ModContainer; | ||
import org.quiltmc.loader.api.QuiltLoader; | ||
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; | ||
import pl.panszelescik.colorize.common.api.config.BasicConfig; | ||
|
||
import java.io.IOException; | ||
|
||
public class ColorizeQuilt implements ModInitializer { | ||
|
||
@Override | ||
public void onInitialize(ModContainer mod) { | ||
BasicConfig config; | ||
try { | ||
config = new BasicConfig(QuiltLoader.getConfigDir().toFile()); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
var handler = new ColorizeQuiltHandler(config); | ||
|
||
UseBlockCallback.EVENT.register((player, level, hand, hitResult) | ||
-> handler.handle(player, level, hand, hitResult.getBlockPos()) ? InteractionResult.SUCCESS : InteractionResult.PASS); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
quilt/src/main/java/pl/panszelescik/colorize/quilt/ColorizeQuiltHandler.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,77 @@ | ||
package pl.panszelescik.colorize.quilt; | ||
|
||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap; | ||
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; | ||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; | ||
import it.unimi.dsi.fastutil.objects.ObjectImmutableList; | ||
import net.minecraft.core.registries.Registries; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.TagKey; | ||
import net.minecraft.world.item.Item; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.crafting.Ingredient; | ||
import org.jetbrains.annotations.NotNull; | ||
import pl.panszelescik.colorize.common.api.ColorizeConfig; | ||
import pl.panszelescik.colorize.common.api.ColorizeEventHandler; | ||
import pl.panszelescik.colorize.common.api.Colors; | ||
|
||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public class ColorizeQuiltHandler extends ColorizeEventHandler { | ||
|
||
private final Object2ObjectMap<Colors, ObjectImmutableList<TagKey<Item>>> tags; | ||
|
||
public ColorizeQuiltHandler(@NotNull ColorizeConfig config) { | ||
super(config); | ||
var map = new Object2ObjectOpenHashMap<Colors, ObjectImmutableList<TagKey<Item>>>(); | ||
|
||
for (Colors c : Colors.values()) { | ||
var dyeColor = c.getDyeColor(); | ||
if (dyeColor == null) { | ||
continue; | ||
} | ||
|
||
var list = ObjectImmutableList.of( | ||
TagKey.create(Registries.ITEM, new ResourceLocation("c", dyeColor.getName() + "_dye")), | ||
TagKey.create(Registries.ITEM, new ResourceLocation("c", dyeColor.getName() + "_dyes")), | ||
TagKey.create(Registries.ITEM, new ResourceLocation("c", "dye_" + dyeColor.getName())) | ||
); | ||
|
||
map.put(c, list); | ||
} | ||
|
||
this.tags = Object2ObjectMaps.unmodifiable(map); | ||
} | ||
|
||
@Override | ||
protected @NotNull Optional<Colors> getDyeColor(@NotNull ItemStack stack) { | ||
var optional = super.getDyeColor(stack); | ||
if (optional.isPresent()) { | ||
return optional; | ||
} | ||
|
||
return this.tags | ||
.object2ObjectEntrySet() | ||
.stream() | ||
.filter(e -> e | ||
.getValue() | ||
.stream() | ||
.anyMatch(stack::is)) | ||
.findFirst() | ||
.map(Map.Entry::getKey); | ||
} | ||
|
||
public @NotNull Ingredient getColorIngredient(@NotNull Colors color) { | ||
return Ingredient.of(this.tags | ||
.object2ObjectEntrySet() | ||
.stream() | ||
.filter(e -> e.getKey() == color) | ||
.findFirst() | ||
.stream() | ||
.flatMap(t -> t.getValue().stream()) | ||
.map(Ingredient::of) | ||
.flatMap(i -> Arrays.stream(i.getItems()))); | ||
} | ||
} |
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,44 @@ | ||
{ | ||
"schema_version": 1, | ||
"quilt_loader": { | ||
"group": "${group}", | ||
"id": "colorize", | ||
"version": "${version}", | ||
"metadata": { | ||
"name": "Colorize", | ||
"description": "A short description of your mod.", | ||
"contributors": { | ||
"PanSzelescik": "Owner" | ||
}, | ||
"contact": { | ||
"website": "https://www.curseforge.com/minecraft/mc-mods/colorize", | ||
"repo": "https://github.com/PanSzelescik/colorize", | ||
"issues": "https://github.com/PanSzelescik/colorize/issues", | ||
"homepage": "https://www.curseforge.com/minecraft/mc-mods/colorize", | ||
"sources": "https://github.com/PanSzelescik/colorize" | ||
} | ||
}, | ||
"intermediate_mappings": "net.fabricmc:intermediary", | ||
"entrypoints": { | ||
"init": [ | ||
"pl.panszelescik.colorize.quilt.ColorizeQuilt" | ||
], | ||
"jei_mod_plugin": [ | ||
"pl.panszelescik.colorize.common.recipes.jei.ColorizeJEIPlugin" | ||
] | ||
}, | ||
"depends": [ | ||
{ | ||
"id": "quilted_fabric_api", | ||
"versions": "*" | ||
}, | ||
{ | ||
"id": "minecraft", | ||
"versions": ">=1.19.3" | ||
} | ||
] | ||
}, | ||
"minecraft": { | ||
"environment": "*" | ||
} | ||
} |
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