Skip to content

Commit

Permalink
sounds!
Browse files Browse the repository at this point in the history
  • Loading branch information
reoseah committed Nov 2, 2024
1 parent 306a958 commit a44562e
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 13 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.21.1+build.3
loader_version=0.16.2

# Mod Properties
mod_version=0.0.1
mod_version=0.0.2
maven_group=io.github.reoseah
archives_base_name=magisterium

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/io/github/reoseah/magisterium/Magisterium.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ public void onInitialize() {
Registry.register(Registries.PARTICLE_TYPE, "magisterium:glyph_d", MagisteriumParticles.GLYPH_D);
Registry.register(Registries.PARTICLE_TYPE, "magisterium:glyph_e", MagisteriumParticles.GLYPH_E);

Registry.register(Registries.SOUND_EVENT, "magisterium:chant", MagisteriumSounds.CHANT);
Registry.register(Registries.SOUND_EVENT, "magisterium:arcane_lift_loop", MagisteriumSounds.ARCANE_LIFT_LOOP);

MagisteriumGameRules.initialize();
MagisteriumCommands.initialize();

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/github/reoseah/magisterium/MagisteriumSounds.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.github.reoseah.magisterium;

import net.minecraft.sound.SoundEvent;
import net.minecraft.util.Identifier;

public class MagisteriumSounds {
public static final SoundEvent CHANT = SoundEvent.of(Identifier.of("magisterium:magisterium.chant"));
public static final SoundEvent ARCANE_LIFT_LOOP = SoundEvent.of(Identifier.of("magisterium:magisterium.arcane_lift_loop"));

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.github.reoseah.magisterium.block;

import io.github.reoseah.magisterium.MagisteriumSounds;
import io.github.reoseah.magisterium.particle.MagisteriumParticles;
import net.minecraft.block.*;
import net.minecraft.block.piston.PistonBehavior;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
Expand Down Expand Up @@ -58,6 +58,9 @@ protected VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos

@Override
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
if (random.nextInt(10) == 0) {
world.playSoundAtBlockCenter(pos, MagisteriumSounds.ARCANE_LIFT_LOOP, SoundCategory.BLOCKS, 0.15F, 1.0F, true);
}

if (random.nextInt(4) == 0) {
double x = pos.getX() - .5 + random.nextFloat() * 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public static ItemStack createTestBook() {
list.set(2, SpellPageItem.QUENCH_THE_FLAME.getDefaultStack());
list.set(3, SpellPageItem.GLYPHIC_IGNITION.getDefaultStack());
list.set(4, SpellPageItem.CONFLAGRATE.getDefaultStack());
list.set(5, SpellPageItem.ILLUSORY_WALL.getDefaultStack());
// list.set(6, SpellPageItem.UNSTABLE_CHARGE.getDefaultStack());
list.set(6, SpellPageItem.ARCANE_LIFT.getDefaultStack());
list.set(7, SpellPageItem.COLD_SNAP.getDefaultStack());
list.set(5, SpellPageItem.COLD_SNAP.getDefaultStack());
list.set(6, SpellPageItem.ILLUSORY_WALL.getDefaultStack());
list.set(7, SpellPageItem.ARCANE_LIFT.getDefaultStack());
list.set(8, SpellPageItem.DISPEL_MAGIC.getDefaultStack());
// list.set(17, SpellPageItem.UNSTABLE_CHARGE.getDefaultStack());
}));

return book;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.reoseah.magisterium.screen;

import io.github.reoseah.magisterium.MagisteriumSounds;
import io.github.reoseah.magisterium.item.SpellBookItem;
import io.github.reoseah.magisterium.recipe.SpellBookRecipe;
import io.github.reoseah.magisterium.recipe.SpellBookRecipeInput;
Expand All @@ -21,6 +22,7 @@
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.screen.slot.Slot;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.Hand;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
Expand Down Expand Up @@ -161,20 +163,28 @@ public void onClosed(PlayerEntity player) {
this.dropInventory(player, this.inventory);
}

private Long lastSoundTime = null;

@Override
public boolean canUse(PlayerEntity player) {
// this gets called every tick, so it's a tick method effectively

// TODO allow for spells that are active as long as the player holds the casting button down?
if (this.utteranceRecipe != null && !player.getWorld().isClient) {
if (this.utteranceRecipe != null) {
var recipeDuration = this.utteranceRecipe.duration;
if (player.getWorld().getTime() - this.utteranceStart >= recipeDuration * player.getWorld().getTickManager().getTickRate()) {
long time = player.getWorld().getTime();
if (time - this.utteranceStart >= recipeDuration * player.getWorld().getTickManager().getTickRate()) {
ItemStack result = this.utteranceRecipe.craft(new SpellBookRecipeInput(this.inventory, player, this.context), player.getWorld().getRegistryManager());

if (!result.isEmpty()) {
this.insertResult(result, player);
}
this.stopUtterance();
} else if (this.lastSoundTime == null || time - this.lastSoundTime >= 50) {
if (this.lastSoundTime == null || time - this.utteranceStart <= recipeDuration * player.getWorld().getTickManager().getTickRate() - 50) {
player.getWorld().playSound(null, player.getX(), player.getY(), player.getZ(), MagisteriumSounds.CHANT, SoundCategory.PLAYERS, 0.5F, 1.0F);
}
this.lastSoundTime = time;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

import java.time.Instant;
import java.util.List;

// TODO: have the utterance text shortly highlight to indicate finishing
Expand Down
9 changes: 5 additions & 4 deletions src/main/resources/assets/magisterium/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"tag.item.magisterium.spell_book_components": "Spell Book Components",
"tag.item.magisterium.conflagrate_ingredients": "Conflagrate Ingredients",
"container.magisterium.arcane_table": "Arcane Table",
"subtitles.magisterium.chant": "Chanting",
"subtitles.magisterium.magic_hum": "Magic hums",
"gamerule.enableMagisteriumPlaygrounds": "Enable Magisterium playgrounds (block most spells outside the designated areas, see /magisterium playgrounds)",
"commands.magisterium.playgrounds.list.success": "Available playgrounds: %s",
"commands.magisterium.playgrounds.get.not_found": "Playground with the name %s not found",
Expand Down Expand Up @@ -62,14 +64,13 @@
"magisterium.spell.magisterium.illusory_wall.utterance": "Pᴀʀɪᴇs ꜰᴀʟʟᴀx, ᴠɪᴅᴇᴀʀɪs ꜰɪʀᴍᴜs ᴇᴛ ᴀʟᴛᴜs!\n\nTᴀɴɢᴀɴᴛ ᴛᴇ ꜰʀᴜsᴛʀᴀ, sᴏʟɪᴅᴜᴍ ᴠɪᴅᴇʀᴇ sᴇᴅ ᴜᴍʙʀᴀ sɪs.\n\nVᴇʀɪᴛᴀs ᴀʙsᴄᴏɴᴅɪᴛᴀ, ᴜᴍʙʀᴀ ᴘᴇʀᴍᴀɴᴇ!",
"magisterium.spell.magisterium.arcane_lift": "Arcane Lift",
"magisterium.spell.magisterium.arcane_lift.heading": "ᴀʀᴄᴀɴᴇ ʟɪꜰᴛ",
"magisterium.spell.magisterium.arcane_lift.components": "ᴄᴏᴍᴘᴏɴᴇɴᴛs: a three by three circle of arcane glyphs, TODO something",
"magisterium.spell.magisterium.arcane_lift.components": "ᴄᴏᴍᴘᴏɴᴇɴᴛs: a three by three circle of arcane glyphs, bottle of liquid magic",
"magisterium.spell.magisterium.arcane_lift.description": "Call into existence a rising stream of arcane energy that lifts the creatures and objects into the air.",
"magisterium.spell.magisterium.arcane_lift.utterance": "TODO TODO TODO\n\nTODO TODO TODO\n\nTODO TODO TODO",
"magisterium.spell.magisterium.arcane_lift.utterance": "Aʀᴄᴀɴᴜᴍ ʟᴇᴠᴀʀᴇ, ᴀᴇᴛʜᴇʀᴀ ᴛᴀɴɢᴀᴍᴜs!\n\nCᴏʀᴘᴏʀᴀ ᴇᴛ ᴍᴇɴs sᴜʀɢᴀɴᴛ, ɪɴ ᴀʟᴛᴜᴍ ᴇʟᴇᴠᴇɴᴛᴜʀ!",
"magisterium.spell.magisterium.dispel_magic": "Dispel Magic",
"magisterium.spell.magisterium.dispel_magic.heading": "ᴅɪsᴘᴇʟ ᴍᴀɢɪᴄ",
"magisterium.spell.magisterium.dispel_magic.components": "ᴄᴏᴍᴘᴏɴᴇɴᴛs: TODO",
"magisterium.spell.magisterium.dispel_magic.description": "End the effects of the closest spell or magical effect.",
"magisterium.spell.magisterium.dispel_magic.utterance": "TODO TODO TODO\n\nTODO TODO TODO\n\nTODO TODO TODO",
"magisterium.spell.magisterium.dispel_magic.utterance": "Mᴀɢɪᴀ ᴅɪssᴏʟᴠᴀᴛᴜʀ, ᴠɪɴᴄᴜʟᴀ ᴀʀᴄᴀɴᴀ ʀᴜᴍᴘᴀɴᴛᴜʀ!\n\nNɪʜɪʟ ᴍᴀɴᴇᴀᴛ, ᴀʀs ɪʟʟᴀ ᴇxsᴛɪɴɢᴜᴀᴛᴜʀ!",
"magisterium.spell.magisterium.unstable_charge": "Unstable Charge",
"magisterium.spell.magisterium.unstable_charge.heading": "ᴜɴsᴛᴀʙʟᴇ ᴄʜᴀʀɢᴇ",
"magisterium.spell.magisterium.unstable_charge.components": "ᴄᴏᴍᴘᴏɴᴇɴᴛs: one measure of nether wart and a bottle of liquid magic",
Expand Down
21 changes: 21 additions & 0 deletions src/main/resources/assets/magisterium/sounds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"magisterium.chant": {
"subtitle": "subtitles.magisterium.chant",
"sounds": [
"magisterium:chant_0",
"magisterium:chant_1",
"magisterium:chant_2",
"magisterium:chant_3",
"magisterium:chant_4",
"magisterium:chant_5"
]
},
"magisterium.arcane_lift_loop": {
"subtitle": "subtitles.magisterium.magic_hum",
"sounds": [
"magisterium:arcane_lift_loop_0",
"magisterium:arcane_lift_loop_1",
"magisterium:arcane_lift_loop_2"
]
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit a44562e

Please sign in to comment.