mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 14:24:35 +00:00
Remove voice server functionality; there's plenty of other systems out there that do this (and better)
This commit is contained in:
1 parent
53181aae64
commit
f05391062f
10 files changed
-344
No files matched your search
@@ -1,43 +0,0 @@
|
||||
package mekanism.client;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import mekanism.client.voice.VoiceClient;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ClientConnectionHandler
|
||||
{
|
||||
@SubscribeEvent
|
||||
public void onConnection(ClientConnectedToServerEvent event)
|
||||
{
|
||||
if(general.voiceServerEnabled)
|
||||
{
|
||||
if(event.isLocal())
|
||||
{
|
||||
//If the client is connecting to its own corresponding integrated server.
|
||||
try {
|
||||
MekanismClient.voiceClient = new VoiceClient("127.0.0.1");
|
||||
//Will probably not work when multiple integrateds are running on one computer
|
||||
} catch(Throwable e) {
|
||||
Mekanism.logger.error("Unable to establish VoiceClient on local connection.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
//If the client is connecting to a foreign integrated or dedicated server.
|
||||
try {
|
||||
MekanismClient.voiceClient = new VoiceClient(((InetSocketAddress)event.getManager().getRemoteAddress()).getHostString());
|
||||
} catch(Throwable e) {
|
||||
Mekanism.logger.error("Unable to establish VoiceClient on remote connection.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1032,7 +1032,6 @@ public class ClientProxy extends CommonProxy
|
||||
return (int)(dye.getColor(0)*255) << 16 | (int)(dye.getColor(1)*255) << 8 | (int)(dye.getColor(2)*255);
|
||||
}, MekanismItems.Balloon);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(new ClientConnectionHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new ClientPlayerTracker());
|
||||
MinecraftForge.EVENT_BUS.register(new ClientTickHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new RenderTickHandler());
|
||||
@@ -1099,17 +1098,6 @@ public class ClientProxy extends CommonProxy
|
||||
return Minecraft.getMinecraft().gameDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigSync(boolean fromPacket)
|
||||
{
|
||||
super.onConfigSync(fromPacket);
|
||||
|
||||
if(fromPacket && general.voiceServerEnabled && MekanismClient.voiceClient != null)
|
||||
{
|
||||
MekanismClient.voiceClient.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPlayer getPlayer(MessageContext context)
|
||||
{
|
||||
|
||||
@@ -8,10 +8,8 @@ import mekanism.api.MekanismAPI;
|
||||
import mekanism.api.MekanismAPI.BoxBlacklistEvent;
|
||||
import mekanism.client.render.obj.TransmitterModel;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.client.voice.VoiceClient;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IModule;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import mekanism.common.content.boiler.SynchronizedBoilerData;
|
||||
import mekanism.common.network.PacketKey.KeyMessage;
|
||||
import mekanism.common.security.SecurityData;
|
||||
@@ -23,8 +21,6 @@ public class MekanismClient extends Mekanism
|
||||
{
|
||||
public static Map<UUID, SecurityData> clientSecurityMap = new HashMap<>();
|
||||
public static Map<UUID, String> clientUUIDMap = new HashMap<>();
|
||||
|
||||
public static VoiceClient voiceClient;
|
||||
|
||||
public static long ticksPassed = 0;
|
||||
|
||||
@@ -43,15 +39,6 @@ public class MekanismClient extends Mekanism
|
||||
{
|
||||
clientSecurityMap.clear();
|
||||
clientUUIDMap.clear();
|
||||
|
||||
if(general.voiceServerEnabled)
|
||||
{
|
||||
if(MekanismClient.voiceClient != null)
|
||||
{
|
||||
MekanismClient.voiceClient.disconnect();
|
||||
MekanismClient.voiceClient = null;
|
||||
}
|
||||
}
|
||||
|
||||
ClientTickHandler.tickingSet.clear();
|
||||
ClientTickHandler.portableTeleports.clear();
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
package mekanism.client.voice;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.net.ConnectException;
|
||||
import java.net.Socket;
|
||||
|
||||
import javax.sound.sampled.AudioFormat;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.config.MekanismConfig.general;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class VoiceClient extends Thread
|
||||
{
|
||||
public Socket socket;
|
||||
|
||||
public String ip;
|
||||
|
||||
public AudioFormat format = new AudioFormat(16000F, 16, 1, true, true);
|
||||
|
||||
public VoiceInput inputThread;
|
||||
public VoiceOutput outputThread;
|
||||
|
||||
public DataInputStream input;
|
||||
public DataOutputStream output;
|
||||
|
||||
public boolean running;
|
||||
|
||||
public VoiceClient(String s)
|
||||
{
|
||||
ip = s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Mekanism.logger.info("VoiceServer: Starting client connection...");
|
||||
|
||||
try {
|
||||
socket = new Socket(ip, general.VOICE_PORT);
|
||||
running = true;
|
||||
|
||||
input = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
|
||||
output = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
|
||||
|
||||
(outputThread = new VoiceOutput(this)).start();
|
||||
(inputThread = new VoiceInput(this)).start();
|
||||
|
||||
Mekanism.logger.info("VoiceServer: Successfully connected to server.");
|
||||
} catch(ConnectException e) {
|
||||
Mekanism.logger.error("VoiceServer: Server's VoiceServer is disabled.");
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while starting client connection.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void disconnect()
|
||||
{
|
||||
Mekanism.logger.info("VoiceServer: Stopping client connection...");
|
||||
|
||||
try {
|
||||
inputThread.interrupt();
|
||||
outputThread.interrupt();
|
||||
inputThread.close();
|
||||
outputThread.close();
|
||||
output.close();
|
||||
input.close();
|
||||
socket.close();
|
||||
|
||||
interrupt();
|
||||
|
||||
running = false;
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while stopping client connection.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package mekanism.client.voice;
|
||||
|
||||
import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.DataLine;
|
||||
import javax.sound.sampled.TargetDataLine;
|
||||
|
||||
import mekanism.client.MekanismKeyHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class VoiceInput extends Thread
|
||||
{
|
||||
private VoiceClient voiceClient;
|
||||
|
||||
private DataLine.Info microphone;
|
||||
|
||||
private TargetDataLine targetLine;
|
||||
|
||||
public VoiceInput(VoiceClient client)
|
||||
{
|
||||
voiceClient = client;
|
||||
microphone = new DataLine.Info(TargetDataLine.class, voiceClient.format, 2200);
|
||||
|
||||
setDaemon(true);
|
||||
setName("VoiceServer Client Input Thread");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try {
|
||||
if(!AudioSystem.isLineSupported(microphone))
|
||||
{
|
||||
Mekanism.logger.info("No audio system available.");
|
||||
return;
|
||||
}
|
||||
targetLine = ((TargetDataLine)AudioSystem.getLine(microphone));
|
||||
targetLine.open(voiceClient.format, 2200);
|
||||
targetLine.start();
|
||||
AudioInputStream audioInput = new AudioInputStream(targetLine);
|
||||
|
||||
boolean doFlush = false;
|
||||
|
||||
while(voiceClient.running)
|
||||
{
|
||||
if(MekanismKeyHandler.voiceKey.isPressed())
|
||||
{
|
||||
targetLine.flush();
|
||||
|
||||
while(voiceClient.running && MekanismKeyHandler.voiceKey.isPressed())
|
||||
{
|
||||
try {
|
||||
int availableBytes = audioInput.available();
|
||||
byte[] audioData = new byte[availableBytes > 2200 ? 2200 : availableBytes];
|
||||
int bytesRead = audioInput.read(audioData, 0, audioData.length);
|
||||
|
||||
if(bytesRead > 0)
|
||||
{
|
||||
voiceClient.output.writeShort(audioData.length);
|
||||
voiceClient.output.write(audioData);
|
||||
}
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(200L);
|
||||
} catch(Exception e) {}
|
||||
|
||||
doFlush = true;
|
||||
}
|
||||
else if(doFlush)
|
||||
{
|
||||
try {
|
||||
voiceClient.output.flush();
|
||||
} catch(Exception e) {}
|
||||
|
||||
doFlush = false;
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(20L);
|
||||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
audioInput.close();
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while running client input thread.", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
if(targetLine != null)
|
||||
{
|
||||
targetLine.flush();
|
||||
targetLine.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
package mekanism.client.voice;
|
||||
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
import javax.sound.sampled.DataLine;
|
||||
import javax.sound.sampled.SourceDataLine;
|
||||
import java.io.EOFException;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class VoiceOutput extends Thread
|
||||
{
|
||||
public VoiceClient voiceClient;
|
||||
|
||||
public DataLine.Info speaker;
|
||||
|
||||
public SourceDataLine sourceLine;
|
||||
|
||||
public VoiceOutput(VoiceClient client)
|
||||
{
|
||||
voiceClient = client;
|
||||
speaker = new DataLine.Info(SourceDataLine.class, voiceClient.format, 2200);
|
||||
|
||||
setDaemon(true);
|
||||
setName("VoiceServer Client Output Thread");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try {
|
||||
sourceLine = ((SourceDataLine)AudioSystem.getLine(speaker));
|
||||
sourceLine.open(voiceClient.format, 2200);
|
||||
sourceLine.start();
|
||||
byte[] audioData = new byte[4096]; // less allocation/gc (if done outside the loop)
|
||||
int byteCount;
|
||||
int length;
|
||||
while(voiceClient.running)
|
||||
{
|
||||
try {
|
||||
byteCount = voiceClient.input.readUnsignedShort(); //Why would we only read signed shorts? negative amount of waiting data doesn't make sense anyway :D
|
||||
while(byteCount>0 && voiceClient.running){
|
||||
length=audioData.length;
|
||||
if(length>byteCount) length=byteCount;
|
||||
length = voiceClient.input.read(audioData, 0, length); // That one returns the actual read amount of data (we can begin transferring even if input is waiting/incomplete)
|
||||
if(length<0) throw new EOFException();
|
||||
sourceLine.write(audioData, 0, length);
|
||||
byteCount-=length;
|
||||
}
|
||||
} catch(EOFException eof){
|
||||
Mekanism.logger.error("VoiceServer: Unexpected input EOF Exception occured.");
|
||||
break; // voiceClient.input will continue throwing EOFs -> no need to go on checking
|
||||
} catch(Exception e) {
|
||||
/*Would a debug output be good here?*/
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
Mekanism.logger.error("VoiceServer: Error while running client output thread.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
sourceLine.flush();
|
||||
sourceLine.close();
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,6 @@ public class CommonProxy implements IGuiProvider
|
||||
general.controlCircuitOreDict = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ControlCircuitOreDict", true).getBoolean();
|
||||
general.logPackets = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "LogPackets", false).getBoolean();
|
||||
general.dynamicTankEasterEgg = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DynamicTankEasterEgg", false).getBoolean();
|
||||
general.voiceServerEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoiceServerEnabled", true).getBoolean();
|
||||
general.cardboardSpawners = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowSpawnerBoxPickup", true).getBoolean();
|
||||
general.enableWorldRegeneration = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableWorldRegeneration", false).getBoolean();
|
||||
general.spawnBabySkeletons = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "SpawnBabySkeletons", true).getBoolean();
|
||||
|
||||
@@ -675,22 +675,12 @@ public class Mekanism
|
||||
@EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent event)
|
||||
{
|
||||
if(general.voiceServerEnabled)
|
||||
{
|
||||
voiceManager.start();
|
||||
}
|
||||
|
||||
event.registerServerCommand(new CommandMekanism());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverStopping(FMLServerStoppingEvent event)
|
||||
{
|
||||
if(general.voiceServerEnabled)
|
||||
{
|
||||
voiceManager.stop();
|
||||
}
|
||||
|
||||
//Clear all cache data
|
||||
jetpackOn.clear();
|
||||
gasmaskOn.clear();
|
||||
@@ -800,12 +790,6 @@ public class Mekanism
|
||||
//Register this module's GUI handler in the simple packet protocol
|
||||
PacketSimpleGui.handlers.add(0, proxy);
|
||||
|
||||
//Set up VoiceServerManager
|
||||
if(general.voiceServerEnabled)
|
||||
{
|
||||
voiceManager = new VoiceServerManager();
|
||||
}
|
||||
|
||||
//Register with TransmitterNetworkRegistry
|
||||
TransmitterNetworkRegistry.initiate();
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ public class MekanismConfig
|
||||
public static boolean controlCircuitOreDict = true;
|
||||
public static boolean logPackets = false;
|
||||
public static boolean dynamicTankEasterEgg = false;
|
||||
public static boolean voiceServerEnabled = true;
|
||||
public static boolean cardboardSpawners = true;
|
||||
public static boolean enableWorldRegeneration = true;
|
||||
public static boolean spawnBabySkeletons = true;
|
||||
|
||||
@@ -32,7 +32,6 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||
dataStream.writeBoolean(general.controlCircuitOreDict);
|
||||
dataStream.writeBoolean(general.logPackets);
|
||||
dataStream.writeBoolean(general.dynamicTankEasterEgg);
|
||||
dataStream.writeBoolean(general.voiceServerEnabled);
|
||||
dataStream.writeBoolean(general.cardboardSpawners);
|
||||
dataStream.writeBoolean(general.spawnBabySkeletons);
|
||||
dataStream.writeInt(general.obsidianTNTDelay);
|
||||
@@ -132,7 +131,6 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||
general.controlCircuitOreDict = dataStream.readBoolean();
|
||||
general.logPackets = dataStream.readBoolean();
|
||||
general.dynamicTankEasterEgg = dataStream.readBoolean();
|
||||
general.voiceServerEnabled = dataStream.readBoolean();
|
||||
general.cardboardSpawners = dataStream.readBoolean();
|
||||
general.spawnBabySkeletons = dataStream.readBoolean();
|
||||
general.obsidianTNTDelay = dataStream.readInt();
|
||||
|
||||
Reference in new issue
Block a user