mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-02-14 10:00:06 +00:00
Fix Speaker not playing sounds on break and replace for entire Lua session
This commit is contained in:
parent
2899246dbc
commit
dc96f2121a
@ -334,6 +334,7 @@ public class BlockPeripheral extends BlockPeripheralBase
|
||||
break;
|
||||
}
|
||||
case Speaker: {
|
||||
state = state.withProperty( Properties.FACING, dir );
|
||||
break;
|
||||
}
|
||||
case Monitor:
|
||||
|
@ -16,7 +16,7 @@ import net.minecraft.util.SoundEvent;
|
||||
|
||||
public class SpeakerPeripheral implements IPeripheral {
|
||||
|
||||
private final TileSpeaker m_speaker;
|
||||
private TileSpeaker m_speaker;
|
||||
private long m_clock;
|
||||
private long m_lastPlayTime;
|
||||
|
||||
@ -27,12 +27,11 @@ public class SpeakerPeripheral implements IPeripheral {
|
||||
m_lastPlayTime = 0;
|
||||
}
|
||||
|
||||
protected void updateClock()
|
||||
void updateClock()
|
||||
{
|
||||
m_clock++;
|
||||
}
|
||||
|
||||
|
||||
/* IPeripheral implementations */
|
||||
|
||||
@Override
|
||||
@ -80,7 +79,6 @@ public class SpeakerPeripheral implements IPeripheral {
|
||||
@Override
|
||||
public Object[] callMethod(IComputerAccess computerAccess, ILuaContext context, int methodIndex, Object[] args) throws LuaException
|
||||
{
|
||||
|
||||
switch (methodIndex)
|
||||
{
|
||||
// playsound
|
||||
@ -96,7 +94,7 @@ public class SpeakerPeripheral implements IPeripheral {
|
||||
|
||||
default:
|
||||
{
|
||||
return null;
|
||||
throw new LuaException("Method index out of range!");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
package dan200.computercraft.shared.peripheral.speaker;
|
||||
|
||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
import dan200.computercraft.shared.peripheral.common.TilePeripheralBase;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@ -18,20 +19,21 @@ public class TileSpeaker extends TilePeripheralBase
|
||||
// Members
|
||||
private SpeakerPeripheral m_peripheral;
|
||||
|
||||
@Override
|
||||
public synchronized void update()
|
||||
public TileSpeaker()
|
||||
{
|
||||
if (m_peripheral != null)
|
||||
{
|
||||
m_peripheral.updateClock();
|
||||
}
|
||||
super();
|
||||
m_peripheral = new SpeakerPeripheral(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void update() {
|
||||
m_peripheral.updateClock();
|
||||
}
|
||||
|
||||
// IPeripheralTile implementation
|
||||
|
||||
public IPeripheral getPeripheral(EnumFacing side)
|
||||
{
|
||||
m_peripheral = new SpeakerPeripheral(this);
|
||||
return m_peripheral;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user