Skip to content

Commit

Permalink
Merge pull request #1 from Robustum/tag_format
Browse files Browse the repository at this point in the history
Tag format
  • Loading branch information
Hiiragi283 authored Jan 31, 2024
2 parents b24b369 + 8c5ce7b commit 695484f
Show file tree
Hide file tree
Showing 69 changed files with 551 additions and 469 deletions.
11 changes: 9 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "io.github.hiiragi283.material"
version = "1.2.0+1.16.5"
version = "1.3.0+1.16.5"

repositories {
mavenCentral()
Expand All @@ -19,14 +19,21 @@ repositories {
content { includeGroup("maven.modrinth") }
}
maven(url = "https://maven.architectury.dev/")
maven(url = "https://maven.blamejared.com") {
content { includeGroup("vazkii.patchouli") }
}
maven(url = "https://maven.shedaniel.me/")
maven(url = "https://maven.terraformersmc.com/releases/")
}

dependencies {
minecraft(libs.minecraft)
mappings("net.fabricmc:yarn:${libs.versions.fabric.yarn.get()}:v2")
modImplementation(libs.bundles.mods.fabric) {
modApi(libs.bundles.mods.fabric) {
exclude(module = "fabric-api")
exclude(module = "fabric-loader")
}
modCompileOnly(libs.bundles.mods.compile) {
exclude(module = "fabric-api")
exclude(module = "fabric-loader")
}
Expand Down
9 changes: 6 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ fabric-kotlin = { group = "net.fabricmc", name = "fabric-language-kotlin", versi

mod-modmenu = { group = "maven.modrinth", name = "modmenu", version = "1.16.23" }
rei = { group = "me.shedaniel", name = "RoughlyEnoughItems", version = "5.12.385" }
tech_reborn = { group = "TechReborn", name = "TechReborn-1.16", version = "+" }
tech-reborn = { group = "TechReborn", name = "TechReborn-1.16", version = "+" }
industrial-revolution = { group = "curse.maven", name = "industrial-revolution-391708", version = "3364481" }
patchouli = { group = "vazkii.patchouli", name = "Patchouli", version = "1.16.4-54-FABRIC-SNAPSHOT" }

[bundles]
mods-fabric = ["fabric-loader", "fabric-api", "fabric-kotlin", "rei", "tech_reborn"]
mods-debug = ["mod-modmenu"]
mods-fabric = ["fabric-loader", "fabric-api", "fabric-kotlin", "rei", "tech-reborn"]
mods-compile = ["industrial-revolution"]
mods-debug = ["mod-modmenu", "patchouli"]

[plugins]
fabric-loom = { id = "fabric-loom", version.ref = "fabric-loom" }
Expand Down
Binary file removed images/fluid_unification.png
Binary file not shown.
Binary file removed images/material_item.png
Binary file not shown.
Binary file removed images/material_system.png
Binary file not shown.
Binary file removed images/tag_sync.png
Binary file not shown.
31 changes: 12 additions & 19 deletions src/main/java/io/github/hiiragi283/material/HTTestAddon.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.github.hiiragi283.material;

import com.google.common.collect.ImmutableSet;
import io.github.hiiragi283.material.api.HTMaterialsAddon;
import io.github.hiiragi283.material.api.material.*;
import io.github.hiiragi283.material.api.material.content.HTMaterialContentMap;
import io.github.hiiragi283.material.api.material.content.HTSimpleFluidContent;
import io.github.hiiragi283.material.api.material.content.HTSimpleItemContent;
import io.github.hiiragi283.material.api.material.property.HTMaterialPropertyMap;
import io.github.hiiragi283.material.api.registry.HTDefaultedMap;
import io.github.hiiragi283.material.api.registry.HTDefaultedTable;
import io.github.hiiragi283.material.api.registry.HTObjectKeySet;
import io.github.hiiragi283.material.api.util.collection.DefaultedMap;
import io.github.hiiragi283.material.api.util.collection.DefaultedTable;
import io.github.hiiragi283.material.api.shape.HTShape;
import io.github.hiiragi283.material.api.shape.HTShapeKey;
import io.github.hiiragi283.material.api.shape.HTShapes;
Expand All @@ -17,13 +17,12 @@
import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.Items;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.Map;

@SuppressWarnings("unused")
public class HTTestAddon implements HTMaterialsAddon {

@NotNull
Expand All @@ -42,7 +41,7 @@ public int getPriority() {
public static final HTShapeKey DIRTY_DUST = new HTShapeKey("dirty_dust");

@Override
public void registerShape(@NotNull HTObjectKeySet<HTShapeKey> registry) {
public void registerShape(@NotNull ImmutableSet.Builder<HTShapeKey> registry) {
registry.add(DIRTY_DUST);
}

Expand All @@ -51,12 +50,12 @@ public void registerShape(@NotNull HTObjectKeySet<HTShapeKey> registry) {
public static final HTMaterialKey INFINITY = new HTMaterialKey("infinity");

@Override
public void registerMaterialKey(@NotNull HTObjectKeySet<HTMaterialKey> registry) {
public void registerMaterialKey(@NotNull ImmutableSet.Builder<HTMaterialKey> registry) {
registry.add(INFINITY);
}

@Override
public void modifyMaterialContent(@NotNull HTDefaultedMap<HTMaterialKey, HTMaterialContentMap> registry) {
public void modifyMaterialContent(@NotNull DefaultedMap<HTMaterialKey, HTMaterialContentMap> registry) {
HTMaterialContentMap builder = registry.getOrCreate(INFINITY);
builder.add(new HTSimpleFluidContent());
builder.add(new HTSimpleItemContent(HTShapes.DUST));
Expand All @@ -68,12 +67,8 @@ public void modifyMaterialContent(@NotNull HTDefaultedMap<HTMaterialKey, HTMater
}

@Override
public void modifyMaterialProperty(@NotNull HTDefaultedMap<HTMaterialKey, HTMaterialPropertyMap.Builder> registry) {
public void modifyMaterialProperty(@NotNull DefaultedMap<HTMaterialKey, HTMaterialPropertyMap.Builder> registry) {
HTMaterialPropertyMap.Builder builder = registry.getOrCreate(INFINITY);
/*builder.add(new HTFluidProperty(), prop -> {
prop.setTemperature(32768);
return Unit.INSTANCE;
});*/
}

@Override
Expand All @@ -99,21 +94,19 @@ public void modifyMaterialType(@NotNull Map<HTMaterialKey, HTMaterialType> regis
// Post Init //

@Override
public void bindFluidToPart(@NotNull HTDefaultedMap<HTMaterialKey, Collection<Fluid>> registry) {
public void bindFluidToPart(@NotNull DefaultedMap<HTMaterialKey, Collection<Fluid>> registry) {

}

@Override
public void bindItemToPart(@NotNull HTDefaultedTable<HTMaterialKey, HTShapeKey, Collection<ItemConvertible>> registry) {
public void bindItemToPart(@NotNull DefaultedTable<HTMaterialKey, HTShapeKey, Collection<ItemConvertible>> registry) {
registry.getOrCreate(INFINITY, HTShapes.GEM).add(Items.NETHER_STAR);
}

private static final Logger LOGGER = LogManager.getLogger(HTTestAddon.class);

@Override
public void postInitialize(@NotNull EnvType envType) {
HTShape.getShapeKeys().forEach(key -> LOGGER.info("Shape: " + key));
HTMaterial.getMaterials().forEach(key -> LOGGER.info("Material: " + key));
HTShape.getShapeKeys().forEach(key -> HTMaterials.log("Shape: " + key));
HTMaterial.getMaterials().forEach(key -> HTMaterials.log("Material: " + key));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@SuppressWarnings("UnstableApiUsage")
@Mixin(FluidEntryStack.class)
public class FluidEntryStackMixin {
public abstract class FluidEntryStackMixin {

@Shadow
private Fluid fluid;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.hiiragi283.material.mixin;

import io.github.hiiragi283.material.util.HTUtil;
import io.github.hiiragi283.material.api.util.HTUtil;
import org.objectweb.asm.tree.ClassNode;
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.hiiragi283.material.mixin;

import com.google.gson.JsonElement;
import io.github.hiiragi283.material.api.resource.HTRuntimeDataManager;
import io.github.hiiragi283.material.util.HTMixinLogger;
import io.github.hiiragi283.material.HTMaterials;
import io.github.hiiragi283.material.api.util.resource.HTRuntimeDataManager;
import net.minecraft.loot.LootManager;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
Expand All @@ -15,12 +15,12 @@
import java.util.Map;

@Mixin(LootManager.class)
public class LootManagerMixin {
public abstract class LootManagerMixin {

@Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At(value = "HEAD"))
private void ht_materials$apply(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo ci) {
HTRuntimeDataManager.lootTableConsumer(map::putAll);
HTMixinLogger.INSTANCE.info("HTMaterials registered loot tables!");
HTMaterials.log("Registered loot tables!");
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.hiiragi283.material.mixin;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import io.github.hiiragi283.material.api.resource.HTRuntimeResourcePack;
import io.github.hiiragi283.material.util.HTMixinLogger;
import io.github.hiiragi283.material.HTMaterials;
import io.github.hiiragi283.material.api.util.resource.HTRuntimeResourcePack;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
Expand All @@ -24,7 +24,7 @@ public abstract class MinecraftClientMixin {
private List<ResourcePack> ht_materials$resourcePackManager(List<ResourcePack> original) {
List<ResourcePack> copyList = new ArrayList<>(original);
copyList.add(HTRuntimeResourcePack.INSTANCE);
HTMixinLogger.INSTANCE.info("HTRuntimeResourcePack added!");
HTMaterials.log("HTRuntimeResourcePack added!");
return copyList;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.hiiragi283.material.mixin;

import com.google.gson.JsonElement;
import io.github.hiiragi283.material.api.resource.HTRuntimeDataManager;
import io.github.hiiragi283.material.util.HTMixinLogger;
import io.github.hiiragi283.material.HTMaterials;
import io.github.hiiragi283.material.api.util.resource.HTRuntimeDataManager;
import net.minecraft.recipe.RecipeManager;
import net.minecraft.resource.ResourceManager;
import net.minecraft.util.Identifier;
Expand All @@ -20,7 +20,7 @@ public abstract class RecipeManagerMixin {
@Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At("HEAD"))
private void ht_materials$apply(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo ci) {
HTRuntimeDataManager.recipeConsumer(map::putAll);
HTMixinLogger.INSTANCE.info("HTMaterials registered recipes!");
HTMaterials.log("Registered recipes!");
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.github.hiiragi283.material.mixin;

import com.google.gson.JsonElement;
import io.github.hiiragi283.material.api.resource.HTRuntimeDataManager;
import io.github.hiiragi283.material.HTMaterials;
import io.github.hiiragi283.material.api.util.resource.HTRuntimeDataManager;
import net.minecraft.resource.ResourceManager;
import net.minecraft.server.ServerAdvancementLoader;
import net.minecraft.util.Identifier;
Expand All @@ -14,11 +15,12 @@
import java.util.Map;

@Mixin(ServerAdvancementLoader.class)
public class ServerAdvancementLoaderMixin {
public abstract class ServerAdvancementLoaderMixin {

@Inject(method = "apply(Ljava/util/Map;Lnet/minecraft/resource/ResourceManager;Lnet/minecraft/util/profiler/Profiler;)V", at = @At(value = "HEAD"))
private void ht_materials$apply(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo ci) {
HTRuntimeDataManager.advancementConsumer(map::putAll);
HTMaterials.log("Registered Advancements!");
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.github.hiiragi283.material.mixin;

import io.github.hiiragi283.material.impl.mixin.HTTagLoaderMixin;
import io.github.hiiragi283.material.HTTagLoaderMixin;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagGroup;
import net.minecraft.tag.TagGroupLoader;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.github.hiiragi283.material.mixin;

import io.github.hiiragi283.material.api.part.HTPart;
import net.minecraft.tag.Tag;
import net.minecraft.tag.TagGroup;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Map;

@Mixin(TagGroup.class)
public interface TagGroupMixin<T> {

@Shadow
Map<Identifier, Tag<T>> getTags();

@Inject(method = "getTag", at = @At(value = "RETURN"), cancellable = true)
default void ht_materials$getTag(Identifier id, CallbackInfoReturnable<Tag<T>> cir) {
HTPart part = HTPart.fromId(id);
if (part != null) {
cir.setReturnValue(this.getTags().get(part.getPartId()));
}
}

}

This file was deleted.

Loading

0 comments on commit 695484f

Please sign in to comment.