From b977a53bbed380aaddbd8075f843074e6c0fa3c3 Mon Sep 17 00:00:00 2001 From: Robotia Date: Mon, 1 Feb 2016 18:35:07 -0500 Subject: [PATCH] Moving getIndirect() stuff around --- patches/net/minecraft/world/World.java.patch | 112 +++++++++--------- src/main/java/net/minecraft/world/Coords.java | 23 ++++ 2 files changed, 80 insertions(+), 55 deletions(-) create mode 100644 src/main/java/net/minecraft/world/Coords.java diff --git a/patches/net/minecraft/world/World.java.patch b/patches/net/minecraft/world/World.java.patch index 8d01656..f4175af 100644 --- a/patches/net/minecraft/world/World.java.patch +++ b/patches/net/minecraft/world/World.java.patch @@ -8,18 +8,20 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; -@@ -10,8 +11,10 @@ +@@ -10,8 +11,12 @@ import java.util.List; import java.util.Random; import java.util.Set; +import java.util.HashMap; import java.util.UUID; import java.util.concurrent.Callable; ++ ++import net.minecraft.world.Coords; + import net.minecraft.block.Block; import net.minecraft.block.BlockHopper; import net.minecraft.block.BlockLiquid; -@@ -23,9 +26,11 @@ +@@ -23,9 +28,11 @@ import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; import net.minecraft.entity.Entity; @@ -31,7 +33,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.pathfinding.PathEntity; -@@ -51,7 +56,6 @@ +@@ -51,7 +58,6 @@ import net.minecraft.world.storage.ISaveHandler; import net.minecraft.world.storage.MapStorage; import net.minecraft.world.storage.WorldInfo; @@ -39,7 +41,7 @@ import cpw.mods.fml.common.FMLLog; import com.google.common.collect.ImmutableSetMultimap; -@@ -70,6 +74,56 @@ +@@ -70,6 +76,56 @@ import net.minecraftforge.event.entity.PlaySoundAtEntityEvent; import net.minecraft.entity.EnumCreatureType; @@ -96,7 +98,7 @@ public abstract class World implements IBlockAccess { /** -@@ -83,15 +137,14 @@ +@@ -83,15 +139,14 @@ public boolean scheduledUpdatesAreImmediate; public List loadedEntityList = new ArrayList(); @@ -114,7 +116,7 @@ protected final int DIST_HASH_MAGIC = 1013904223; public float prevRainingStrength; public float rainingStrength; -@@ -100,26 +153,88 @@ +@@ -100,26 +155,88 @@ public int lastLightningBolt; public EnumDifficulty difficultySetting; public Random rand = new Random(); @@ -210,7 +212,7 @@ private static final String __OBFID = "CL_00000140"; public boolean restoringBlockSnapshots = false; public boolean captureBlockSnapshots = false; -@@ -166,6 +281,27 @@ +@@ -166,6 +283,27 @@ return this.provider.worldChunkMgr; } @@ -238,7 +240,7 @@ @SideOnly(Side.CLIENT) public World(ISaveHandler p_i45368_1_, String p_i45368_2_, WorldProvider p_i45368_3_, WorldSettings p_i45368_4_, Profiler p_i45368_5_) { -@@ -179,6 +315,12 @@ +@@ -179,6 +317,12 @@ this.worldInfo = new WorldInfo(p_i45368_4_, p_i45368_2_); this.provider = p_i45368_3_; perWorldStorage = new MapStorage((ISaveHandler)null); @@ -251,7 +253,7 @@ } // Broken up so that the WorldClient gets the chance to set the mapstorage object before the dimension initializes -@@ -207,8 +349,175 @@ +@@ -207,8 +351,175 @@ this.calculateInitialWeather(); } @@ -427,7 +429,7 @@ this.ambientTickCountdown = this.rand.nextInt(12000); this.spawnHostileMobs = true; this.spawnPeacefulMobs = true; -@@ -216,7 +525,6 @@ +@@ -216,7 +527,6 @@ this.lightUpdateBlockList = new int[32768]; this.saveHandler = p_i45369_1_; this.theProfiler = p_i45369_5_; @@ -435,7 +437,7 @@ this.worldInfo = p_i45369_1_.loadWorldInfo(); if (p_i45369_4_ != null) -@@ -235,13 +543,26 @@ +@@ -235,13 +545,26 @@ if (this.worldInfo == null) { this.worldInfo = new WorldInfo(p_i45369_3_, p_i45369_2_); @@ -462,7 +464,7 @@ this.chunkProvider = this.createChunkProvider(); if (this instanceof WorldServer) -@@ -294,6 +615,7 @@ +@@ -294,6 +617,7 @@ this.calculateInitialSkylight(); this.calculateInitialWeather(); } @@ -470,7 +472,7 @@ private static MapStorage s_mapStorage; private static ISaveHandler s_savehandler; -@@ -336,6 +658,18 @@ +@@ -336,6 +660,18 @@ public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_) { @@ -489,7 +491,7 @@ if (p_147439_1_ >= -30000000 && p_147439_3_ >= -30000000 && p_147439_1_ < 30000000 && p_147439_3_ < 30000000 && p_147439_2_ >= 0 && p_147439_2_ < 256) { Chunk chunk = null; -@@ -404,7 +738,7 @@ +@@ -404,7 +740,7 @@ } } @@ -498,7 +500,7 @@ { return this.chunkProvider.chunkExists(p_72916_1_, p_72916_2_); } -@@ -421,6 +755,27 @@ +@@ -421,6 +757,27 @@ public boolean setBlock(int p_147465_1_, int p_147465_2_, int p_147465_3_, Block p_147465_4_, int p_147465_5_, int p_147465_6_) { @@ -526,7 +528,7 @@ if (p_147465_1_ >= -30000000 && p_147465_3_ >= -30000000 && p_147465_1_ < 30000000 && p_147465_3_ < 30000000) { if (p_147465_2_ < 0) -@@ -448,8 +803,22 @@ +@@ -448,8 +805,22 @@ this.capturedBlockSnapshots.add(blockSnapshot); } @@ -549,7 +551,7 @@ if (!flag && blockSnapshot != null) { this.capturedBlockSnapshots.remove(blockSnapshot); -@@ -460,6 +829,7 @@ +@@ -460,6 +831,7 @@ this.func_147451_t(p_147465_1_, p_147465_2_, p_147465_3_); this.theProfiler.endSection(); @@ -557,7 +559,7 @@ if (flag && blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates { // Modularize client and physic updates -@@ -496,6 +866,19 @@ +@@ -496,6 +868,19 @@ public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_) { @@ -577,7 +579,7 @@ if (p_72805_1_ >= -30000000 && p_72805_3_ >= -30000000 && p_72805_1_ < 30000000 && p_72805_3_ < 30000000) { if (p_72805_2_ < 0) -@@ -511,7 +894,7 @@ +@@ -511,7 +896,7 @@ Chunk chunk = this.getChunkFromChunkCoords(p_72805_1_ >> 4, p_72805_3_ >> 4); p_72805_1_ &= 15; p_72805_3_ &= 15; @@ -586,7 +588,7 @@ } } else -@@ -610,6 +993,12 @@ +@@ -610,6 +995,12 @@ public void notifyBlockChange(int p_147444_1_, int p_147444_2_, int p_147444_3_, Block p_147444_4_) { @@ -599,7 +601,7 @@ this.notifyBlocksOfNeighborChange(p_147444_1_, p_147444_2_, p_147444_3_, p_147444_4_); } -@@ -694,6 +1083,21 @@ +@@ -694,6 +1085,21 @@ try { @@ -621,7 +623,7 @@ block.onNeighborBlockChange(this, p_147460_1_, p_147460_2_, p_147460_3_, p_147460_4_); } catch (Throwable throwable1) -@@ -1307,6 +1711,13 @@ +@@ -1307,6 +1713,13 @@ public boolean spawnEntityInWorld(Entity p_72838_1_) { @@ -635,7 +637,7 @@ // do not drop any items while restoring blocksnapshots. Prevents dupes if (!this.isRemote && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false; -@@ -1319,23 +1730,99 @@ +@@ -1319,23 +1732,99 @@ flag = true; } @@ -737,7 +739,7 @@ return true; } } -@@ -1346,6 +1833,8 @@ +@@ -1346,6 +1835,8 @@ { ((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_); } @@ -746,7 +748,7 @@ } public void onEntityRemoved(Entity p_72847_1_) -@@ -1354,6 +1843,8 @@ +@@ -1354,6 +1845,8 @@ { ((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_); } @@ -755,7 +757,7 @@ } public void removeEntity(Entity p_72900_1_) -@@ -1397,6 +1888,19 @@ +@@ -1397,6 +1890,19 @@ } this.loadedEntityList.remove(p_72973_1_); @@ -775,7 +777,7 @@ this.onEntityRemoved(p_72973_1_); } -@@ -1408,40 +1912,58 @@ +@@ -1408,40 +1914,58 @@ public List getCollidingBoundingBoxes(Entity p_72945_1_, AxisAlignedBB p_72945_2_) { this.collidingBoundingBoxes.clear(); @@ -848,7 +850,7 @@ for (int j2 = 0; j2 < list.size(); ++j2) { -@@ -1797,11 +2319,22 @@ +@@ -1797,11 +2321,22 @@ Entity entity; CrashReport crashreport; CrashReportCategory crashreportcategory; @@ -871,7 +873,7 @@ try { ++entity.ticksExisted; -@@ -1862,10 +2395,14 @@ +@@ -1862,10 +2397,14 @@ this.unloadedEntityList.clear(); this.theProfiler.endStartSection("regular"); @@ -889,7 +891,7 @@ if (entity.ridingEntity != null) { -@@ -1884,7 +2421,9 @@ +@@ -1884,7 +2423,9 @@ { try { @@ -899,7 +901,7 @@ } catch (Throwable throwable1) { -@@ -1916,30 +2455,83 @@ +@@ -1916,30 +2457,83 @@ { this.getChunkFromChunkCoords(j, l).removeEntity(entity); } @@ -990,7 +992,7 @@ crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity"); crashreportcategory = crashreport.makeCategory("Block entity being ticked"); tileentity.func_145828_a(crashreportcategory); -@@ -1955,23 +2547,13 @@ +@@ -1955,23 +2549,13 @@ } } } @@ -1019,7 +1021,7 @@ if (!this.field_147483_b.isEmpty()) { for (Object tile : field_147483_b) -@@ -1981,6 +2563,7 @@ +@@ -1981,6 +2565,7 @@ this.loadedTileEntityList.removeAll(this.field_147483_b); this.field_147483_b.clear(); } @@ -1027,7 +1029,7 @@ this.field_147481_N = false; -@@ -2016,17 +2599,23 @@ +@@ -2016,17 +2601,23 @@ this.addedTileEntityList.clear(); } @@ -1054,7 +1056,7 @@ } public void updateEntity(Entity p_72870_1_) -@@ -2036,21 +2625,36 @@ +@@ -2036,21 +2627,36 @@ public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_) { @@ -1093,7 +1095,7 @@ p_72866_1_.lastTickPosX = p_72866_1_.posX; p_72866_1_.lastTickPosY = p_72866_1_.posY; p_72866_1_.lastTickPosZ = p_72866_1_.posZ; -@@ -2134,6 +2738,7 @@ +@@ -2134,6 +2740,7 @@ p_72866_1_.riddenByEntity = null; } } @@ -1101,7 +1103,7 @@ } } -@@ -2570,7 +3175,7 @@ +@@ -2570,7 +3177,7 @@ return; } @@ -1110,7 +1112,7 @@ { if (this.field_147481_N) { -@@ -2718,7 +3323,15 @@ +@@ -2718,7 +3325,15 @@ if (i <= 0) { @@ -1127,7 +1129,7 @@ } } -@@ -2754,7 +3367,15 @@ +@@ -2754,7 +3369,15 @@ if (j <= 0) { @@ -1144,7 +1146,7 @@ } } -@@ -2777,8 +3398,41 @@ +@@ -2777,8 +3400,41 @@ protected void setActivePlayerChunksAndCheckLight() { this.activeChunkSet.clear(); @@ -1187,7 +1189,7 @@ int i; EntityPlayer entityplayer; int j; -@@ -2788,17 +3442,28 @@ +@@ -2788,17 +3444,28 @@ for (i = 0; i < this.playerEntities.size(); ++i) { entityplayer = (EntityPlayer)this.playerEntities.get(i); @@ -1223,7 +1225,7 @@ } this.theProfiler.endSection(); -@@ -2810,7 +3475,7 @@ +@@ -2810,7 +3477,7 @@ this.theProfiler.startSection("playerCheckLight"); @@ -1232,7 +1234,7 @@ { i = this.rand.nextInt(this.playerEntities.size()); entityplayer = (EntityPlayer)this.playerEntities.get(i); -@@ -3034,9 +3699,9 @@ +@@ -3034,9 +3701,9 @@ } } @@ -1244,7 +1246,7 @@ { return false; } -@@ -3166,6 +3831,16 @@ +@@ -3166,6 +3833,16 @@ } } @@ -1261,7 +1263,7 @@ this.theProfiler.endSection(); return true; } -@@ -3284,8 +3959,21 @@ +@@ -3284,8 +3961,21 @@ { Entity entity = (Entity)this.loadedEntityList.get(j); @@ -1284,7 +1286,7 @@ ++i; } } -@@ -3298,6 +3986,7 @@ +@@ -3298,6 +3988,7 @@ for (int i = 0; i < p_72868_1_.size(); ++i) { Entity entity = (Entity)p_72868_1_.get(i); @@ -1292,7 +1294,7 @@ if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this))) { loadedEntityList.add(entity); -@@ -3314,8 +4003,17 @@ +@@ -3314,8 +4005,17 @@ public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_) { Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_); @@ -1311,17 +1313,17 @@ } public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_) -@@ -3418,10 +4116,19 @@ +@@ -3418,10 +4118,19 @@ return this.getIndirectPowerLevelTo(p_94574_1_, p_94574_2_, p_94574_3_, p_94574_4_) > 0; } -+ private final HashMap indirect = new HashMap(); // TCPR KC ++ private final HashMap indirect = new HashMap(); // TCPR KC + public int getIndirectPowerLevelTo(int p_72878_1_, int p_72878_2_, int p_72878_3_, int p_72878_4_) { Block block = this.getBlock(p_72878_1_, p_72878_2_, p_72878_3_); - return block.shouldCheckWeakPower(this, p_72878_1_, p_72878_2_, p_72878_3_, p_72878_4_) ? this.getBlockPowerInput(p_72878_1_, p_72878_2_, p_72878_3_) : block.isProvidingWeakPower(this, p_72878_1_, p_72878_2_, p_72878_3_, p_72878_4_); -+ kcauldron.Coords c = new kcauldron.Coords(p_72878_1_, p_72878_2_, p_72878_3_) ++ Coords c = new Coords(p_72878_1_, p_72878_2_, p_72878_3_); + if(!indirect.containsKey(c) || System.currentTimeMillis() - (indirect.get(c)[1]) > 50) + { + int power = block.shouldCheckWeakPower(this, p_72878_1_, p_72878_2_, p_72878_3_, p_72878_4_) ? this.getBlockPowerInput(p_72878_1_, p_72878_2_, p_72878_3_) : block.isProvidingWeakPower(this, p_72878_1_, p_72878_2_, p_72878_3_, p_72878_4_); @@ -1332,7 +1334,7 @@ } public boolean isBlockIndirectlyGettingPowered(int p_72864_1_, int p_72864_2_, int p_72864_3_) -@@ -3464,6 +4171,12 @@ +@@ -3464,6 +4173,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1345,7 +1347,7 @@ double d5 = entityplayer1.getDistanceSq(p_72977_1_, p_72977_3_, p_72977_5_); if ((p_72977_7_ < 0.0D || d5 < p_72977_7_ * p_72977_7_) && (d4 == -1.0D || d5 < d4)) -@@ -3489,7 +4202,12 @@ +@@ -3489,7 +4204,12 @@ for (int i = 0; i < this.playerEntities.size(); ++i) { EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i); @@ -1359,7 +1361,7 @@ if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive()) { double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_); -@@ -3660,6 +4378,18 @@ +@@ -3660,6 +4380,18 @@ public void updateAllPlayersSleepingFlag() {} @@ -1378,7 +1380,7 @@ public float getWeightedThunderStrength(float p_72819_1_) { return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_); -@@ -3932,8 +4662,8 @@ +@@ -3932,8 +4664,8 @@ */ public void addTileEntity(TileEntity entity) { @@ -1389,7 +1391,7 @@ { dest.add(entity); } -@@ -4029,4 +4759,122 @@ +@@ -4029,4 +4761,122 @@ } return count; } diff --git a/src/main/java/net/minecraft/world/Coords.java b/src/main/java/net/minecraft/world/Coords.java new file mode 100644 index 0000000..84eef30 --- /dev/null +++ b/src/main/java/net/minecraft/world/Coords.java @@ -0,0 +1,23 @@ +package net.minecraft.world; +public class Coords +{ +public final int[] c; +private final int hash; +public Coords (int x, int y, int z) +{ +this.c = new int[] { x, y, z }; + this.hash = ((y * 31 + x) * 31 + z) * 17 + y; +} +@Override +public int hashCode() +{ +return this.hash; +} +@Override +public boolean equals(Object o) +{ +if(!(o instanceof Coords))return false; +Coords c = (Coords)o; +return this.c[0] == c.c[0] && this.c[1] == c.c[1] && this.c[2] == c.c[2]; +} +}