2023-01-21 20:23:24 +01:00
|
|
|
package at.petrak.hexcasting.datagen.tag;
|
|
|
|
|
|
|
|
import at.petrak.hexcasting.api.casting.ActionRegistryEntry;
|
|
|
|
import at.petrak.hexcasting.api.mod.HexTags;
|
|
|
|
import at.petrak.hexcasting.xplat.IXplatAbstractions;
|
2023-07-08 22:23:22 +02:00
|
|
|
import at.petrak.hexcasting.xplat.Platform;
|
2023-01-21 20:23:24 +01:00
|
|
|
import net.minecraft.data.DataGenerator;
|
|
|
|
import net.minecraft.data.tags.TagsProvider;
|
|
|
|
import net.minecraft.resources.ResourceKey;
|
2023-07-08 22:23:22 +02:00
|
|
|
import net.minecraft.resources.ResourceLocation;
|
|
|
|
import net.minecraft.tags.TagKey;
|
2023-01-21 20:23:24 +01:00
|
|
|
|
|
|
|
import static at.petrak.hexcasting.api.HexAPI.modLoc;
|
|
|
|
|
|
|
|
public class HexActionTagProvider extends TagsProvider<ActionRegistryEntry> {
|
|
|
|
public HexActionTagProvider(DataGenerator generator) {
|
|
|
|
super(generator, IXplatAbstractions.INSTANCE.getActionRegistry());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void addTags() {
|
|
|
|
// In-game almost all great spells are always per-world
|
|
|
|
for (var normalGreat : new String[]{
|
2023-06-20 21:08:35 +02:00
|
|
|
"lightning", "flight", "create_lava", "teleport/great", "sentinel/create/great",
|
2023-02-24 18:38:21 +01:00
|
|
|
"dispel_rain", "summon_rain", "brainsweep", "craft/battery",
|
|
|
|
"potion/regeneration", "potion/night_vision", "potion/absorption", "potion/haste", "potion/strength"
|
2023-01-21 20:23:24 +01:00
|
|
|
}) {
|
|
|
|
var loc = modLoc(normalGreat);
|
|
|
|
var key = ResourceKey.create(IXplatAbstractions.INSTANCE.getActionRegistry().key(), loc);
|
2023-07-08 22:23:22 +02:00
|
|
|
tag(ersatzActionTag(HexTags.Actions.REQUIRES_ENLIGHTENMENT)).add(key);
|
|
|
|
tag(ersatzActionTag(HexTags.Actions.CAN_START_ENLIGHTEN)).add(key);
|
|
|
|
tag(ersatzActionTag(HexTags.Actions.PER_WORLD_PATTERN)).add(key);
|
2023-01-21 20:23:24 +01:00
|
|
|
}
|
2023-01-21 22:49:20 +01:00
|
|
|
// deciding that akashic write can be just a normal spell (as a treat)
|
2023-01-21 20:23:24 +01:00
|
|
|
}
|
2023-07-08 22:23:22 +02:00
|
|
|
|
|
|
|
private static TagKey<ActionRegistryEntry> ersatzActionTag(TagKey<ActionRegistryEntry> real) {
|
|
|
|
if (IXplatAbstractions.INSTANCE.platform() == Platform.FABRIC) {
|
|
|
|
// Vanilla (and Fabric) has a bug here where it *writes* hexcasting action tags to `.../tags/action`
|
|
|
|
// instead of `.../tags/hexcasting/action`.
|
|
|
|
// So we pull this bullshit
|
|
|
|
var fakeKey = ResourceKey.<ActionRegistryEntry>createRegistryKey(
|
|
|
|
new ResourceLocation("foobar", "hexcasting/tags/action"));
|
|
|
|
return TagKey.create(fakeKey, real.location());
|
|
|
|
} else {
|
|
|
|
return real;
|
|
|
|
}
|
|
|
|
}
|
2023-01-21 20:23:24 +01:00
|
|
|
}
|