1
0
forked from xjboss/KCauldronX

增加对entity tick的拦截与判定

This commit is contained in:
2017-06-28 08:26:41 +08:00
parent 467c637ca6
commit 05b874f281
8 changed files with 419 additions and 93 deletions

View File

@ -35,7 +35,7 @@
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -80,18 +86,54 @@
@@ -80,18 +86,55 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.WorldEvent;
@ -66,6 +66,7 @@
+import net.minecraft.world.WorldProvider;
+import net.minecraftforge.cauldron.CauldronUtils;
+import net.minecraftforge.cauldron.configuration.CauldronConfig;
+import net.minecraftforge.cauldron.configuration.EntityConfig;
+import net.minecraftforge.cauldron.configuration.TileEntityConfig;
+import net.minecraftforge.common.util.EnumHelper;
+
@ -93,7 +94,7 @@
private final ServerStatusResponse field_147147_p = new ServerStatusResponse();
private final Random field_147146_q = new Random();
@SideOnly(Side.SERVER)
@@ -135,8 +177,40 @@
@@ -135,8 +178,41 @@
private long field_147142_T = 0L;
private final GameProfileRepository field_152365_W;
private final PlayerProfileCache field_152366_X;
@ -118,6 +119,7 @@
+ public static CauldronConfig cauldronConfig;
+ public static KCauldronConfig kcauldronConfig;
+ public static TileEntityConfig tileEntityConfig;
+ public static EntityConfig entityConfig;
+ public static YamlConfiguration configuration;
+ public static YamlConfiguration commandsConfiguration;
+ public static File configFile;
@ -134,7 +136,7 @@
public MinecraftServer(File p_i45281_1_, Proxy p_i45281_2_)
{
this.field_152366_X = new PlayerProfileCache(this, field_152367_a);
@@ -149,10 +223,70 @@
@@ -149,10 +225,72 @@
this.field_152364_T = new YggdrasilAuthenticationService(p_i45281_2_, UUID.randomUUID().toString());
this.field_147143_S = this.field_152364_T.createMinecraftSessionService();
this.field_152365_W = this.field_152364_T.createProfileRepository();
@ -142,6 +144,7 @@
+ kcauldronConfig = new KCauldronConfig();
+ cauldronConfig = new CauldronConfig("cauldron.yml", "cauldron");
+ tileEntityConfig = new TileEntityConfig("tileentities.yml", "cauldron_te");
+ entityConfig = new EntityConfig("entities.yml", "cauldron_e");
}
+ // Cauldron end
@ -162,6 +165,7 @@
+ kcauldronConfig = new KCauldronConfig();
+ cauldronConfig = new CauldronConfig("cauldron.yml", "cauldron");
+ tileEntityConfig = new TileEntityConfig("tileentities.yml", "cauldron_te");
+ entityConfig = new EntityConfig("entities.yml", "cauldron_e");
+ // Cauldron end
+ // CraftBukkit start
+ this.options = options;
@ -206,7 +210,7 @@
protected void convertMapIfNeeded(String p_71237_1_)
{
if (this.getActiveAnvilConverter().isOldMapFormat(p_71237_1_))
@@ -172,6 +306,7 @@
@@ -172,6 +310,7 @@
MinecraftServer.logger.info("Converting... " + p_73718_1_ + "%");
}
}
@ -214,7 +218,7 @@
@SideOnly(Side.CLIENT)
public void resetProgressAndMessage(String p_73721_1_) {}
@SideOnly(Side.CLIENT)
@@ -195,10 +330,17 @@
@@ -195,10 +334,17 @@
protected void loadAllWorlds(String p_71247_1_, String p_71247_2_, long p_71247_3_, WorldType p_71247_5_, String p_71247_6_)
{
@ -234,7 +238,7 @@
WorldSettings worldsettings;
if (worldinfo == null)
@@ -215,11 +357,79 @@
@@ -215,11 +361,79 @@
{
worldsettings.enableBonusChest();
}
@ -317,7 +321,7 @@
world.addWorldAccess(new WorldManager(this, world));
if (!this.isSinglePlayer())
@@ -227,12 +437,14 @@
@@ -227,12 +441,14 @@
world.getWorldInfo().setGameType(this.getGameType());
}
@ -335,7 +339,7 @@
}
protected void initialWorldChunkLoad()
@@ -244,9 +456,12 @@
@@ -244,9 +460,12 @@
int i = 0;
this.setUserMessage("menu.generatingTerrain");
byte b0 = 0;
@ -348,7 +352,7 @@
long j = getSystemTimeMillis();
for (int k = -192; k <= 192 && this.isServerRunning(); k += 16)
@@ -265,7 +480,8 @@
@@ -265,7 +484,8 @@
worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + k >> 4, chunkcoordinates.posZ + l >> 4);
}
}
@ -358,7 +362,7 @@
this.clearCurrentTask();
}
@@ -292,19 +508,17 @@
@@ -292,19 +512,17 @@
{
this.currentTask = null;
this.percentDone = 0;
@ -383,7 +387,7 @@
if (worldserver != null)
{
@@ -313,25 +527,41 @@
@@ -313,25 +531,41 @@
logger.info("Saving chunks for level \'" + worldserver.getWorldInfo().getWorldName() + "\'/" + worldserver.provider.getDimensionName());
}
@ -430,7 +434,7 @@
if (this.func_147137_ag() != null)
{
this.func_147137_ag().terminateEndpoints();
@@ -347,7 +577,14 @@
@@ -347,7 +581,14 @@
if (this.worldServers != null)
{
logger.info("Saving worlds");
@ -446,7 +450,7 @@
for (int i = 0; i < this.worldServers.length; ++i)
{
@@ -380,6 +617,13 @@
@@ -380,6 +621,13 @@
this.serverRunning = false;
}
@ -460,7 +464,7 @@
public void run()
{
try
@@ -392,45 +636,41 @@
@@ -392,45 +640,41 @@
this.field_147147_p.func_151315_a(new ChatComponentText(this.motd));
this.field_147147_p.func_151321_a(new ServerStatusResponse.MinecraftProtocolVersionIdentifier("1.7.10", 5));
this.func_147138_a(this.field_147147_p);
@ -527,7 +531,7 @@
FMLCommonHandler.instance().handleServerStopping();
FMLCommonHandler.instance().expectServerStopped(); // has to come before finalTick to avoid race conditions
}
@@ -448,6 +688,14 @@
@@ -448,6 +692,14 @@
catch (Throwable throwable1)
{
logger.error("Encountered an unexpected exception", throwable1);
@ -542,7 +546,7 @@
CrashReport crashreport = null;
if (throwable1 instanceof ReportedException)
@@ -477,6 +725,7 @@
@@ -477,6 +729,7 @@
{
try
{
@ -550,7 +554,7 @@
this.stopServer();
this.serverStopped = true;
}
@@ -486,6 +735,16 @@
@@ -486,6 +739,16 @@
}
finally
{
@ -567,7 +571,7 @@
FMLCommonHandler.instance().handleServerStopped();
this.serverStopped = true;
this.systemExitNow();
@@ -532,8 +791,11 @@
@@ -532,8 +795,11 @@
public void tick()
{
@ -579,7 +583,7 @@
++this.tickCounter;
if (this.startProfiling)
@@ -562,12 +824,21 @@
@@ -562,12 +828,21 @@
this.field_147147_p.func_151318_b().func_151330_a(agameprofile);
}
@ -603,7 +607,7 @@
}
this.theProfiler.startSection("tallying");
@@ -575,25 +846,57 @@
@@ -575,25 +850,57 @@
this.theProfiler.endSection();
this.theProfiler.startSection("snooper");
@ -663,7 +667,7 @@
int i;
Integer[] ids = DimensionManager.getIDs(this.tickCounter % 200 == 0);
@@ -602,19 +905,21 @@
@@ -602,19 +909,21 @@
int id = ids[x];
long j = System.nanoTime();
@ -688,7 +692,7 @@
this.theProfiler.startSection("tick");
FMLCommonHandler.instance().onPreWorldTick(worldserver);
@@ -622,22 +927,46 @@
@@ -622,22 +931,46 @@
try
{
@ -737,7 +741,7 @@
worldserver.addWorldInfoToCrashReport(crashreport);
throw new ReportedException(crashreport);
}
@@ -645,10 +974,12 @@
@@ -645,10 +978,12 @@
FMLCommonHandler.instance().onPostWorldTick(worldserver);
this.theProfiler.endSection();
this.theProfiler.startSection("tracker");
@ -751,7 +755,7 @@
worldTickTimes.get(id)[this.tickCounter % 100] = System.nanoTime() - j;
}
@@ -656,15 +987,21 @@
@@ -656,15 +991,21 @@
this.theProfiler.endStartSection("dim_unloading");
DimensionManager.unloadWorlds(worldTickTimes);
this.theProfiler.endStartSection("connection");
@ -773,7 +777,7 @@
this.theProfiler.endSection();
}
@@ -699,6 +1036,13 @@
@@ -699,6 +1040,13 @@
public WorldServer worldServerForDimension(int p_71218_1_)
{
@ -787,7 +791,7 @@
WorldServer ret = DimensionManager.getWorld(p_71218_1_);
if (ret == null)
{
@@ -784,13 +1128,14 @@
@@ -784,13 +1132,14 @@
public List getPossibleCompletions(ICommandSender p_71248_1_, String p_71248_2_)
{
@ -806,7 +810,7 @@
if (list != null)
{
@@ -798,40 +1143,25 @@
@@ -798,40 +1147,25 @@
while (iterator.hasNext())
{
@ -855,7 +859,7 @@
}
public static MinecraftServer getServer()
@@ -1034,7 +1364,7 @@
@@ -1034,7 +1368,7 @@
public boolean isServerInOnlineMode()
{
@ -864,7 +868,7 @@
}
public void setOnlineMode(boolean p_71229_1_)
@@ -1124,7 +1454,7 @@
@@ -1124,7 +1458,7 @@
public NetworkSystem func_147137_ag()
{
@ -873,7 +877,7 @@
}
@SideOnly(Side.CLIENT)
@@ -1259,8 +1589,11 @@
@@ -1259,8 +1593,11 @@
{
Bootstrap.func_151354_b();
@ -885,7 +889,7 @@
boolean flag = true;
String s = null;
String s1 = ".";
@@ -1356,16 +1689,34 @@
@@ -1356,16 +1693,34 @@
{
dedicatedserver.setGuiEnabled();
}
@ -926,7 +930,7 @@
}
catch (Exception exception)
{
@@ -1400,15 +1751,70 @@
@@ -1400,15 +1755,70 @@
@SideOnly(Side.SERVER)
public String getPlugins()
{
@ -1002,7 +1006,7 @@
}
@SideOnly(Side.SERVER)
@@ -1455,9 +1861,213 @@
@@ -1455,9 +1865,213 @@
return this.serverStopped;
}

View File

@ -140,7 +140,7 @@
this.field_154332_n = new ServerEula(new File("eula.txt"));
if (!this.field_154332_n.func_154346_a())
@@ -172,6 +231,17 @@
@@ -172,6 +231,18 @@
this.setServerPort(this.settings.getIntProperty("server-port", 25565));
}
@ -153,12 +153,13 @@
+ kcauldronConfig.registerCommands();
+ cauldronConfig.registerCommands();
+ tileEntityConfig.registerCommands();
+ entityConfig.registerCommands();
+ // Cauldron end
+
field_155771_h.info("Generating keypair");
this.setKeyPair(CryptManager.createNewKeyPair());
field_155771_h.info("Starting Minecraft server on " + (this.getServerHostname().length() == 0 ? "*" : this.getServerHostname()) + ":" + this.getServerPort());
@@ -180,7 +250,7 @@
@@ -180,7 +251,7 @@
{
this.func_147137_ag().addLanEndpoint(inetaddress, this.getServerPort());
}
@ -167,7 +168,7 @@
{
field_155771_h.warn("**** FAILED TO BIND TO PORT!");
field_155771_h.warn("The exception was: {}", new Object[] {ioexception.toString()});
@@ -196,10 +266,17 @@
@@ -196,10 +267,17 @@
field_155771_h.warn("To change this, set \"online-mode\" to \"true\" in the server.properties file.");
}
@ -187,7 +188,7 @@
if (!PreYggdrasilConverter.func_152714_a(this.settings))
{
@@ -208,7 +285,8 @@
@@ -208,7 +286,8 @@
else
{
FMLCommonHandler.instance().onServerStarted();
@ -197,7 +198,7 @@
long j = System.nanoTime();
if (this.getFolderName() == null)
@@ -274,11 +352,30 @@
@@ -274,11 +353,30 @@
this.theRConThreadMain.startThread();
}
@ -228,7 +229,7 @@
public boolean canStructuresSpawn()
{
return this.canSpawnStructures;
@@ -364,11 +461,19 @@
@@ -364,11 +462,19 @@
public void executePendingCommands()
{