client? sort of?

This commit is contained in:
gamma-delta 2022-05-06 00:18:01 -05:00
parent bcf5a3fe3b
commit 67a2bc24a3
14 changed files with 457 additions and 318 deletions

View file

@ -3,7 +3,7 @@ package at.petrak.hexcasting.client;
import at.petrak.hexcasting.api.client.ScryingLensOverlayRegistry;
import at.petrak.hexcasting.api.player.Sentinel;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.api.player.HexPlayerDataHelper;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack;
@ -21,29 +21,22 @@ import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderLevelLastEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import java.util.function.BiConsumer;
public class HexAdditionalRenderers {
@SubscribeEvent
public static void overlayLevel(RenderLevelLastEvent evt) {
public static void overlayLevel(PoseStack ps, float partialTick) {
var player = Minecraft.getInstance().player;
if (player != null) {
var sentinel = HexPlayerDataHelper.getSentinel(player);
var sentinel = IXplatAbstractions.INSTANCE.getSentinel(player);
if (sentinel.hasSentinel() && player.getLevel().dimension().equals(sentinel.dimension())) {
renderSentinel(sentinel, player, evt.getPoseStack(), evt.getPartialTick());
renderSentinel(sentinel, player, ps, partialTick);
}
}
}
@SubscribeEvent
public static void overlayGui(RenderGameOverlayEvent.Post evt) {
if (evt.getType() == RenderGameOverlayEvent.ElementType.ALL) {
tryRenderScryingLensOverlay(evt.getMatrixStack(), evt.getPartialTicks());
}
public static void overlayGui(PoseStack ps, float partialTicks) {
tryRenderScryingLensOverlay(ps, partialTicks);
}
private static void renderSentinel(Sentinel sentinel, LocalPlayer owner,
@ -82,7 +75,7 @@ public class HexAdditionalRenderers {
RenderSystem.disableCull();
RenderSystem.lineWidth(5f);
var colorizer = HexPlayerDataHelper.getColorizer(owner);
var colorizer = IXplatAbstractions.INSTANCE.getColorizer(owner);
BiConsumer<float[], float[]> v = (l, r) -> {
int lcolor = colorizer.getColor(time, new Vec3(l[0], l[1], l[2])),
rcolor = colorizer.getColor(time, new Vec3(r[0], r[1], r[2]));
@ -154,13 +147,13 @@ public class HexAdditionalRenderers {
boolean foundLens = false;
InteractionHand lensHand = null;
for (var hand : InteractionHand.values()) {
if (mc.player.getItemInHand(hand).is(HexItems.SCRYING_LENS.get())) {
if (mc.player.getItemInHand(hand).is(HexItems.SCRYING_LENS)) {
lensHand = hand;
foundLens = true;
break;
}
}
if (!foundLens && mc.player.getItemBySlot(EquipmentSlot.HEAD).is(HexItems.SCRYING_LENS.get())) {
if (!foundLens && mc.player.getItemBySlot(EquipmentSlot.HEAD).is(HexItems.SCRYING_LENS)) {
foundLens = true;
}
@ -173,6 +166,8 @@ public class HexAdditionalRenderers {
var pos = bhr.getBlockPos();
var bs = mc.level.getBlockState(pos);
var lineSpace = 9.0 * (mc.options.chatLineSpacing + 1.0);
var lines = ScryingLensOverlayRegistry.getLines(bs, pos, mc.player, mc.level, bhr.getDirection(), lensHand);
if (!lines.isEmpty()) {
var window = mc.getWindow();
@ -198,13 +193,13 @@ public class HexAdditionalRenderers {
for (var line : textLines) {
var actualLine = Language.getInstance().getVisualOrder(line);
mc.font.drawShadow(ps, actualLine, tx, ty, 0xffffffff);
ps.translate(0, 9, 0);
ps.translate(0, lineSpace, 0);
}
if (textLines.isEmpty()) {
ps.translate(0, 9, 0);
ps.translate(0, lineSpace, 0);
}
ps.translate(0, 6, 0);
ps.translate(0, lineSpace * 0.66666, 0);
}
ps.popPose();

View file

@ -12,23 +12,23 @@ import at.petrak.hexcasting.client.be.BlockEntityAkashicBookshelfRenderer;
import at.petrak.hexcasting.client.be.BlockEntitySlateRenderer;
import at.petrak.hexcasting.client.entity.WallScrollRenderer;
import at.petrak.hexcasting.client.particles.ConjureParticle;
import at.petrak.hexcasting.common.lib.HexBlockEntities;
import at.petrak.hexcasting.common.lib.HexBlocks;
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicBookshelf;
import at.petrak.hexcasting.common.blocks.akashic.BlockEntityAkashicRecord;
import at.petrak.hexcasting.common.entities.HexEntities;
import at.petrak.hexcasting.common.items.*;
import at.petrak.hexcasting.common.items.ItemFocus;
import at.petrak.hexcasting.common.items.ItemScroll;
import at.petrak.hexcasting.common.items.ItemSlate;
import at.petrak.hexcasting.common.items.ItemWand;
import at.petrak.hexcasting.common.items.magic.ItemManaBattery;
import at.petrak.hexcasting.common.items.magic.ItemPackagedHex;
import at.petrak.hexcasting.common.lib.HexBlockEntities;
import at.petrak.hexcasting.common.lib.HexBlocks;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.lib.HexParticles;
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
import com.mojang.datafixers.util.Pair;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
@ -41,67 +41,61 @@ import net.minecraft.world.level.block.RedStoneWireBlock;
import net.minecraft.world.level.block.RepeaterBlock;
import net.minecraft.world.level.block.state.properties.ComparatorMode;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import java.util.Locale;
public class RegisterClientStuff {
public static void init() {
registerDataHolderOverrides(HexItems.FOCUS);
registerDataHolderOverrides(HexItems.SPELLBOOK);
@SubscribeEvent
public static void init(FMLClientSetupEvent evt) {
evt.enqueueWork(() -> {
registerDataHolderOverrides(HexItems.FOCUS.get());
registerDataHolderOverrides(HexItems.SPELLBOOK.get());
registerPackagedSpellOverrides(HexItems.CYPHER);
registerPackagedSpellOverrides(HexItems.TRINKET);
registerPackagedSpellOverrides(HexItems.ARTIFACT);
registerPackagedSpellOverrides(HexItems.CYPHER.get());
registerPackagedSpellOverrides(HexItems.TRINKET.get());
registerPackagedSpellOverrides(HexItems.ARTIFACT.get());
IClientXplatAbstractions x = IClientXplatAbstractions.INSTANCE;
x.registerItemProperty(HexItems.BATTERY, ItemManaBattery.MANA_PREDICATE,
(stack, level, holder, holderID) -> {
var item = (ManaHolderItem) stack.getItem();
return item.getManaFullness(stack);
});
x.registerItemProperty(HexItems.BATTERY, ItemManaBattery.MAX_MANA_PREDICATE,
(stack, level, holder, holderID) -> {
var item = (ItemManaBattery) stack.getItem();
var max = item.getMaxMana(stack);
return (float) Math.sqrt((float) max / HexConfig.common().chargedCrystalManaAmount() / 10);
});
ItemProperties.register(HexItems.BATTERY.get(), ItemManaBattery.MANA_PREDICATE,
(stack, level, holder, holderID) -> {
var item = (ManaHolderItem) stack.getItem();
return item.getManaFullness(stack);
});
ItemProperties.register(HexItems.BATTERY.get(), ItemManaBattery.MAX_MANA_PREDICATE,
(stack, level, holder, holderID) -> {
var item = (ItemManaBattery) stack.getItem();
var max = item.getMaxMana(stack);
return (float) Math.sqrt((float) max / HexConfig.chargedCrystalManaAmount.get() / 10);
});
x.registerItemProperty(HexItems.SCROLL, ItemScroll.ANCIENT_PREDICATE,
(stack, level, holder, holderID) -> stack.getOrCreateTag().contains(ItemScroll.TAG_OP_ID) ? 1f : 0f);
ItemProperties.register(HexItems.SCROLL.get(), ItemScroll.ANCIENT_PREDICATE,
(stack, level, holder, holderID) -> stack.getOrCreateTag().contains(ItemScroll.TAG_OP_ID) ? 1f : 0f);
x.registerItemProperty(HexItems.SLATE, ItemSlate.WRITTEN_PRED,
(stack, level, holder, holderID) -> ItemSlate.hasPattern(stack) ? 1f : 0f);
ItemProperties.register(HexItems.SLATE.get(), ItemSlate.WRITTEN_PRED,
(stack, level, holder, holderID) -> ItemSlate.hasPattern(stack) ? 1f : 0f);
registerWandOverrides(HexItems.WAND_OAK);
registerWandOverrides(HexItems.WAND_BIRCH);
registerWandOverrides(HexItems.WAND_SPRUCE);
registerWandOverrides(HexItems.WAND_JUNGLE);
registerWandOverrides(HexItems.WAND_DARK_OAK);
registerWandOverrides(HexItems.WAND_ACACIA);
registerWandOverrides(HexItems.WAND_AKASHIC);
registerWandOverrides(HexItems.WAND_OAK.get());
registerWandOverrides(HexItems.WAND_BIRCH.get());
registerWandOverrides(HexItems.WAND_SPRUCE.get());
registerWandOverrides(HexItems.WAND_JUNGLE.get());
registerWandOverrides(HexItems.WAND_DARK_OAK.get());
registerWandOverrides(HexItems.WAND_ACACIA.get());
registerWandOverrides(HexItems.WAND_AKASHIC.get());
HexTooltips.init();
HexTooltips.init();
});
x.setRenderLayer(HexBlocks.CONJURED_LIGHT, RenderType.cutout());
x.setRenderLayer(HexBlocks.CONJURED_BLOCK, RenderType.cutout());
x.setRenderLayer(HexBlocks.AKASHIC_DOOR, RenderType.cutout());
x.setRenderLayer(HexBlocks.AKASHIC_TRAPDOOR, RenderType.cutout());
x.setRenderLayer(HexBlocks.SCONCE, RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(HexBlocks.CONJURED_LIGHT.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(HexBlocks.CONJURED_BLOCK.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(HexBlocks.AKASHIC_DOOR.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(HexBlocks.AKASHIC_TRAPDOOR.get(), RenderType.cutout());
ItemBlockRenderTypes.setRenderLayer(HexBlocks.SCONCE.get(), RenderType.cutout());
x.setRenderLayer(HexBlocks.AKASHIC_LEAVES1, RenderType.cutoutMipped());
x.setRenderLayer(HexBlocks.AKASHIC_LEAVES2, RenderType.cutoutMipped());
x.setRenderLayer(HexBlocks.AKASHIC_LEAVES3, RenderType.cutoutMipped());
ItemBlockRenderTypes.setRenderLayer(HexBlocks.AKASHIC_LEAVES1.get(), RenderType.cutoutMipped());
ItemBlockRenderTypes.setRenderLayer(HexBlocks.AKASHIC_LEAVES2.get(), RenderType.cutoutMipped());
ItemBlockRenderTypes.setRenderLayer(HexBlocks.AKASHIC_LEAVES3.get(), RenderType.cutoutMipped());
x.setRenderLayer(HexBlocks.AKASHIC_RECORD, RenderType.translucent());
ItemBlockRenderTypes.setRenderLayer(HexBlocks.AKASHIC_RECORD.get(), RenderType.translucent());
EntityRenderers.register(HexEntities.WALL_SCROLL.get(), WallScrollRenderer::new);
x.registerEntityRenderer(HexEntities.WALL_SCROLL, WallScrollRenderer::new);
addScryingLensStuff();
}
@ -115,13 +109,13 @@ public class RegisterClientStuff {
}
});
ScryingLensOverlayRegistry.addDisplayer(HexBlocks.AKASHIC_BOOKSHELF.get(),
ScryingLensOverlayRegistry.addDisplayer(HexBlocks.AKASHIC_BOOKSHELF,
(lines, state, pos, observer, world, direction, lensHand) -> {
if (world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile) {
var recordPos = tile.getRecordPos();
var pattern = tile.getPattern();
if (recordPos != null && pattern != null) {
lines.add(new Pair<>(new ItemStack(HexBlocks.AKASHIC_RECORD.get()), new TranslatableComponent(
lines.add(new Pair<>(new ItemStack(HexBlocks.AKASHIC_RECORD), new TranslatableComponent(
"hexcasting.tooltip.lens.akashic.bookshelf.location",
recordPos.toShortString()
)));
@ -132,12 +126,12 @@ public class RegisterClientStuff {
}
});
ScryingLensOverlayRegistry.addDisplayer(HexBlocks.AKASHIC_RECORD.get(),
ScryingLensOverlayRegistry.addDisplayer(HexBlocks.AKASHIC_RECORD,
(lines, state, pos, observer, world, direction, lensHand) -> {
if (world.getBlockEntity(pos) instanceof BlockEntityAkashicRecord tile) {
int count = tile.getCount();
lines.add(new Pair<>(new ItemStack(HexBlocks.AKASHIC_BOOKSHELF.get()), new TranslatableComponent(
lines.add(new Pair<>(new ItemStack(HexBlocks.AKASHIC_BOOKSHELF), new TranslatableComponent(
"hexcasting.tooltip.lens.akashic.record.count" + (count == 1 ? ".single" : ""),
count
)));
@ -196,7 +190,7 @@ public class RegisterClientStuff {
}
private static void registerDataHolderOverrides(DataHolderItem item) {
ItemProperties.register((Item) item, ItemFocus.DATATYPE_PRED,
IClientXplatAbstractions.INSTANCE.registerItemProperty((Item) item, ItemFocus.DATATYPE_PRED,
(stack, level, holder, holderID) -> {
var datum = item.readDatumTag(stack);
if (datum != null) {
@ -213,19 +207,19 @@ public class RegisterClientStuff {
}
return 0f;
});
ItemProperties.register((Item) item, ItemFocus.SEALED_PRED,
IClientXplatAbstractions.INSTANCE.registerItemProperty((Item) item, ItemFocus.SEALED_PRED,
(stack, level, holder, holderID) -> item.canWrite(stack, SpellDatum.make(Widget.NULL)) ? 0f : 1f);
}
private static void registerPackagedSpellOverrides(ItemPackagedHex item) {
ItemProperties.register(item, ItemPackagedHex.HAS_PATTERNS_PRED,
IClientXplatAbstractions.INSTANCE.registerItemProperty(item, ItemPackagedHex.HAS_PATTERNS_PRED,
(stack, level, holder, holderID) ->
item.getPatterns(stack) != null ? 1f : 0f
);
}
private static void registerWandOverrides(ItemWand item) {
ItemProperties.register(item, ItemWand.FUNNY_LEVEL_PREDICATE,
IClientXplatAbstractions.INSTANCE.registerItemProperty(item, ItemWand.FUNNY_LEVEL_PREDICATE,
(stack, level, holder, holderID) -> {
var name = stack.getHoverName().getString().toLowerCase(Locale.ROOT);
if (name.contains("old")) {
@ -238,12 +232,12 @@ public class RegisterClientStuff {
});
}
@SubscribeEvent(priority = EventPriority.LOWEST)
public static void registerParticles(ParticleFactoryRegisterEvent event) {
// does whatever a particle can
var particleMan = Minecraft.getInstance().particleEngine;
particleMan.register(HexParticles.LIGHT_PARTICLE.get(), ConjureParticle.Provider::new);
particleMan.register(HexParticles.CONJURE_PARTICLE.get(), ConjureParticle.Provider::new);
public static void registerParticles() {
// rip particle man
IClientXplatAbstractions.INSTANCE.registerParticleType(HexParticles.LIGHT_PARTICLE.get(),
ConjureParticle.Provider::new);
IClientXplatAbstractions.INSTANCE.registerParticleType(HexParticles.CONJURE_PARTICLE.get(),
ConjureParticle.Provider::new);
}
@SubscribeEvent

View file

@ -4,6 +4,9 @@ import at.petrak.hexcasting.api.PatternRegistry;
import at.petrak.hexcasting.api.spell.Operator;
import at.petrak.hexcasting.api.spell.SpellDatum;
import at.petrak.hexcasting.api.spell.Widget;
import at.petrak.hexcasting.api.spell.math.HexAngle;
import at.petrak.hexcasting.api.spell.math.HexDir;
import at.petrak.hexcasting.api.spell.math.HexPattern;
import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.casting.operators.*;
import at.petrak.hexcasting.common.casting.operators.akashic.OpAkashicRead;
@ -29,395 +32,389 @@ import at.petrak.hexcasting.common.casting.operators.spells.sentinel.OpGetSentin
import at.petrak.hexcasting.common.casting.operators.spells.sentinel.OpGetSentinelWayfind;
import at.petrak.hexcasting.common.casting.operators.stack.*;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.api.spell.math.HexAngle;
import at.petrak.hexcasting.api.spell.math.HexDir;
import at.petrak.hexcasting.api.spell.math.HexPattern;
import it.unimi.dsi.fastutil.booleans.BooleanArrayList;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import static at.petrak.hexcasting.common.lib.RegisterHelper.prefix;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
public class RegisterPatterns {
// I guess this means the client will have a big empty map for patterns
@SubscribeEvent
public static void registerSpellPatterns(FMLCommonSetupEvent evt) {
public static void registerPatterns() {
try {
// In general:
// - CCW is the normal or construction version
// - CW is the special or destruction version
// == Getters ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaq", HexDir.NORTH_EAST), prefix("get_caster"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaq", HexDir.NORTH_EAST), modLoc("get_caster"),
OpGetCaster.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aa", HexDir.EAST), prefix("get_entity_pos"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aa", HexDir.EAST), modLoc("get_entity_pos"),
OpEntityPos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wa", HexDir.EAST), prefix("get_entity_look"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wa", HexDir.EAST), modLoc("get_entity_look"),
OpEntityLook.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awq", HexDir.NORTH_EAST), prefix("get_entity_height"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awq", HexDir.NORTH_EAST), modLoc("get_entity_height"),
OpEntityHeight.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wq", HexDir.EAST), prefix("get_entity_velocity"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wq", HexDir.EAST), modLoc("get_entity_velocity"),
OpEntityVelocity.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaawdd", HexDir.EAST), prefix("raycast"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaawdd", HexDir.EAST), modLoc("raycast"),
OpBlockRaycast.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("weddwaa", HexDir.EAST), prefix("raycast/axis"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("weddwaa", HexDir.EAST), modLoc("raycast/axis"),
OpBlockAxisRaycast.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("weaqa", HexDir.EAST), prefix("raycast/entity"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("weaqa", HexDir.EAST), modLoc("raycast/entity"),
OpEntityRaycast.INSTANCE);
// == spell circle getters ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eaqwqae", HexDir.SOUTH_WEST),
prefix("circle/impetus_pos"), OpImpetusPos.INSTANCE);
modLoc("circle/impetus_pos"), OpImpetusPos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eaqwqaewede", HexDir.SOUTH_WEST),
prefix("circle/impetus_dir"), OpImpetusDir.INSTANCE);
modLoc("circle/impetus_dir"), OpImpetusDir.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eaqwqaewdd", HexDir.SOUTH_WEST),
prefix("circle/bounds/min"), new OpCircleBounds(false));
modLoc("circle/bounds/min"), new OpCircleBounds(false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqwqawaaqa", HexDir.WEST),
prefix("circle/bounds/max"), new OpCircleBounds(true));
modLoc("circle/bounds/max"), new OpCircleBounds(true));
// == Modify Stack ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("d", HexDir.EAST), prefix("const/null"), Widget.NULL);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aadaa", HexDir.EAST), prefix("duplicate"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("d", HexDir.EAST), modLoc("const/null"), Widget.NULL);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aadaa", HexDir.EAST), modLoc("duplicate"),
OpDuplicate.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aadaadaa", HexDir.EAST), prefix("duplicate_n"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aadaadaa", HexDir.EAST), modLoc("duplicate_n"),
OpDuplicateN.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aawdd", HexDir.EAST), prefix("swap"), OpSwap.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddad", HexDir.WEST), prefix("fisherman"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aawdd", HexDir.EAST), modLoc("swap"), OpSwap.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddad", HexDir.WEST), modLoc("fisherman"),
OpFisherman.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaawdde", HexDir.SOUTH_EAST), prefix("swizzle"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaawdde", HexDir.SOUTH_EAST), modLoc("swizzle"),
OpAlwinfyHasAscendedToABeingOfPureMath.INSTANCE);
// == Math ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waaw", HexDir.NORTH_EAST), prefix("add"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waaw", HexDir.NORTH_EAST), modLoc("add"),
OpAdd.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wddw", HexDir.NORTH_WEST), prefix("sub"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wddw", HexDir.NORTH_WEST), modLoc("sub"),
OpSub.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waqaw", HexDir.SOUTH_EAST), prefix("mul_dot"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waqaw", HexDir.SOUTH_EAST), modLoc("mul_dot"),
OpMulDot.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wdedw", HexDir.NORTH_EAST), prefix("div_cross"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wdedw", HexDir.NORTH_EAST), modLoc("div_cross"),
OpDivCross.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaqw", HexDir.NORTH_EAST), prefix("abs_len"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaqw", HexDir.NORTH_EAST), modLoc("abs_len"),
OpAbsLen.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wedew", HexDir.NORTH_WEST), prefix("pow_proj"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wedew", HexDir.NORTH_WEST), modLoc("pow_proj"),
OpPowProj.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eqqqqq", HexDir.EAST), prefix("construct_vec"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eqqqqq", HexDir.EAST), modLoc("construct_vec"),
OpConstructVec.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qeeeee", HexDir.EAST), prefix("deconstruct_vec"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qeeeee", HexDir.EAST), modLoc("deconstruct_vec"),
OpDeconstructVec.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqaww", HexDir.NORTH_WEST), prefix("coerce_axial"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqaww", HexDir.NORTH_WEST), modLoc("coerce_axial"),
OpCoerceToAxial.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wdw", HexDir.NORTH_EAST), prefix("and"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wdw", HexDir.NORTH_EAST), modLoc("and"),
OpAnd.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waw", HexDir.SOUTH_EAST), prefix("or"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waw", HexDir.SOUTH_EAST), modLoc("or"),
OpOr.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dwa", HexDir.NORTH_WEST), prefix("xor"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dwa", HexDir.NORTH_WEST), modLoc("xor"),
OpXor.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("e", HexDir.SOUTH_EAST), prefix("greater"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("e", HexDir.SOUTH_EAST), modLoc("greater"),
new OpCompare((a, b) -> a > b));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("q", HexDir.SOUTH_WEST), prefix("less"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("q", HexDir.SOUTH_WEST), modLoc("less"),
new OpCompare((a, b) -> a < b));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ee", HexDir.SOUTH_EAST), prefix("greater_eq"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ee", HexDir.SOUTH_EAST), modLoc("greater_eq"),
new OpCompare((a, b) -> a >= b));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qq", HexDir.SOUTH_WEST), prefix("less_eq"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qq", HexDir.SOUTH_WEST), modLoc("less_eq"),
new OpCompare((a, b) -> a <= b));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ad", HexDir.EAST), prefix("equals"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ad", HexDir.EAST), modLoc("equals"),
new OpEquality(false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("da", HexDir.EAST), prefix("not_equals"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("da", HexDir.EAST), modLoc("not_equals"),
new OpEquality(true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dw", HexDir.NORTH_WEST), prefix("not"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dw", HexDir.NORTH_WEST), modLoc("not"),
OpNot.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aw", HexDir.NORTH_EAST), prefix("identity"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aw", HexDir.NORTH_EAST), modLoc("identity"),
OpIdentityKindOf.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ewq", HexDir.EAST), prefix("floor"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ewq", HexDir.EAST), modLoc("floor"),
OpFloor.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qwe", HexDir.EAST), prefix("ceil"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qwe", HexDir.EAST), modLoc("ceil"),
OpCeil.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eqaqe", HexDir.NORTH_WEST), prefix("logarithm"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eqaqe", HexDir.NORTH_WEST), modLoc("logarithm"),
OpLog.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqaa", HexDir.SOUTH_EAST), prefix("sin"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqaa", HexDir.SOUTH_EAST), modLoc("sin"),
OpSin.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqad", HexDir.SOUTH_EAST), prefix("cos"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqad", HexDir.SOUTH_EAST), modLoc("cos"),
OpCos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqqqqqadq", HexDir.SOUTH_WEST), prefix("tan"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqqqqqadq", HexDir.SOUTH_WEST), modLoc("tan"),
OpTan.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddeeeee", HexDir.SOUTH_EAST), prefix("arcsin"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddeeeee", HexDir.SOUTH_EAST), modLoc("arcsin"),
OpArcSin.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("adeeeee", HexDir.NORTH_EAST), prefix("arccos"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("adeeeee", HexDir.NORTH_EAST), modLoc("arccos"),
OpArcCos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eadeeeeew", HexDir.NORTH_EAST), prefix("arctan"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eadeeeeew", HexDir.NORTH_EAST), modLoc("arctan"),
OpArcTan.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eqqq", HexDir.NORTH_WEST), prefix("random"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eqqq", HexDir.NORTH_WEST), modLoc("random"),
OpRandom.INSTANCE);
// == Spells ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("de", HexDir.NORTH_EAST), prefix("print"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("de", HexDir.NORTH_EAST), modLoc("print"),
OpPrint.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aawaawaa", HexDir.EAST), prefix("explode"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aawaawaa", HexDir.EAST), modLoc("explode"),
new OpExplode(false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddwddwdd", HexDir.EAST), prefix("explode/fire"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddwddwdd", HexDir.EAST), modLoc("explode/fire"),
new OpExplode(true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awqqqwaqw", HexDir.SOUTH_WEST), prefix("add_motion"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awqqqwaqw", HexDir.SOUTH_WEST), modLoc("add_motion"),
OpAddMotion.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awqqqwaq", HexDir.SOUTH_WEST), prefix("blink"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awqqqwaq", HexDir.SOUTH_WEST), modLoc("blink"),
OpBlink.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaqqqqq", HexDir.EAST), prefix("break_block"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaqqqqq", HexDir.EAST), modLoc("break_block"),
OpBreakBlock.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeede", HexDir.SOUTH_WEST), prefix("place_block"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeede", HexDir.SOUTH_WEST), modLoc("place_block"),
OpPlaceBlock.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("awddwqawqwawq", HexDir.EAST),
prefix("colorize"),
modLoc("colorize"),
OpColorize.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqawqadaq", HexDir.SOUTH_EAST), prefix("create_water"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqawqadaq", HexDir.SOUTH_EAST), modLoc("create_water"),
OpCreateWater.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dedwedade", HexDir.SOUTH_WEST),
prefix("destroy_water"),
modLoc("destroy_water"),
OpDestroyWater.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aaqawawa", HexDir.SOUTH_EAST), prefix("ignite"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aaqawawa", HexDir.SOUTH_EAST), modLoc("ignite"),
OpIgnite.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddedwdwd", HexDir.SOUTH_WEST), prefix("extinguish"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ddedwdwd", HexDir.SOUTH_WEST), modLoc("extinguish"),
OpExtinguish.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqa", HexDir.NORTH_EAST), prefix("conjure_block"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqa", HexDir.NORTH_EAST), modLoc("conjure_block"),
new OpConjure(false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqd", HexDir.NORTH_EAST), prefix("conjure_light"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqd", HexDir.NORTH_EAST), modLoc("conjure_light"),
new OpConjure(true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaqwawqaqw", HexDir.NORTH_EAST), prefix("bonemeal"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaqwawqaqw", HexDir.NORTH_EAST), modLoc("bonemeal"),
OpTheOnlyReasonAnyoneDownloadedPsi.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwaeaeaeaeaea", HexDir.NORTH_WEST),
prefix("recharge"),
modLoc("recharge"),
OpRecharge.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qdqawwaww", HexDir.EAST), prefix("erase"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qdqawwaww", HexDir.EAST), modLoc("erase"),
new OpErase());
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaqwd", HexDir.NORTH_EAST), prefix("edify"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wqaqwd", HexDir.NORTH_EAST), modLoc("edify"),
OpEdifySapling.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("adaa", HexDir.WEST), prefix("beep"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("adaa", HexDir.WEST), modLoc("beep"),
OpBeep.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waqqqqq", HexDir.EAST), prefix("craft/cypher"),
new OpMakePackagedSpell<>(HexItems.CYPHER.get(), 100_000));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waqqqqq", HexDir.EAST), modLoc("craft/cypher"),
new OpMakePackagedSpell<>(HexItems.CYPHER, 100_000));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wwaqqqqqeaqeaeqqqeaeq", HexDir.EAST),
prefix("craft/trinket"),
new OpMakePackagedSpell<>(HexItems.TRINKET.get(), 500_000));
modLoc("craft/trinket"),
new OpMakePackagedSpell<>(HexItems.TRINKET, 500_000));
PatternRegistry.mapPattern(
HexPattern.FromAnglesSig("wwaqqqqqeawqwqwqwqwqwwqqeadaeqqeqqeadaeqq", HexDir.EAST),
prefix("craft/artifact"),
new OpMakePackagedSpell<>(HexItems.ARTIFACT.get(), 1_000_000));
modLoc("craft/artifact"),
new OpMakePackagedSpell<>(HexItems.ARTIFACT, 1_000_000));
PatternRegistry.mapPattern(
HexPattern.FromAnglesSig("aqqqaqwwaqqqqqeqaqqqawwqwqwqwqwqw", HexDir.SOUTH_WEST),
prefix("craft/battery"),
modLoc("craft/battery"),
OpMakeBattery.INSTANCE,
true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqaqwawaw", HexDir.NORTH_WEST),
prefix("potion/weakness"),
modLoc("potion/weakness"),
new OpPotionEffect(MobEffects.WEAKNESS, 10_000 / 10, true, false, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqawwawawd", HexDir.WEST),
prefix("potion/levitation"),
modLoc("potion/levitation"),
new OpPotionEffect(MobEffects.LEVITATION, 10_000 / 5, false, false, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqaewawawe", HexDir.SOUTH_WEST),
prefix("potion/wither"),
modLoc("potion/wither"),
new OpPotionEffect(MobEffects.WITHER, 10_000, true, false, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqadwawaww", HexDir.SOUTH_EAST),
prefix("potion/poison"),
modLoc("potion/poison"),
new OpPotionEffect(MobEffects.POISON, 10_000 / 3, true, false, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqadwawaw", HexDir.SOUTH_EAST),
prefix("potion/slowness"),
modLoc("potion/slowness"),
new OpPotionEffect(MobEffects.MOVEMENT_SLOWDOWN, 10_000 / 3, true, false, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqaawawaedd", HexDir.NORTH_WEST),
prefix("potion/regeneration"),
modLoc("potion/regeneration"),
new OpPotionEffect(MobEffects.REGENERATION, 10_000, true, true, true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqaawawaeqdd", HexDir.WEST),
prefix("potion/night_vision"),
modLoc("potion/night_vision"),
new OpPotionEffect(MobEffects.NIGHT_VISION, 10_000 / 5, false, true, true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqaawawaeqqdd", HexDir.SOUTH_WEST),
prefix("potion/absorption"),
modLoc("potion/absorption"),
new OpPotionEffect(MobEffects.ABSORPTION, 10_000, true, true, true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaawawaeqqqdd", HexDir.SOUTH_EAST),
prefix("potion/haste"),
modLoc("potion/haste"),
new OpPotionEffect(MobEffects.DIG_SPEED, 10_000 / 3, true, true, true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aawawaeqqqqdd", HexDir.EAST),
prefix("potion/strength"),
modLoc("potion/strength"),
new OpPotionEffect(MobEffects.DAMAGE_BOOST, 10_000 / 3, true, true, true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waeawae", HexDir.EAST),
prefix("sentinel/create"),
modLoc("sentinel/create"),
new OpCreateSentinel(false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qdwdqdw", HexDir.NORTH_EAST),
prefix("sentinel/destroy"),
modLoc("sentinel/destroy"),
OpDestroySentinel.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waeawaede", HexDir.EAST),
prefix("sentinel/get_pos"),
modLoc("sentinel/get_pos"),
OpGetSentinelPos.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waeawaedwa", HexDir.EAST),
prefix("sentinel/wayfind"),
modLoc("sentinel/wayfind"),
OpGetSentinelWayfind.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waadwawdaaweewq", HexDir.EAST),
prefix("lightning"), OpLightning.INSTANCE, true);
modLoc("lightning"), OpLightning.INSTANCE, true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eawwaeawawaa", HexDir.NORTH_WEST),
prefix("flight"), OpFlight.INSTANCE, true);
modLoc("flight"), OpFlight.INSTANCE, true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eaqawqadaqd", HexDir.EAST),
prefix("create_lava"), OpCreateLava.INSTANCE, true);
modLoc("create_lava"), OpCreateLava.INSTANCE, true);
PatternRegistry.mapPattern(
HexPattern.FromAnglesSig("wwwqqqwwwqqeqqwwwqqwqqdqqqqqdqq", HexDir.EAST),
prefix("teleport"), OpTeleport.INSTANCE, true);
modLoc("teleport"), OpTeleport.INSTANCE, true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("waeawaeqqqwqwqqwq", HexDir.EAST),
prefix("sentinel/create/great"),
modLoc("sentinel/create/great"),
new OpCreateSentinel(true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeewwweeewwaqqddqdqd", HexDir.EAST),
prefix("dispel_rain"),
modLoc("dispel_rain"),
new OpWeather(false), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wwweeewwweewdawdwad", HexDir.WEST),
prefix("summon_rain"),
modLoc("summon_rain"),
new OpWeather(true), true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qeqwqwqwqwqeqaeqeaqeqaeqaqded", HexDir.NORTH_EAST),
prefix("brainsweep"),
modLoc("brainsweep"),
OpBrainsweep.INSTANCE, true);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqwqqqqqaq", HexDir.WEST), prefix("akashic/read"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqwqqqqqaq", HexDir.WEST), modLoc("akashic/read"),
OpAkashicRead.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeweeeeede", HexDir.EAST), prefix("akashic/write"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeweeeeede", HexDir.EAST), modLoc("akashic/write"),
OpAkashicWrite.INSTANCE);
// == Meta stuff ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqq", HexDir.WEST), prefix("open_paren"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqq", HexDir.WEST), modLoc("open_paren"),
Widget.OPEN_PAREN);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eee", HexDir.EAST), prefix("close_paren"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eee", HexDir.EAST), modLoc("close_paren"),
Widget.CLOSE_PAREN);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqaw", HexDir.WEST), prefix("escape"), Widget.ESCAPE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqaw", HexDir.WEST), modLoc("escape"), Widget.ESCAPE);
// http://www.toroidalsnark.net/mkss3-pix/CalderheadJMM2014.pdf
// eval being a space filling curve feels apt doesn't it
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("deaqq", HexDir.SOUTH_EAST), prefix("eval"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("deaqq", HexDir.SOUTH_EAST), modLoc("eval"),
OpEval.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqdee", HexDir.SOUTH_WEST), prefix("eval/delay"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqdee", HexDir.SOUTH_WEST), modLoc("eval/delay"),
OpEvalDelay.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqqqqq", HexDir.EAST), prefix("read"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqqqqq", HexDir.EAST), modLoc("read"),
OpRead.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("deeeee", HexDir.EAST), prefix("write"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("deeeee", HexDir.EAST), modLoc("write"),
OpWrite.INSTANCE);
// lorge boy
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("wawqwqwqwqwqw", HexDir.EAST),
prefix("read/entity"), OpTheCoolerRead.INSTANCE);
modLoc("read/entity"), OpTheCoolerRead.INSTANCE);
// == Consts ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqea", HexDir.NORTH_WEST), prefix("const/vec/px"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqea", HexDir.NORTH_WEST), modLoc("const/vec/px"),
Operator.makeConstantOp(SpellDatum.make(new Vec3(1.0, 0.0, 0.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqew", HexDir.NORTH_WEST), prefix("const/vec/py"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqew", HexDir.NORTH_WEST), modLoc("const/vec/py"),
Operator.makeConstantOp(SpellDatum.make(new Vec3(0.0, 1.0, 0.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqed", HexDir.NORTH_WEST), prefix("const/vec/pz"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqed", HexDir.NORTH_WEST), modLoc("const/vec/pz"),
Operator.makeConstantOp(SpellDatum.make(new Vec3(0.0, 0.0, 1.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeeqa", HexDir.SOUTH_WEST), prefix("const/vec/nx"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeeqa", HexDir.SOUTH_WEST), modLoc("const/vec/nx"),
Operator.makeConstantOp(SpellDatum.make(new Vec3(-1.0, 0.0, 0.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeeqw", HexDir.SOUTH_WEST), prefix("const/vec/ny"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeeqw", HexDir.SOUTH_WEST), modLoc("const/vec/ny"),
Operator.makeConstantOp(SpellDatum.make(new Vec3(0.0, -1.0, 0.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeeqd", HexDir.SOUTH_WEST), prefix("const/vec/nz"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeeqd", HexDir.SOUTH_WEST), modLoc("const/vec/nz"),
Operator.makeConstantOp(SpellDatum.make(new Vec3(0.0, 0.0, -1.0))));
// Yep, this is what I spend the "plain hexagon" pattern on.
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqq", HexDir.NORTH_WEST), prefix("const/vec/0"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqq", HexDir.NORTH_WEST), modLoc("const/vec/0"),
Operator.makeConstantOp(SpellDatum.make(new Vec3(0.0, 0.0, 0.0))));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qdwdq", HexDir.NORTH_EAST), prefix("const/double/pi"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qdwdq", HexDir.NORTH_EAST), modLoc("const/double/pi"),
Operator.makeConstantOp(SpellDatum.make(Math.PI)));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eawae", HexDir.NORTH_WEST), prefix("const/double/tau"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eawae", HexDir.NORTH_WEST), modLoc("const/double/tau"),
Operator.makeConstantOp(SpellDatum.make(HexUtils.TAU)));
// e
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aaq", HexDir.EAST), prefix("const/double/e"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aaq", HexDir.EAST), modLoc("const/double/e"),
Operator.makeConstantOp(SpellDatum.make(Math.E)));
// == Entities ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqa", HexDir.SOUTH_EAST), prefix("get_entity"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqa", HexDir.SOUTH_EAST), modLoc("get_entity"),
new OpGetEntityAt(e -> true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqaawa", HexDir.SOUTH_EAST),
prefix("get_entity/animal"),
modLoc("get_entity/animal"),
new OpGetEntityAt(OpGetEntitiesBy::isAnimal));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqaawq", HexDir.SOUTH_EAST),
prefix("get_entity/monster"),
modLoc("get_entity/monster"),
new OpGetEntityAt(OpGetEntitiesBy::isMonster));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqaaww", HexDir.SOUTH_EAST),
prefix("get_entity/item"),
modLoc("get_entity/item"),
new OpGetEntityAt(OpGetEntitiesBy::isItem));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqaawe", HexDir.SOUTH_EAST),
prefix("get_entity/player"),
modLoc("get_entity/player"),
new OpGetEntityAt(OpGetEntitiesBy::isPlayer));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqdaqaawd", HexDir.SOUTH_EAST),
prefix("get_entity/living"),
modLoc("get_entity/living"),
new OpGetEntityAt(OpGetEntitiesBy::isLiving));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwded", HexDir.SOUTH_EAST), prefix("zone_entity"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwded", HexDir.SOUTH_EAST), modLoc("zone_entity"),
new OpGetEntitiesBy(e -> true, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwdeddwa", HexDir.SOUTH_EAST),
prefix("zone_entity/animal"),
modLoc("zone_entity/animal"),
new OpGetEntitiesBy(OpGetEntitiesBy::isAnimal, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeewaqaawa", HexDir.NORTH_EAST),
prefix("zone_entity/not_animal"),
modLoc("zone_entity/not_animal"),
new OpGetEntitiesBy(OpGetEntitiesBy::isAnimal, true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwdeddwq", HexDir.SOUTH_EAST),
prefix("zone_entity/monster"),
modLoc("zone_entity/monster"),
new OpGetEntitiesBy(OpGetEntitiesBy::isMonster, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeewaqaawq", HexDir.NORTH_EAST),
prefix("zone_entity/not_monster"),
modLoc("zone_entity/not_monster"),
new OpGetEntitiesBy(OpGetEntitiesBy::isMonster, true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwdeddww", HexDir.SOUTH_EAST),
prefix("zone_entity/item"),
modLoc("zone_entity/item"),
new OpGetEntitiesBy(OpGetEntitiesBy::isItem, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeewaqaaww", HexDir.NORTH_EAST),
prefix("zone_entity/not_item"),
modLoc("zone_entity/not_item"),
new OpGetEntitiesBy(OpGetEntitiesBy::isItem, true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwdeddwe", HexDir.SOUTH_EAST),
prefix("zone_entity/player"),
modLoc("zone_entity/player"),
new OpGetEntitiesBy(OpGetEntitiesBy::isPlayer, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeewaqaawe", HexDir.NORTH_EAST),
prefix("zone_entity/not_player"),
modLoc("zone_entity/not_player"),
new OpGetEntitiesBy(OpGetEntitiesBy::isPlayer, true));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqqqwdeddwd", HexDir.SOUTH_EAST),
prefix("zone_entity/living"),
modLoc("zone_entity/living"),
new OpGetEntitiesBy(OpGetEntitiesBy::isLiving, false));
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("eeeeewaqaawd", HexDir.NORTH_EAST),
prefix("zone_entity/not_living"),
modLoc("zone_entity/not_living"),
new OpGetEntitiesBy(OpGetEntitiesBy::isLiving, true));
// == Lists ==
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("edqde", HexDir.SOUTH_WEST), prefix("append"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("edqde", HexDir.SOUTH_WEST), modLoc("append"),
OpAppend.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaeaq", HexDir.NORTH_WEST), prefix("concat"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qaeaq", HexDir.NORTH_WEST), modLoc("concat"),
OpConcat.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("deeed", HexDir.NORTH_WEST), prefix("index"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("deeed", HexDir.NORTH_WEST), modLoc("index"),
OpIndex.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dadad", HexDir.NORTH_EAST), prefix("for_each"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dadad", HexDir.NORTH_EAST), modLoc("for_each"),
OpForEach.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqaeaq", HexDir.EAST), prefix("list_size"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("aqaeaq", HexDir.EAST), modLoc("list_size"),
OpListSize.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("adeeed", HexDir.EAST), prefix("singleton"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("adeeed", HexDir.EAST), modLoc("singleton"),
OpSingleton.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqaeaae", HexDir.NORTH_EAST), prefix("empty_list"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqaeaae", HexDir.NORTH_EAST), modLoc("empty_list"),
OpEmptyList.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqaede", HexDir.EAST), prefix("reverse_list"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qqqaede", HexDir.EAST), modLoc("reverse_list"),
OpReverski.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ewdqdwe", HexDir.SOUTH_WEST), prefix("last_n_list"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("ewdqdwe", HexDir.SOUTH_WEST), modLoc("last_n_list"),
OpLastNToList.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qwaeawq", HexDir.NORTH_WEST), prefix("splat"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("qwaeawq", HexDir.NORTH_WEST), modLoc("splat"),
OpSplat.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dedqde", HexDir.EAST), prefix("index_of"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("dedqde", HexDir.EAST), modLoc("index_of"),
OpIndexOf.INSTANCE);
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("edqdewaqa", HexDir.SOUTH_WEST), prefix("list_remove"),
PatternRegistry.mapPattern(HexPattern.FromAnglesSig("edqdewaqa", HexDir.SOUTH_WEST), modLoc("list_remove"),
OpRemove.INSTANCE);
} catch (PatternRegistry.RegisterPatternException exn) {
@ -425,7 +422,7 @@ public class RegisterPatterns {
}
// Add zilde->number
PatternRegistry.addSpecialHandler(prefix("number"), pat -> {
PatternRegistry.addSpecialHandler(modLoc("number"), pat -> {
var sig = pat.anglesSignature();
if (sig.startsWith("aqaa") || sig.startsWith("dedd")) {
var negate = sig.startsWith("dedd");
@ -452,7 +449,7 @@ public class RegisterPatterns {
}
});
PatternRegistry.addSpecialHandler(prefix("mask"), pat -> {
PatternRegistry.addSpecialHandler(modLoc("mask"), pat -> {
var directions = pat.directions();
HexDir flatDir;

View file

@ -1,18 +1,28 @@
package at.petrak.hexcasting.common.lib;
import at.petrak.hexcasting.HexMod;
import at.petrak.hexcasting.common.particles.ConjureParticleOptions;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import net.minecraft.resources.ResourceLocation;
import java.util.LinkedHashMap;
import java.util.Map;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
public class HexParticles {
public static final DeferredRegister<ParticleType<?>> PARTICLES = DeferredRegister.create(
ForgeRegistries.PARTICLE_TYPES, HexMod.MOD_ID);
private static final Map<ResourceLocation, ParticleType<?>> PARTICLES = new LinkedHashMap<>();
public static final RegistryObject<ConjureParticleOptions.Type> CONJURE_PARTICLE = PARTICLES.register(
"conjure_block_particle", () -> new ConjureParticleOptions.Type(false));
public static final RegistryObject<ConjureParticleOptions.Type> LIGHT_PARTICLE = PARTICLES.register(
public static final ConjureParticleOptions.Type CONJURE_PARTICLE = register(
"conjure_block_particle", new ConjureParticleOptions.Type(false));
public static final ConjureParticleOptions.Type LIGHT_PARTICLE = register(
"conjure_light_particle", () -> new ConjureParticleOptions.Type(false));
private static <T extends ParticleOptions> ParticleType<T> register(String id, ParticleType<T> particle) {
var old = PARTICLES.put(modLoc(id), particle);
if (old != null) {
throw new IllegalArgumentException("Typo? Duplicate id " + id);
}
return particle;
}
}

View file

@ -0,0 +1,51 @@
package at.petrak.hexcasting.xplat;
import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.common.network.IMessage;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import java.util.ServiceLoader;
import java.util.function.Function;
import java.util.stream.Collectors;
public interface IClientXplatAbstractions {
void sendPacketToServer(IMessage packet);
// The funny thing is both forge and fabric separately access widen the SAME FUNCTION
// but i can't use it without xplat cause it's not widened in common
// waa
void registerItemProperty(Item item, ResourceLocation id, ClampedItemPropertyFunction func);
void setRenderLayer(Block block, RenderType type);
<T extends Entity> void registerEntityRenderer(EntityType<? extends T> type, EntityRendererProvider<T> renderer);
<T extends ParticleOptions> void registerParticleType(ParticleType<T> type,
Function<SpriteSet, ParticleProvider<T>> factory);
IClientXplatAbstractions INSTANCE = find();
private static IClientXplatAbstractions find() {
var providers = ServiceLoader.load(IClientXplatAbstractions.class).stream().toList();
if (providers.size() != 1) {
var names = providers.stream().map(p -> p.type().getName()).collect(Collectors.joining(",", "[", "]"));
throw new IllegalStateException(
"There should be exactly one IClientXplatAbstractions implementation on the classpath. Found: " + names);
} else {
var provider = providers.get(0);
HexAPI.LOGGER.debug("Instantiating client xplat impl: " + provider.type().getName());
return provider.get();
}
}
}

View file

@ -4,11 +4,13 @@ import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.api.addldata.DataHolder;
import at.petrak.hexcasting.api.addldata.HexHolder;
import at.petrak.hexcasting.api.addldata.ManaHolder;
import at.petrak.hexcasting.api.advancements.HexAdvancementTriggers;
import at.petrak.hexcasting.api.misc.FrozenColorizer;
import at.petrak.hexcasting.api.player.FlightAbility;
import at.petrak.hexcasting.api.player.Sentinel;
import at.petrak.hexcasting.api.spell.casting.CastingHarness;
import at.petrak.hexcasting.api.spell.casting.ResolvedPattern;
import at.petrak.hexcasting.common.casting.RegisterPatterns;
import at.petrak.hexcasting.common.command.PatternResLocArgument;
import at.petrak.hexcasting.common.network.IMessage;
import net.minecraft.commands.synchronization.ArgumentTypes;
@ -41,11 +43,8 @@ public interface IXplatAbstractions {
boolean isPhysicalClient();
void sendPacketToPlayer(ServerPlayer target, IMessage packet);
void sendPacketToServer(IMessage packet);
// Things that used to be caps
/**
@ -108,6 +107,8 @@ public interface IXplatAbstractions {
PatternResLocArgument.class,
new EmptyArgumentSerializer<>(PatternResLocArgument::id)
);
RegisterPatterns.registerPatterns();
HexAdvancementTriggers.registerTriggers();
}

View file

@ -1,8 +1,16 @@
import at.petrak.hexcasting.client.HexAdditionalRenderers
import at.petrak.hexcasting.fabric.network.FabricPacketHandler
import net.fabricmc.api.ClientModInitializer
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents
object FabricHexClientInitializer : ClientModInitializer {
override fun onInitializeClient() {
FabricPacketHandler.initClient()
WorldRenderEvents.BEFORE_DEBUG_RENDER.register { ctx ->
HexAdditionalRenderers.overlayLevel(ctx.matrixStack(), ctx.tickDelta())
}
HudRenderCallback.EVENT.register(HexAdditionalRenderers::overlayGui)
}
}

View file

@ -0,0 +1,52 @@
package at.petrak.hexcasting.fabric.xplat;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import java.util.function.Function;
public class FabricClientXplatImpl implements IClientXplatAbstractions {
@Override
public void sendPacketToServer(IMessage packet) {
ClientPlayNetworking.send(packet.getFabricId(), packet.toBuf());
}
@Override
public void registerItemProperty(Item item, ResourceLocation id, ClampedItemPropertyFunction func) {
ItemProperties.register(item, id, func);
}
@Override
public void setRenderLayer(Block block, RenderType type) {
BlockRenderLayerMap.INSTANCE.putBlock(block, type);
}
@Override
public <T extends Entity> void registerEntityRenderer(EntityType<? extends T> type,
EntityRendererProvider<T> renderer) {
EntityRendererRegistry.register(type, renderer);
}
@Override
public <T extends ParticleOptions> void registerParticleType(ParticleType<T> type,
Function<SpriteSet, ParticleProvider<T>> factory) {
ParticleFactoryRegistry.getInstance().register(type, factory::apply);
}
}

View file

@ -15,7 +15,6 @@ import at.petrak.hexcasting.xplat.IXplatAbstractions;
import at.petrak.hexcasting.xplat.Platform;
import net.fabricmc.api.EnvType;
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
@ -56,11 +55,6 @@ public class FabricXplatImpl implements IXplatAbstractions {
ServerPlayNetworking.send(target, packet.getFabricId(), packet.toBuf());
}
@Override
public void sendPacketToServer(IMessage packet) {
ClientPlayNetworking.send(packet.getFabricId(), packet.toBuf());
}
@Override
public void brainsweep(Mob mob) {
var cc = HexCardinalComponents.BRAINSWEPT.get(mob);

View file

@ -0,0 +1 @@
at.petrak.hexcasting.fabric.xplat.FabricClientXplatImpl

View file

@ -2,8 +2,9 @@ package at.petrak.hexcasting
import at.petrak.hexcasting.api.HexAPI
import at.petrak.hexcasting.api.PatternRegistry
import at.petrak.hexcasting.api.advancements.HexAdvancementTriggers
import at.petrak.hexcasting.api.mod.HexConfig
import at.petrak.hexcasting.client.HexAdditionalRenderers
import at.petrak.hexcasting.client.RegisterClientStuff
import at.petrak.hexcasting.common.lib.HexBlockEntities
import at.petrak.hexcasting.common.lib.HexBlocks
import at.petrak.hexcasting.common.lib.HexItems
@ -15,14 +16,20 @@ import at.petrak.hexcasting.forge.cap.CapSyncers
import at.petrak.hexcasting.forge.network.ForgePacketHandler
import at.petrak.hexcasting.xplat.IXplatAbstractions
import net.minecraft.resources.ResourceLocation
import net.minecraftforge.api.distmarker.Dist
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.client.event.RenderLevelLastEvent
import net.minecraftforge.common.ForgeConfigSpec
import net.minecraftforge.event.RegistryEvent
import net.minecraftforge.event.entity.living.LivingConversionEvent
import net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteract
import net.minecraftforge.eventbus.api.SubscribeEvent
import net.minecraftforge.eventbus.api.EventPriority
import net.minecraftforge.fml.DistExecutor
import net.minecraftforge.fml.ModLoadingContext
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.config.ModConfig
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext
@ -39,6 +46,13 @@ object ForgeHexInitializer {
init {
IXplatAbstractions.INSTANCE.init()
initConfig()
initRegistry()
initListeners()
}
fun initConfig() {
val config = ForgeConfigSpec.Builder()
.configure { builder: ForgeConfigSpec.Builder? -> ForgeHexConfig(builder) }
val serverConfig = ForgeConfigSpec.Builder()
@ -51,9 +65,6 @@ object ForgeHexInitializer {
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, config.right)
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, serverConfig.right)
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, clientConfig.right)
initRegistry()
initListeners()
}
fun initRegistry() {
@ -70,7 +81,23 @@ object ForgeHexInitializer {
// game events
val evBus = thedarkcolour.kotlinforforge.forge.FORGE_BUS
modBus.addListener(this::commonSetup)
modBus.addListener { evt: FMLCommonSetupEvent ->
evt.enqueueWork {
ForgePacketHandler.init()
}
}
modBus.addListener { evt: FMLClientSetupEvent ->
evt.enqueueWork {
RegisterClientStuff.init()
}
}
modBus.addListener { _: FMLLoadCompleteEvent ->
getLogger().info(
PatternRegistry.getPatternCountInfo()
)
}
evBus.addListener { evt: EntityInteract ->
val res = Brainsweeping.tradeWithVillager(
@ -91,43 +118,19 @@ object ForgeHexInitializer {
evBus.register(CapSyncers::class.java)
evBus.register(ForgeOnlyEvents::class.java)
/*
modBus.register(this)
// gotta do it at *some* point
modBus.register(RegisterPatterns::class.java)
modBus.register(HexDataGenerators::class.java)
HexItems.ITEMS.register(modBus)
HexBlocks.BLOCKS.register(modBus)
HexBlockEntities.BLOCK_ENTITIES.register(modBus)
HexEntities.ENTITIES.register(modBus)
HexLootModifiers.LOOT_MODS.register(modBus)
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)
modBus.register(HexComposting::class.java)
evBus.register(HexCommands::class.java)
evBus.register(TickScheduler)
evBus.register(HexCapabilityHandler::class.java)
evBus.register(HexPlayerDataHelper::class.java)
evBus.register(OpFlight)
evBus.register(Brainsweeping::class.java)
DistExecutor.unsafeRunWhenOn(Dist.CLIENT) {
Runnable {
modBus.register(RegisterClientStuff::class.java)
evBus.register(ClientTickCounter::class.java)
evBus.register(HexAdditionalRenderers::class.java)
evBus.register(ShiftScrollListener::class.java)
evBus.register(HexTooltips::class.java)
evBus.addListener { evt: RenderLevelLastEvent ->
HexAdditionalRenderers.overlayLevel(evt.poseStack, evt.partialTick)
}
evBus.addListener { evt: RenderGameOverlayEvent.PreLayer ->
HexAdditionalRenderers.overlayGui(evt.matrixStack, evt.partialTicks)
}
evBus.addListener(EventPriority.LOWEST) { _: ParticleFactoryRegisterEvent ->
RegisterClientStuff.registerParticles()
}
}
}
*/
}
private fun <T : IForgeRegistryEntry<T>> bind(
@ -145,21 +148,6 @@ object ForgeHexInitializer {
}
}
@SubscribeEvent
fun commonSetup(evt: FMLCommonSetupEvent) {
evt.enqueueWork {
HexAdvancementTriggers.registerTriggers()
ForgePacketHandler.init()
}
}
@JvmStatic
fun getLogger(): Logger = HexAPI.LOGGER
@SubscribeEvent
fun printPatternCount(evt: FMLLoadCompleteEvent) {
getLogger().info(
PatternRegistry.getPatternCountInfo()
)
}
}

View file

@ -0,0 +1,52 @@
package at.petrak.hexcasting.forge.xplat;
import at.petrak.hexcasting.common.network.IMessage;
import at.petrak.hexcasting.forge.network.ForgePacketHandler;
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.ParticleProvider;
import net.minecraft.client.particle.SpriteSet;
import net.minecraft.client.renderer.ItemBlockRenderTypes;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
import net.minecraft.client.renderer.item.ItemProperties;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import java.util.function.Function;
public class ForgeClientXplatImpl implements IClientXplatAbstractions {
@Override
public void sendPacketToServer(IMessage packet) {
ForgePacketHandler.getNetwork().sendToServer(packet);
}
@Override
public void registerItemProperty(Item item, ResourceLocation id, ClampedItemPropertyFunction func) {
ItemProperties.register(item, id, func);
}
@Override
public void setRenderLayer(Block block, RenderType type) {
ItemBlockRenderTypes.setRenderLayer(block, type);
}
@Override
public <T extends Entity> void registerEntityRenderer(EntityType<? extends T> type,
EntityRendererProvider<T> renderer) {
EntityRenderers.register(type, renderer);
}
@Override
public <T extends ParticleOptions> void registerParticleType(ParticleType<T> type,
Function<SpriteSet, ParticleProvider<T>> factory) {
Minecraft.getInstance().particleEngine.register(type, factory::apply);
}
}

View file

@ -242,11 +242,6 @@ public class ForgeXplatImpl implements IXplatAbstractions {
ForgePacketHandler.getNetwork().send(PacketDistributor.PLAYER.with(() -> target), packet);
}
@Override
public void sendPacketToServer(IMessage packet) {
ForgePacketHandler.getNetwork().sendToServer(packet);
}
@Override
public <T extends BlockEntity> BlockEntityType<T> createBlockEntityType(BiFunction<BlockPos, BlockState, T> func,
Block... blocks) {

View file

@ -0,0 +1 @@
at.petrak.hexcasting.forge.xplat.ForgeClientXplatImpl