Detect and log cascading chunk generation issues during terrain population (#3756)

This commit is contained in:
mezz 2017-03-14 19:19:47 -07:00 committed by LexManos
parent 43375ded29
commit 4fbc847736
3 changed files with 42 additions and 7 deletions

View File

@ -206,15 +206,27 @@
i = MathHelper.func_76125_a(i, 0, this.field_76645_j.length - 1);
j = MathHelper.func_76125_a(j, 0, this.field_76645_j.length - 1);
@@ -995,6 +998,7 @@
@@ -984,6 +987,8 @@
protected void func_186034_a(IChunkGenerator p_186034_1_)
{
+ if (populating && net.minecraftforge.common.ForgeModContainer.logCascadingWorldGeneration) logCascadingWorldGeneration();
+ populating = true;
if (this.func_177419_t())
{
if (p_186034_1_.func_185933_a(this, this.field_76635_g, this.field_76647_h))
@@ -995,8 +1000,10 @@
{
this.func_150809_p();
p_186034_1_.func_185931_b(this.field_76635_g, this.field_76647_h);
+ net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(this.field_76635_g, this.field_76647_h, this.field_76637_e, p_186034_1_, this.field_76637_e.func_72863_F());
this.func_76630_e();
}
+ populating = false;
}
@@ -1051,7 +1055,7 @@
public BlockPos func_177440_h(BlockPos p_177440_1_)
@@ -1051,7 +1058,7 @@
{
BlockPos blockpos = (BlockPos)this.field_177447_w.poll();
@ -223,7 +235,7 @@
{
TileEntity tileentity = this.func_177422_i(blockpos);
this.field_76637_e.func_175690_a(blockpos, tileentity);
@@ -1115,6 +1119,13 @@
@@ -1115,6 +1122,13 @@
@SideOnly(Side.CLIENT)
public void func_186033_a(PacketBuffer p_186033_1_, int p_186033_2_, boolean p_186033_3_)
{
@ -237,7 +249,7 @@
boolean flag = this.field_76637_e.field_73011_w.func_191066_m();
for (int i = 0; i < this.field_76652_q.length; ++i)
@@ -1163,10 +1174,16 @@
@@ -1163,10 +1177,16 @@
this.field_76646_k = true;
this.func_76590_a();
@ -254,7 +266,7 @@
}
public Biome func_177411_a(BlockPos p_177411_1_, BiomeProvider p_177411_2_)
@@ -1231,13 +1248,13 @@
@@ -1231,13 +1251,13 @@
BlockPos blockpos1 = blockpos.func_177982_a(k, (j << 4) + i1, l);
boolean flag = i1 == 0 || i1 == 15 || k == 0 || k == 15 || l == 0 || l == 15;
@ -270,7 +282,7 @@
{
this.field_76637_e.func_175664_x(blockpos2);
}
@@ -1368,7 +1385,7 @@
@@ -1368,7 +1388,7 @@
{
blockpos$mutableblockpos.func_181079_c(blockpos$mutableblockpos.func_177958_n(), l, blockpos$mutableblockpos.func_177952_p());
@ -279,11 +291,12 @@
{
this.field_76637_e.func_175664_x(blockpos$mutableblockpos);
}
@@ -1476,4 +1493,20 @@
@@ -1476,4 +1496,34 @@
QUEUED,
CHECK;
}
+
+ /* ======================================== FORGE START =====================================*/
+ /**
+ * Removes the tile entity at the specified position, only if it's
+ * marked as invalid.
@ -298,5 +311,18 @@
+ field_150816_i.remove(pos);
+ }
+ }
+ }
+
+ private static boolean populating = false; // keep track of cascading chunk generation during chunk population
+
+ private void logCascadingWorldGeneration()
+ {
+ net.minecraftforge.fml.common.ModContainer activeModContainer = net.minecraftforge.fml.common.Loader.instance().activeModContainer();
+ String format = "%s loaded a new chunk (%d, %d Dimension: %d) during chunk population, causing cascading worldgen lag. Please report this to the mod's issue tracker. This log can be disabled in the Forge config.";
+
+ if (activeModContainer == null) // vanilla minecraft has problems too (MC-114332), log it at a quieter level.
+ net.minecraftforge.fml.common.FMLLog.fine(format, "Minecraft", this.field_76635_g, this.field_76647_h, this.field_76637_e.field_73011_w.getDimension());
+ else
+ net.minecraftforge.fml.common.FMLLog.warning(format, activeModContainer.getName(), this.field_76635_g, this.field_76647_h, this.field_76637_e.field_73011_w.getDimension());
+ }
}

View File

@ -116,6 +116,7 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
public static long java8Reminder = 0;
public static boolean disableStairSlabCulling = false; // Also known as the "DontCullStairsBecauseIUseACrappyTexturePackThatBreaksBasicBlockShapesSoICantTrustBasicBlockCulling" flag
public static boolean alwaysSetupTerrainOffThread = false; // In RenderGlobal.setupTerrain, always force the chunk render updates to be queued to the thread
public static boolean logCascadingWorldGeneration = true; // see Chunk#logCascadingWorldGeneration()
private static Configuration config;
private static ForgeModContainer INSTANCE;
@ -274,6 +275,12 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
prop.setLanguageKey("forge.configgui.forgeLightPipelineEnabled");
propOrder.add(prop.getName());
prop = config.get(Configuration.CATEGORY_GENERAL, "logCascadingWorldGeneration", true,
"Log cascading chunk generation issues during terrain population.");
logCascadingWorldGeneration = prop.getBoolean();
prop.setLanguageKey("forge.configgui.logCascadingWorldGeneration");
propOrder.add(prop.getName());
config.setCategoryPropertyOrder(CATEGORY_GENERAL, propOrder);
propOrder = new ArrayList<String>();

View File

@ -66,6 +66,8 @@ forge.configgui.maximumTicketCount.tooltip=This is the number of chunk loading r
forge.configgui.maximumTicketCount=Mod Ticket Limit
forge.configgui.playerTicketCount.tooltip=The number of tickets a player can be assigned instead of a mod. This is shared across all mods and it is up to the mods to use it.
forge.configgui.playerTicketCount=Player Ticket Limit
forge.configgui.logCascadingWorldGeneration=Log Cascading World Gen
forge.configgui.logCascadingWorldGeneration.tooltip=Log cascading chunk generation issues during terrain population.
fml.config.sample.basicDouble.tooltip=A double property with no defined bounds.
fml.config.sample.basicDouble=Unbounded Double