Browse Source

Limit RedstoneDiode (repeater) and RedstoneTorch update speed

master
Robotia 9 years ago
parent
commit
35265035ea
  1. 40
      patches/net/minecraft/block/BlockRedstoneDiode.java.patch
  2. 24
      patches/net/minecraft/block/BlockRedstoneTorch.java.patch

40
patches/net/minecraft/block/BlockRedstoneDiode.java.patch

@ -1,6 +1,6 @@
--- ../src-base/minecraft/net/minecraft/block/BlockRedstoneDiode.java --- ../src-base/minecraft/net/minecraft/block/BlockRedstoneDiode.java
+++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneDiode.java +++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneDiode.java
@@ -13,6 +13,8 @@ @@ -13,16 +13,19 @@
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -9,7 +9,26 @@
public abstract class BlockRedstoneDiode extends BlockDirectional public abstract class BlockRedstoneDiode extends BlockDirectional
{ {
protected final boolean isRepeaterPowered; protected final boolean isRepeaterPowered;
@@ -44,16 +46,30 @@ private static final String __OBFID = "CL_00000226";
-
+private boolean limit;
protected BlockRedstoneDiode(boolean p_i45400_1_)
{
super(Material.circuits);
this.isRepeaterPowered = p_i45400_1_;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
+if(this.getClass().getSimpleName().toLowerCase().contains("redstonerepeater"))limit = true;
}
public boolean renderAsNormalBlock()
@@ -39,27 +42,45 @@
{
return !World.doesBlockHaveSolidTopSurface(p_149718_1_, p_149718_2_, p_149718_3_ - 1, p_149718_4_) ? false : super.canBlockStay(p_149718_1_, p_149718_2_, p_149718_3_, p_149718_4_);
}
-
+boolean state = false;
+long last = 0L;
public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
{ {
int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_); int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
@ -25,9 +44,11 @@
+ { + {
+ return; + return;
+ } + }
+if(limit && System.currentTimeMillis() - last <= 150)return;
+ +
+ // CraftBukkit end + // CraftBukkit end
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, this.getBlockUnpowered(), l, 2); p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, this.getBlockUnpowered(), l, 2);
+last = System.currentTimeMillis();
} }
else if (!this.isRepeaterPowered) else if (!this.isRepeaterPowered)
{ {
@ -36,8 +57,21 @@
+ { + {
+ return; + return;
+ } + }
+ +if(limit && System.currentTimeMillis() - last <= 150)return;
+ // CraftBukkit end + // CraftBukkit end
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, this.getBlockPowered(), l, 2); p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, this.getBlockPowered(), l, 2);
if (!flag) if (!flag)
{
p_149674_1_.scheduleBlockUpdateWithPriority(p_149674_2_, p_149674_3_, p_149674_4_, this.getBlockPowered(), this.func_149899_k(l), -1);
}
+last = System.currentTimeMillis();
}
}
}
@@ -315,4 +336,4 @@
{
return this.func_149907_e(p_149667_1_);
}
-}
+}

24
patches/net/minecraft/block/BlockRedstoneTorch.java.patch

@ -9,7 +9,15 @@
public class BlockRedstoneTorch extends BlockTorch public class BlockRedstoneTorch extends BlockTorch
{ {
private boolean field_150113_a; private boolean field_150113_a;
@@ -125,10 +127,30 @@ @@ -114,6 +116,7 @@
int l = p_150110_1_.getBlockMetadata(p_150110_2_, p_150110_3_, p_150110_4_);
return l == 5 && p_150110_1_.getIndirectPowerOutput(p_150110_2_, p_150110_3_ - 1, p_150110_4_, 0) ? true : (l == 3 && p_150110_1_.getIndirectPowerOutput(p_150110_2_, p_150110_3_, p_150110_4_ - 1, 2) ? true : (l == 4 && p_150110_1_.getIndirectPowerOutput(p_150110_2_, p_150110_3_, p_150110_4_ + 1, 3) ? true : (l == 1 && p_150110_1_.getIndirectPowerOutput(p_150110_2_ - 1, p_150110_3_, p_150110_4_, 4) ? true : l == 2 && p_150110_1_.getIndirectPowerOutput(p_150110_2_ + 1, p_150110_3_, p_150110_4_, 5))));
}
+long last = 0L;
public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
{
@@ -125,11 +128,33 @@
list.remove(0); list.remove(0);
} }
@ -37,10 +45,13 @@
+ } + }
+ +
+ // CraftBukkit end + // CraftBukkit end
+ if(System.currentTimeMillis() - last <= 150) return;
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.unlit_redstone_torch, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 3); p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.unlit_redstone_torch, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 3);
+ last = System.currentTimeMillis();
if (this.func_150111_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, true)) if (this.func_150111_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, true))
@@ -147,6 +169,19 @@ {
@@ -147,7 +172,22 @@
} }
else if (!flag && !this.func_150111_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, false)) else if (!flag && !this.func_150111_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, false))
{ {
@ -57,6 +68,15 @@
+ } + }
+ +
+ // CraftBukkit end + // CraftBukkit end
+ if(System.currentTimeMillis() - last <= 150) return;
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.redstone_torch, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 3); p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.redstone_torch, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 3);
+ last = System.currentTimeMillis();
}
}
@@ -241,4 +281,4 @@
this.field_150844_d = p_i45422_4_;
} }
} }
-}
+}

Loading…
Cancel
Save