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