crimes against humanity

This commit is contained in:
gamma-delta 2022-03-21 20:08:21 -05:00
parent 70a11cc841
commit 83ffae316e
31 changed files with 391 additions and 74 deletions

View file

@ -1,6 +1,8 @@
0c822eb2acf14b943bc813d5156ea62017b64e7c assets/hexcasting/blockstates/empty_impetus.json
6ffdff8f82bab364cacdcad8aecaead9028ce4d1 assets/hexcasting/blockstates/impetus_rightclick.json
e26f9f72db9fab9b78bad75ec4c1746b4f84fa12 assets/hexcasting/blockstates/slate.json
043abd5bbfd1186415049d24d185d4e4395320f9 assets/hexcasting/blockstates/slate_block.json
c16c01e29c536391db8cedf03383ebd11e82de74 assets/hexcasting/models/block/empty_impetus.json
aa21181c678331a51488a4afc1495489fb949ae6 assets/hexcasting/models/block/impetus_rightclick.json
5644693cfd0552f0afd5d7491dd8fb196f1e177f assets/hexcasting/models/block/impetus_rightclick_lit.json
d51541b464840530f4e734db1f67ed20e811ad14 assets/hexcasting/models/block/slate_block.json
@ -28,6 +30,7 @@ c2ceb08a8662a7e4a311401b0baced1add6f2e35 assets/hexcasting/models/item/dye_color
f41fb9405b869644333872cd1ece40b1b07410d2 assets/hexcasting/models/item/dye_colorizer_red.json
5894e7a1cc38ae5b09c651791c65c983d984d20c assets/hexcasting/models/item/dye_colorizer_white.json
07959b86ed25559b4960c5f4aa7bab88bf9b5bf1 assets/hexcasting/models/item/dye_colorizer_yellow.json
46bca89ab580243b2bcb59c166d4940ba97a44ea assets/hexcasting/models/item/empty_impetus.json
f7f98a306a8a0529a54446b4876e624201525a1d assets/hexcasting/models/item/focus.json
0146e90177ed71b25d2936ff3b2d9975e47c5142 assets/hexcasting/models/item/focus_double.json
167b8e3f3367f12f8045369bea26d7a48e59b0d0 assets/hexcasting/models/item/focus_double_sealed.json
@ -93,6 +96,7 @@ b6593ea802a692c29b5032292df31beb84878ad8 data/hexcasting/advancements/aaa_wastef
4f4c94021adfb296e3ef3dce1acc46f724f38f92 data/hexcasting/advancements/aab_big_cast.json
a165e3959b7d0c37bea586d0e94609b483255569 data/hexcasting/advancements/enlightenment.json
eb6393ffc79966e4b5983a68157742b78cd12414 data/hexcasting/advancements/opened_eyes.json
e4abb6a463164c72ad0b631e58b11d4b2c618b12 data/hexcasting/advancements/recipes/brainsweep/impetus_rightclick.json
47000a9b5a409038e369dbef156a72ec93cb51db data/hexcasting/advancements/recipes/hexcasting/abacus.json
af81f4442801d794920d6330d82cb1289a78f236 data/hexcasting/advancements/recipes/hexcasting/artifact.json
7e4de1f72dd75e3efea6e879e1be15fa4216bd4b data/hexcasting/advancements/recipes/hexcasting/cypher.json
@ -165,6 +169,7 @@ bc79add419b8791e68b35076355fea11dfc640c6 data/hexcasting/recipes/dye_colorizer_w
c5341777604a4be5a311e300a4de89967b7caad2 data/hexcasting/recipes/dye_colorizer_yellow.json
db8a00478e1c4b0f9b143b5946d1ba25e489591d data/hexcasting/recipes/dynamic/seal_focus.json
91d690ba6ad40da05111aff1ea5804c859618986 data/hexcasting/recipes/focus.json
9631f6616c6a63c9e0a9eaa8126e2f116636fab5 data/hexcasting/recipes/impetus_rightclick.json
3a47933ad88386e7e70712d9db682f0a987afeda data/hexcasting/recipes/lens.json
0ea329526c81c1e4064bab61721ab4586cfcf706 data/hexcasting/recipes/pride_colorizer_0.json
c742a0a5fba2388263bfccfb49c60277d817f8cd data/hexcasting/recipes/pride_colorizer_1.json
@ -187,6 +192,8 @@ d14cf2f8f0895a5b6dc09b7582c0abf1c2514adf data/hexcasting/recipes/sub_sandwich.js
33b9d3a5e65343fc0e442e17d55a1eaa08943c8f data/hexcasting/recipes/trinket.json
14d6be5d47b54676a349564ea32c045c76c39b45 data/hexcasting/recipes/uuid_colorizer.json
0521d57838cb3e9795fc02ce47aa58db3b0188f9 data/hexcasting/recipes/wand.json
bb1b6b77482fd9778a8c0473495aa8e22cddd706 data/minecraft/advancements/recipes/brainsweep/budding_amethyst.json
996fb8e48bacec65d5d3de31d733e87656b74df5 data/minecraft/advancements/recipes/hexcasting/slate_block_from_slates.json
1cb9f605890a215a965e1088abd3013bd34e0fc0 data/minecraft/recipes/budding_amethyst.json
6f5c41ab9f87ec1206efaaab8d91adc766bb79fd data/minecraft/recipes/slate_block_from_slates.json
cf2e739eb059c69251e4a1305b259aff866f6f5f data/minecraft/tags/blocks/mineable/pickaxe.json

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "hexcasting:block/empty_impetus"
}
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "hexcasting:block/impetus/empty"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "hexcasting:block/empty_impetus"
}

View file

@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"hexcasting:impetus_rightclick"
]
},
"criteria": {
"enlightenment": {
"trigger": "hexcasting:overcast",
"conditions": {
"health_used": {
"min": 17.95
},
"mojang_i_am_begging_and_crying_please_add_an_entity_health_criterion": {
"min": 0.1,
"max": 2.05
}
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "hexcasting:impetus_rightclick"
}
}
},
"requirements": [
[
"enlightenment",
"has_the_recipe"
]
]
}

View file

@ -0,0 +1,18 @@
{
"type": "hexcasting:brainsweep",
"blockIn": {
"type": "block",
"block": "hexcasting:empty_impetus"
},
"villagerIn": {
"profession": "minecraft:toolsmith",
"minLevel": 1
},
"result": {
"name": "hexcasting:impetus_rightclick",
"properties": {
"facing": "north",
"energized": "false"
}
}
}

View file

@ -0,0 +1,34 @@
{
"parent": "minecraft:recipes/root",
"rewards": {
"recipes": [
"minecraft:budding_amethyst"
]
},
"criteria": {
"enlightenment": {
"trigger": "hexcasting:overcast",
"conditions": {
"health_used": {
"min": 17.95
},
"mojang_i_am_begging_and_crying_please_add_an_entity_health_criterion": {
"min": 0.1,
"max": 2.05
}
}
},
"has_the_recipe": {
"trigger": "minecraft:recipe_unlocked",
"conditions": {
"recipe": "minecraft:budding_amethyst"
}
}
},
"requirements": [
[
"enlightenment",
"has_the_recipe"
]
]
}

View file

@ -0,0 +1,13 @@
{
"type": "hexcasting:brainsweep",
"blockIn": {
"type": "block",
"block": "minecraft:amethyst_block"
},
"villagerIn": {
"minLevel": 5
},
"result": {
"name": "minecraft:budding_amethyst"
}
}

View file

@ -4,6 +4,7 @@ import at.petrak.hexcasting.client.*
import at.petrak.hexcasting.common.ContributorList
import at.petrak.hexcasting.common.blocks.HexBlocks
import at.petrak.hexcasting.common.casting.RegisterPatterns
import at.petrak.hexcasting.common.casting.misc.Brainsweeping
import at.petrak.hexcasting.common.casting.operators.spells.great.OpFlight
import at.petrak.hexcasting.common.command.HexCommands
import at.petrak.hexcasting.common.items.HexItems
@ -13,6 +14,7 @@ import at.petrak.hexcasting.common.lib.HexStatistics
import at.petrak.hexcasting.common.network.HexMessages
import at.petrak.hexcasting.common.particles.HexParticles
import at.petrak.hexcasting.common.recipe.HexCustomRecipes
import at.petrak.hexcasting.common.recipe.HexRecipeSerializers
import at.petrak.hexcasting.datagen.HexAdvancements
import at.petrak.hexcasting.datagen.HexDataGenerators
import at.petrak.hexcasting.datagen.lootmods.HexLootModifiers
@ -64,11 +66,15 @@ object HexMod {
HexSounds.SOUNDS.register(modBus)
HexParticles.PARTICLES.register(modBus)
HexCustomRecipes.RECIPES.register(modBus)
HexRecipeSerializers.SERIALIZERS.register(modBus)
modBus.register(HexStatistics::class.java)
modBus.register(HexRecipeSerializers::class.java)
evBus.register(HexCommands::class.java)
evBus.register(TickScheduler)
evBus.register(HexCapabilities::class.java)
evBus.register(OpFlight)
evBus.register(Brainsweeping::class.java)
DistExecutor.unsafeRunWhenOn(Dist.CLIENT) {
Runnable {
@ -82,7 +88,6 @@ object HexMod {
// and then things that don't require busses
HexMessages.register()
HexStatistics.register()
ContributorList.loadContributors()
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, CONFIG_SPEC)

View file

@ -42,7 +42,7 @@ public class HexTooltips {
tag.contains(ItemScroll.TAG_OP_ID)
? PatternTooltipGreeble.ANCIENT_BG : PatternTooltipGreeble.PRISTINE_BG)));
}
} else if (stack.is(HexItems.SLATE.get()) && ItemSlate.hasPattern(stack)) {
} else if (stack.is(HexItems.Blocks.SLATE.get()) && ItemSlate.hasPattern(stack)) {
var tag = stack.getOrCreateTag()
.getCompound("BlockEntityTag")
.getCompound(BlockEntitySlate.TAG_PATTERN);

View file

@ -91,7 +91,7 @@ public class RegisterClientStuff {
ItemProperties.register(HexItems.SCROLL.get(), ItemScroll.ANCIENT_PREDICATE,
(stack, level, holder, holderID) -> stack.getOrCreateTag().contains(ItemScroll.TAG_OP_ID) ? 1f : 0f);
ItemProperties.register(HexItems.SLATE.get(), ItemSlate.WRITTEN_PRED,
ItemProperties.register(HexItems.Blocks.SLATE.get(), ItemSlate.WRITTEN_PRED,
(stack, level, holder, holderID) -> ItemSlate.hasPattern(stack) ? 1f : 0f);
HexTooltips.init();

View file

@ -6,9 +6,6 @@ import at.petrak.hexcasting.common.blocks.circles.BlockSlate;
import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockAbstractImpetus;
import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockEntityRightClickImpetus;
import at.petrak.hexcasting.common.blocks.circles.impetuses.BlockRightClickImpetus;
import at.petrak.hexcasting.common.items.HexItems;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.entity.BlockEntityType;
@ -24,8 +21,8 @@ public class HexBlocks {
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITIES = DeferredRegister.create(
ForgeRegistries.BLOCK_ENTITIES, HexMod.MOD_ID);
public static final RegistryObject<Block> CONJURED = registerBlock("conjured",
new BlockConjured(
public static final RegistryObject<Block> CONJURED = BLOCKS.register("conjured",
() -> new BlockConjured(
BlockBehaviour.Properties.of(Material.AMETHYST, MaterialColor.DIAMOND)
.sound(SoundType.AMETHYST)
.noDrops()
@ -38,19 +35,20 @@ public class HexBlocks {
() -> new BlockSlate(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DEEPSLATE)
.sound(SoundType.DEEPSLATE_TILES)
.strength(4f, 4f)));
public static final RegistryObject<Block> EMPTY_IMPETUS = registerBlock("empty_impetus",
new Block(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DEEPSLATE)
public static final RegistryObject<Block> EMPTY_IMPETUS = BLOCKS.register("empty_impetus",
() -> new Block(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DEEPSLATE)
.sound(SoundType.DEEPSLATE_TILES)
.strength(4f, 4f)));
public static final RegistryObject<BlockRightClickImpetus> IMPETUS_RIGHTCLICK = registerBlock("impetus_rightclick",
new BlockRightClickImpetus(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DEEPSLATE)
public static final RegistryObject<BlockRightClickImpetus> IMPETUS_RIGHTCLICK = BLOCKS.register(
"impetus_rightclick",
() -> new BlockRightClickImpetus(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DEEPSLATE)
.sound(SoundType.DEEPSLATE_TILES)
.strength(4f, 4f)
.lightLevel(bs -> bs.getValue(BlockAbstractImpetus.ENERGIZED) ? 15 : 0)));
// Decoration?!
public static final RegistryObject<Block> SLATE_BLOCK = registerBlock("slate_block",
new Block(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DEEPSLATE)
public static final RegistryObject<Block> SLATE_BLOCK = BLOCKS.register("slate_block",
() -> new Block(BlockBehaviour.Properties.of(Material.STONE, MaterialColor.DEEPSLATE)
.sound(SoundType.DEEPSLATE_TILES)
.strength(2f, 4f)));
@ -65,11 +63,6 @@ public class HexBlocks {
() -> BlockEntityType.Builder.of(BlockEntityRightClickImpetus::new, IMPETUS_RIGHTCLICK.get()).build(null));
private static <T extends Block> RegistryObject<T> registerBlock(String label, T block) {
HexItems.ITEMS.register(label, () -> new BlockItem(block, new Item.Properties().tab(HexItems.TAB)));
return BLOCKS.register(label, () -> block);
}
private static boolean never(Object... args) {
return false;
}

View file

@ -95,7 +95,14 @@ class CastException(val reason: Reason, vararg val data: Any) : Exception() {
*
* `BlockPos pos`
*/
REQUIRES_INVENTORY
REQUIRES_INVENTORY,
/**
* Extracting sentience didn't work
*
* for fucks sake i need to just implement mishaps already
*/
RECIPE_DIDNT_WORK
}
override val message: String
@ -112,5 +119,6 @@ class CastException(val reason: Reason, vararg val data: Any) : Exception() {
Reason.BAD_OFFHAND_ITEM_ITEM -> "operator expected ${(this.data[0] as Item).registryName} in offhand but got ${this.data[1]}"
Reason.BAD_OFFHAND_COUNT -> "operator expected ${this.data[0]} items in the offhand but got ${this.data[1]}"
Reason.REQUIRES_INVENTORY -> "required an inventory at ${this.data[0] as BlockPos}"
Reason.RECIPE_DIDNT_WORK -> "bad recipe"
}
}

View file

@ -1,8 +1,8 @@
package at.petrak.hexcasting.common.casting;
import at.petrak.hexcasting.HexMod;
import at.petrak.hexcasting.api.spell.Operator;
import at.petrak.hexcasting.api.PatternRegistry;
import at.petrak.hexcasting.api.spell.Operator;
import at.petrak.hexcasting.api.spell.SpellDatum;
import at.petrak.hexcasting.common.casting.operators.*;
import at.petrak.hexcasting.common.casting.operators.eval.OpEval;
@ -228,6 +228,9 @@ public class RegisterPatterns {
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wwweeewwweewdawdwad", HexDir.WEST),
prefix("summon_rain"),
new OpWeather(true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qeqwqwqwqwqeqaeqeaqeqaeqaqded", HexDir.NORTH_EAST),
prefix("brainsweep"),
OpBrainsweep.INSTANCE, true);
// == Meta stuff ==

View file

@ -0,0 +1,43 @@
package at.petrak.hexcasting.common.casting.misc;
import at.petrak.hexcasting.common.lib.HexCapabilities;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.npc.Villager;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class Brainsweeping {
public static final String CAP_NAME = "brainsweeping";
public static class Cap implements ICapabilitySerializable<CompoundTag> {
public boolean brainswept = false;
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
return HexCapabilities.BRAINSWEPT.orEmpty(cap, LazyOptional.of(() -> this));
}
public CompoundTag serializeNBT() {
var out = new CompoundTag();
out.putBoolean("brainswept", this.brainswept);
return out;
}
public void deserializeNBT(CompoundTag tag) {
this.brainswept = tag.getBoolean("brainswept");
}
}
@SubscribeEvent
public static void tradeWithVillager(PlayerInteractEvent.EntityInteract evt) {
if (evt.getTarget() instanceof Villager v) {
var maybeCap = v.getCapability(HexCapabilities.BRAINSWEPT).resolve();
if (maybeCap.isPresent() && maybeCap.get().brainswept) {
evt.setCanceled(true);
}
}
}
}

View file

@ -34,7 +34,7 @@ object OpWrite : SpellOperator {
handItem.writeDatum(tag, datum)
} else if (handItem == HexItems.SCROLL.get() && !tag.contains(ItemScroll.TAG_PATTERN) && datum.payload is HexPattern) {
tag.put(ItemScroll.TAG_PATTERN, datum.payload.serializeToNBT())
} else if (handItem == HexItems.SLATE.get() && datum.payload is HexPattern) {
} else if (handItem == HexItems.Blocks.SLATE.get() && datum.payload is HexPattern) {
val bet = tag.getCompound("BlockEntityTag")
bet.put(BlockEntitySlate.TAG_PATTERN, datum.payload.serializeToNBT())
// Just in case it's brand new

View file

@ -0,0 +1,67 @@
package at.petrak.hexcasting.common.casting.operators.spells.great
import at.petrak.hexcasting.api.spell.Operator.Companion.getChecked
import at.petrak.hexcasting.api.spell.ParticleSpray
import at.petrak.hexcasting.api.spell.RenderedSpell
import at.petrak.hexcasting.api.spell.SpellDatum
import at.petrak.hexcasting.api.spell.SpellOperator
import at.petrak.hexcasting.common.casting.CastException
import at.petrak.hexcasting.common.casting.CastingContext
import at.petrak.hexcasting.common.lib.HexCapabilities
import at.petrak.hexcasting.common.recipe.BrainsweepRecipe
import at.petrak.hexcasting.common.recipe.HexRecipeSerializers
import net.minecraft.core.BlockPos
import net.minecraft.sounds.SoundEvents
import net.minecraft.sounds.SoundSource
import net.minecraft.world.entity.npc.Villager
import net.minecraft.world.phys.Vec3
object OpBrainsweep : SpellOperator {
override val argc = 2
override fun execute(
args: List<SpellDatum<*>>,
ctx: CastingContext
): Triple<RenderedSpell, Int, List<ParticleSpray>> {
val pos = args.getChecked<Vec3>(0)
val sacrifice = args.getChecked<Villager>(1)
ctx.assertVecInRange(pos)
ctx.assertEntityInRange(sacrifice)
val maybeCap = sacrifice.getCapability(HexCapabilities.BRAINSWEPT)
maybeCap.ifPresent {
if (it.brainswept)
throw CastException(CastException.Reason.RECIPE_DIDNT_WORK)
}
val bpos = BlockPos(pos)
val state = ctx.world.getBlockState(bpos)
val recman = ctx.world.recipeManager
val recipes = recman.getAllRecipesFor(HexRecipeSerializers.BRAINSWEEP_TYPE)
val recipe = recipes.find { it.matches(state, sacrifice) }
?: throw CastException(CastException.Reason.RECIPE_DIDNT_WORK)
return Triple(
Spell(bpos, sacrifice, recipe),
1_000_000,
listOf(ParticleSpray.Cloud(sacrifice.position(), 1.0), ParticleSpray.Burst(Vec3.atCenterOf(bpos), 0.5, 50))
)
}
private data class Spell(val pos: BlockPos, val sacrifice: Villager, val recipe: BrainsweepRecipe) : RenderedSpell {
override fun cast(ctx: CastingContext) {
ctx.world.setBlockAndUpdate(pos, recipe.result)
val maybeCap = sacrifice.getCapability(HexCapabilities.BRAINSWEPT)
maybeCap.ifPresent {
it.brainswept = true
}
ctx.world.playSound(null, sacrifice, SoundEvents.VILLAGER_DEATH, SoundSource.AMBIENT, 0.8f, 1f)
ctx.world.playSound(null, sacrifice, SoundEvents.PLAYER_LEVELUP, SoundSource.AMBIENT, 0.5f, 0.8f)
}
}
}

View file

@ -5,6 +5,7 @@ import at.petrak.hexcasting.common.items.HexItems;
import at.petrak.hexcasting.common.items.ItemScroll;
import at.petrak.hexcasting.hexmath.HexPattern;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.datafixers.util.Pair;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.ResourceLocationArgument;
@ -19,14 +20,21 @@ public class ListPatsCommand {
dispatcher.register(Commands.literal("hexcasting:patterns")
.requires(dp -> dp.hasPermission(Commands.LEVEL_ADMINS))
.then(Commands.literal("list").executes(ctx -> {
var bob = new StringBuilder("Patterns in this world:");
var lookup = PatternRegistry.getPerWorldPatterns(ctx.getSource().getLevel());
lookup.forEach((sig, opId) -> {
var listing = lookup.keySet()
.stream()
.map(key -> new Pair<>(lookup.get(key).getFirst(), key))
.sorted((a, b) -> a.getFirst().compareNamespaced(b.getFirst()))
.toList();
var bob = new StringBuilder("Patterns in this world:");
for (var pair : listing) {
bob.append('\n');
bob.append(opId.toString());
bob.append(pair.getFirst());
bob.append(": ");
bob.append(sig);
});
bob.append(pair.getSecond());
}
ctx.getSource().sendSuccess(new TextComponent(bob.toString()), true);
return lookup.size();

View file

@ -10,10 +10,7 @@ import at.petrak.hexcasting.common.items.magic.ItemManaBattery;
import at.petrak.hexcasting.common.items.magic.ItemTrinket;
import net.minecraft.core.NonNullList;
import net.minecraft.world.food.FoodProperties;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.*;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
@ -98,13 +95,28 @@ public class HexItems {
public static final RegistryObject<ItemAbacus> ABACUS = ITEMS.register("abacus",
() -> new ItemAbacus(unstackable()));
public static final RegistryObject<ItemSlate> SLATE = ITEMS.register("slate",
() -> new ItemSlate(HexBlocks.SLATE.get(), props()));
// BUFF SANDVICH
public static final RegistryObject<Item> SUBMARINE_SANDWICH = ITEMS.register("sub_sandwich",
() -> new Item(props().food(new FoodProperties.Builder().nutrition(14).saturationMod(1.2f).build())));
static {
// Force it to reify all the statics inside
new Blocks();
}
public static class Blocks {
public static final RegistryObject<ItemSlate> SLATE = ITEMS.register("slate",
() -> new ItemSlate(HexBlocks.SLATE.get(), props()));
public static final RegistryObject<BlockItem> EMPTY_IMPETUS = ITEMS.register("empty_impetus",
() -> new BlockItem(HexBlocks.EMPTY_IMPETUS.get(), props()));
public static final RegistryObject<BlockItem> IMPETUS_RIGHTCLICK = ITEMS.register("impetus_rightclick",
() -> new BlockItem(HexBlocks.IMPETUS_RIGHTCLICK.get(), props()));
public static final RegistryObject<BlockItem> SLATE_BLOCK = ITEMS.register("slate_block",
() -> new BlockItem(HexBlocks.SLATE_BLOCK.get(), props()));
}
public static Item.Properties props() {
return new Item.Properties().tab(TAB);
}

View file

@ -3,6 +3,7 @@ package at.petrak.hexcasting.common.lib;
import at.petrak.hexcasting.HexMod;
import at.petrak.hexcasting.common.casting.colors.CapPreferredColorizer;
import at.petrak.hexcasting.common.casting.colors.FrozenColorizer;
import at.petrak.hexcasting.common.casting.misc.Brainsweeping;
import at.petrak.hexcasting.common.casting.operators.spells.great.OpFlight;
import at.petrak.hexcasting.common.casting.operators.spells.sentinel.CapSentinel;
import at.petrak.hexcasting.common.network.HexMessages;
@ -11,6 +12,7 @@ import at.petrak.hexcasting.common.network.MsgSentinelStatusUpdateAck;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.npc.Villager;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.common.capabilities.Capability;
@ -30,12 +32,16 @@ public class HexCapabilities {
public static final Capability<CapPreferredColorizer> PREFERRED_COLORIZER =
CapabilityManager.get(new CapabilityToken<>() {
});
public static final Capability<Brainsweeping.Cap> BRAINSWEPT = CapabilityManager.get(
new CapabilityToken<>() {
});
@SubscribeEvent
public static void registerCaps(RegisterCapabilitiesEvent evt) {
evt.register(OpFlight.CapFlight.class);
evt.register(CapSentinel.class);
evt.register(CapPreferredColorizer.class);
evt.register(Brainsweeping.Cap.class);
}
@SubscribeEvent
@ -48,6 +54,9 @@ public class HexCapabilities {
new CapSentinel(false, false, Vec3.ZERO));
evt.addCapability(new ResourceLocation(HexMod.MOD_ID, CapPreferredColorizer.CAP_NAME),
new CapPreferredColorizer(FrozenColorizer.DEFAULT));
} else if (evt.getObject() instanceof Villager) {
evt.addCapability(new ResourceLocation(HexMod.MOD_ID, Brainsweeping.CAP_NAME),
new Brainsweeping.Cap());
}
}

View file

@ -6,25 +6,31 @@ import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.stats.StatFormatter;
import net.minecraft.stats.Stats;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
public class HexStatistics {
public static final ResourceLocation MANA_USED = makeCustomStat(HexMod.MOD_ID + ":mana_used",
manamount -> StatFormatter.DEFAULT.format(manamount / HexConfig.dustManaAmount.get())
);
public static final ResourceLocation MANA_OVERCASTED = makeCustomStat(HexMod.MOD_ID + ":mana_overcasted",
manamount -> StatFormatter.DEFAULT.format(manamount / HexConfig.dustManaAmount.get())
);
public static final ResourceLocation PATTERNS_DRAWN = makeCustomStat(HexMod.MOD_ID + ":patterns_drawn",
StatFormatter.DEFAULT);
public static final ResourceLocation SPELLS_CAST = makeCustomStat(HexMod.MOD_ID + ":spells_cast",
StatFormatter.DEFAULT);
public static ResourceLocation MANA_USED;
public static ResourceLocation MANA_OVERCASTED;
public static ResourceLocation PATTERNS_DRAWN;
public static ResourceLocation SPELLS_CAST;
public static void register() {
// No-op! Just to un-lazy this class.
// We need to listen to *something* so we don't fire too early
@SubscribeEvent
public static void register(RegistryEvent.Register<Block> evt) {
MANA_USED = makeCustomStat("mana_used",
manamount -> StatFormatter.DEFAULT.format(manamount / HexConfig.dustManaAmount.get())
);
MANA_OVERCASTED = makeCustomStat("mana_overcasted",
manamount -> StatFormatter.DEFAULT.format(manamount / HexConfig.dustManaAmount.get())
);
PATTERNS_DRAWN = makeCustomStat("patterns_drawn", StatFormatter.DEFAULT);
SPELLS_CAST = makeCustomStat("spells_cast", StatFormatter.DEFAULT);
}
private static ResourceLocation makeCustomStat(String pKey, StatFormatter pFormatter) {
ResourceLocation resourcelocation = new ResourceLocation(pKey);
ResourceLocation resourcelocation = new ResourceLocation(HexMod.MOD_ID, pKey);
Registry.register(Registry.CUSTOM_STAT, pKey, resourcelocation);
Stats.CUSTOM.get(resourcelocation, pFormatter);
return resourcelocation;

View file

@ -1,6 +1,5 @@
package at.petrak.hexcasting.common.recipe;
import at.petrak.hexcasting.HexMod;
import at.petrak.hexcasting.common.recipe.ingredient.StateIngredient;
import at.petrak.hexcasting.common.recipe.ingredient.StateIngredientHelper;
import at.petrak.hexcasting.common.recipe.ingredient.VillagerIngredient;
@ -9,6 +8,7 @@ import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
import net.minecraft.world.Container;
import net.minecraft.world.entity.npc.Villager;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeSerializer;
@ -26,8 +26,11 @@ public record BrainsweepRecipe(
VillagerIngredient villagerIn,
BlockState result
) implements Recipe<Container> {
public static final RecipeType<BrainsweepRecipe> TYPE = RecipeType.register(HexMod.MOD_ID + ":brainsweep");
public static final Serializer SERIALIZER = new Serializer();
public boolean matches(BlockState blockIn, Villager villagerIn) {
return this.blockIn.test(blockIn) && this.villagerIn.test(villagerIn);
}
@Override
public ResourceLocation getId() {
@ -36,12 +39,12 @@ public record BrainsweepRecipe(
@Override
public RecipeType<?> getType() {
return TYPE;
return HexRecipeSerializers.BRAINSWEEP_TYPE;
}
@Override
public RecipeSerializer<?> getSerializer() {
return null;
return HexRecipeSerializers.BRAINSWEEP.get();
}
// in order to get this to be a "Recipe" we need to do a lot of bending-over-backwards
@ -66,7 +69,7 @@ public record BrainsweepRecipe(
return ItemStack.EMPTY;
}
private static class Serializer extends ForgeRegistryEntry<RecipeSerializer<?>> implements RecipeSerializer<BrainsweepRecipe> {
public static class Serializer extends ForgeRegistryEntry<RecipeSerializer<?>> implements RecipeSerializer<BrainsweepRecipe> {
@Override
public BrainsweepRecipe fromJson(ResourceLocation recipeID, JsonObject json) {
var blockIn = StateIngredientHelper.deserialize(GsonHelper.getAsJsonObject(json, "blockIn"));

View file

@ -0,0 +1,26 @@
package at.petrak.hexcasting.common.recipe;
import at.petrak.hexcasting.HexMod;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
public class HexRecipeSerializers {
public static final DeferredRegister<RecipeSerializer<?>> SERIALIZERS = DeferredRegister.create(
ForgeRegistries.RECIPE_SERIALIZERS, HexMod.MOD_ID);
public static final RegistryObject<RecipeSerializer<?>> BRAINSWEEP = SERIALIZERS.register("brainsweep",
BrainsweepRecipe.Serializer::new);
public static RecipeType<BrainsweepRecipe> BRAINSWEEP_TYPE;
// Like in the statistics, gotta register it at some point
@SubscribeEvent
public static void registerTypes(RegistryEvent.Register<Item> evt) {
BRAINSWEEP_TYPE = RecipeType.register(HexMod.MOD_ID + ":brainsweep");
}
}

View file

@ -158,7 +158,9 @@ public class StateIngredientHelper {
private static void renameTag(CompoundTag tag, String from, String to) {
var t = tag.get(from);
tag.remove(from);
tag.put(to, t);
if (t != null) {
tag.remove(from);
tag.put(to, t);
}
}
}

View file

@ -21,6 +21,10 @@ public class HexBlockStatesAndModels extends BlockStateProvider {
simpleBlock(HexBlocks.SLATE_BLOCK.get(), slateBlock);
simpleBlockItem(HexBlocks.SLATE_BLOCK.get(), slateBlock);
var emptyImpetus = models().cubeAll("empty_impetus", modLoc("block/impetus/empty"));
simpleBlock(HexBlocks.EMPTY_IMPETUS.get(), emptyImpetus);
simpleBlockItem(HexBlocks.EMPTY_IMPETUS.get(), emptyImpetus);
getVariantBuilder(HexBlocks.IMPETUS_RIGHTCLICK.get()).forAllStates(bs -> {
var isLit = bs.getValue(BlockAbstractImpetus.ENERGIZED);
var litness = isLit ? "lit" : "dim";

View file

@ -117,7 +117,7 @@ public class HexItemModels extends ItemModelProvider {
simpleItem(modLoc("slate_blank"));
simpleItem(modLoc("slate_written"));
getBuilder(HexItems.SLATE.getId().getPath()).override()
getBuilder(HexItems.Blocks.SLATE.getId().getPath()).override()
.predicate(ItemSlate.WRITTEN_PRED, 0)
.model(new ModelFile.UncheckedModelFile(modLoc("item/slate_blank")))
.end()

View file

@ -173,7 +173,7 @@ public class HexRecipes extends RecipeProvider {
.pattern(" B ")
.unlockedBy("has_item", has(HexItems.AMETHYST_DUST.get())).save(recipes);
ShapedRecipeBuilder.shaped(HexItems.SLATE.get(), 6)
ShapedRecipeBuilder.shaped(HexItems.Blocks.SLATE.get(), 6)
.define('S', Items.DEEPSLATE)
.define('A', HexItems.AMETHYST_DUST.get())
.pattern(" A ")
@ -181,10 +181,11 @@ public class HexRecipes extends RecipeProvider {
.unlockedBy("has_item", has(HexItems.AMETHYST_DUST.get())).save(recipes);
ShapedRecipeBuilder.shaped(HexBlocks.SLATE_BLOCK.get())
.define('S', HexItems.SLATE.get())
.define('S', HexItems.Blocks.SLATE.get())
.pattern("S")
.pattern("S")
.unlockedBy("has_item", has(HexItems.SLATE.get())).save(recipes, "slate_block_from_slates");
.unlockedBy("has_item", has(HexItems.Blocks.SLATE.get()))
.save(recipes, "slate_block_from_slates");
ShapedRecipeBuilder.shaped(HexBlocks.SLATE_BLOCK.get(), 8)
.define('S', Blocks.DEEPSLATE)
@ -192,18 +193,24 @@ public class HexRecipes extends RecipeProvider {
.pattern("SSS")
.pattern("SAS")
.pattern("SSS")
.unlockedBy("has_item", has(HexItems.SLATE.get())).save(recipes);
.unlockedBy("has_item", has(HexItems.Blocks.SLATE.get())).save(recipes);
var enlightenment = new OvercastTrigger.Instance(EntityPredicate.Composite.ANY,
MinMaxBounds.Ints.ANY,
// add a little bit of slop here
MinMaxBounds.Doubles.atLeast(17.95),
MinMaxBounds.Doubles.between(0.1, 2.05));
new BrainsweepRecipeBuilder(StateIngredientHelper.of(HexBlocks.EMPTY_IMPETUS.get()),
new VillagerIngredient(new ResourceLocation("toolsmith"), null, 1),
HexBlocks.IMPETUS_RIGHTCLICK.get().defaultBlockState())
.unlockedBy("enlightenment",
new OvercastTrigger.Instance(EntityPredicate.Composite.ANY,
MinMaxBounds.Ints.ANY,
// add a little bit of slop here
MinMaxBounds.Doubles.atLeast(17.95),
MinMaxBounds.Doubles.between(0.1, 2.05)))
.unlockedBy("enlightenment", enlightenment)
.save(recipes);
new BrainsweepRecipeBuilder(StateIngredientHelper.of(Blocks.AMETHYST_BLOCK),
new VillagerIngredient(null, null, 5),
Blocks.BUDDING_AMETHYST.defaultBlockState())
.unlockedBy("enlightenment", enlightenment)
.save(recipes);
}

View file

@ -18,7 +18,7 @@ import net.minecraftforge.registries.RegistryObject;
public class HexLootModifiers extends GlobalLootModifierProvider {
public static final DeferredRegister<GlobalLootModifierSerializer<?>> LOOT_MODS = DeferredRegister.create(
ForgeRegistries.LOOT_MODIFIER_SERIALIZERS.get(), HexMod.MOD_ID);
ForgeRegistries.Keys.LOOT_MODIFIER_SERIALIZERS, HexMod.MOD_ID);
private static final RegistryObject<AmethystClusterModifier.Serializer> AMETHYST_CLUSTER = LOOT_MODS.register(
"amethyst_cluster", AmethystClusterModifier.Serializer::new);
private static final RegistryObject<PatternScrollModifier.Serializer> SCROLLS_IN_CHESTS = LOOT_MODS.register(

View file

@ -1,6 +1,6 @@
package at.petrak.hexcasting.datagen.recipebuilders;
import at.petrak.hexcasting.common.recipe.BrainsweepRecipe;
import at.petrak.hexcasting.common.recipe.HexRecipeSerializers;
import at.petrak.hexcasting.common.recipe.ingredient.StateIngredient;
import at.petrak.hexcasting.common.recipe.ingredient.StateIngredientHelper;
import at.petrak.hexcasting.common.recipe.ingredient.VillagerIngredient;
@ -14,7 +14,6 @@ import net.minecraft.data.recipes.FinishedRecipe;
import net.minecraft.data.recipes.RecipeBuilder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;
@ -22,8 +21,8 @@ import org.jetbrains.annotations.Nullable;
import java.util.function.Consumer;
public class BrainsweepRecipeBuilder implements RecipeBuilder {
private StateIngredient blockIn = null;
private VillagerIngredient villagerIn = null;
private StateIngredient blockIn;
private VillagerIngredient villagerIn;
private final BlockState result;
private final Advancement.Builder advancement;
@ -48,7 +47,7 @@ public class BrainsweepRecipeBuilder implements RecipeBuilder {
@Override
public Item getResult() {
return Items.AIR;
return this.result.getBlock().asItem();
}
@Override
@ -71,7 +70,6 @@ public class BrainsweepRecipeBuilder implements RecipeBuilder {
public record Result(ResourceLocation id, StateIngredient blockIn, VillagerIngredient villagerIn,
BlockState result, Advancement.Builder advancement,
ResourceLocation advancementId) implements FinishedRecipe {
@Override
public void serializeRecipeData(JsonObject json) {
json.add("blockIn", this.blockIn.serialize());
@ -86,7 +84,7 @@ public class BrainsweepRecipeBuilder implements RecipeBuilder {
@Override
public RecipeSerializer<?> getType() {
return BrainsweepRecipe.SERIALIZER;
return HexRecipeSerializers.BRAINSWEEP.get();
}
@Nullable

View file

@ -186,6 +186,7 @@
"hexcasting.spell.hexcasting:dispel_rain": "Dispel Rain",
"hexcasting.spell.hexcasting:create_lava": "Create Lava",
"hexcasting.spell.hexcasting:teleport": "Greater Teleport",
"hexcasting.spell.hexcasting:brainsweep": "Flay Mind",
"hexcasting.spell.hexcasting:sentinel/create/great": "Summon Greater Sentinel",
"hexcasting.spell.hexcasting:open_paren": "Introspection",
"hexcasting.spell.hexcasting:close_paren": "Retrospection",