mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-08-04 21:03:58 +00:00
Fix speaker peripheral API
This commit is contained in:
parent
2444245b80
commit
2899246dbc
@ -104,8 +104,8 @@ public class SpeakerPeripheral implements IPeripheral {
|
|||||||
|
|
||||||
private Object[] playNote(Object[] arguments) throws LuaException
|
private Object[] playNote(Object[] arguments) throws LuaException
|
||||||
{
|
{
|
||||||
float volume = 1f;
|
double volume = 1f;
|
||||||
float pitch = 1f;
|
double pitch = 1f;
|
||||||
|
|
||||||
// Check if arguments are correct
|
// Check if arguments are correct
|
||||||
if (arguments.length == 0) // Too few args
|
if (arguments.length == 0) // Too few args
|
||||||
@ -114,7 +114,7 @@ public class SpeakerPeripheral implements IPeripheral {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(arguments[0] instanceof String)) // Arg wrong type
|
if (!(arguments[0] instanceof String)) // Arg wrong type
|
||||||
{
|
{
|
||||||
throw new LuaException("Expected string, number (optional), number (optional)");
|
throw new LuaException("Expected string, number (optional), number (optional)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ public class SpeakerPeripheral implements IPeripheral {
|
|||||||
|
|
||||||
if (arguments.length > 1)
|
if (arguments.length > 1)
|
||||||
{
|
{
|
||||||
if (!(arguments[1] instanceof Double)) // Arg wrong type
|
if (!(arguments[1] instanceof Double)) // Arg wrong type
|
||||||
{
|
{
|
||||||
throw new LuaException("Expected string, number (optional), number (optional)");
|
throw new LuaException("Expected string, number (optional), number (optional)");
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ public class SpeakerPeripheral implements IPeripheral {
|
|||||||
|
|
||||||
if (arguments.length > 2)
|
if (arguments.length > 2)
|
||||||
{
|
{
|
||||||
if (!(arguments[2] instanceof Double)) // Arg wrong type
|
if (!(arguments[1] instanceof Double)) // Arg wrong type
|
||||||
{
|
{
|
||||||
throw new LuaException("Expected string, number (optional), number (optional)");
|
throw new LuaException("Expected string, number (optional), number (optional)");
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ public class SpeakerPeripheral implements IPeripheral {
|
|||||||
throw new LuaException("Expected string, number (optional), number (optional)");
|
throw new LuaException("Expected string, number (optional), number (optional)");
|
||||||
}
|
}
|
||||||
|
|
||||||
return playSound(new Object[] {"block.note." + arguments[0], volume, pitch});
|
return playSound(new Object[] {"block.note." + arguments[0], volume, Math.pow(2d, (pitch - 12) / 12d)});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ public class SpeakerPeripheral implements IPeripheral {
|
|||||||
|
|
||||||
if (arguments.length > 2)
|
if (arguments.length > 2)
|
||||||
{
|
{
|
||||||
if (!(arguments[2] instanceof Double)) // Arg wrong type
|
if (!(arguments[1] instanceof Double)) // Arg wrong type
|
||||||
{
|
{
|
||||||
throw new LuaException("Expected string, number (optional), number (optional)");
|
throw new LuaException("Expected string, number (optional), number (optional)");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user