From 7c00cbaec86057843bcb704fc91ccfeea60d10b2 Mon Sep 17 00:00:00 2001 From: "petrak@" Date: Tue, 22 Nov 2022 19:31:09 -0600 Subject: [PATCH] possibly impl arbitrary brainsweeps. i don't know. i'm in offline mode --- .../hexcasting/api/spell/OperatorUtils.kt | 10 +- .../spell/mishaps/MishapAlreadyBrainswept.kt | 10 +- .../api/spell/mishaps/MishapBadBrainsweep.kt | 8 +- .../operators/spells/great/OpBrainsweep.kt | 23 +- .../hexcasting/common/misc/Brainsweeping.java | 29 +- .../common/recipe/BrainsweepRecipe.java | 27 +- .../brainsweep/BrainsweepIngredient.java | 11 +- .../EntityBrainsweepIngredient.java | 40 +- .../VillagerBrainsweepIngredient.java | 27 +- .../datagen/recipe/HexplatRecipes.kt | 565 +++++++++--------- .../builders/BrainsweepRecipeBuilder.java | 28 +- .../patchouli/BrainsweepProcessor.java | 8 +- .../at/petrak/hexcasting/mixin/MixinMob.java | 6 +- .../assets/hexcasting/lang/en_us.json | 8 +- .../hexcasting/fabric/FabricHexInitializer.kt | 4 +- .../fabric/interop/emi/HexEMIPlugin.java | 48 +- .../hexcasting/forge/ForgeHexInitializer.java | 6 +- .../interop/jei/BrainsweepRecipeCategory.java | 4 +- 18 files changed, 439 insertions(+), 423 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/OperatorUtils.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/OperatorUtils.kt index 6389208f..840ca0ba 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/OperatorUtils.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/OperatorUtils.kt @@ -13,9 +13,9 @@ import net.minecraft.core.BlockPos import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.Entity import net.minecraft.world.entity.LivingEntity +import net.minecraft.world.entity.Mob import net.minecraft.world.entity.decoration.ArmorStand import net.minecraft.world.entity.item.ItemEntity -import net.minecraft.world.entity.npc.Villager import net.minecraft.world.phys.Vec3 import java.util.function.DoubleUnaryOperator import kotlin.math.abs @@ -99,14 +99,14 @@ fun List.getPlayer(idx: Int, argc: Int = 0): ServerPlayer { throw MishapInvalidIota.ofType(x, if (argc == 0) idx else argc - (idx + 1), "entity.player") } -fun List.getVillager(idx: Int, argc: Int = 0): Villager { +fun List.getMob(idx: Int, argc: Int = 0): Mob { val x = this.getOrElse(idx) { throw MishapNotEnoughArgs(idx + 1, this.size) } if (x is EntityIota) { val e = x.entity - if (e is Villager) + if (e is Mob) return e } - throw MishapInvalidIota.ofType(x, if (argc == 0) idx else argc - (idx + 1), "entity.villager") + throw MishapInvalidIota.ofType(x, if (argc == 0) idx else argc - (idx + 1), "entity.mob") } fun List.getLivingEntityButNotArmorStand(idx: Int, argc: Int = 0): LivingEntity { @@ -216,7 +216,7 @@ fun List.getPositiveIntUnderInclusive(idx: Int, max: Int, argc: Int = 0): if (x is DoubleIota) { val double = x.double val rounded = double.roundToInt() - if (abs(double - rounded) <= DoubleIota.TOLERANCE && rounded in 0 .. max) { + if (abs(double - rounded) <= DoubleIota.TOLERANCE && rounded in 0..max) { return rounded } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapAlreadyBrainswept.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapAlreadyBrainswept.kt index d23b1092..07e5a00d 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapAlreadyBrainswept.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapAlreadyBrainswept.kt @@ -2,22 +2,22 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer import at.petrak.hexcasting.api.misc.HexDamageSources -import at.petrak.hexcasting.api.spell.iota.Iota import at.petrak.hexcasting.api.spell.ParticleSpray import at.petrak.hexcasting.api.spell.casting.CastingContext -import net.minecraft.world.entity.npc.Villager +import at.petrak.hexcasting.api.spell.iota.Iota +import net.minecraft.world.entity.Mob import net.minecraft.world.item.DyeColor -class MishapAlreadyBrainswept(val villager: Villager) : Mishap() { +class MishapAlreadyBrainswept(val mob: Mob) : Mishap() { override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.GREEN) override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - villager.hurt(HexDamageSources.overcastDamageFrom(ctx.caster), villager.health) + mob.hurt(HexDamageSources.overcastDamageFrom(ctx.caster), mob.health) } override fun particleSpray(ctx: CastingContext) = - ParticleSpray.burst(villager.eyePosition, 1.0) + ParticleSpray.burst(mob.eyePosition, 1.0) override fun errorMessage(ctx: CastingContext, errorCtx: Context) = error("already_brainswept") diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBrainsweep.kt b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBrainsweep.kt index 7f121c18..78e35e2b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBrainsweep.kt +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/mishaps/MishapBadBrainsweep.kt @@ -3,19 +3,19 @@ package at.petrak.hexcasting.api.spell.mishaps import at.petrak.hexcasting.api.misc.FrozenColorizer import at.petrak.hexcasting.api.misc.HexDamageSources import at.petrak.hexcasting.api.spell.ParticleSpray -import at.petrak.hexcasting.api.spell.iota.Iota import at.petrak.hexcasting.api.spell.casting.CastingContext +import at.petrak.hexcasting.api.spell.iota.Iota import net.minecraft.core.BlockPos -import net.minecraft.world.entity.npc.Villager +import net.minecraft.world.entity.Mob import net.minecraft.world.item.DyeColor import net.minecraft.world.phys.Vec3 -class MishapBadBrainsweep(val villager: Villager, val pos: BlockPos) : Mishap() { +class MishapBadBrainsweep(val mob: Mob, val pos: BlockPos) : Mishap() { override fun accentColor(ctx: CastingContext, errorCtx: Context): FrozenColorizer = dyeColor(DyeColor.GREEN) override fun execute(ctx: CastingContext, errorCtx: Context, stack: MutableList) { - trulyHurt(villager, HexDamageSources.overcastDamageFrom(ctx.caster), villager.health) + trulyHurt(mob, HexDamageSources.overcastDamageFrom(ctx.caster), mob.health) } override fun particleSpray(ctx: CastingContext): ParticleSpray { diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpBrainsweep.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpBrainsweep.kt index 276ddf7e..d9e3d9b0 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpBrainsweep.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/spells/great/OpBrainsweep.kt @@ -1,19 +1,20 @@ package at.petrak.hexcasting.common.casting.operators.spells.great -import at.petrak.hexcasting.api.misc.MediaConstants import at.petrak.hexcasting.api.mod.HexConfig import at.petrak.hexcasting.api.spell.* import at.petrak.hexcasting.api.spell.casting.CastingContext import at.petrak.hexcasting.api.spell.iota.Iota import at.petrak.hexcasting.api.spell.mishaps.MishapAlreadyBrainswept import at.petrak.hexcasting.api.spell.mishaps.MishapBadBrainsweep -import at.petrak.hexcasting.common.misc.Brainsweeping import at.petrak.hexcasting.common.recipe.BrainsweepRecipe import at.petrak.hexcasting.common.recipe.HexRecipeStuffRegistry import at.petrak.hexcasting.ktxt.tellWitnessesThatIWasMurdered +import at.petrak.hexcasting.mixin.accessor.AccessorLivingEntity +import at.petrak.hexcasting.xplat.IXplatAbstractions import net.minecraft.core.BlockPos import net.minecraft.sounds.SoundEvents import net.minecraft.sounds.SoundSource +import net.minecraft.world.entity.Mob import net.minecraft.world.entity.npc.Villager import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.phys.Vec3 @@ -30,12 +31,12 @@ object OpBrainsweep : SpellAction { args: List, ctx: CastingContext ): Triple>? { - val sacrifice = args.getVillager(0, argc) + val sacrifice = args.getMob(0, argc) val pos = args.getBlockPos(1, argc) ctx.assertVecInRange(pos) ctx.assertEntityInRange(sacrifice) - if (Brainsweeping.isBrainswept(sacrifice)) + if (IXplatAbstractions.INSTANCE.isBrainswept(sacrifice)) throw MishapAlreadyBrainswept(sacrifice) val state = ctx.world.getBlockState(pos) @@ -45,12 +46,12 @@ object OpBrainsweep : SpellAction { val recman = ctx.world.recipeManager val recipes = recman.getAllRecipesFor(HexRecipeStuffRegistry.BRAINSWEEP_TYPE) - val recipe = recipes.find { it.matches(state, sacrifice) } + val recipe = recipes.find { it.matches(state, sacrifice, ctx.world) } ?: throw MishapBadBrainsweep(sacrifice, pos) return Triple( Spell(pos, state, sacrifice, recipe), - 10 * MediaConstants.CRYSTAL_UNIT, + recipe.mediaCost, listOf(ParticleSpray.cloud(sacrifice.position(), 1.0), ParticleSpray.burst(Vec3.atCenterOf(pos), 0.3, 100)) ) } @@ -58,18 +59,20 @@ object OpBrainsweep : SpellAction { private data class Spell( val pos: BlockPos, val state: BlockState, - val sacrifice: Villager, + val sacrifice: Mob, val recipe: BrainsweepRecipe ) : RenderedSpell { override fun cast(ctx: CastingContext) { ctx.world.setBlockAndUpdate(pos, BrainsweepRecipe.copyProperties(state, recipe.result)) - Brainsweeping.brainsweep(sacrifice) - if (HexConfig.server().doVillagersTakeOffenseAtMindMurder()) { + IXplatAbstractions.INSTANCE.brainsweep(sacrifice) + if (sacrifice is Villager && HexConfig.server().doVillagersTakeOffenseAtMindMurder()) { sacrifice.tellWitnessesThatIWasMurdered(ctx.caster) } - ctx.world.playSound(null, sacrifice, SoundEvents.VILLAGER_DEATH, SoundSource.AMBIENT, 0.8f, 1f) + val sound = (sacrifice as AccessorLivingEntity).`hex$getDeathSound`() + if (sound != null) + ctx.world.playSound(null, sacrifice, sound, SoundSource.AMBIENT, 0.8f, 1f) ctx.world.playSound(null, sacrifice, SoundEvents.PLAYER_LEVELUP, SoundSource.AMBIENT, 0.5f, 0.8f) } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/misc/Brainsweeping.java b/Common/src/main/java/at/petrak/hexcasting/common/misc/Brainsweeping.java index 7821c3c7..6a5b1996 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/misc/Brainsweeping.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/misc/Brainsweeping.java @@ -6,43 +6,24 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; -import net.minecraft.world.entity.npc.Villager; -import net.minecraft.world.entity.npc.VillagerDataHolder; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.raid.Raider; import net.minecraft.world.level.Level; import net.minecraft.world.phys.EntityHitResult; import org.jetbrains.annotations.Nullable; public class Brainsweeping { - // Keeping these functions in Brainsweeping just so we have to change less code - public static void brainsweep(Mob entity) { - if (isValidTarget(entity)) { - IXplatAbstractions.INSTANCE.brainsweep(entity); - } - } - - public static boolean isBrainswept(Mob entity) { - return isValidTarget(entity) && IXplatAbstractions.INSTANCE.isBrainswept(entity); - } - - // TODO: make this a tag - public static boolean isValidTarget(Mob mob) { - return mob instanceof VillagerDataHolder || mob instanceof Raider; - } - - public static InteractionResult tradeWithVillager(Player player, Level world, InteractionHand hand, Entity entity, - @Nullable EntityHitResult hitResult) { - if (entity instanceof Villager v && IXplatAbstractions.INSTANCE.isBrainswept(v)) { + public static InteractionResult interactWithBrainswept(Player player, Level world, InteractionHand hand, + Entity entity, @Nullable EntityHitResult hitResult) { + if (entity instanceof Mob mob && IXplatAbstractions.INSTANCE.isBrainswept(mob)) { return InteractionResult.FAIL; } return InteractionResult.PASS; } - public static InteractionResult copyBrainsweepFromVillager(LivingEntity original, LivingEntity outcome) { + public static InteractionResult copyBrainsweepPostTransformation(LivingEntity original, LivingEntity outcome) { if (original instanceof Mob mOriginal && outcome instanceof Mob mOutcome - && IXplatAbstractions.INSTANCE.isBrainswept(mOriginal) && Brainsweeping.isValidTarget(mOutcome)) { + && IXplatAbstractions.INSTANCE.isBrainswept(mOriginal)) { IXplatAbstractions.INSTANCE.brainsweep(mOutcome); } return InteractionResult.PASS; diff --git a/Common/src/main/java/at/petrak/hexcasting/common/recipe/BrainsweepRecipe.java b/Common/src/main/java/at/petrak/hexcasting/common/recipe/BrainsweepRecipe.java index b19bed30..10c055f2 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/recipe/BrainsweepRecipe.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/recipe/BrainsweepRecipe.java @@ -6,9 +6,10 @@ import at.petrak.hexcasting.common.recipe.ingredient.brainsweep.BrainsweepIngred import com.google.gson.JsonObject; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; import net.minecraft.util.GsonHelper; import net.minecraft.world.Container; -import net.minecraft.world.entity.npc.Villager; +import net.minecraft.world.entity.Entity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeSerializer; @@ -21,13 +22,14 @@ import org.jetbrains.annotations.NotNull; // God I am a horrible person public record BrainsweepRecipe( - ResourceLocation id, - StateIngredient blockIn, - BrainsweepIngredient villagerIn, - BlockState result + ResourceLocation id, + StateIngredient blockIn, + BrainsweepIngredient entityIn, + int mediaCost, + BlockState result ) implements Recipe { - public boolean matches(BlockState blockIn, Villager villagerIn) { - return this.blockIn.test(blockIn) && this.villagerIn.test(villagerIn); + public boolean matches(BlockState blockIn, Entity victim, ServerLevel level) { + return this.blockIn.test(blockIn) && this.entityIn.test(victim, level); } @Override @@ -84,15 +86,17 @@ public record BrainsweepRecipe( @Override public @NotNull BrainsweepRecipe fromJson(ResourceLocation recipeID, JsonObject json) { var blockIn = StateIngredientHelper.deserialize(GsonHelper.getAsJsonObject(json, "blockIn")); - var villagerIn = BrainsweepIngredient.deserialize(GsonHelper.getAsJsonObject(json, "villagerIn")); + var villagerIn = BrainsweepIngredient.deserialize(GsonHelper.getAsJsonObject(json, "entityIn")); + var cost = GsonHelper.getAsInt(json, "cost"); var result = StateIngredientHelper.readBlockState(GsonHelper.getAsJsonObject(json, "result")); - return new BrainsweepRecipe(recipeID, blockIn, villagerIn, result); + return new BrainsweepRecipe(recipeID, blockIn, villagerIn, cost, result); } @Override public void toNetwork(FriendlyByteBuf buf, BrainsweepRecipe recipe) { recipe.blockIn.write(buf); - recipe.villagerIn.write(buf); + recipe.entityIn.write(buf); + buf.writeVarInt(recipe.mediaCost); buf.writeVarInt(Block.getId(recipe.result)); } @@ -100,8 +104,9 @@ public record BrainsweepRecipe( public @NotNull BrainsweepRecipe fromNetwork(ResourceLocation recipeID, FriendlyByteBuf buf) { var blockIn = StateIngredientHelper.read(buf); var villagerIn = BrainsweepIngredient.read(buf); + var cost = buf.readVarInt(); var result = Block.stateById(buf.readVarInt()); - return new BrainsweepRecipe(recipeID, blockIn, villagerIn, result); + return new BrainsweepRecipe(recipeID, blockIn, villagerIn, cost, result); } } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/brainsweep/BrainsweepIngredient.java b/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/brainsweep/BrainsweepIngredient.java index 1f55f593..f110ce88 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/brainsweep/BrainsweepIngredient.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/brainsweep/BrainsweepIngredient.java @@ -3,14 +3,16 @@ package at.petrak.hexcasting.common.recipe.ingredient.brainsweep; import com.google.gson.JsonObject; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; import net.minecraft.util.GsonHelper; import net.minecraft.util.StringRepresentable; import net.minecraft.world.entity.Entity; import java.util.List; -import java.util.function.Predicate; -public abstract class BrainsweepIngredient implements Predicate { +public abstract class BrainsweepIngredient { + public abstract boolean test(Entity entity, ServerLevel level); + public abstract List getTooltip(boolean advanced); public abstract JsonObject serialize(); @@ -21,8 +23,7 @@ public abstract class BrainsweepIngredient implements Predicate { var type = buf.readVarInt(); return switch (Type.values()[type]) { case VILLAGER -> VillagerBrainsweepIngredient.read(buf); - case ENTITY -> { - } + case ENTITY -> EntityBrainsweepIngredient.read(buf); }; } @@ -31,7 +32,7 @@ public abstract class BrainsweepIngredient implements Predicate { var type = Type.valueOf(typestr); return switch (type) { case VILLAGER -> VillagerBrainsweepIngredient.deserialize(json); - case ENTITY -> null; + case ENTITY -> EntityBrainsweepIngredient.deserialize(json); }; } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/brainsweep/EntityBrainsweepIngredient.java b/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/brainsweep/EntityBrainsweepIngredient.java index 8ba7460c..e317734e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/brainsweep/EntityBrainsweepIngredient.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/brainsweep/EntityBrainsweepIngredient.java @@ -1,30 +1,35 @@ package at.petrak.hexcasting.common.recipe.ingredient.brainsweep; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import net.minecraft.advancements.critereon.DeserializationContext; import net.minecraft.advancements.critereon.EntityPredicate; -import net.minecraft.advancements.critereon.SerializationContext; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; import java.util.List; +// Code based on: +// https://github.com/SlimeKnights/Mantle/blob/1.18.2/src/main/java/slimeknights/mantle/recipe/ingredient/EntityIngredient.java +// Licensed under MIT public class EntityBrainsweepIngredient extends BrainsweepIngredient { - public final EntityPredicate.Composite requirements; + public static final Gson GSON = new GsonBuilder().create(); + + public final EntityPredicate requirements; // Just tell the player what it is you want public final Component tooltip; - protected EntityBrainsweepIngredient(EntityPredicate.Composite requirements, Component tooltip) { - super(); + public EntityBrainsweepIngredient(EntityPredicate requirements, Component tooltip) { this.requirements = requirements; this.tooltip = tooltip; } @Override - public boolean test(Entity entity) { - return false; + public boolean test(Entity entity, ServerLevel level) { + return this.requirements.matches(level, null, entity); } @Override @@ -35,17 +40,32 @@ public class EntityBrainsweepIngredient extends BrainsweepIngredient { @Override public JsonObject serialize() { var obj = new JsonObject(); - obj.add("requirements", this.requirements.toJson(SerializationContext.INSTANCE)); + obj.addProperty("type", "entity"); + + obj.add("requirements", this.requirements.serializeToJson()); obj.addProperty("tooltip", Component.Serializer.toJson(this.tooltip)); return obj; } @Override public void write(FriendlyByteBuf buf) { + buf.writeVarInt(Type.ENTITY.ordinal()); + buf.writeUtf(this.requirements.serializeToJson().toString()); + buf.writeUtf(Component.Serializer.toJson(this.tooltip)); } public static EntityBrainsweepIngredient deserialize(JsonObject obj) { - var reqs = EntityPredicate.Composite.fromJson(obj, "requirements", DeserializationContext) + var reqs = EntityPredicate.fromJson(obj.get("requirements")); + var tooltip = Component.Serializer.fromJson(obj.get("tooltip")); + return new EntityBrainsweepIngredient(reqs, tooltip); + } + + public static EntityBrainsweepIngredient read(FriendlyByteBuf buf) { + var reqsObj = GSON.fromJson(buf.readUtf(), JsonElement.class); + + var reqs = EntityPredicate.fromJson(reqsObj); + var tooltip = Component.Serializer.fromJson(buf.readUtf()); + return new EntityBrainsweepIngredient(reqs, tooltip); } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/brainsweep/VillagerBrainsweepIngredient.java b/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/brainsweep/VillagerBrainsweepIngredient.java index 4d4ff14a..12fa8048 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/brainsweep/VillagerBrainsweepIngredient.java +++ b/Common/src/main/java/at/petrak/hexcasting/common/recipe/ingredient/brainsweep/VillagerBrainsweepIngredient.java @@ -8,6 +8,7 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; import net.minecraft.util.GsonHelper; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -26,27 +27,26 @@ public class VillagerBrainsweepIngredient extends BrainsweepIngredient { private final @Nullable ResourceLocation biome; private final int minLevel; - protected VillagerBrainsweepIngredient( - @Nullable ResourceLocation profession, - @Nullable ResourceLocation biome, // aka their "type" - int minLevel + public VillagerBrainsweepIngredient( + @Nullable ResourceLocation profession, + @Nullable ResourceLocation biome, // aka their "type" + int minLevel ) { - super(); this.profession = profession; this.biome = biome; this.minLevel = minLevel; } @Override - public boolean test(Entity entity) { + public boolean test(Entity entity, ServerLevel level) { if (!(entity instanceof Villager villager)) return false; var data = villager.getVillagerData(); ResourceLocation profID = IXplatAbstractions.INSTANCE.getID(data.getProfession()); return (this.profession == null || this.profession.equals(profID)) - && (this.biome == null || this.biome.equals(Registry.VILLAGER_TYPE.getKey(data.getType()))) - && this.minLevel <= data.getLevel(); + && (this.biome == null || this.biome.equals(Registry.VILLAGER_TYPE.getKey(data.getType()))) + && this.minLevel <= data.getLevel(); } @Override @@ -57,10 +57,10 @@ public class VillagerBrainsweepIngredient extends BrainsweepIngredient { if (advanced) { if (minLevel >= 5) { tooltip.add(Component.translatable("hexcasting.tooltip.brainsweep.level", 5) - .withStyle(ChatFormatting.DARK_GRAY)); + .withStyle(ChatFormatting.DARK_GRAY)); } else if (minLevel > 1) { tooltip.add(Component.translatable("hexcasting.tooltip.brainsweep.min_level", minLevel) - .withStyle(ChatFormatting.DARK_GRAY)); + .withStyle(ChatFormatting.DARK_GRAY)); } if (biome != null) { @@ -68,7 +68,7 @@ public class VillagerBrainsweepIngredient extends BrainsweepIngredient { } ResourceLocation displayId = Objects.requireNonNullElseGet(profession, - () -> Registry.ENTITY_TYPE.getKey(EntityType.VILLAGER)); + () -> Registry.ENTITY_TYPE.getKey(EntityType.VILLAGER)); tooltip.add(Component.literal(displayId.toString()).withStyle(ChatFormatting.DARK_GRAY)); } @@ -153,14 +153,15 @@ public class VillagerBrainsweepIngredient extends BrainsweepIngredient { public static VillagerBrainsweepIngredient deserialize(JsonObject json) { ResourceLocation profession = null; - if (json.has("profession")) { + if (json.has("profession") && !json.get("profession").isJsonNull()) { profession = new ResourceLocation(GsonHelper.getAsString(json, "profession")); } ResourceLocation biome = null; - if (json.has("biome")) { + if (json.has("biome") && !json.get("biome").isJsonNull()) { biome = new ResourceLocation(GsonHelper.getAsString(json, "biome")); } int minLevel = GsonHelper.getAsInt(json, "minLevel"); + int cost = GsonHelper.getAsInt(json, "cost"); return new VillagerBrainsweepIngredient(profession, biome, minLevel); } diff --git a/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.kt b/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.kt index c75b1ea0..55c4c465 100644 --- a/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.kt +++ b/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/HexplatRecipes.kt @@ -2,6 +2,7 @@ package at.petrak.hexcasting.datagen.recipe import at.petrak.hexcasting.api.HexAPI import at.petrak.hexcasting.api.advancements.OvercastTrigger +import at.petrak.hexcasting.api.misc.MediaConstants import at.petrak.hexcasting.api.mod.HexItemTags import at.petrak.hexcasting.common.items.ItemStaff import at.petrak.hexcasting.common.items.colorizer.ItemPrideColorizer @@ -10,7 +11,7 @@ import at.petrak.hexcasting.common.lib.HexItems import at.petrak.hexcasting.common.recipe.SealFocusRecipe import at.petrak.hexcasting.common.recipe.SealSpellbookRecipe import at.petrak.hexcasting.common.recipe.ingredient.StateIngredientHelper -import at.petrak.hexcasting.common.recipe.ingredient.brainsweep.BrainsweepIngredient +import at.petrak.hexcasting.common.recipe.ingredient.brainsweep.VillagerBrainsweepIngredient import at.petrak.hexcasting.datagen.IXplatConditionsBuilder import at.petrak.hexcasting.datagen.IXplatIngredients import at.petrak.hexcasting.datagen.recipe.builders.BrainsweepRecipeBuilder @@ -36,9 +37,9 @@ import net.minecraft.world.level.block.Blocks import java.util.function.Consumer class HexplatRecipes( - val generator: DataGenerator, - val ingredients: IXplatIngredients, - val conditions: (RecipeBuilder) -> IXplatConditionsBuilder + val generator: DataGenerator, + val ingredients: IXplatIngredients, + val conditions: (RecipeBuilder) -> IXplatConditionsBuilder ) : PaucalRecipeProvider(generator, HexAPI.MOD_ID) { override fun makeRecipes(recipes: Consumer) { @@ -56,78 +57,78 @@ class HexplatRecipes( wandRecipe(recipes, HexItems.STAFF_EDIFIED, HexBlocks.EDIFIED_PLANKS.asItem()) ringCornered(HexItems.FOCUS, 1, - ingredients.glowstoneDust(), - ingredients.leather(), - Ingredient.of(HexItems.CHARGED_AMETHYST)) - .unlockedBy("has_item", hasItem(HexItemTags.STAVES)) - .save(recipes) + ingredients.glowstoneDust(), + ingredients.leather(), + Ingredient.of(HexItems.CHARGED_AMETHYST)) + .unlockedBy("has_item", hasItem(HexItemTags.STAVES)) + .save(recipes) ShapedRecipeBuilder.shaped(HexItems.SPELLBOOK) - .define('N', ingredients.goldNugget()) - .define('B', Items.WRITABLE_BOOK) - .define('A', HexItems.CHARGED_AMETHYST) - .define('F', Items.CHORUS_FRUIT) // i wanna gate this behind the end SOMEHOW - // hey look its my gender ^^ - .pattern("NBA") - .pattern("NFA") - .pattern("NBA") - .unlockedBy("has_focus", hasItem(HexItems.FOCUS)) - .unlockedBy("has_chorus", hasItem(Items.CHORUS_FRUIT)).save(recipes) + .define('N', ingredients.goldNugget()) + .define('B', Items.WRITABLE_BOOK) + .define('A', HexItems.CHARGED_AMETHYST) + .define('F', Items.CHORUS_FRUIT) // i wanna gate this behind the end SOMEHOW + // hey look its my gender ^^ + .pattern("NBA") + .pattern("NFA") + .pattern("NBA") + .unlockedBy("has_focus", hasItem(HexItems.FOCUS)) + .unlockedBy("has_chorus", hasItem(Items.CHORUS_FRUIT)).save(recipes) ringCornerless( - HexItems.CYPHER, 1, - ingredients.copperIngot(), - Ingredient.of(HexItems.AMETHYST_DUST)) - .unlockedBy("has_item", hasItem(HexItemTags.STAVES)).save(recipes) + HexItems.CYPHER, 1, + ingredients.copperIngot(), + Ingredient.of(HexItems.AMETHYST_DUST)) + .unlockedBy("has_item", hasItem(HexItemTags.STAVES)).save(recipes) ringCornerless( - HexItems.TRINKET, 1, - ingredients.ironIngot(), - Ingredient.of(Items.AMETHYST_SHARD)) - .unlockedBy("has_item", hasItem(HexItemTags.STAVES)).save(recipes) + HexItems.TRINKET, 1, + ingredients.ironIngot(), + Ingredient.of(Items.AMETHYST_SHARD)) + .unlockedBy("has_item", hasItem(HexItemTags.STAVES)).save(recipes) ShapedRecipeBuilder.shaped(HexItems.ARTIFACT) - .define('F', ingredients.goldIngot()) - .define('A', HexItems.CHARGED_AMETHYST) - // why in god's name does minecraft have two different places for item tags - .define('D', ItemTags.MUSIC_DISCS) - .pattern(" F ") - .pattern("FAF") - .pattern(" D ") - .unlockedBy("has_item", hasItem(HexItemTags.STAVES)).save(recipes) + .define('F', ingredients.goldIngot()) + .define('A', HexItems.CHARGED_AMETHYST) + // why in god's name does minecraft have two different places for item tags + .define('D', ItemTags.MUSIC_DISCS) + .pattern(" F ") + .pattern("FAF") + .pattern(" D ") + .unlockedBy("has_item", hasItem(HexItemTags.STAVES)).save(recipes) ringCornerless(HexItems.SCRYING_LENS, 1, Items.GLASS, HexItems.AMETHYST_DUST) - .unlockedBy("has_item", hasItem(HexItemTags.STAVES)).save(recipes) + .unlockedBy("has_item", hasItem(HexItemTags.STAVES)).save(recipes) ShapedRecipeBuilder.shaped(HexItems.ABACUS) - .define('S', Items.STICK) - .define('A', Items.AMETHYST_SHARD) - .define('W', ItemTags.PLANKS) - .pattern("WAW") - .pattern("SAS") - .pattern("WAW") - .unlockedBy("has_item", hasItem(HexItemTags.STAVES)).save(recipes) + .define('S', Items.STICK) + .define('A', Items.AMETHYST_SHARD) + .define('W', ItemTags.PLANKS) + .pattern("WAW") + .pattern("SAS") + .pattern("WAW") + .unlockedBy("has_item", hasItem(HexItemTags.STAVES)).save(recipes) // Why am I like this ShapedRecipeBuilder.shaped(HexItems.SUBMARINE_SANDWICH) - .define('S', Items.STICK) - .define('A', Items.AMETHYST_SHARD) - .define('C', Items.COOKED_BEEF) - .define('B', Items.BREAD) - .pattern(" SA") - .pattern(" C ") - .pattern(" B ") - .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) + .define('S', Items.STICK) + .define('A', Items.AMETHYST_SHARD) + .define('C', Items.COOKED_BEEF) + .define('B', Items.BREAD) + .pattern(" SA") + .pattern(" C ") + .pattern(" B ") + .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) for (dye in DyeColor.values()) { val item = HexItems.DYE_COLORIZERS[dye]!! ShapedRecipeBuilder.shaped(item) - .define('D', HexItems.AMETHYST_DUST) - .define('C', DyeItem.byColor(dye)) - .pattern(" D ") - .pattern("DCD") - .pattern(" D ") - .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes) + .define('D', HexItems.AMETHYST_DUST) + .define('C', DyeItem.byColor(dye)) + .pattern(" D ") + .pattern("DCD") + .pattern(" D ") + .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes) } gayRecipe(recipes, ItemPrideColorizer.Type.AGENDER, Ingredient.of(Items.GLASS)) @@ -144,337 +145,337 @@ class HexplatRecipes( gayRecipe(recipes, ItemPrideColorizer.Type.LESBIAN, Ingredient.of(Items.HONEYCOMB)) gayRecipe(recipes, ItemPrideColorizer.Type.NONBINARY, Ingredient.of(Items.MOSS_BLOCK)) gayRecipe(recipes, ItemPrideColorizer.Type.PANSEXUAL, ingredients.whenModIngredient( - Ingredient.of(Items.CARROT), - "farmersdelight", - CompatIngredientValue.of("farmersdelight:skillet") + Ingredient.of(Items.CARROT), + "farmersdelight", + CompatIngredientValue.of("farmersdelight:skillet") )) gayRecipe(recipes, ItemPrideColorizer.Type.PLURAL, Ingredient.of(Items.REPEATER)) gayRecipe(recipes, ItemPrideColorizer.Type.TRANSGENDER, Ingredient.of(Items.EGG)) ShapedRecipeBuilder.shaped(HexItems.UUID_COLORIZER) - .define('B', Items.BOWL) - .define('D', HexItems.AMETHYST_DUST) - .define('C', Items.AMETHYST_SHARD) - .pattern(" C ") - .pattern(" D ") - .pattern(" B ") - .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes) + .define('B', Items.BOWL) + .define('D', HexItems.AMETHYST_DUST) + .define('C', Items.AMETHYST_SHARD) + .pattern(" C ") + .pattern(" D ") + .pattern(" B ") + .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes) ShapedRecipeBuilder.shaped(HexItems.SCROLL_SMOL) - .define('P', Items.PAPER) - .define('A', Items.AMETHYST_SHARD) - .pattern(" A") - .pattern("P ") - .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) + .define('P', Items.PAPER) + .define('A', Items.AMETHYST_SHARD) + .pattern(" A") + .pattern("P ") + .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) ShapedRecipeBuilder.shaped(HexItems.SCROLL_MEDIUM) - .define('P', Items.PAPER) - .define('A', Items.AMETHYST_SHARD) - .pattern(" A") - .pattern("PP ") - .pattern("PP ") - .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) + .define('P', Items.PAPER) + .define('A', Items.AMETHYST_SHARD) + .pattern(" A") + .pattern("PP ") + .pattern("PP ") + .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) ShapedRecipeBuilder.shaped(HexItems.SCROLL_LARGE) - .define('P', Items.PAPER) - .define('A', Items.AMETHYST_SHARD) - .pattern("PPA") - .pattern("PPP") - .pattern("PPP") - .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) + .define('P', Items.PAPER) + .define('A', Items.AMETHYST_SHARD) + .pattern("PPA") + .pattern("PPP") + .pattern("PPP") + .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) ShapedRecipeBuilder.shaped(HexItems.SLATE, 6) - .define('S', Items.DEEPSLATE) - .define('A', HexItems.AMETHYST_DUST) - .pattern(" A ") - .pattern("SSS") - .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes) + .define('S', Items.DEEPSLATE) + .define('A', HexItems.AMETHYST_DUST) + .pattern(" A ") + .pattern("SSS") + .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes) ShapedRecipeBuilder.shaped(HexItems.JEWELER_HAMMER) - .define('I', ingredients.ironIngot()) - .define('N', ingredients.ironNugget()) - .define('A', Items.AMETHYST_SHARD) - .define('S', ingredients.stick()) - .pattern("IAN") - .pattern(" S ") - .pattern(" S ") - .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) + .define('I', ingredients.ironIngot()) + .define('N', ingredients.ironNugget()) + .define('A', Items.AMETHYST_SHARD) + .define('S', ingredients.stick()) + .pattern("IAN") + .pattern(" S ") + .pattern(" S ") + .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.SLATE_BLOCK) - .define('S', HexItems.SLATE) - .pattern("S") - .pattern("S") - .unlockedBy("has_item", hasItem(HexItems.SLATE)) - .save(recipes, modLoc("slate_block_from_slates")) + .define('S', HexItems.SLATE) + .pattern("S") + .pattern("S") + .unlockedBy("has_item", hasItem(HexItems.SLATE)) + .save(recipes, modLoc("slate_block_from_slates")) ringAll(HexBlocks.SLATE_BLOCK, 8, Blocks.DEEPSLATE, HexItems.AMETHYST_DUST) - .unlockedBy("has_item", hasItem(HexItems.SLATE)).save(recipes) + .unlockedBy("has_item", hasItem(HexItems.SLATE)).save(recipes) packing(HexItems.AMETHYST_DUST, HexBlocks.AMETHYST_DUST_BLOCK.asItem(), "amethyst_dust", - false, recipes) + false, recipes) ringAll(HexBlocks.AMETHYST_TILES, 8, Blocks.AMETHYST_BLOCK, HexItems.AMETHYST_DUST) - .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes) + .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)).save(recipes) SingleItemRecipeBuilder.stonecutting(Ingredient.of(Blocks.AMETHYST_BLOCK), HexBlocks.AMETHYST_TILES) - .unlockedBy("has_item", hasItem(Blocks.AMETHYST_BLOCK)) - .save(recipes, modLoc("stonecutting/amethyst_tiles")) + .unlockedBy("has_item", hasItem(Blocks.AMETHYST_BLOCK)) + .save(recipes, modLoc("stonecutting/amethyst_tiles")) ringAll(HexBlocks.SCROLL_PAPER, 8, Items.PAPER, Items.AMETHYST_SHARD) - .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) + .unlockedBy("has_item", hasItem(Items.AMETHYST_SHARD)).save(recipes) ShapelessRecipeBuilder.shapeless(HexBlocks.ANCIENT_SCROLL_PAPER, 8) - .requires(ingredients.dyes()[DyeColor.BROWN]!!) - .requires(HexBlocks.SCROLL_PAPER, 8) - .unlockedBy("has_item", hasItem(HexBlocks.SCROLL_PAPER)).save(recipes) + .requires(ingredients.dyes()[DyeColor.BROWN]!!) + .requires(HexBlocks.SCROLL_PAPER, 8) + .unlockedBy("has_item", hasItem(HexBlocks.SCROLL_PAPER)).save(recipes) stack(HexBlocks.SCROLL_PAPER_LANTERN, 1, HexBlocks.SCROLL_PAPER, Items.TORCH) - .unlockedBy("has_item", hasItem(HexBlocks.SCROLL_PAPER)).save(recipes) + .unlockedBy("has_item", hasItem(HexBlocks.SCROLL_PAPER)).save(recipes) stack(HexBlocks.ANCIENT_SCROLL_PAPER_LANTERN, 1, HexBlocks.ANCIENT_SCROLL_PAPER, Items.TORCH) - .unlockedBy("has_item", hasItem(HexBlocks.ANCIENT_SCROLL_PAPER)).save(recipes) + .unlockedBy("has_item", hasItem(HexBlocks.ANCIENT_SCROLL_PAPER)).save(recipes) ShapelessRecipeBuilder.shapeless(HexBlocks.ANCIENT_SCROLL_PAPER_LANTERN, 8) - .requires(ingredients.dyes()[DyeColor.BROWN]!!) - .requires(HexBlocks.SCROLL_PAPER_LANTERN, 8) - .unlockedBy("has_item", hasItem(HexBlocks.SCROLL_PAPER_LANTERN)) - .save(recipes, modLoc("ageing_scroll_paper_lantern")) + .requires(ingredients.dyes()[DyeColor.BROWN]!!) + .requires(HexBlocks.SCROLL_PAPER_LANTERN, 8) + .unlockedBy("has_item", hasItem(HexBlocks.SCROLL_PAPER_LANTERN)) + .save(recipes, modLoc("ageing_scroll_paper_lantern")) stack(HexBlocks.SCONCE, 4, - Ingredient.of(HexItems.CHARGED_AMETHYST), - ingredients.copperIngot()) - .unlockedBy("has_item", hasItem(HexItems.CHARGED_AMETHYST)).save(recipes) + Ingredient.of(HexItems.CHARGED_AMETHYST), + ingredients.copperIngot()) + .unlockedBy("has_item", hasItem(HexItems.CHARGED_AMETHYST)).save(recipes) ShapelessRecipeBuilder.shapeless(HexBlocks.EDIFIED_PLANKS, 4) - .requires(HexItemTags.EDIFIED_LOGS) - .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_LOGS)).save(recipes) + .requires(HexItemTags.EDIFIED_LOGS) + .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_LOGS)).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.EDIFIED_WOOD, 3) - .define('W', HexBlocks.EDIFIED_LOG) - .pattern("WW") - .pattern("WW") - .unlockedBy("has_item", hasItem(HexBlocks.EDIFIED_LOG)).save(recipes) + .define('W', HexBlocks.EDIFIED_LOG) + .pattern("WW") + .pattern("WW") + .unlockedBy("has_item", hasItem(HexBlocks.EDIFIED_LOG)).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.STRIPPED_EDIFIED_WOOD, 3) - .define('W', HexBlocks.STRIPPED_EDIFIED_LOG) - .pattern("WW") - .pattern("WW") - .unlockedBy("has_item", hasItem(HexBlocks.STRIPPED_EDIFIED_LOG)).save(recipes) + .define('W', HexBlocks.STRIPPED_EDIFIED_LOG) + .pattern("WW") + .pattern("WW") + .unlockedBy("has_item", hasItem(HexBlocks.STRIPPED_EDIFIED_LOG)).save(recipes) ring(HexBlocks.EDIFIED_PANEL, 8, - HexItemTags.EDIFIED_PLANKS, null) - .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) + HexItemTags.EDIFIED_PLANKS, null) + .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.EDIFIED_TILE, 6) - .define('W', HexItemTags.EDIFIED_PLANKS) - .pattern("WW ") - .pattern("W W") - .pattern(" WW") - .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) + .define('W', HexItemTags.EDIFIED_PLANKS) + .pattern("WW ") + .pattern("W W") + .pattern(" WW") + .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.EDIFIED_DOOR, 3) - .define('W', HexItemTags.EDIFIED_PLANKS) - .pattern("WW") - .pattern("WW") - .pattern("WW") - .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) + .define('W', HexItemTags.EDIFIED_PLANKS) + .pattern("WW") + .pattern("WW") + .pattern("WW") + .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.EDIFIED_TRAPDOOR, 2) - .define('W', HexItemTags.EDIFIED_PLANKS) - .pattern("WWW") - .pattern("WWW") - .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) + .define('W', HexItemTags.EDIFIED_PLANKS) + .pattern("WWW") + .pattern("WWW") + .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.EDIFIED_STAIRS, 4) - .define('W', HexItemTags.EDIFIED_PLANKS) - .pattern("W ") - .pattern("WW ") - .pattern("WWW") - .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) + .define('W', HexItemTags.EDIFIED_PLANKS) + .pattern("W ") + .pattern("WW ") + .pattern("WWW") + .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.EDIFIED_SLAB, 6) - .define('W', HexItemTags.EDIFIED_PLANKS) - .pattern("WWW") - .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) + .define('W', HexItemTags.EDIFIED_PLANKS) + .pattern("WWW") + .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.EDIFIED_PRESSURE_PLATE, 1) - .define('W', HexItemTags.EDIFIED_PLANKS) - .pattern("WW") - .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) + .define('W', HexItemTags.EDIFIED_PLANKS) + .pattern("WW") + .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) ShapelessRecipeBuilder.shapeless(HexBlocks.EDIFIED_BUTTON) - .requires(HexItemTags.EDIFIED_PLANKS) - .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) + .requires(HexItemTags.EDIFIED_PLANKS) + .unlockedBy("has_item", hasItem(HexItemTags.EDIFIED_PLANKS)).save(recipes) val enlightenment = OvercastTrigger.Instance( - EntityPredicate.Composite.ANY, - MinMaxBounds.Ints.ANY, // add a little bit of slop here - MinMaxBounds.Doubles.atLeast(0.8), - MinMaxBounds.Doubles.between(0.1, 2.05) + EntityPredicate.Composite.ANY, + MinMaxBounds.Ints.ANY, // add a little bit of slop here + MinMaxBounds.Doubles.atLeast(0.8), + MinMaxBounds.Doubles.between(0.1, 2.05) ) ShapedRecipeBuilder.shaped(HexBlocks.EMPTY_IMPETUS) - .define('B', Items.IRON_BARS) - .define('A', HexItems.CHARGED_AMETHYST) - .define('S', HexBlocks.SLATE_BLOCK) - .define('P', Items.PURPUR_BLOCK) - .pattern("PSS") - .pattern("BAB") - .pattern("SSP") - .unlockedBy("enlightenment", enlightenment).save(recipes) + .define('B', Items.IRON_BARS) + .define('A', HexItems.CHARGED_AMETHYST) + .define('S', HexBlocks.SLATE_BLOCK) + .define('P', Items.PURPUR_BLOCK) + .pattern("PSS") + .pattern("BAB") + .pattern("SSP") + .unlockedBy("enlightenment", enlightenment).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.EMPTY_DIRECTRIX) - .define('C', Items.COMPARATOR) - .define('O', Items.OBSERVER) - .define('A', HexItems.CHARGED_AMETHYST) - .define('S', HexBlocks.SLATE_BLOCK) - .pattern("CSS") - .pattern("OAO") - .pattern("SSC") - .unlockedBy("enlightenment", enlightenment).save(recipes) + .define('C', Items.COMPARATOR) + .define('O', Items.OBSERVER) + .define('A', HexItems.CHARGED_AMETHYST) + .define('S', HexBlocks.SLATE_BLOCK) + .pattern("CSS") + .pattern("OAO") + .pattern("SSC") + .unlockedBy("enlightenment", enlightenment).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.AKASHIC_BOOKSHELF) - .define('L', HexItemTags.EDIFIED_LOGS) - .define('P', HexItemTags.EDIFIED_PLANKS) - .define('C', Items.BOOK) - /*this is the*/.pattern("LPL") // and what i have for you today is - .pattern("CCC") - .pattern("LPL") - .unlockedBy("enlightenment", enlightenment).save(recipes) + .define('L', HexItemTags.EDIFIED_LOGS) + .define('P', HexItemTags.EDIFIED_PLANKS) + .define('C', Items.BOOK) + /*this is the*/.pattern("LPL") // and what i have for you today is + .pattern("CCC") + .pattern("LPL") + .unlockedBy("enlightenment", enlightenment).save(recipes) ShapedRecipeBuilder.shaped(HexBlocks.AKASHIC_LIGATURE) - .define('L', HexItemTags.EDIFIED_LOGS) - .define('P', HexItemTags.EDIFIED_PLANKS) - .define('C', HexItems.CHARGED_AMETHYST) - .pattern("LPL") - .pattern("CCC") - .pattern("LPL") - .unlockedBy("enlightenment", enlightenment).save(recipes) + .define('L', HexItemTags.EDIFIED_LOGS) + .define('P', HexItemTags.EDIFIED_PLANKS) + .define('C', HexItems.CHARGED_AMETHYST) + .pattern("LPL") + .pattern("CCC") + .pattern("LPL") + .unlockedBy("enlightenment", enlightenment).save(recipes) BrainsweepRecipeBuilder(StateIngredientHelper.of(Blocks.AMETHYST_BLOCK), - BrainsweepIngredient(null, null, 3), - Blocks.BUDDING_AMETHYST.defaultBlockState()) - .unlockedBy("enlightenment", enlightenment) - .save(recipes, modLoc("brainsweep/budding_amethyst")) + VillagerBrainsweepIngredient(null, null, 3), + Blocks.BUDDING_AMETHYST.defaultBlockState(), MediaConstants.CRYSTAL_UNIT * 10) + .unlockedBy("enlightenment", enlightenment) + .save(recipes, modLoc("brainsweep/budding_amethyst")) BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_IMPETUS), - BrainsweepIngredient(ResourceLocation("toolsmith"), null, 2), - HexBlocks.IMPETUS_RIGHTCLICK.defaultBlockState()) - .unlockedBy("enlightenment", enlightenment) - .save(recipes, modLoc("brainsweep/impetus_rightclick")) + VillagerBrainsweepIngredient(ResourceLocation("toolsmith"), null, 2), + HexBlocks.IMPETUS_RIGHTCLICK.defaultBlockState(), MediaConstants.CRYSTAL_UNIT * 10) + .unlockedBy("enlightenment", enlightenment) + .save(recipes, modLoc("brainsweep/impetus_rightclick")) BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_IMPETUS), - BrainsweepIngredient(ResourceLocation("fletcher"), null, 2), - HexBlocks.IMPETUS_LOOK.defaultBlockState()) - .unlockedBy("enlightenment", enlightenment) - .save(recipes, modLoc("brainsweep/impetus_look")) + VillagerBrainsweepIngredient(ResourceLocation("fletcher"), null, 2), + HexBlocks.IMPETUS_LOOK.defaultBlockState(), MediaConstants.CRYSTAL_UNIT * 10) + .unlockedBy("enlightenment", enlightenment) + .save(recipes, modLoc("brainsweep/impetus_look")) BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_IMPETUS), - BrainsweepIngredient(ResourceLocation("cleric"), null, 2), - HexBlocks.IMPETUS_STOREDPLAYER.defaultBlockState()) - .unlockedBy("enlightenment", enlightenment) - .save(recipes, modLoc("brainsweep/impetus_storedplayer")) + VillagerBrainsweepIngredient(ResourceLocation("cleric"), null, 2), + HexBlocks.IMPETUS_STOREDPLAYER.defaultBlockState(), MediaConstants.CRYSTAL_UNIT * 10) + .unlockedBy("enlightenment", enlightenment) + .save(recipes, modLoc("brainsweep/impetus_storedplayer")) BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_DIRECTRIX), - BrainsweepIngredient(ResourceLocation("mason"), null, 1), - HexBlocks.DIRECTRIX_REDSTONE.defaultBlockState()) - .unlockedBy("enlightenment", enlightenment) - .save(recipes, modLoc("brainsweep/directrix_redstone")) + VillagerBrainsweepIngredient(ResourceLocation("mason"), null, 1), + HexBlocks.DIRECTRIX_REDSTONE.defaultBlockState(), MediaConstants.CRYSTAL_UNIT * 10) + .unlockedBy("enlightenment", enlightenment) + .save(recipes, modLoc("brainsweep/directrix_redstone")) BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.AKASHIC_LIGATURE), - BrainsweepIngredient(ResourceLocation("librarian"), null, 5), - HexBlocks.AKASHIC_RECORD.defaultBlockState()) - .unlockedBy("enlightenment", enlightenment) - .save(recipes, modLoc("brainsweep/akashic_record")) + VillagerBrainsweepIngredient(ResourceLocation("librarian"), null, 5), + HexBlocks.AKASHIC_RECORD.defaultBlockState(), MediaConstants.CRYSTAL_UNIT * 10) + .unlockedBy("enlightenment", enlightenment) + .save(recipes, modLoc("brainsweep/akashic_record")) // Create compat CreateCrushingRecipeBuilder() - .withInput(Blocks.AMETHYST_CLUSTER) - .duration(150) - .withOutput(Items.AMETHYST_SHARD, 7) - .withOutput(HexItems.AMETHYST_DUST, 5) - .withOutput(0.25f, HexItems.CHARGED_AMETHYST) - .withConditions() - .whenModLoaded("create") - .save(recipes, ResourceLocation("create", "crushing/amethyst_cluster")) + .withInput(Blocks.AMETHYST_CLUSTER) + .duration(150) + .withOutput(Items.AMETHYST_SHARD, 7) + .withOutput(HexItems.AMETHYST_DUST, 5) + .withOutput(0.25f, HexItems.CHARGED_AMETHYST) + .withConditions() + .whenModLoaded("create") + .save(recipes, ResourceLocation("create", "crushing/amethyst_cluster")) CreateCrushingRecipeBuilder() - .withInput(Blocks.AMETHYST_BLOCK) - .duration(150) - .withOutput(Items.AMETHYST_SHARD, 3) - .withOutput(0.5f, HexItems.AMETHYST_DUST, 4) - .withConditions() - .whenModLoaded("create") - .save(recipes, ResourceLocation("create", "crushing/amethyst_block")) + .withInput(Blocks.AMETHYST_BLOCK) + .duration(150) + .withOutput(Items.AMETHYST_SHARD, 3) + .withOutput(0.5f, HexItems.AMETHYST_DUST, 4) + .withConditions() + .whenModLoaded("create") + .save(recipes, ResourceLocation("create", "crushing/amethyst_block")) CreateCrushingRecipeBuilder() - .withInput(Items.AMETHYST_SHARD) - .duration(150) - .withOutput(HexItems.AMETHYST_DUST, 4) - .withOutput(0.5f, HexItems.AMETHYST_DUST) - .withConditions() - .whenModLoaded("create") - .save(recipes, modLoc("compat/create/crushing/amethyst_shard")) + .withInput(Items.AMETHYST_SHARD) + .duration(150) + .withOutput(HexItems.AMETHYST_DUST, 4) + .withOutput(0.5f, HexItems.AMETHYST_DUST) + .withConditions() + .whenModLoaded("create") + .save(recipes, modLoc("compat/create/crushing/amethyst_shard")) // FD compat FarmersDelightCuttingRecipeBuilder() - .withInput(HexBlocks.EDIFIED_LOG) - .withTool(ingredients.axeStrip()) - .withOutput(HexBlocks.STRIPPED_EDIFIED_LOG) - .withOutput("farmersdelight:tree_bark") - .withSound(SoundEvents.AXE_STRIP) - .withConditions() - .whenModLoaded("farmersdelight") - .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_log")) + .withInput(HexBlocks.EDIFIED_LOG) + .withTool(ingredients.axeStrip()) + .withOutput(HexBlocks.STRIPPED_EDIFIED_LOG) + .withOutput("farmersdelight:tree_bark") + .withSound(SoundEvents.AXE_STRIP) + .withConditions() + .whenModLoaded("farmersdelight") + .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_log")) FarmersDelightCuttingRecipeBuilder() - .withInput(HexBlocks.EDIFIED_WOOD) - .withTool(ingredients.axeStrip()) - .withOutput(HexBlocks.STRIPPED_EDIFIED_WOOD) - .withOutput("farmersdelight:tree_bark") - .withSound(SoundEvents.AXE_STRIP) - .withConditions() - .whenModLoaded("farmersdelight") - .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_wood")) + .withInput(HexBlocks.EDIFIED_WOOD) + .withTool(ingredients.axeStrip()) + .withOutput(HexBlocks.STRIPPED_EDIFIED_WOOD) + .withOutput("farmersdelight:tree_bark") + .withSound(SoundEvents.AXE_STRIP) + .withConditions() + .whenModLoaded("farmersdelight") + .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_wood")) FarmersDelightCuttingRecipeBuilder() - .withInput(HexBlocks.EDIFIED_TRAPDOOR) - .withTool(ingredients.axeDig()) - .withOutput(HexBlocks.EDIFIED_PLANKS) - .withConditions() - .whenModLoaded("farmersdelight") - .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_trapdoor")) + .withInput(HexBlocks.EDIFIED_TRAPDOOR) + .withTool(ingredients.axeDig()) + .withOutput(HexBlocks.EDIFIED_PLANKS) + .withConditions() + .whenModLoaded("farmersdelight") + .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_trapdoor")) FarmersDelightCuttingRecipeBuilder() - .withInput(HexBlocks.EDIFIED_DOOR) - .withTool(ingredients.axeDig()) - .withOutput(HexBlocks.EDIFIED_PLANKS) - .withConditions() - .whenModLoaded("farmersdelight") - .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_door")) + .withInput(HexBlocks.EDIFIED_DOOR) + .withTool(ingredients.axeDig()) + .withOutput(HexBlocks.EDIFIED_PLANKS) + .withConditions() + .whenModLoaded("farmersdelight") + .save(recipes, modLoc("compat/farmersdelight/cutting/akashic_door")) } private fun wandRecipe(recipes: Consumer, wand: ItemStaff, plank: Item) { ShapedRecipeBuilder.shaped(wand) - .define('W', plank) - .define('S', Items.STICK) - .define('A', HexItems.CHARGED_AMETHYST) - .pattern(" SA") - .pattern(" WS") - .pattern("S ") - .unlockedBy("has_item", hasItem(HexItems.CHARGED_AMETHYST)) - .save(recipes) + .define('W', plank) + .define('S', Items.STICK) + .define('A', HexItems.CHARGED_AMETHYST) + .pattern(" SA") + .pattern(" WS") + .pattern("S ") + .unlockedBy("has_item", hasItem(HexItems.CHARGED_AMETHYST)) + .save(recipes) } private fun gayRecipe(recipes: Consumer, type: ItemPrideColorizer.Type, material: Ingredient) { val colorizer = HexItems.PRIDE_COLORIZERS[type]!! ShapedRecipeBuilder.shaped(colorizer) - .define('D', HexItems.AMETHYST_DUST) - .define('C', material) - .pattern(" D ") - .pattern("DCD") - .pattern(" D ") - .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)) - .save(recipes) + .define('D', HexItems.AMETHYST_DUST) + .define('C', material) + .pattern(" D ") + .pattern("DCD") + .pattern(" D ") + .unlockedBy("has_item", hasItem(HexItems.AMETHYST_DUST)) + .save(recipes) } private fun specialRecipe(consumer: Consumer, serializer: SimpleRecipeSerializer<*>) { diff --git a/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/builders/BrainsweepRecipeBuilder.java b/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/builders/BrainsweepRecipeBuilder.java index 9166c53e..d2b99fed 100644 --- a/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/builders/BrainsweepRecipeBuilder.java +++ b/Common/src/main/java/at/petrak/hexcasting/datagen/recipe/builders/BrainsweepRecipeBuilder.java @@ -21,16 +21,19 @@ import org.jetbrains.annotations.Nullable; import java.util.function.Consumer; public class BrainsweepRecipeBuilder implements RecipeBuilder { - private StateIngredient blockIn; - private BrainsweepIngredient villagerIn; + private final StateIngredient blockIn; + private final BrainsweepIngredient villagerIn; + private final int mediaCost; private final BlockState result; private final Advancement.Builder advancement; - public BrainsweepRecipeBuilder(StateIngredient blockIn, BrainsweepIngredient villagerIn, BlockState result) { + public BrainsweepRecipeBuilder(StateIngredient blockIn, BrainsweepIngredient villagerIn, BlockState result, + int mediaCost) { this.blockIn = blockIn; this.villagerIn = villagerIn; this.result = result; + this.mediaCost = mediaCost; this.advancement = Advancement.Builder.advancement(); } @@ -57,23 +60,24 @@ public class BrainsweepRecipeBuilder implements RecipeBuilder { } this.advancement.parent(new ResourceLocation("recipes/root")) - .addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(pRecipeId)) - .rewards(AdvancementRewards.Builder.recipe(pRecipeId)) - .requirements(RequirementsStrategy.OR); + .addCriterion("has_the_recipe", RecipeUnlockedTrigger.unlocked(pRecipeId)) + .rewards(AdvancementRewards.Builder.recipe(pRecipeId)) + .requirements(RequirementsStrategy.OR); pFinishedRecipeConsumer.accept(new Result( - pRecipeId, - this.blockIn, this.villagerIn, this.result, - this.advancement, - new ResourceLocation(pRecipeId.getNamespace(), "recipes/brainsweep/" + pRecipeId.getPath()))); + pRecipeId, + this.blockIn, this.villagerIn, this.mediaCost, this.result, + this.advancement, + new ResourceLocation(pRecipeId.getNamespace(), "recipes/brainsweep/" + pRecipeId.getPath()))); } public record Result(ResourceLocation id, StateIngredient blockIn, BrainsweepIngredient villagerIn, - BlockState result, Advancement.Builder advancement, + int mediaCost, BlockState result, Advancement.Builder advancement, ResourceLocation advancementId) implements FinishedRecipe { @Override public void serializeRecipeData(JsonObject json) { json.add("blockIn", this.blockIn.serialize()); - json.add("villagerIn", this.villagerIn.serialize()); + json.add("entityIn", this.villagerIn.serialize()); + json.addProperty("cost", this.mediaCost); json.add("result", StateIngredientHelper.serializeBlockState(this.result)); } diff --git a/Common/src/main/java/at/petrak/hexcasting/interop/patchouli/BrainsweepProcessor.java b/Common/src/main/java/at/petrak/hexcasting/interop/patchouli/BrainsweepProcessor.java index 80c4a65d..18ef268c 100644 --- a/Common/src/main/java/at/petrak/hexcasting/interop/patchouli/BrainsweepProcessor.java +++ b/Common/src/main/java/at/petrak/hexcasting/interop/patchouli/BrainsweepProcessor.java @@ -47,11 +47,11 @@ public class BrainsweepProcessor implements IComponentProcessor { } case "entity" -> { - var profession = Objects.requireNonNullElse(this.recipe.villagerIn().profession(), + var profession = Objects.requireNonNullElse(this.recipe.entityIn().profession(), new ResourceLocation("toolsmith")); - var biome = Objects.requireNonNullElse(this.recipe.villagerIn().biome(), + var biome = Objects.requireNonNullElse(this.recipe.entityIn().biome(), new ResourceLocation("plains")); - var level = this.recipe.villagerIn().minLevel(); + var level = this.recipe.entityIn().minLevel(); var iHatePatchouli = String.format( "minecraft:villager{VillagerData:{profession:'%s',type:'%s',level:%d}}", profession, biome, level); @@ -59,7 +59,7 @@ public class BrainsweepProcessor implements IComponentProcessor { } case "entityTooltip" -> { Minecraft mc = Minecraft.getInstance(); - return IVariable.wrapList(this.recipe.villagerIn() + return IVariable.wrapList(this.recipe.entityIn() .getTooltip(mc.options.advancedItemTooltips) .stream() .map(IVariable::from) diff --git a/Common/src/main/java/at/petrak/hexcasting/mixin/MixinMob.java b/Common/src/main/java/at/petrak/hexcasting/mixin/MixinMob.java index 9fa7af63..9404606e 100644 --- a/Common/src/main/java/at/petrak/hexcasting/mixin/MixinMob.java +++ b/Common/src/main/java/at/petrak/hexcasting/mixin/MixinMob.java @@ -1,6 +1,6 @@ package at.petrak.hexcasting.mixin; -import at.petrak.hexcasting.common.misc.Brainsweeping; +import at.petrak.hexcasting.xplat.IXplatAbstractions; import net.minecraft.world.entity.Mob; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -13,7 +13,7 @@ public class MixinMob { @Inject(method = "serverAiStep", at = @At("HEAD"), cancellable = true) private void onRegisterBrainGoals(CallbackInfo ci) { var self = (Mob) (Object) this; - if (Brainsweeping.isBrainswept(self)) { + if (IXplatAbstractions.INSTANCE.isBrainswept(self)) { ci.cancel(); } } @@ -21,7 +21,7 @@ public class MixinMob { @Inject(method = "playAmbientSound", at = @At("HEAD"), cancellable = true) protected void onPlayAmbientSound(CallbackInfo ci) { var self = (Mob) (Object) this; - if (Brainsweeping.isBrainswept(self)) { + if (IXplatAbstractions.INSTANCE.isBrainswept(self)) { ci.cancel(); } } diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.json b/Common/src/main/resources/assets/hexcasting/lang/en_us.json index 57b6ceff..8e825c94 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.json +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.json @@ -253,7 +253,7 @@ "command.hexcasting.pats.specific.success": "Gave %s with id %s to %s", "command.hexcasting.recalc": "Recalculated patterns", "command.hexcasting.brainsweep": "Brainswept %s", - "command.hexcasting.brainsweep.fail.badtype": "%s is not a villager", + "command.hexcasting.brainsweep.fail.badtype": "%s is not a mob", "command.hexcasting.brainsweep.fail.already": "%s is already empty", "hexcasting.pattern.unknown": "Unknown pattern resource location %s", "hexcasting.debug.media_withdrawn": "%s - Media withdrawn: %s", @@ -561,8 +561,8 @@ "hexcasting.mishap.bad_block": "Expected %s at %s, but got %s", "hexcasting.mishap.bad_block.sapling": "a sapling", "hexcasting.mishap.bad_block.replaceable": "somewhere to place a block", - "hexcasting.mishap.bad_brainsweep": "The %s rejected the villager's mind", - "hexcasting.mishap.already_brainswept": "The villager has already been used", + "hexcasting.mishap.bad_brainsweep": "The %s rejected the being's mind", + "hexcasting.mishap.already_brainswept": "The mind has already been used", "hexcasting.mishap.no_spell_circle": "%s requires a spell circle", "hexcasting.mishap.others_name": "Tried to invade the privacy of %s's soul", "hexcasting.mishap.others_name.self": "Tried to divulge my Name too recklessly", @@ -714,7 +714,7 @@ "hexcasting.entry.mishaps2": "Enlightened Mishaps", "hexcasting.page.mishaps2.1": "I have discovered new and horrifying modes of failure. I must not succumb to them.", "hexcasting.page.mishaps2.bad_mindflay.title": "Inert Mindflay", - "hexcasting.page.mishaps2.bad_mindflay": "Attempted to flay the mind of a villager that I have either already used, or of a character not suitable for the target block.$(br2)Causes dark green sparks, and kills the subject. If another villager sees that, I doubt they would look on it favorably.", + "hexcasting.page.mishaps2.bad_mindflay": "Attempted to flay the mind of something that I have either already used, or of a character not suitable for the target block.$(br2)Causes dark green sparks, and kills the subject. If a villager sees that, I doubt they would look on it favorably.", "hexcasting.page.mishaps2.no_circle.title": "Lack Spell Circle", "hexcasting.page.mishaps2.no_circle": "Tried to cast an action requiring a spell circle without a spell circle.$(br2)Causes light blue sparks, and upends my inventory onto the ground.", "hexcasting.page.mishaps2.no_record.title": "Lack Akashic Record", diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexInitializer.kt b/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexInitializer.kt index f694a5e2..f3c5e2e7 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexInitializer.kt +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/FabricHexInitializer.kt @@ -63,8 +63,8 @@ object FabricHexInitializer : ModInitializer { } fun initListeners() { - UseEntityCallback.EVENT.register(Brainsweeping::tradeWithVillager) - VillagerConversionCallback.EVENT.register(Brainsweeping::copyBrainsweepFromVillager) + UseEntityCallback.EVENT.register(Brainsweeping::interactWithBrainswept) + VillagerConversionCallback.EVENT.register(Brainsweeping::copyBrainsweepPostTransformation) AttackBlockCallback.EVENT.register { player, world, _, pos, _ -> // SUCCESS cancels further processing and, on the client, sends a packet to the server. // PASS falls back to further processing. diff --git a/Fabric/src/main/java/at/petrak/hexcasting/fabric/interop/emi/HexEMIPlugin.java b/Fabric/src/main/java/at/petrak/hexcasting/fabric/interop/emi/HexEMIPlugin.java index d5a1c489..3054676d 100644 --- a/Fabric/src/main/java/at/petrak/hexcasting/fabric/interop/emi/HexEMIPlugin.java +++ b/Fabric/src/main/java/at/petrak/hexcasting/fabric/interop/emi/HexEMIPlugin.java @@ -39,24 +39,24 @@ public class HexEMIPlugin implements EmiPlugin { private static final ResourceLocation SIMPLIFIED_ICON_PROFESSION = modLoc("textures/gui/villager_profession.png"); public static final EmiRecipeCategory BRAINSWEEP = new EmiRecipeCategory(BRAINSWEEP_ID, - new PatternRendererEMI(BRAINSWEEP_ID, 16, 16), - new EmiTexture(SIMPLIFIED_ICON_BRAINSWEEP, 0, 0, 16, 16, 16, 16, 16, 16)); + new PatternRendererEMI(BRAINSWEEP_ID, 16, 16), + new EmiTexture(SIMPLIFIED_ICON_BRAINSWEEP, 0, 0, 16, 16, 16, 16, 16, 16)); public static final EmiRecipeCategory PHIAL = new EmiRecipeCategory(PHIAL_ID, - new PatternRendererEMI(PHIAL_ID, 12, 12).shift(2, 2), - new EmiTexture(SIMPLIFIED_ICON_PHIAL, 0, 0, 16, 16, 16, 16, 16, 16)); + new PatternRendererEMI(PHIAL_ID, 12, 12).shift(2, 2), + new EmiTexture(SIMPLIFIED_ICON_PHIAL, 0, 0, 16, 16, 16, 16, 16, 16)); public static final EmiRecipeCategory EDIFY = new EmiRecipeCategory(EDIFY_ID, - new PatternRendererEMI(EDIFY_ID, 16, 16).strokeOrder(false), - new EmiTexture(SIMPLIFIED_ICON_EDIFY, 0, 0, 16, 16, 16, 16, 16, 16)); + new PatternRendererEMI(EDIFY_ID, 16, 16).strokeOrder(false), + new EmiTexture(SIMPLIFIED_ICON_EDIFY, 0, 0, 16, 16, 16, 16, 16, 16)); public static final EmiRecipeCategory VILLAGER_LEVELING = new EmiRecipeCategory(VILLAGER_LEVELING_ID, - EmiStack.of(Items.EMERALD), - new EmiTexture(SIMPLIFIED_ICON_LEVELING, 0, 0, 16, 16, 16, 16, 16, 16)); + EmiStack.of(Items.EMERALD), + new EmiTexture(SIMPLIFIED_ICON_LEVELING, 0, 0, 16, 16, 16, 16, 16, 16)); public static final EmiRecipeCategory VILLAGER_PROFESSION = new EmiRecipeCategory(VILLAGER_PROFESSION_ID, - EmiStack.of(Blocks.LECTERN), - new EmiTexture(SIMPLIFIED_ICON_PROFESSION, 0, 0, 16, 16, 16, 16, 16, 16)); + EmiStack.of(Blocks.LECTERN), + new EmiTexture(SIMPLIFIED_ICON_PROFESSION, 0, 0, 16, 16, 16, 16, 16, 16)); @Override public void register(EmiRegistry registry) { @@ -70,10 +70,10 @@ public class HexEMIPlugin implements EmiPlugin { registry.addWorkstation(EDIFY, EmiIngredient.of(HexItemTags.STAVES)); for (BrainsweepRecipe recipe : registry.getRecipeManager() - .getAllRecipesFor(HexRecipeStuffRegistry.BRAINSWEEP_TYPE)) { + .getAllRecipesFor(HexRecipeStuffRegistry.BRAINSWEEP_TYPE)) { var inputs = EmiIngredient.of(recipe.blockIn().getDisplayedStacks().stream() - .map(EmiStack::of).toList()); - var villagerInput = VillagerEmiStack.atLevelOrHigher(recipe.villagerIn(), true); + .map(EmiStack::of).toList()); + var villagerInput = VillagerEmiStack.atLevelOrHigher(recipe.entityIn(), true); var output = EmiStack.of(recipe.result().getBlock()); registry.addRecipe(new EmiBrainsweepRecipe(inputs, villagerInput, output, recipe.getId())); } @@ -94,28 +94,28 @@ public class HexEMIPlugin implements EmiPlugin { Set states = VillagerEmiStack.matchingStatesForProfession(profession); if (!states.isEmpty()) { List workstations = states.stream() - .map(BlockState::getBlock) - .map(Block::asItem) - .distinct() - .filter((it) -> it != Items.AIR) - .toList(); + .map(BlockState::getBlock) + .map(Block::asItem) + .distinct() + .filter((it) -> it != Items.AIR) + .toList(); if (!workstations.isEmpty()) { registry.addWorkstation(VILLAGER_LEVELING, - EmiIngredient.of(workstations.stream().map(EmiStack::of).toList())); + EmiIngredient.of(workstations.stream().map(EmiStack::of).toList())); registry.addWorkstation(VILLAGER_PROFESSION, - EmiIngredient.of(workstations.stream().map(EmiStack::of).toList())); + EmiIngredient.of(workstations.stream().map(EmiStack::of).toList())); registry.addRecipe(new EmiProfessionRecipe(new VillagerEmiStack(basicVillager), - EmiIngredient.of(workstations.stream().map(EmiStack::of).toList()), - new VillagerEmiStack(manWithJob), poiRecipeId)); + EmiIngredient.of(workstations.stream().map(EmiStack::of).toList()), + new VillagerEmiStack(manWithJob), poiRecipeId)); for (int lvl = 1; lvl < 5; lvl++) { ResourceLocation levelRecipeId = modLoc( - "villager/levelup/" + lvl + "/" + id.getNamespace() + "/" + id.getPath()); + "villager/levelup/" + lvl + "/" + id.getNamespace() + "/" + id.getPath()); var manWithBadJob = new BrainsweepIngredient(id, null, lvl); var manWithBetterJob = new BrainsweepIngredient(id, null, lvl + 1); registry.addRecipe(new EmiLevelupRecipe(new VillagerEmiStack(manWithBadJob), - new VillagerEmiStack(manWithBetterJob), levelRecipeId)); + new VillagerEmiStack(manWithBetterJob), levelRecipeId)); } } } diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java b/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java index 8479a00a..06b4706d 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/ForgeHexInitializer.java @@ -112,7 +112,7 @@ public class ForgeHexInitializer { // https://github.com/VazkiiMods/Botania/blob/1.18.x/Forge/src/main/java/vazkii/botania/forge/ForgeCommonInitializer.java private static void bind(ResourceKey> registry, - Consumer> source) { + Consumer> source) { getModEventBus().addListener((RegisterEvent event) -> { if (registry.equals(event.getRegistryKey())) { source.accept((t, rl) -> event.register(registry, rl, () -> t)); @@ -159,7 +159,7 @@ public class ForgeHexInitializer { HexAPI.LOGGER.info(PatternRegistry.getPatternCountInfo())); evBus.addListener((PlayerInteractEvent.EntityInteract evt) -> { - var res = Brainsweeping.tradeWithVillager( + var res = Brainsweeping.interactWithBrainswept( evt.getEntity(), evt.getLevel(), evt.getHand(), evt.getTarget(), null); if (res.consumesAction()) { evt.setCanceled(true); @@ -167,7 +167,7 @@ public class ForgeHexInitializer { } }); evBus.addListener((LivingConversionEvent.Post evt) -> - Brainsweeping.copyBrainsweepFromVillager(evt.getEntity(), evt.getOutcome())); + Brainsweeping.copyBrainsweepPostTransformation(evt.getEntity(), evt.getOutcome())); evBus.addListener((LivingEvent.LivingTickEvent evt) -> { OpFlight.INSTANCE.tickDownFlight(evt.getEntity()); diff --git a/Forge/src/main/java/at/petrak/hexcasting/forge/interop/jei/BrainsweepRecipeCategory.java b/Forge/src/main/java/at/petrak/hexcasting/forge/interop/jei/BrainsweepRecipeCategory.java index b0985bb0..3d42d3ac 100644 --- a/Forge/src/main/java/at/petrak/hexcasting/forge/interop/jei/BrainsweepRecipeCategory.java +++ b/Forge/src/main/java/at/petrak/hexcasting/forge/interop/jei/BrainsweepRecipeCategory.java @@ -70,7 +70,7 @@ public class BrainsweepRecipeCategory implements IRecipeCategory