|
2 | 2 |
|
3 | 3 | import com.google.common.collect.ImmutableSet; |
4 | 4 | import cpw.mods.fml.common.FMLCommonHandler; |
| 5 | +import cpw.mods.fml.common.ObfuscationReflectionHelper; |
5 | 6 | import it.unimi.dsi.fastutil.longs.LongCollection; |
6 | 7 | import it.unimi.dsi.fastutil.longs.LongOpenHashSet; |
7 | 8 | import net.minecraft.entity.Entity; |
8 | 9 | import net.minecraft.entity.EntityList; |
| 10 | +import net.minecraft.entity.EntityLiving; |
9 | 11 | import net.minecraft.entity.EntityLivingBase; |
10 | 12 | import net.minecraft.entity.player.EntityPlayer; |
11 | 13 | import net.minecraft.tileentity.TileEntity; |
@@ -98,20 +100,24 @@ else if (difficulty == EnumDifficulty.HARD) |
98 | 100 | private void skipUpdateIfOptimizing(Entity entity, boolean force, CallbackInfo ci, int chunkX, int chunkZ, boolean isInForcedChunk) { |
99 | 101 | if(!ArchaicConfig.optimizeEntityTicking) |
100 | 102 | return; |
| 103 | + if (isRemote || isInForcedChunk || !(entity instanceof EntityLivingBase) || entity instanceof EntityPlayer || !entity.addedToChunk) { |
| 104 | + return; |
| 105 | + } |
101 | 106 | if(entityOptimizationIgnoreSet == null) |
102 | 107 | entityOptimizationIgnoreSet = ImmutableSet.copyOf(ArchaicConfig.optimizeEntityTickingIgnoreList); |
103 | 108 | if(entityOptimizationIgnoreSet.contains(EntityList.getEntityString(entity))) |
104 | 109 | return; |
105 | | - if (isInForcedChunk || !(entity instanceof EntityLivingBase) || entity instanceof EntityPlayer) { |
106 | | - return; |
107 | | - } |
108 | 110 | double finalDist = Double.MAX_VALUE; |
109 | 111 | for(EntityPlayer player : (List<EntityPlayer>)entity.worldObj.playerEntities) { |
110 | 112 | finalDist = Math.min(finalDist, player.getDistanceSq(entity.posX, entity.posY, entity.posZ)); |
111 | 113 | if(finalDist <= ArchaicConfig.optimizeEntityTickingDistance) |
112 | 114 | break; |
113 | 115 | } |
114 | 116 | if(((EntityLivingBase)entity).deathTime <= 0 && finalDist > ArchaicConfig.optimizeEntityTickingDistance) { |
| 117 | + if(entity instanceof EntityLiving && ((AccessorEntityLiving)entity).invokeCanDespawn()) { |
| 118 | + /* Despawn even if outside the ticking range */ |
| 119 | + ((AccessorEntityLiving)entity).invokeDespawnEntity(); |
| 120 | + } |
115 | 121 | ci.cancel(); |
116 | 122 | } |
117 | 123 | } |
|
0 commit comments