Skip to content

Commit 2de9eec

Browse files
committed
こうしん
1 parent 152f8ae commit 2de9eec

3 files changed

Lines changed: 39 additions & 2 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sourceCompatibility = JavaVersion.VERSION_1_8
77
targetCompatibility = JavaVersion.VERSION_1_8
88

99
archivesBaseName = project.archives_base_name
10-
version = project.mod_version
10+
version = minecraft_version + "-" + project.mod_version
1111
group = project.maven_group
1212

1313
dependencies {

src/main/java/net/gorayan/mc/noteduplicator/mixin/BlockMixin.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package net.gorayan.mc.noteduplicator.mixin;
22

3+
import javafx.scene.control.TextFormatter;
34
import net.minecraft.block.Block;
45
import net.minecraft.block.BlockState;
56
import net.minecraft.block.NoteBlock;
67
import net.minecraft.item.ItemStack;
78
import net.minecraft.nbt.CompoundTag;
9+
import net.minecraft.text.LiteralText;
10+
import net.minecraft.text.TextColor;
811
import net.minecraft.util.math.BlockPos;
912
import net.minecraft.world.BlockView;
1013
import org.spongepowered.asm.mixin.Mixin;
@@ -25,7 +28,40 @@ private void inject(BlockView world, BlockPos pos, BlockState state, CallbackInf
2528
ItemStack itemStack = cir.getReturnValue();
2629
itemStack.setTag(new CompoundTag());
2730
itemStack.getTag().putInt("note", i);
31+
itemStack.setCustomName(new LiteralText("\u00A7" + "f" + getNoteName(i) + " " + i));
2832

2933
}
3034

35+
private String getNoteName(int i) {
36+
int mod = i % 12;
37+
switch (mod) {
38+
case 0:
39+
return "F#";
40+
case 1:
41+
return "G";
42+
case 2:
43+
return "G#";
44+
case 3:
45+
return "A";
46+
case 4:
47+
return "A#";
48+
case 5:
49+
return "B";
50+
case 6:
51+
return "C";
52+
case 7:
53+
return "C#";
54+
case 8:
55+
return "D";
56+
case 9:
57+
return "D#";
58+
case 10:
59+
return "E";
60+
case 11:
61+
return "F";
62+
default:
63+
return null;
64+
}
65+
}
66+
3167
}

src/main/java/net/gorayan/mc/noteduplicator/mixin/NoteBlockMixin.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import net.minecraft.item.ItemStack;
88
import net.minecraft.nbt.CompoundTag;
99
import net.minecraft.util.math.BlockPos;
10+
import net.minecraft.util.math.MathHelper;
1011
import net.minecraft.world.BlockView;
1112
import org.spongepowered.asm.mixin.Mixin;
1213
import org.spongepowered.asm.mixin.injection.At;
@@ -26,7 +27,7 @@ private void inject(ItemPlacementContext ctx, CallbackInfoReturnable<BlockState>
2627
int i = compoundTag.getInt("note");
2728

2829
BlockState blockState = cir.getReturnValue();
29-
cir.setReturnValue(blockState.with(NoteBlock.NOTE, i));
30+
cir.setReturnValue(blockState.with(NoteBlock.NOTE, MathHelper.clamp(i, 0, 24)));
3031

3132
}
3233

0 commit comments

Comments
 (0)