make note is now less weirdly esoteric

This commit is contained in:
yrsegal@gmail.com 2022-04-27 00:02:03 -04:00
parent 7e7c38b681
commit 139b2805ee
3 changed files with 49 additions and 4 deletions

View file

@ -29,13 +29,17 @@ 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.TextColor;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.Mth;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.properties.ComparatorMode;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.material.MaterialColor;
import net.minecraftforge.client.event.EntityRenderersEvent;
import net.minecraftforge.client.event.ParticleFactoryRegisterEvent;
import net.minecraftforge.eventbus.api.EventPriority;
@ -111,6 +115,28 @@ public class RegisterClientStuff {
}
});
ScryingLensOverlayRegistry.addDisplayer(Blocks.NOTE_BLOCK,
(lines, state, pos, observer, world, direction, lensHand) -> {
int note = state.getValue(NoteBlock.NOTE);
float rCol = Math.max(0.0F, Mth.sin((note / 24F + 0.0F) * Mth.TWO_PI) * 0.65F + 0.35F);
float gCol = Math.max(0.0F, Mth.sin((note / 24F + 0.33333334F) * Mth.TWO_PI) * 0.65F + 0.35F);
float bCol = Math.max(0.0F, Mth.sin((note / 24F + 0.6666667F) * Mth.TWO_PI) * 0.65F + 0.35F);
int noteColor = 0xFF000000 | ((int) (rCol * 0xFF) << 16) | ((int) (gCol * 0xFF) << 8) | ((int) (bCol * 0xFF));
var instrument = state.getValue(NoteBlock.INSTRUMENT);
lines.add(new Pair<>(
new ItemStack(Items.MUSIC_DISC_CHIRP),
new TextComponent(String.valueOf(instrument.ordinal()))
.withStyle((style) -> style.withColor(TextColor.fromRgb(instrumentColor(instrument))))));
lines.add(new Pair<>(
new ItemStack(Items.NOTE_BLOCK),
new TextComponent(String.valueOf(note))
.withStyle((style) -> style.withColor(TextColor.fromRgb(noteColor)))));
});
ScryingLensOverlayRegistry.addDisplayer(HexBlocks.AKASHIC_BOOKSHELF.get(),
(lines, state, pos, observer, world, direction, lensHand) -> {
if (world.getBlockEntity(pos) instanceof BlockEntityAkashicBookshelf tile) {
@ -189,6 +215,25 @@ public class RegisterClientStuff {
});
}
private static int instrumentColor(NoteBlockInstrument instrument) {
return switch(instrument) {
case BASEDRUM -> MaterialColor.STONE.col;
case SNARE, XYLOPHONE, PLING -> MaterialColor.SAND.col;
case HAT -> MaterialColor.QUARTZ.col;
case BASS -> MaterialColor.WOOD.col;
case FLUTE -> MaterialColor.CLAY.col;
case BELL -> MaterialColor.GOLD.col;
case GUITAR -> MaterialColor.WOOL.col;
case CHIME -> MaterialColor.ICE.col;
case IRON_XYLOPHONE -> MaterialColor.METAL.col;
case COW_BELL -> MaterialColor.COLOR_BROWN.col;
case DIDGERIDOO -> MaterialColor.COLOR_ORANGE.col;
case BIT -> MaterialColor.EMERALD.col;
case BANJO -> MaterialColor.COLOR_YELLOW.col;
default -> -1;
};
}
private static void registerDataHolderOverrides(DataHolderItem item) {
ItemProperties.register((Item) item, ItemFocus.DATATYPE_PRED,
(stack, level, holder, holderID) -> {

View file

@ -49,8 +49,8 @@ class GridSoundInstance(val player: Player) : AbstractTickableSoundInstance(HexS
}
private fun calculateVectorFromPitchAndYaw(pitch: Float, yaw: Float): Vec3 {
val radiansPitch = pitch * (Math.PI.toFloat() / 180f)
val radiansYaw = -yaw * (Math.PI.toFloat() / 180f)
val radiansPitch = pitch * Mth.DEG_TO_RAD
val radiansYaw = -yaw * Mth.DEG_TO_RAD
val xComponent = Mth.cos(radiansYaw).toDouble()
val zComponent = Mth.sin(radiansYaw).toDouble()
val azimuthHorizontal = Mth.cos(radiansPitch).toDouble()

View file

@ -816,8 +816,8 @@
"hexcasting.page.basic_spell.explode.fire.2": "Costs three $(l:items/amethyst)$(item)Amethyst Shards/$, plus about one extra $(l:items/amethyst)$(item)Amethyst Shard/$ per point of explosion power. Otherwise, the same as $(l:patterns/spells/basic#hexcasting:explode)$(action)Explosion/$, except with fire.",
"hexcasting.page.basic_spell.add_motion": "Remove an entity and direction from the stack, then give a shove to the given entity in the given direction. The strength of the impulse is determined by the length of the vector.$(br)Costs units of $(l:items/amethyst)$(item)Amethyst Dust/$ equal to the square of the length of the vector.",
"hexcasting.page.basic_spell.blink": "Remove an entity and length from the stack, then teleport the given entity along its look vector by the given length.$(br)Costs about 1 $(l:items/amethyst)$(item)Amethyst Shard/$ per block travelled.",
"hexcasting.page.basic_spell.beep.1": "Remove a vector and two numbers from the stack. Plays a instrument defined by the first number at the given location, with a note defined by the second number. Costs a negligible amount of _media.",
"hexcasting.page.basic_spell.beep.2": "There appear to be 16 different instruments and 25 different notes. Both are indexed by zero.$(br2)These seem to be the same instruments I can produce with a $(item)Note Block/$, though the reason for each instrument's number being what it is eludes me.",
"hexcasting.page.basic_spell.beep.1": "Remove a vector and two numbers from the stack. Plays an $(thing)instrument/$ defined by the first number at the given location, with a $(thing)note/$ defined by the second number. Costs a negligible amount of _media.",
"hexcasting.page.basic_spell.beep.2": "There appear to be 16 different $(thing)instruments/$ and 25 different $(thing)notes/$. Both are indexed by zero.$(br2)These seem to be the same instruments I can produce with a $(item)Note Block/$, though the reason for each instrument's number being what it is eludes me.$(br2)Either way, I can find the numbers I need to use by inspecting a $(item)Note Block/$ through a $(l:items/lens)$(item)Scrying Lens/$.",
"hexcasting.entry.blockworks": "Blockworks",
"hexcasting.page.blockworks.place_block": "Remove a location from the stack, then pick a block item and place it at the given location.$(br)Costs about 1 $(l:items/amethyst)$(item)Amethyst Dust/$.",