Browse Source

Fixing getIndirect() in progress

master
Robotia 9 years ago
parent
commit
be6d06bcd1
  1. 10
      patches/net/minecraft/world/World.java.patch
  2. 22
      src/main/java/kcauldron/Coords.java

10
patches/net/minecraft/world/World.java.patch

@ -1315,20 +1315,20 @@
return this.getIndirectPowerLevelTo(p_94574_1_, p_94574_2_, p_94574_3_, p_94574_4_) > 0; return this.getIndirectPowerLevelTo(p_94574_1_, p_94574_2_, p_94574_3_, p_94574_4_) > 0;
} }
+ private final HashMap<Block, long[]> indirect = new HashMap<Block, long[]>(); // TCPR KC + private final HashMap<kcauldron.Coords, long[]> indirect = new HashMap<kcauldron.Coords, long[]>(); // TCPR KC
+ +
public int getIndirectPowerLevelTo(int p_72878_1_, int p_72878_2_, int p_72878_3_, int p_72878_4_) 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_); 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_); - 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_)
+ if(!indirect.containsKey(block) || System.currentTimeMillis() - (indirect.get(block)[1]) > 1) + 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_); + 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_);
+ indirect.put(block, new long[] { power, (System.currentTimeMillis()) }); + indirect.put(c, new long[] { power, (System.currentTimeMillis()) });
+ return power; + return power;
+ } + }
+ return (int)(indirect.get(block)[0]); + return (int)(indirect.get(c)[0]);
} }
public boolean isBlockIndirectlyGettingPowered(int p_72864_1_, int p_72864_2_, int p_72864_3_) public boolean isBlockIndirectlyGettingPowered(int p_72864_1_, int p_72864_2_, int p_72864_3_)

22
src/main/java/kcauldron/Coords.java

@ -0,0 +1,22 @@
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];
}
}
Loading…
Cancel
Save