1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-11-15 12:37:13 +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

@@ -46,11 +46,6 @@ import static net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABI
public class TileDiskDrive extends TilePeripheralBase
implements IInventory, ITickable
{
// Statics
private static final int BLOCKEVENT_PLAY_RECORD = 0;
private static final int BLOCKEVENT_STOP_RECORD = 1;
private static class MountInfo
{
public String mountPath;
@@ -90,7 +85,7 @@ public class TileDiskDrive extends TilePeripheralBase
{
if( m_recordPlaying )
{
sendBlockEvent( BLOCKEVENT_STOP_RECORD );
stopRecord();
}
}
}
@@ -188,7 +183,7 @@ public class TileDiskDrive extends TilePeripheralBase
// Music
synchronized( this )
{
if( m_recordPlaying != m_recordQueued || m_restartRecord )
if( !world.isRemote && m_recordPlaying != m_recordQueued || m_restartRecord )
{
m_restartRecord = false;
if( m_recordQueued )
@@ -198,7 +193,7 @@ public class TileDiskDrive extends TilePeripheralBase
if( record != null )
{
m_recordPlaying = true;
sendBlockEvent( BLOCKEVENT_PLAY_RECORD );
playRecord();
}
else
{
@@ -207,7 +202,7 @@ public class TileDiskDrive extends TilePeripheralBase
}
else
{
sendBlockEvent( BLOCKEVENT_STOP_RECORD );
stopRecord();
m_recordPlaying = false;
}
}
@@ -306,7 +301,7 @@ public class TileDiskDrive extends TilePeripheralBase
// Stop music
if( m_recordPlaying )
{
sendBlockEvent( BLOCKEVENT_STOP_RECORD );
stopRecord();
m_recordPlaying = false;
m_recordQueued = false;
}
@@ -658,25 +653,6 @@ public class TileDiskDrive extends TilePeripheralBase
}
}
@Override
public void onBlockEvent( int eventID, int eventParameter )
{
super.onBlockEvent( eventID, eventParameter );
switch( eventID )
{
case BLOCKEVENT_PLAY_RECORD:
{
playRecord();
break;
}
case BLOCKEVENT_STOP_RECORD:
{
stopRecord();
break;
}
}
}
@Override
public boolean shouldRefresh( World world, BlockPos pos, @Nonnull IBlockState oldState, @Nonnull IBlockState newState )
{