bang on langfile, half-fix sounds

This commit is contained in:
petrak@ 2023-04-24 21:18:24 -05:00
parent 92860e463d
commit 7f73db1786
26 changed files with 1607 additions and 1403 deletions

View file

@ -2,7 +2,6 @@ package at.petrak.hexcasting.api.casting.eval.env;
import at.petrak.hexcasting.api.casting.eval.CastResult;
import at.petrak.hexcasting.api.casting.eval.sideeffects.EvalSound;
import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect;
import at.petrak.hexcasting.api.misc.FrozenColorizer;
import at.petrak.hexcasting.common.lib.hex.HexEvalSounds;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
@ -23,13 +22,8 @@ public class PackagedItemCastEnv extends PlayerBasedCastEnv {
@Override
public void postExecution(CastResult result) {
super.postExecution(result);
this.sound = this.sound.greaterOf(result.getSound());
for (var sideEffect : result.getSideEffects()) {
if (sideEffect instanceof OperatorSideEffect.DoMishap doMishap) {
this.sendMishapMsgToPlayer(doMishap);
}
}
}
@Override

View file

@ -4,6 +4,7 @@ import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.api.addldata.ADMediaHolder;
import at.petrak.hexcasting.api.advancements.HexAdvancementTriggers;
import at.petrak.hexcasting.api.casting.ParticleSpray;
import at.petrak.hexcasting.api.casting.eval.CastResult;
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment;
import at.petrak.hexcasting.api.casting.eval.MishapEnvironment;
import at.petrak.hexcasting.api.casting.eval.sideeffects.EvalSound;
@ -51,7 +52,16 @@ public abstract class PlayerBasedCastEnv extends CastingEnvironment {
@Override
public EvalSound getSoundType() {
return HexEvalSounds.ADD_PATTERN;
return HexEvalSounds.NORMAL_EXECUTE;
}
@Override
public void postExecution(CastResult result) {
for (var sideEffect : result.getSideEffects()) {
if (sideEffect instanceof OperatorSideEffect.DoMishap doMishap) {
this.sendMishapMsgToPlayer(doMishap);
}
}
}
@Override
@ -111,7 +121,8 @@ public abstract class PlayerBasedCastEnv extends CastingEnvironment {
if (primaryItem.isEmpty())
primaryItem = ItemStack.EMPTY.copy();
return List.of(new HeldItemInfo(getAlternateItem(), this.getOtherHand()), new HeldItemInfo(primaryItem, this.castingHand));
return List.of(new HeldItemInfo(getAlternateItem(), this.getOtherHand()), new HeldItemInfo(primaryItem,
this.castingHand));
}
@Override

View file

@ -4,7 +4,6 @@ import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.api.casting.eval.CastResult;
import at.petrak.hexcasting.api.casting.eval.ExecutionClientView;
import at.petrak.hexcasting.api.casting.eval.ResolvedPattern;
import at.petrak.hexcasting.api.casting.eval.sideeffects.OperatorSideEffect;
import at.petrak.hexcasting.api.casting.iota.PatternIota;
import at.petrak.hexcasting.api.casting.math.HexCoord;
import at.petrak.hexcasting.api.misc.FrozenColorizer;
@ -14,6 +13,7 @@ import at.petrak.hexcasting.common.network.MsgNewSpellPatternSyn;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import java.util.HashSet;
@ -31,10 +31,13 @@ public class StaffCastEnv extends PlayerBasedCastEnv {
@Override
public void postExecution(CastResult result) {
for (var sideEffect : result.getSideEffects()) {
if (sideEffect instanceof OperatorSideEffect.DoMishap doMishap) {
this.sendMishapMsgToPlayer(doMishap);
}
super.postExecution(result);
var sound = result.getSound().sound();
if (sound != null) {
var soundPos = this.caster.position();
this.caster.getLevel().playSound(null, soundPos.x, soundPos.y, soundPos.z,
sound, SoundSource.PLAYERS, 1f, 1f);
}
}
@ -87,10 +90,7 @@ public class StaffCastEnv extends PlayerBasedCastEnv {
var vm = IXplatAbstractions.INSTANCE.getStaffcastVM(sender, msg.handUsed());
// every time we send a new pattern it'll be happening in a different tick, so reset here
// i don't think we can do this in the casting vm itself because it doesn't know if `queueAndExecuteIotas`
// is being called from the top level or not
vm.getImage().getUserData().remove(HexAPI.OP_COUNT_USERDATA);
// TODO: do we reset the number of evals run via the staff? because each new pat is a new tick.
ExecutionClientView clientInfo = vm.queueExecuteAndWrapIota(new PatternIota(msg.pattern()), sender.getLevel());

View file

@ -79,7 +79,7 @@ class CastingVM(var image: CastingImage, val env: CastingEnvironment) {
// ALSO TODO need to add reader macro-style things
try {
this.handleParentheses(iota)?.let { (data, resolutionType) ->
return@executeInner CastResult(continuation, data, listOf(), resolutionType, HexEvalSounds.ADD_PATTERN)
return@executeInner CastResult(continuation, data, listOf(), resolutionType, HexEvalSounds.NORMAL_EXECUTE)
}
} catch (e: MishapTooManyCloseParens) {
// This is ridiculous and needs to be fixed

View file

@ -62,6 +62,11 @@ class GuiSpellcasting constructor(
}
fun recvServerUpdate(info: ExecutionClientView, index: Int) {
if (info.isStackClear && info.ravenmind == null) {
this.minecraft?.setScreen(null)
return
}
this.patterns.getOrNull(index)?.let {
it.type = info.resolutionType
}
@ -206,7 +211,7 @@ class GuiSpellcasting constructor(
if (playSound) {
Minecraft.getInstance().soundManager.play(
SimpleSoundInstance(
HexSounds.ADD_LINE,
HexSounds.ADD_TO_PATTERN,
SoundSource.PLAYERS,
0.25f,
1f + (Math.random().toFloat() - 0.5f) * 0.1f,

View file

@ -26,7 +26,7 @@ public class ItemStaff extends Item {
public InteractionResultHolder<ItemStack> use(Level world, Player player, InteractionHand hand) {
if (player.isShiftKeyDown()) {
if (world.isClientSide()) {
player.playSound(HexSounds.FAIL_PATTERN, 1f, 1f);
player.playSound(HexSounds.STAFF_RESET, 1f, 1f);
} else if (player instanceof ServerPlayer serverPlayer) {
IXplatAbstractions.INSTANCE.clearCastingData(serverPlayer);
}

View file

@ -18,21 +18,24 @@ public class HexSounds {
private static final Map<ResourceLocation, SoundEvent> SOUNDS = new LinkedHashMap<>();
public static final SoundEvent ADD_LINE = sound("casting.add_line");
public static final SoundEvent START_PATTERN = sound("casting.start_pattern");
public static final SoundEvent ADD_PATTERN = sound("casting.add_pattern");
public static final SoundEvent FAIL_PATTERN = sound("casting.fail_pattern");
public static final SoundEvent START_PATTERN = sound("casting.pattern.start");
public static final SoundEvent ADD_TO_PATTERN = sound("casting.pattern.add_segment");
public static final SoundEvent CASTING_AMBIANCE = sound("casting.ambiance");
public static final SoundEvent ACTUALLY_CAST = sound("casting.cast");
public static final SoundEvent CAST_HERMES = sound("casting.hermes");
public static final SoundEvent CAST_THOTH = sound("casting.thoth");
public static final SoundEvent CAST_NORMAL = sound("casting.cast.normal");
public static final SoundEvent CAST_SPELL = sound("casting.cast.spell");
public static final SoundEvent CAST_HERMES = sound("casting.cast.hermes");
public static final SoundEvent CAST_THOTH = sound("casting.cast.thoth");
public static final SoundEvent CAST_FAILURE = sound("casting.cast.fail");
public static final SoundEvent ABACUS = sound("abacus");
public static final SoundEvent ABACUS_SHAKE = sound("abacus.shake");
public static final SoundEvent STAFF_RESET = sound("staff.reset");
public static final SoundEvent SPELL_CIRCLE_FIND_BLOCK = sound("spellcircle.find_block");
public static final SoundEvent SPELL_CIRCLE_FAIL = sound("spellcircle.fail");
public static final SoundEvent SPELL_CIRCLE_CAST = sound("spellcircle.cast");
public static final SoundEvent SCROLL_DUST = sound("scroll.dust");
public static final SoundEvent SCROLL_SCRIBBLE = sound("scroll.scribble");

View file

@ -15,10 +15,10 @@ public class HexEvalSounds {
public static final EvalSound NOTHING = make("nothing",
new EvalSound(null, Integer.MIN_VALUE));
public static final EvalSound ADD_PATTERN = make("operator",
new EvalSound(HexSounds.ADD_PATTERN, 0));
public static final EvalSound NORMAL_EXECUTE = make("operator",
new EvalSound(HexSounds.CAST_NORMAL, 0));
public static final EvalSound SPELL = make("spell",
new EvalSound(HexSounds.ACTUALLY_CAST, 1000));
new EvalSound(HexSounds.CAST_SPELL, 1000));
public static final EvalSound HERMES = make("hermes",
new EvalSound(HexSounds.CAST_HERMES, 2000));
public static final EvalSound THOTH = make("thoth",
@ -28,7 +28,7 @@ public class HexEvalSounds {
new EvalSound(null, 3000));
public static final EvalSound MISHAP = make("mishap",
new EvalSound(HexSounds.FAIL_PATTERN, 4000));
new EvalSound(HexSounds.CAST_FAILURE, 4000));
private static EvalSound make(String name, EvalSound sound) {
var old = SOUNDS.put(modLoc(name), sound);

View file

@ -58,11 +58,7 @@ public record MsgNewSpellPatternAck(ExecutionClientView info, int index) impleme
}
var screen = Minecraft.getInstance().screen;
if (screen instanceof GuiSpellcasting spellGui) {
if (self.info().isStackClear() && self.info.getRavenmind() == null) {
mc.setScreen(null);
} else {
spellGui.recvServerUpdate(self.info(), self.index());
}
spellGui.recvServerUpdate(self.info(), self.index());
}
});
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,61 +1,64 @@
{
"casting.start_pattern": {
"subtitle": "hexcasting.subtitles.start_pattern",
"sounds": [
"casting.pattern.start": {
subtitle: "hexcasting.subtitles.casting.pattern.start",
sounds: [
{
"name": "hexcasting:add_line",
"volume": 1.0,
"pitch": 0.8
name: "hexcasting:add_segment",
volume: 1.0,
pitch: 0.8
}
]
},
"casting.add_line": {
"subtitle": "hexcasting.subtitles.add_line",
"sounds": [
"casting.pattern.add_segment": {
subtitle: "hexcasting.subtitles.casting.pattern.add_segment",
sounds: [
{
"name": "hexcasting:add_line",
"volume": 0.8,
"pitch": 1.0
name: "hexcasting:add_segment",
volume: 0.8,
pitch: 1.0
}
]
},
"casting.add_pattern": {
"subtitle": "hexcasting.subtitles.add_pattern",
"sounds": [
"hexcasting:add_pattern"
]
},
"casting.fail_pattern": {
"subtitle": "hexcasting.subtitles.fail_pattern",
"sounds": [
"hexcasting:fail_pattern"
]
},
"casting.ambiance": {
"subtitle": "hexcasting.subtitles.ambiance",
"sounds": [
subtitle: "hexcasting.subtitles.ambiance",
sounds: [
"hexcasting:casting_ambiance"
]
},
"casting.cast": {
"subtitle": "hexcasting.subtitles.cast",
"sounds": [
"hexcasting:cast_hex"
"casting.cast.normal": {
subtitle: "hexcasting.subtitles.casting.cast.normal",
sounds: [
"hexcasting:cast/normal"
]
},
"casting.hermes": {
"subtitle": "hexcasting.subtitles.cast",
"sounds": [
"hexcasting:hermes"
"casting.cast.spell": {
subtitle: "hexcasting.subtitles.casting.cast.spell",
sounds: [
"hexcasting:cast/spell"
]
},
"casting.thoth": {
"subtitle": "hexcasting.subtitles.cast",
"sounds": [
"hexcasting:thoth"
"casting.cast.hermes": {
subtitle: "hexcasting.subtitles.casting.cast.hermes",
sounds: [
"hexcasting:cast/hermes"
]
},
"abacus": {
"casting.cast.thoth": {
subtitle: "hexcasting.subtitles.casting.cast.thoth",
sounds: [
"hexcasting:cast/thoth"
],
},
"casting.cast.fail": {
subtitle: "hexcasting.subtitles.casting.cast.fail",
sounds: [
"hexcasting:cast/fail"
],
},
abacus: {
"subtitle": "hexcasting.subtitles.abacus",
"sounds": [
"hexcasting:abacus1",
@ -69,10 +72,21 @@
"hexcasting:abacus_shake"
]
},
"staff.reset": {
"subtitle": "hexcasting.subtitles.staff.reset",
"sounds": [
{
"name": "hexcasting:cast/fail",
"pitch": 0.8
}
]
},
"spellcircle.find_block": {
"sounds": [
{
"name": "hexcasting:add_pattern",
"name": "hexcasting:cast/normal",
"pitch": 0.8
}
],
@ -81,18 +95,13 @@
"spellcircle.fail": {
"sounds": [
{
"name": "hexcasting:fail_pattern",
"name": "hexcasting:cast/fail",
"pitch": 0.8
}
],
"subtitle": "hexcasting.subtitles.spellcircle.fail"
},
"spellcircle.cast": {
"sounds": [
"hexcasting:cast_hex"
],
"subtitle": "hexcasting.subtitles.spellcircle.cast"
},
"scroll.dust": {
"sounds": [
"minecraft:dig/sand1",
@ -110,6 +119,7 @@
],
"subtitle": "hexcasting.subtitles.scroll.scribble"
},
"impetus.fletcher.tick": {
"sounds": [
"minecraft:note/hat"
@ -122,6 +132,7 @@
],
"subtitle": "hexcasting.subtitles.impetus.cleric.register"
},
"lore_fragment.read": {
"sounds": [
"block/enchantment_table/enchant1",
@ -130,6 +141,8 @@
],
"subtitle": "hexcasting.subtitles.lore_fragment.read"
},
// this is for altiora
"flight.ambience": {
"sounds": [
"block/amethyst/shimmer"

View file

@ -1,6 +1,6 @@
{
"name": "hexcasting.entry.basics",
"name": "hexcasting.category.basics",
"icon": "minecraft:amethyst_shard",
"description": "hexcasting.entry.basics.desc",
"description": "hexcasting.category.basics.desc",
"sortnum": 0
}

View file

@ -1,6 +1,6 @@
{
"name": "hexcasting.entry.casting",
"name": "hexcasting.category.casting",
"icon": "hexcasting:oak_staff",
"description": "hexcasting.entry.casting.desc",
"description": "hexcasting.category.casting.desc",
"sortnum": 1
}

View file

@ -1,6 +1,6 @@
{
"name": "hexcasting.entry.greatwork",
"description": "hexcasting.entry.greatwork.desc",
"name": "hexcasting.category.greatwork",
"description": "hexcasting.category.greatwork.desc",
"icon": "minecraft:music_disc_11",
"sortnum": 3,
"entry_color": "54398a"

View file

@ -1,8 +1,8 @@
{
"name": "hexcasting.entry.interop",
"name": "hexcasting.category.interop",
"icon": "minecraft:chain",
"description": "hexcasting.entry.interop.desc",
"description": "hexcasting.category.interop.desc",
"sortnum": 99,
"flag": "hexcasting:any_interop"
}

View file

@ -1,6 +1,6 @@
{
"name": "hexcasting.entry.items",
"name": "hexcasting.category.items",
"icon": "hexcasting:focus",
"description": "hexcasting.entry.items.desc",
"description": "hexcasting.category.items.desc",
"sortnum": 2
}

View file

@ -1,6 +1,6 @@
{
"name": "hexcasting.entry.lore",
"name": "hexcasting.category.lore",
"icon": "hexcasting:lore_fragment",
"description": "hexcasting.entry.lore.desc",
"description": "hexcasting.category.lore.desc",
"sortnum": 98
}

View file

@ -1,6 +1,6 @@
{
"name": "hexcasting.entry.patterns",
"name": "hexcasting.category.patterns",
"icon": "minecraft:bookshelf",
"description": "hexcasting.entry.patterns.desc",
"description": "hexcasting.category.patterns.desc",
"sortnum": 100
}

View file

@ -17,8 +17,8 @@ plugins {
// Also it looks like property lookups don't work this early
id 'fabric-loom' version '1.0-SNAPSHOT' apply false
id("at.petra-k.PKPlugin") version "0.1.0-pre-64"
id("at.petra-k.PKSubprojPlugin") version "0.1.0-pre-64" apply false
id("at.petra-k.PKPlugin") version "0.1.0-pre-65"
id("at.petra-k.PKSubprojPlugin") version "0.1.0-pre-65" apply false
}
repositories {