Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved UpdateSuppressionCrashFix #143

Open
wants to merge 6 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion carpetmodSrc/carpet/CarpetSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ private static boolean validateRandomTickOptimization(boolean value) {
@Rule(desc = "Players go invisible when dying or using portals.", category = FIX)
public static boolean playersTurningInvisibleFix;

@Rule(desc = "Fixes updates suppression causing server crashes.", category = FIX)
@Rule(desc = "Fixes updates suppression causing server crashes. Also fixes instant scheduling crashes", category = FIX)
public static boolean updateSuppressionCrashFix;

@Rule(desc = "Fixes double tile tick scheduling", category = FIX)
Expand Down
33 changes: 23 additions & 10 deletions patches/net/minecraft/server/MinecraftServer.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,17 @@
}
+ catch (ThrowableSuppression e)
+ {
+ Messenger.print_server_message(this, "You just caused a server crash in world tick.");
+ Messenger.print_server_message(this, "You just caused a server crash in world tick. Cause: "+e.getMessage());
+ }
catch (Throwable throwable1)
{
CrashReport crashreport = CrashReport.func_85055_a(throwable1, "Exception ticking world");
worldserver.func_72914_a(crashreport);
- throw new ReportedException(crashreport);
+ if(!CarpetSettings.updateSuppressionCrashFix || !(crashreport.func_71505_b() instanceof ThrowableSuppression) ) {
+ if(!CarpetSettings.updateSuppressionCrashFix || !(crashreport.func_71505_b() instanceof ThrowableSuppression)) {
+ throw new ReportedException(crashreport);
+ } else {
+ Messenger.print_server_message(this, "You just caused a server crash in world tick.");
+ Messenger.print_server_message(this, "You just caused a server crash in world tick. Cause: "+crashreport.func_71505_b().getMessage());
+ }
}

Expand All @@ -306,17 +306,17 @@
}
+ catch (ThrowableSuppression e)
+ {
+ Messenger.print_server_message(this, "You just caused a server crash in update entities.");
+ Messenger.print_server_message(this, "You just caused a server crash in update entities. Cause: "+e.getMessage());
+ }
catch (Throwable throwable)
{
CrashReport crashreport1 = CrashReport.func_85055_a(throwable, "Exception ticking world entities");
worldserver.func_72914_a(crashreport1);
- throw new ReportedException(crashreport1);
+ if(!CarpetSettings.updateSuppressionCrashFix || !(crashreport1.func_71505_b() instanceof ThrowableSuppression) ) {
+ if(!CarpetSettings.updateSuppressionCrashFix || !(crashreport1.func_71505_b() instanceof ThrowableSuppression)) {
+ throw new ReportedException(crashreport1);
+ } else {
+ Messenger.print_server_message(this, "You just caused a server crash in update entities.");
+ Messenger.print_server_message(this, "You just caused a server crash in update entities. Cause: "+crashreport1.func_71505_b().getMessage());
+ }
}

Expand All @@ -327,20 +327,33 @@
this.field_71304_b.func_76319_b();
this.field_71304_b.func_76319_b();
}
@@ -714,10 +825,12 @@
@@ -714,10 +825,24 @@
this.field_71312_k[j][this.field_71315_w % 100] = System.nanoTime() - i;
}

+ CarpetProfiler.start_section(null, "Network");
this.field_71304_b.func_76318_c("connection");
this.func_147137_ag().func_151269_c();
- this.func_147137_ag().func_151269_c();
+ try {
+ this.func_147137_ag().func_151269_c();
+ } catch (ThrowableSuppression e){
+ Messenger.print_server_message(this, "You just caused a server crash in network tick. Cause: "+e.getMessage());
+ } catch (Throwable throwable){
+ CrashReport crashreport1 = CrashReport.func_85055_a(throwable, "Exception in network tick");
+ this.func_71230_b(crashreport1);
+ if(!CarpetSettings.updateSuppressionCrashFix || !(crashreport1.func_71505_b() instanceof ThrowableSuppression)) {
+ throw new ReportedException(crashreport1);
+ } else {
+ Messenger.print_server_message(this, "You just caused a server crash in network tick. Cause: "+crashreport1.func_71505_b().getMessage());
+ }
+ }
this.field_71304_b.func_76318_c("players");
this.field_71318_t.func_72374_b();
+ CarpetProfiler.end_current_section();
this.field_71304_b.func_76318_c("commandFunctions");
this.func_193030_aL().func_73660_a();
this.field_71304_b.func_76318_c("tickables");
@@ -728,6 +841,8 @@
@@ -728,6 +853,8 @@
}

this.field_71304_b.func_76319_b();
Expand All @@ -349,7 +362,7 @@
}

public boolean func_71255_r()
@@ -939,7 +1054,7 @@
@@ -939,7 +1066,7 @@

public String getServerModName()
{
Expand Down
75 changes: 41 additions & 34 deletions patches/net/minecraft/world/WorldServer.java.patch
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
--- ../src-base/minecraft/net/minecraft/world/WorldServer.java
+++ ../src-work/minecraft/net/minecraft/world/WorldServer.java
@@ -1,5 +1,7 @@
@@ -1,5 +1,6 @@
package net.minecraft.world;

+import carpet.helpers.NextTickListEntryFix;
+import carpet.helpers.ScheduledBlockEventSerializer;
+import carpet.helpers.*;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -14,7 +16,6 @@
@@ -14,7 +15,6 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
-import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import net.minecraft.advancements.AdvancementManager;
@@ -60,6 +61,7 @@
@@ -60,6 +60,7 @@
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
+import net.minecraft.util.text.ITextComponent;
import net.minecraft.village.VillageCollection;
import net.minecraft.village.VillageSiege;
import net.minecraft.world.biome.Biome;
@@ -80,14 +82,23 @@
@@ -80,14 +81,20 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

+import carpet.CarpetSettings;
+import carpet.helpers.LagSpikeHelper;
+import carpet.helpers.RandomTickOptimization;
+import carpet.helpers.TickSpeed;
+import carpet.logging.LoggerRegistry;
+import carpet.utils.CarpetProfiler;
+import carpet.utils.Messenger;
Expand All @@ -51,7 +47,7 @@
private final Map<UUID, Entity> field_175741_N = Maps.<UUID, Entity>newHashMap();
public boolean field_73058_d;
private boolean field_73068_P;
@@ -99,6 +110,13 @@
@@ -99,6 +106,13 @@
private int field_147489_T;
private final List<NextTickListEntry> field_94579_S = Lists.<NextTickListEntry>newArrayList();

Expand All @@ -65,7 +61,7 @@
public WorldServer(MinecraftServer p_i45921_1_, ISaveHandler p_i45921_2_, WorldInfo p_i45921_3_, int p_i45921_4_, Profiler p_i45921_5_)
{
super(p_i45921_2_, p_i45921_3_, DimensionType.func_186069_a(p_i45921_4_).func_186070_d(), p_i45921_5_, false);
@@ -159,11 +177,24 @@
@@ -159,11 +173,24 @@
this.func_175723_af().func_177750_a(this.field_72986_A.func_176137_E());
}

Expand All @@ -90,7 +86,7 @@
super.func_72835_b();

if (this.func_72912_H().func_76093_s() && this.func_175659_aa() != EnumDifficulty.HARD)
@@ -184,15 +215,26 @@
@@ -184,15 +211,26 @@
this.func_73053_d();
}

Expand All @@ -117,7 +113,7 @@
int j = this.func_72967_a(1.0F);

if (j != this.func_175657_ab())
@@ -200,26 +242,76 @@
@@ -200,26 +238,76 @@
this.func_175692_b(j);
}

Expand Down Expand Up @@ -196,7 +192,7 @@
}

@Nullable
@@ -255,8 +347,15 @@
@@ -255,8 +343,15 @@
++j;
}
}
Expand All @@ -214,7 +210,7 @@
}
}

@@ -287,6 +386,28 @@
@@ -287,6 +382,28 @@
{
if (this.field_73068_P && !this.field_72995_K)
{
Expand Down Expand Up @@ -243,7 +239,7 @@
for (EntityPlayer entityplayer : this.field_73010_i)
{
if (!entityplayer.func_175149_v() && !entityplayer.func_71026_bH())
@@ -303,7 +424,7 @@
@@ -303,7 +420,7 @@
}
}

Expand All @@ -252,15 +248,15 @@
{
return this.func_72863_F().func_73149_a(p_175680_1_, p_175680_2_);
}
@@ -344,6 +465,7 @@
@@ -344,6 +461,7 @@
boolean flag = this.func_72896_J();
boolean flag1 = this.func_72911_I();
this.field_72984_F.func_76320_a("pollingChunks");
+ boolean overworldIceOnly = !CarpetSettings.enableStableLCGNetherEnd || field_73011_w.func_186058_p().func_186068_a() == 0; // Rule to disable nether and end ice snow and lightning Carpet-XCOM

for (Iterator<Chunk> iterator = this.field_73063_M.func_187300_b(); iterator.hasNext(); this.field_72984_F.func_76319_b())
{
@@ -355,9 +477,14 @@
@@ -355,9 +473,14 @@
chunk.func_76594_o();
this.field_72984_F.func_76318_c("tickChunk");
chunk.func_150804_b(false);
Expand All @@ -276,7 +272,7 @@
{
this.field_73005_l = this.field_73005_l * 3 + 1013904223;
int l = this.field_73005_l >> 2;
@@ -385,7 +512,7 @@
@@ -385,7 +508,7 @@

this.field_72984_F.func_76318_c("iceandsnow");

Expand All @@ -285,7 +281,7 @@
{
this.field_73005_l = this.field_73005_l * 3 + 1013904223;
int j2 = this.field_73005_l >> 2;
@@ -443,7 +570,7 @@
@@ -443,7 +566,7 @@
}
}

Expand All @@ -294,7 +290,7 @@
{
BlockPos blockpos = this.func_175725_q(p_175736_1_);
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(blockpos, new BlockPos(blockpos.func_177958_n(), this.func_72800_K(), blockpos.func_177952_p()))).func_186662_g(3.0D);
@@ -472,13 +599,25 @@
@@ -472,13 +595,25 @@

public boolean func_175691_a(BlockPos p_175691_1_, Block p_175691_2_)
{
Expand Down Expand Up @@ -322,9 +318,20 @@
return this.field_73064_N.contains(nextticklistentry);
}

@@ -503,15 +642,22 @@
@@ -501,17 +636,32 @@

if (iblockstate.func_185904_a() != Material.field_151579_a && iblockstate.func_177230_c() == p_175654_2_)
{
iblockstate.func_177230_c().func_180650_b(this, p_175654_1_, iblockstate, this.field_73012_v);
- iblockstate.func_177230_c().func_180650_b(this, p_175654_1_, iblockstate, this.field_73012_v);
+ try{
+ iblockstate.func_177230_c().func_180650_b(this, p_175654_1_, iblockstate, this.field_73012_v);
+ } catch (Throwable throwable){
+ if(!CarpetSettings.updateSuppressionCrashFix) {
+ throw throwable;
+ }
+ throw new ThrowableSuppression("Instant Tile Tick");
+ }
+
}
+ if(RandomTickOptimization.needsWorldGenFix) return;
}
Expand All @@ -347,7 +354,7 @@

if (this.func_175667_e(p_175654_1_))
{
@@ -531,7 +677,13 @@
@@ -531,7 +681,13 @@

public void func_180497_b(BlockPos p_180497_1_, Block p_180497_2_, int p_180497_3_, int p_180497_4_)
{
Expand All @@ -362,7 +369,7 @@
nextticklistentry.func_82753_a(p_180497_4_);
Material material = p_180497_2_.func_176223_P().func_185904_a();

@@ -549,7 +701,8 @@
@@ -549,7 +705,8 @@

public void func_72939_s()
{
Expand All @@ -372,7 +379,7 @@
{
if (this.field_80004_Q++ >= 300)
{
@@ -644,9 +797,18 @@
@@ -644,9 +801,18 @@
}
else
{
Expand All @@ -393,7 +400,7 @@
}

this.field_72984_F.func_76320_a("cleaning");
@@ -677,6 +839,8 @@
@@ -677,6 +843,8 @@

if (this.func_175707_a(nextticklistentry1.field_180282_a.func_177982_a(0, 0, 0), nextticklistentry1.field_180282_a.func_177982_a(0, 0, 0)))
{
Expand All @@ -402,15 +409,15 @@
IBlockState iblockstate = this.func_180495_p(nextticklistentry1.field_180282_a);

if (iblockstate.func_185904_a() != Material.field_151579_a && Block.func_149680_a(iblockstate.func_177230_c(), nextticklistentry1.func_151351_a()))
@@ -699,6 +863,7 @@
@@ -699,6 +867,7 @@
this.func_175684_a(nextticklistentry1.field_180282_a, nextticklistentry1.func_151351_a(), 0);
}
}
+ carpet.carpetclient.CarpetClientChunkLogger.resetReason();

this.field_72984_F.func_76319_b();
this.field_94579_S.clear();
@@ -950,11 +1115,18 @@
@@ -950,11 +1119,18 @@

chunkproviderserver.func_186027_a(p_73044_1_);

Expand All @@ -430,7 +437,7 @@
}
}
}
@@ -1033,9 +1205,15 @@
@@ -1033,9 +1209,15 @@
}
else
{
Expand All @@ -446,23 +453,23 @@
return false;
}

@@ -1055,6 +1233,7 @@
@@ -1055,6 +1237,7 @@
this.field_175729_l.func_76038_a(p_72923_1_.func_145782_y(), p_72923_1_);
this.field_175741_N.put(p_72923_1_.func_110124_au(), p_72923_1_);
Entity[] aentity = p_72923_1_.func_70021_al();
+ p_72923_1_.postLoad();

if (aentity != null)
{
@@ -1139,6 +1318,7 @@
@@ -1139,6 +1322,7 @@
}

this.field_147490_S[this.field_147489_T].add(blockeventdata);
+ if(CarpetSettings.blockEventSerializer) blockEventSerializer.func_76185_a();
}

private void func_147488_Z()
@@ -1150,14 +1330,19 @@
@@ -1150,14 +1334,19 @@

for (BlockEventData blockeventdata : this.field_147490_S[i])
{
Expand All @@ -482,7 +489,7 @@
}

private boolean func_147485_a(BlockEventData p_147485_1_)
@@ -1299,4 +1484,19 @@
@@ -1299,4 +1488,19 @@
{
}
}
Expand Down