Add the ability for custom records to have finer control over there sound resource location. Closes #933

This commit is contained in:
Lex Manos 2014-01-24 17:16:35 -08:00
parent 796b53f549
commit c62061728b
2 changed files with 52 additions and 0 deletions

View file

@ -111,3 +111,20 @@
double d0 = par2EntityPlayer.lastTickPosX + (par2EntityPlayer.posX - par2EntityPlayer.lastTickPosX) * (double)par3;
double d1 = par2EntityPlayer.lastTickPosY + (par2EntityPlayer.posY - par2EntityPlayer.lastTickPosY) * (double)par3;
double d2 = par2EntityPlayer.lastTickPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.lastTickPosZ) * (double)par3;
@@ -1839,12 +1873,15 @@
{
ItemRecord itemrecord = ItemRecord.func_150926_b(par1Str);
+ ResourceLocation resource = null;
if (itemrecord != null)
{
this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.func_150927_i());
+ resource = itemrecord.getRecordResource(par1Str);
}
- PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.func_147675_a(new ResourceLocation(par1Str), (float)par2, (float)par3, (float)par4);
+ if (resource == null) resource = new ResourceLocation(par1Str);
+ PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.func_147675_a(resource, (float)par2, (float)par3, (float)par4);
this.field_147593_P.put(chunkcoordinates, positionedsoundrecord);
this.mc.func_147118_V().func_147682_a(positionedsoundrecord);
}

View file

@ -0,0 +1,35 @@
--- ../src-base/minecraft/net/minecraft/item/ItemRecord.java
+++ ../src-work/minecraft/net/minecraft/item/ItemRecord.java
@@ -10,6 +10,7 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.util.IIcon;
+import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
@@ -24,7 +25,7 @@
this.field_150929_a = p_i45350_1_;
this.maxStackSize = 1;
this.setCreativeTab(CreativeTabs.tabMisc);
- field_150928_b.put(p_i45350_1_, this);
+ field_150928_b.put("records." + p_i45350_1_, this); //Forge Bug Fix: RenderGlobal adds a "records." when looking up below.
}
// JAVADOC METHOD $$ func_77617_a
@@ -81,4 +82,15 @@
{
return (ItemRecord)field_150928_b.get(p_150926_0_);
}
+
+ /**
+ * Retrieves the resource location of the sound to play for this record.
+ *
+ * @param name The name of the record to play
+ * @return The resource location for the audio, null to use default.
+ */
+ public ResourceLocation getRecordResource(String name)
+ {
+ return new ResourceLocation(name);
+ }
}