fix: multiplayer crash
This commit is contained in:
parent
a26d553b81
commit
8df255fb8b
4 changed files with 42 additions and 5 deletions
|
@ -24,7 +24,7 @@ apply from: './gradle/scripts/mixins.gradle'
|
|||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
version = "1.7.0"
|
||||
version = "1.7.1"
|
||||
group= "dev.tilera.modding"
|
||||
archivesBaseName = "cwg"
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package dev.tilera.cwg;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
|
@ -9,7 +10,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
|||
import dev.tilera.cwg.caves.MapGenCavesSwiss;
|
||||
import dev.tilera.cwg.command.CommandChangeWorld;
|
||||
import dev.tilera.cwg.noisegen.NoiseGeneratorOctavesFarlands;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import dev.tilera.cwg.proxy.CommonProxy;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
@ -27,6 +28,8 @@ public class ClassicWorldgen {
|
|||
|
||||
@Mod.Instance
|
||||
public static ClassicWorldgen INSTANCE;
|
||||
@SidedProxy(modId = Constants.ID, serverSide = "dev.tilera.cwg.proxy.CommonProxy", clientSide = "dev.tilera.cwg.proxy.ClientProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
@ -70,9 +73,7 @@ public class ClassicWorldgen {
|
|||
}
|
||||
|
||||
public static boolean isClassicWorld() {
|
||||
World[] worlds = MinecraftServer.getServer().worldServers;
|
||||
if (worlds.length == 0) return true;
|
||||
World world = worlds[0];
|
||||
World world = proxy.getWorld();
|
||||
if (world == null) return true;
|
||||
return isClassicWorld(world);
|
||||
}
|
||||
|
|
22
src/main/java/dev/tilera/cwg/proxy/ClientProxy.java
Normal file
22
src/main/java/dev/tilera/cwg/proxy/ClientProxy.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
package dev.tilera.cwg.proxy;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
World world = null;
|
||||
if (MinecraftServer.getServer() != null) {
|
||||
World[] worlds = MinecraftServer.getServer().worldServers;
|
||||
if (worlds.length == 0) return null;
|
||||
world = worlds[0];
|
||||
} else if (Minecraft.getMinecraft() != null) {
|
||||
world = Minecraft.getMinecraft().theWorld;
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
}
|
14
src/main/java/dev/tilera/cwg/proxy/CommonProxy.java
Normal file
14
src/main/java/dev/tilera/cwg/proxy/CommonProxy.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package dev.tilera.cwg.proxy;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class CommonProxy {
|
||||
|
||||
public World getWorld() {
|
||||
World[] worlds = MinecraftServer.getServer().worldServers;
|
||||
if (worlds.length == 0) return null;
|
||||
return worlds[0];
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue