Skip to content

Commit

Permalink
add ghostPlayer logger, and rule loggerGhostPlayer as the switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed May 28, 2023
1 parent d23ef87 commit ab9896a
Show file tree
Hide file tree
Showing 6 changed files with 307 additions and 95 deletions.
93 changes: 60 additions & 33 deletions patches/net/minecraft/world/World.java.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
--- a/net/minecraft/world/World.java
+++ b/net/minecraft/world/World.java
@@ -1,20 +1,33 @@
@@ -1,20 +1,34 @@
package net.minecraft.world;

+import carpet.helpers.TickSpeed;
+import carpet.helpers.UpdateSuppressionException;
+import carpet.logging.ghostPlayer.GhostPlayerLogger;
+import carpet.logging.microtiming.MicroTimingLoggerManager;
+import carpet.logging.microtiming.enums.EventType;
+import carpet.logging.microtiming.enums.BlockUpdateType;
Expand Down Expand Up @@ -40,15 +41,15 @@
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
@@ -65,6 +78,7 @@
@@ -65,6 +79,7 @@
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.dimension.Dimension;
+import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.gen.Heightmap;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.SessionLockException;
@@ -72,20 +86,33 @@
@@ -72,20 +87,33 @@
import net.minecraft.world.storage.WorldSavedDataStorage;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
Expand Down Expand Up @@ -87,7 +88,7 @@
public final List<EntityPlayer> playerEntities = Lists.newArrayList();
public final List<Entity> weatherEffects = Lists.newArrayList();
protected final IntHashMap<Entity> entitiesById = new IntHashMap<>();
@@ -116,6 +143,16 @@
@@ -116,6 +144,16 @@
private final WorldBorder worldBorder;
int[] lightUpdateBlockList = new int['\u8000'];

Expand All @@ -104,7 +105,7 @@
protected World(ISaveHandler p_i49813_1_, @Nullable WorldSavedDataStorage p_i49813_2_, WorldInfo p_i49813_3_, Dimension p_i49813_4_, Profiler p_i49813_5_, boolean p_i49813_6_)
{
this.saveHandler = p_i49813_1_;
@@ -125,6 +162,8 @@
@@ -125,6 +163,8 @@
this.dimension = p_i49813_4_;
this.isRemote = p_i49813_6_;
this.worldBorder = p_i49813_4_.createWorldBorder();
Expand All @@ -113,7 +114,7 @@
}

public Biome getBiome(BlockPos pos)
@@ -224,8 +263,25 @@
@@ -224,8 +264,25 @@
}
}

Expand All @@ -139,7 +140,7 @@
if (isOutsideBuildHeight(pos))
{
return false;
@@ -238,7 +294,7 @@
@@ -238,7 +295,7 @@
{
Chunk chunk = this.getChunk(pos);
Block block = newState.getBlock();
Expand All @@ -148,7 +149,7 @@

if (iblockstate == null)
{
@@ -261,7 +317,7 @@
@@ -261,7 +318,7 @@
{
this.markBlockRangeForRenderUpdate(pos, pos);
}
Expand All @@ -157,7 +158,7 @@
if ((flags & 2) != 0 && (!this.isRemote || (flags & 4) == 0) && chunk.isPopulated())
{
this.notifyBlockUpdate(pos, iblockstate, newState, flags);
@@ -277,7 +333,9 @@
@@ -277,7 +334,9 @@
}
}

Expand All @@ -168,7 +169,7 @@
{
int i = flags & -2;
iblockstate.updateDiagonalNeighbors(this, pos, i);
@@ -372,19 +430,22 @@
@@ -372,19 +431,22 @@
this.eventListeners.get(i).markBlockRangeForRenderUpdate(x1, y1, z1, x2, y2, z2);
}
}
Expand All @@ -192,7 +193,7 @@
if (skipSide != EnumFacing.WEST)
{
this.neighborChanged(pos.west(), blockType, pos);
@@ -414,18 +475,34 @@
@@ -414,18 +476,34 @@
{
this.neighborChanged(pos.south(), blockType, pos);
}
Expand Down Expand Up @@ -228,7 +229,33 @@
catch (Throwable throwable)
{
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception while updating neighbours");
@@ -1199,13 +1276,23 @@
@@ -999,6 +1077,12 @@

public void removeEntity(Entity entityIn)
{
+ // TISCM ghostPlayer logger
+ if (entityIn instanceof EntityPlayer)
+ {
+ GhostPlayerLogger.getInstance().onWorldRemoveEntity(this, (EntityPlayer)entityIn, "World#removeEntity");
+ }
+
if (entityIn.isBeingRidden())
{
entityIn.removePassengers();
@@ -1021,6 +1105,12 @@

public void removeEntityDangerously(Entity entityIn)
{
+ // TISCM ghostPlayer logger
+ if (entityIn instanceof EntityPlayer)
+ {
+ GhostPlayerLogger.getInstance().onWorldRemoveEntity(this, (EntityPlayer)entityIn, "World#removeEntityDangerously");
+ }
+
entityIn.setDropItemsWhenDead(false);
entityIn.remove();

@@ -1199,13 +1289,23 @@
{
this.profiler.startSection("entities");
this.profiler.startSection("global");
Expand All @@ -252,15 +279,15 @@
++entity.ticksExisted;
entity.tick();
}
@@ -1233,6 +1320,7 @@
@@ -1233,6 +1333,7 @@
}

this.profiler.endStartSection("remove");
+ MicroTimingLoggerManager.setSubTickStage(this, LiteralSubStage.ENTITY_REMOVING); // TISCM Micro Timing logger
this.loadedEntityList.removeAll(this.unloadedEntityList);

for (int k = 0; k < this.unloadedEntityList.size(); ++k)
@@ -1253,12 +1341,15 @@
@@ -1253,12 +1354,15 @@
}

this.unloadedEntityList.clear();
Expand All @@ -276,7 +303,7 @@
Entity entity3 = entity2.getRidingEntity();

if (entity3 != null)
@@ -1273,8 +1364,10 @@
@@ -1273,8 +1377,10 @@

this.profiler.startSection("tick");

Expand All @@ -288,7 +315,7 @@
try
{
this.tickEntity(entity2);
@@ -1304,11 +1397,18 @@
@@ -1304,11 +1410,18 @@
this.loadedEntityList.remove(i1--);
this.onEntityRemoved(entity2);
}
Expand All @@ -307,7 +334,7 @@

if (!this.tileEntitiesToBeRemoved.isEmpty())
{
@@ -1316,19 +1416,22 @@
@@ -1316,19 +1429,22 @@
this.loadedTileEntityList.removeAll(this.tileEntitiesToBeRemoved);
this.tileEntitiesToBeRemoved.clear();
}
Expand All @@ -332,7 +359,7 @@
{
try
{
@@ -1336,6 +1439,8 @@
@@ -1336,6 +1452,8 @@
{
return String.valueOf((Object)TileEntityType.getId(tileentity.getType()));
});
Expand All @@ -341,7 +368,7 @@
((ITickable)tileentity).tick();
this.profiler.endSection();
}
@@ -1359,13 +1464,23 @@
@@ -1359,13 +1477,23 @@
this.getChunk(tileentity.getPos()).removeTileEntity(tileentity.getPos());
}
}
Expand All @@ -366,7 +393,7 @@
for (int j1 = 0; j1 < this.addedTileEntityList.size(); ++j1)
{
TileEntity tileentity1 = this.addedTileEntityList.get(j1);
@@ -1389,11 +1504,54 @@
@@ -1389,11 +1517,54 @@

this.addedTileEntityList.clear();
}
Expand Down Expand Up @@ -421,7 +448,7 @@
protected void tickPlayers()
{
}
@@ -1413,7 +1571,7 @@
@@ -1413,7 +1584,7 @@
IBlockState iblockstate = this.getBlockState(blockpos);
this.notifyBlockUpdate(blockpos, iblockstate, iblockstate, 2);
}
Expand All @@ -430,15 +457,15 @@
return flag;
}

@@ -1471,6 +1629,7 @@
@@ -1471,6 +1642,7 @@
{
return IRegistry.ENTITY_TYPE.getKey(entityIn.getType()).toString();
});
+ onEntityTick(entityIn); // RSMM
entityIn.tick();
this.profiler.endSection();
}
@@ -1514,7 +1673,8 @@
@@ -1514,7 +1686,8 @@
this.getChunk(entityIn.chunkCoordX, entityIn.chunkCoordZ).removeEntityAtIndex(entityIn, entityIn.chunkCoordY);
}

Expand All @@ -448,7 +475,7 @@
{
entityIn.addedToChunk = false;
}
@@ -1834,6 +1994,14 @@
@@ -1834,6 +2007,14 @@
@Nullable
private TileEntity getPendingTileEntityAt(BlockPos pos)
{
Expand All @@ -463,7 +490,7 @@
for (int i = 0; i < this.addedTileEntityList.size(); ++i)
{
TileEntity tileentity = this.addedTileEntityList.get(i);
@@ -1856,16 +2024,26 @@
@@ -1856,16 +2037,26 @@
if (this.processingLoadedTiles)
{
tileEntityIn.setPos(pos);
Expand Down Expand Up @@ -496,7 +523,7 @@
}
}

@@ -1948,8 +2126,11 @@
@@ -1948,8 +2139,11 @@

public void tick(BooleanSupplier hasTimeLeft)
{
Expand All @@ -508,7 +535,7 @@
}

protected void calculateInitialWeather()
@@ -2149,6 +2330,13 @@
@@ -2149,6 +2343,13 @@

public boolean checkLightFor(EnumLightType lightType, BlockPos pos)
{
Expand All @@ -522,7 +549,7 @@
if (!this.isAreaLoaded(pos, 17, false))
{
return false;
@@ -2284,15 +2472,15 @@
@@ -2284,15 +2485,15 @@
}
}

Expand All @@ -542,7 +569,7 @@
int i = MathHelper.floor((boundingBox.minX - 2.0D) / 16.0D);
int j = MathHelper.floor((boundingBox.maxX + 2.0D) / 16.0D);
int k = MathHelper.floor((boundingBox.minZ - 2.0D) / 16.0D);
@@ -2304,14 +2492,33 @@
@@ -2304,14 +2505,33 @@
{
if (this.isChunkLoaded(i1, j1, true))
{
Expand Down Expand Up @@ -577,7 +604,7 @@
public <T extends Entity> List<T> getEntities(Class <? extends T > entityType, Predicate <? super T > filter)
{
List<T> list = Lists.newArrayList();
@@ -2785,6 +2992,12 @@
@@ -2785,6 +3005,12 @@

public void checkSessionLock() throws SessionLockException
{
Expand All @@ -590,23 +617,23 @@
this.saveHandler.checkSessionLock();
}

@@ -3066,6 +3279,7 @@
@@ -3066,6 +3292,7 @@

if (iblockstate.getBlock() == Blocks.COMPARATOR)
{
+ onComparatorUpdate(blockpos);
iblockstate.neighborChanged(this, blockpos, blockIn, pos);
}
else if (iblockstate.isNormalCube())
@@ -3075,6 +3289,7 @@
@@ -3075,6 +3302,7 @@

if (iblockstate.getBlock() == Blocks.COMPARATOR)
{
+ onComparatorUpdate(blockpos);
iblockstate.neighborChanged(this, blockpos, blockIn, pos);
}
}
@@ -3204,4 +3419,37 @@
@@ -3204,4 +3432,43 @@
public abstract RecipeManager getRecipeManager();

public abstract NetworkTagManager getTags();
Expand Down
Loading

0 comments on commit ab9896a

Please sign in to comment.