修bug,修收藏图标(可能)
This commit is contained in:
parent
70edd3056f
commit
5ba52d0601
@ -6,7 +6,7 @@ minecraft_version=1.21.4
|
|||||||
yarn_mappings=1.21.4+build.8
|
yarn_mappings=1.21.4+build.8
|
||||||
loader_version=0.16.10
|
loader_version=0.16.10
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.14.514
|
mod_version=1.14.514.013
|
||||||
maven_group=semmiedev
|
maven_group=semmiedev
|
||||||
archives_base_name=disc_jockey
|
archives_base_name=disc_jockey
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
@ -5,12 +5,15 @@ import net.minecraft.client.MinecraftClient;
|
|||||||
import net.minecraft.client.gui.DrawContext;
|
import net.minecraft.client.gui.DrawContext;
|
||||||
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
|
||||||
import net.minecraft.client.gui.widget.EntryListWidget;
|
import net.minecraft.client.gui.widget.EntryListWidget;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import semmiedev.disc_jockey.Main;
|
import semmiedev.disc_jockey.Main;
|
||||||
import semmiedev.disc_jockey.Song;
|
import semmiedev.disc_jockey.Song;
|
||||||
|
|
||||||
public class SongListWidget extends EntryListWidget<SongListWidget.SongEntry> {
|
public class SongListWidget extends EntryListWidget<SongListWidget.SongEntry> {
|
||||||
|
private static final String FAVORITE_EMOJI = "收藏★";
|
||||||
|
private static final String NOT_FAVORITE_EMOJI = "收藏☆";
|
||||||
|
|
||||||
public SongListWidget(MinecraftClient client, int width, int height, int top, int itemHeight) {
|
public SongListWidget(MinecraftClient client, int width, int height, int top, int itemHeight) {
|
||||||
super(client, width, height, top, itemHeight);
|
super(client, width, height, top, itemHeight);
|
||||||
@ -69,8 +72,13 @@ public class SongListWidget extends EntryListWidget<SongListWidget.SongEntry> {
|
|||||||
|
|
||||||
context.drawCenteredTextWithShadow(client.textRenderer, song.displayName, x + entryWidth / 2, y + 5, selected ? 0xFFFFFF : 0x808080);
|
context.drawCenteredTextWithShadow(client.textRenderer, song.displayName, x + entryWidth / 2, y + 5, selected ? 0xFFFFFF : 0x808080);
|
||||||
|
|
||||||
RenderSystem.setShaderTexture(0, ICONS);
|
String emoji = String.valueOf(favorite ? FAVORITE_EMOJI : NOT_FAVORITE_EMOJI);
|
||||||
// context.drawTexture(ICONS, x + 2, y + 2, (favorite ? 26 : 0) + (isOverFavoriteButton(mouseX, mouseY) ? 13 : 0), 0, 13, 12, 52, 12);
|
context.drawTextWithShadow(
|
||||||
|
client.textRenderer,
|
||||||
|
emoji,
|
||||||
|
x + 2, y + 2,
|
||||||
|
favorite ? 0xFFD700 : 0x808080
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -89,7 +97,12 @@ public class SongListWidget extends EntryListWidget<SongListWidget.SongEntry> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOverFavoriteButton(double mouseX, double mouseY) {
|
private boolean isOverFavoriteButton(double mouseX, double mouseY) {
|
||||||
return mouseX > x + 2 && mouseX < x + 15 && mouseY > y + 2 && mouseY < y + 14;
|
int textWidth = client.textRenderer.getWidth(favorite ? FAVORITE_EMOJI : NOT_FAVORITE_EMOJI);
|
||||||
|
int textHeight = 8;
|
||||||
|
return mouseX > x + 2 &&
|
||||||
|
mouseX < x + 2 + textWidth &&
|
||||||
|
mouseY > y + 2 &&
|
||||||
|
mouseY < y + 2 + textHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,12 @@ public class ClientWorldMixin {
|
|||||||
) {
|
) {
|
||||||
if (
|
if (
|
||||||
((Main.config.omnidirectionalNoteBlockSounds && Main.SONG_PLAYER.running) || Main.PREVIEWER.running) &&
|
((Main.config.omnidirectionalNoteBlockSounds && Main.SONG_PLAYER.running) || Main.PREVIEWER.running) &&
|
||||||
// 关键修改点:event.id() 替代 event.getId()
|
|
||||||
event.id().getPath().startsWith("block.note_block")
|
event.id().getPath().startsWith("block.note_block")
|
||||||
) {
|
) {
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
client.getSoundManager().play(
|
client.getSoundManager().play(
|
||||||
new PositionedSoundInstance(
|
new PositionedSoundInstance(
|
||||||
event.id(), // ✅ 同样需要修改此处
|
event.id(),
|
||||||
category,
|
category,
|
||||||
volume,
|
volume,
|
||||||
pitch,
|
pitch,
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
"id": "disc_jockey",
|
"id": "disc_jockey",
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
"name": "Disc Jockey",
|
"name": "Disc Jockey",
|
||||||
"description": "Play note block songs in Minecraft",
|
"description": "在游戏中播放音符盒(打碟)",
|
||||||
"authors": [
|
"authors": [
|
||||||
"SemmieDev",
|
"SemmieDev",
|
||||||
"EnderKill98",
|
"EnderKill98",
|
||||||
"BRanulf(非正式)"
|
"BRanulf(仅限该版本,请支持上面两个原作者)"
|
||||||
],
|
],
|
||||||
"contact": {
|
"contact": {
|
||||||
"repo": "https://github.com/SemmieDev/Disc-Jockey"
|
"repo": "http://git.branulf.top/BRanulf/DJ_BR"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"icon": "assets/disc_jockey/icon.png",
|
"icon": "assets/disc_jockey/icon.png",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user