1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-23 16:44:50 +00:00

Use custom packet to play records, instead of using block events

Breaking a disk drive was not stopping the record being played as the
block event never reached the client. Instead, we send a custom packet
which starts/stops music at a given location.

We also remove all the plumbing for eventReceived/sendBlockEvent from
the generic block/tile classes, as they are no longer used.

Closes #443
This commit is contained in:
SquidDev
2017-09-12 15:46:46 +01:00
parent 1fdfcdb5f2
commit afec3743f3
8 changed files with 46 additions and 77 deletions

View File

@@ -145,7 +145,22 @@ public abstract class ComputerCraftProxyCommon implements IComputerCraftProxy
}
@Override
public abstract void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos );
public void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos )
{
ComputerCraftPacket packet = new ComputerCraftPacket();
packet.m_packetType = ComputerCraftPacket.PlayRecord;
if( record != null )
{
packet.m_dataInt = new int[] { pos.getX(), pos.getY(), pos.getZ(), SoundEvent.REGISTRY.getIDForObject( record ) };
packet.m_dataString = new String[] { recordInfo };
}
else
{
packet.m_dataInt = new int[] { pos.getX(), pos.getY(), pos.getZ() };
}
ComputerCraft.sendToAllPlayers( packet );
}
@Override
public abstract Object getDiskDriveGUI( InventoryPlayer inventory, TileDiskDrive drive );