52 lines
2.3 KiB
Diff
52 lines
2.3 KiB
Diff
--- a/net/minecraft/item/MusicDiscItem.java
|
|
+++ b/net/minecraft/item/MusicDiscItem.java
|
|
@@ -22,17 +22,40 @@
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
|
|
public class MusicDiscItem extends Item {
|
|
+ @Deprecated // Forge: refer to WorldRender#playRecord. Modders: there's no need to reflectively modify this map!
|
|
private static final Map<SoundEvent, MusicDiscItem> field_150928_b = Maps.newHashMap();
|
|
private final int field_195977_c;
|
|
+ @Deprecated // Forge: refer to soundSupplier
|
|
private final SoundEvent field_185076_b;
|
|
+ private final java.util.function.Supplier<SoundEvent> soundSupplier;
|
|
|
|
+ @Deprecated // Forge: Use the constructor that takes a supplier instead
|
|
public MusicDiscItem(int p_i48475_1_, SoundEvent p_i48475_2_, Item.Properties p_i48475_3_) {
|
|
super(p_i48475_3_);
|
|
this.field_195977_c = p_i48475_1_;
|
|
this.field_185076_b = p_i48475_2_;
|
|
field_150928_b.put(this.field_185076_b, this);
|
|
+ this.soundSupplier = this.field_185076_b.delegate;
|
|
}
|
|
|
|
+ /**
|
|
+ * For mod use, allows to create a music disc without having to create a new
|
|
+ * SoundEvent before their registry event is fired.
|
|
+ *
|
|
+ * @param comparatorValue The value this music disc should output on the comparator. Must be between 0 and 15.
|
|
+ * @param soundSupplier A supplier that provides the sound that should be played. Use a
|
|
+ * {@link net.minecraftforge.fml.RegistryObject}{@code <SoundEvent>} or a
|
|
+ * {@link net.minecraftforge.registries.IRegistryDelegate} for this parameter.
|
|
+ * @param builder A set of {@link Item.Properties} that describe this item.
|
|
+ */
|
|
+ public MusicDiscItem(int comparatorValue, java.util.function.Supplier<SoundEvent> soundSupplier, Item.Properties builder)
|
|
+ {
|
|
+ super(builder);
|
|
+ this.field_195977_c = comparatorValue;
|
|
+ this.field_185076_b = null;
|
|
+ this.soundSupplier = soundSupplier;
|
|
+ }
|
|
+
|
|
public ActionResultType func_195939_a(ItemUseContext p_195939_1_) {
|
|
World world = p_195939_1_.func_195991_k();
|
|
BlockPos blockpos = p_195939_1_.func_195995_a();
|
|
@@ -77,6 +100,6 @@
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
public SoundEvent func_185075_h() {
|
|
- return this.field_185076_b;
|
|
+ return this.soundSupplier.get();
|
|
}
|
|
}
|