mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-15 12:40:30 +00:00
parent
1b39c9f470
commit
2fe40f669d
@ -8,6 +8,9 @@ package dan200.computercraft.shared.peripheral.speaker;
|
|||||||
import dan200.computercraft.api.peripheral.IComputerAccess;
|
import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||||
import dan200.computercraft.shared.network.NetworkHandler;
|
import dan200.computercraft.shared.network.NetworkHandler;
|
||||||
import dan200.computercraft.shared.network.client.SpeakerStopClientMessage;
|
import dan200.computercraft.shared.network.client.SpeakerStopClientMessage;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraftforge.fml.LogicalSide;
|
||||||
|
import net.minecraftforge.fml.LogicalSidedProvider;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -28,6 +31,10 @@ public abstract class UpgradeSpeakerPeripheral extends SpeakerPeripheral
|
|||||||
@Override
|
@Override
|
||||||
public void detach( @Nonnull IComputerAccess computer )
|
public void detach( @Nonnull IComputerAccess computer )
|
||||||
{
|
{
|
||||||
|
// We could be in the process of shutting down the server, so we can't send packets in this case.
|
||||||
|
MinecraftServer server = LogicalSidedProvider.INSTANCE.get( LogicalSide.SERVER );
|
||||||
|
if( server == null || server.isStopped() ) return;
|
||||||
|
|
||||||
NetworkHandler.sendToAllPlayers( new SpeakerStopClientMessage( source ) );
|
NetworkHandler.sendToAllPlayers( new SpeakerStopClientMessage( source ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user