2016-05-25 03:08:40 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Martin Panzer <postremus1996@googlemail.com>
|
|
|
|
Date: Mon, 23 May 2016 12:12:37 +0200
|
|
|
|
Subject: [PATCH] Faster redstone torch rapid clock removal
|
|
|
|
|
|
|
|
Only resize the the redstone torch list once, since resizing arrays / lists is costly
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2016-05-25 03:08:40 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/BlockRedstoneTorch.java
|
2019-05-10 17:48:58 +02:00
|
|
|
@@ -0,0 +0,0 @@ import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
|
|
|
public class BlockRedstoneTorch extends BlockTorch {
|
|
|
|
|
|
|
|
public static final BlockStateBoolean LIT = BlockProperties.r;
|
|
|
|
- private static final Map<IBlockAccess, List<BlockRedstoneTorch.RedstoneUpdateInfo>> b = new WeakHashMap();
|
|
|
|
+ // Paper - Move the mapped list to World
|
|
|
|
|
2020-06-25 13:00:35 +02:00
|
|
|
protected BlockRedstoneTorch(BlockBase.Info blockbase_info) {
|
|
|
|
super(blockbase_info, ParticleParamRedstone.a);
|
2016-05-25 03:08:40 +02:00
|
|
|
@@ -0,0 +0,0 @@ public class BlockRedstoneTorch extends BlockTorch {
|
2020-06-25 13:00:35 +02:00
|
|
|
@Override
|
|
|
|
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
|
|
|
boolean flag = this.a((World) worldserver, blockposition, iblockdata);
|
|
|
|
- List list = (List) BlockRedstoneTorch.b.get(worldserver);
|
|
|
|
-
|
|
|
|
- while (list != null && !list.isEmpty() && worldserver.getTime() - ((BlockRedstoneTorch.RedstoneUpdateInfo) list.get(0)).b > 60L) {
|
2016-05-25 03:08:40 +02:00
|
|
|
- list.remove(0);
|
2020-06-25 13:00:35 +02:00
|
|
|
+ // Paper start
|
|
|
|
+ java.util.ArrayDeque<BlockRedstoneTorch.RedstoneUpdateInfo> redstoneUpdateInfos = worldserver.redstoneUpdateInfos;
|
2019-05-10 17:48:58 +02:00
|
|
|
+ if (redstoneUpdateInfos != null) {
|
|
|
|
+ BlockRedstoneTorch.RedstoneUpdateInfo curr;
|
2020-06-25 13:00:35 +02:00
|
|
|
+ while ((curr = redstoneUpdateInfos.peek()) != null && worldserver.getTime() - curr.getTime() > 60L) {
|
2019-05-10 17:48:58 +02:00
|
|
|
+ redstoneUpdateInfos.poll();
|
2016-05-25 03:08:40 +02:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
// CraftBukkit start
|
2020-06-25 13:00:35 +02:00
|
|
|
org.bukkit.plugin.PluginManager manager = worldserver.getServer().getPluginManager();
|
2019-05-10 17:48:58 +02:00
|
|
|
@@ -0,0 +0,0 @@ public class BlockRedstoneTorch extends BlockTorch {
|
|
|
|
}
|
|
|
|
|
|
|
|
private static boolean a(World world, BlockPosition blockposition, boolean flag) {
|
|
|
|
- List<BlockRedstoneTorch.RedstoneUpdateInfo> list = (List) BlockRedstoneTorch.b.computeIfAbsent(world, (iblockaccess) -> {
|
|
|
|
- return Lists.newArrayList();
|
|
|
|
- });
|
|
|
|
+ // Paper start
|
|
|
|
+ java.util.ArrayDeque<BlockRedstoneTorch.RedstoneUpdateInfo> list = world.redstoneUpdateInfos;
|
|
|
|
+ if (list == null) {
|
|
|
|
+ list = world.redstoneUpdateInfos = new java.util.ArrayDeque<>();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
list.add(new BlockRedstoneTorch.RedstoneUpdateInfo(blockposition.immutableCopy(), world.getTime()));
|
|
|
|
@@ -0,0 +0,0 @@ public class BlockRedstoneTorch extends BlockTorch {
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
- for (int j = 0; j < list.size(); ++j) {
|
|
|
|
- BlockRedstoneTorch.RedstoneUpdateInfo blockredstonetorch_redstoneupdateinfo = (BlockRedstoneTorch.RedstoneUpdateInfo) list.get(j);
|
|
|
|
-
|
|
|
|
+ for (java.util.Iterator<BlockRedstoneTorch.RedstoneUpdateInfo> iterator = list.iterator(); iterator.hasNext();) {
|
|
|
|
+ BlockRedstoneTorch.RedstoneUpdateInfo blockredstonetorch_redstoneupdateinfo = iterator.next();
|
|
|
|
+ // Paper end
|
|
|
|
if (blockredstonetorch_redstoneupdateinfo.a.equals(blockposition)) {
|
|
|
|
++i;
|
|
|
|
if (i >= 8) {
|
2016-05-25 03:08:40 +02:00
|
|
|
@@ -0,0 +0,0 @@ public class BlockRedstoneTorch extends BlockTorch {
|
2018-07-16 17:34:55 +02:00
|
|
|
public static class RedstoneUpdateInfo {
|
2016-05-25 03:08:40 +02:00
|
|
|
|
2018-07-16 17:34:55 +02:00
|
|
|
private final BlockPosition a;
|
|
|
|
- private final long b;
|
|
|
|
+ private final long b; final long getTime() { return this.b; } // Paper - OBFHELPER
|
2016-05-25 03:08:40 +02:00
|
|
|
|
|
|
|
public RedstoneUpdateInfo(BlockPosition blockposition, long i) {
|
|
|
|
this.a = blockposition;
|
2019-05-10 17:48:58 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2019-05-10 17:48:58 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2019-12-12 00:43:22 +01:00
|
|
|
@@ -0,0 +0,0 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
2019-05-10 17:48:58 +02:00
|
|
|
private org.spigotmc.TickLimiter tileLimiter;
|
|
|
|
private int tileTickPosition;
|
|
|
|
public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
|
|
|
|
+ public java.util.ArrayDeque<BlockRedstoneTorch.RedstoneUpdateInfo> redstoneUpdateInfos; // Paper - Move from Map in BlockRedstoneTorch to here
|
|
|
|
|
|
|
|
public CraftWorld getWorld() {
|
|
|
|
return this.world;
|