Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-16 11:30:06 +01:00
26734e83b0
* Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 8085edde SPIGOT-6918: Add SpawnCategory API and configurations for Axolotls 04c7e13c PR-719: Add Player Profile API 71564210 SPIGOT-6910: Add BlockDamageAbortEvent CraftBukkit Changes: febaa1c6 SPIGOT-6918: Add SpawnCategory API and configurations for Axolotls 9dafd109 Don't send updates over large distances bdac46b0 SPIGOT-6782: EntityPortalEvent should not destroy entity when setTo() uses same world as getFrom() 8f361ece PR-1002: Add Player Profile API 911875d4 Increase outdated build delay e5f8a767 SPIGOT-6917: Use main scoreboard for /trigger a672a531 Clean up callBlockDamageEvent 8e1bdeef SPIGOT-6910: Add BlockDamageAbortEvent Spigot Changes: 6edb62f3 Rebuild patches 7fbc6a1e Rebuild patches * Updated Upstream (CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing CraftBukkit Changes: de951355 SPIGOT-6927: Fix default value of spawn-limits in Worlds
82 Zeilen
4.4 KiB
Diff
82 Zeilen
4.4 KiB
Diff
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/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
|
index 46f8fff21c0d91b9326b9270def43bd99c54b3ac..e33c9116ebd8ad751774fd0fa736c42214aed654 100644
|
|
--- a/src/main/java/net/minecraft/world/level/Level.java
|
|
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
|
@@ -159,6 +159,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
|
private org.spigotmc.TickLimiter tileLimiter;
|
|
private int tileTickPosition;
|
|
public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
|
|
+ public java.util.ArrayDeque<net.minecraft.world.level.block.RedstoneTorchBlock.Toggle> redstoneUpdateInfos; // Paper - Move from Map in BlockRedstoneTorch to here
|
|
|
|
public CraftWorld getWorld() {
|
|
return this.world;
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
|
|
index 298928f9dae5fc307872f4cb286b644ed5dbcfde..954b86bea345a8e0e3a8dd425f356db6f5cd496f 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
|
|
@@ -21,7 +21,7 @@ import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
|
public class RedstoneTorchBlock extends TorchBlock {
|
|
|
|
public static final BooleanProperty LIT = BlockStateProperties.LIT;
|
|
- private static final Map<BlockGetter, List<RedstoneTorchBlock.Toggle>> RECENT_TOGGLES = new WeakHashMap();
|
|
+ // Paper - Move the mapped list to World
|
|
public static final int RECENT_TOGGLE_TIMER = 60;
|
|
public static final int MAX_RECENT_TOGGLES = 8;
|
|
public static final int RESTART_DELAY = 160;
|
|
@@ -72,11 +72,15 @@ public class RedstoneTorchBlock extends TorchBlock {
|
|
@Override
|
|
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
|
|
boolean flag = this.hasNeighborSignal(world, pos, state);
|
|
- List list = (List) RedstoneTorchBlock.RECENT_TOGGLES.get(world);
|
|
-
|
|
- while (list != null && !list.isEmpty() && world.getGameTime() - ((RedstoneTorchBlock.Toggle) list.get(0)).when > 60L) {
|
|
- list.remove(0);
|
|
+ // Paper start
|
|
+ java.util.ArrayDeque<RedstoneTorchBlock.Toggle> redstoneUpdateInfos = world.redstoneUpdateInfos;
|
|
+ if (redstoneUpdateInfos != null) {
|
|
+ RedstoneTorchBlock.Toggle curr;
|
|
+ while ((curr = redstoneUpdateInfos.peek()) != null && world.getGameTime() - curr.when > 60L) {
|
|
+ redstoneUpdateInfos.poll();
|
|
+ }
|
|
}
|
|
+ // Paper end
|
|
|
|
// CraftBukkit start
|
|
org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager();
|
|
@@ -152,9 +156,12 @@ public class RedstoneTorchBlock extends TorchBlock {
|
|
}
|
|
|
|
private static boolean isToggledTooFrequently(Level world, BlockPos pos, boolean addNew) {
|
|
- List<RedstoneTorchBlock.Toggle> list = (List) RedstoneTorchBlock.RECENT_TOGGLES.computeIfAbsent(world, (iblockaccess) -> {
|
|
- return Lists.newArrayList();
|
|
- });
|
|
+ // Paper start
|
|
+ java.util.ArrayDeque<RedstoneTorchBlock.Toggle> list = world.redstoneUpdateInfos;
|
|
+ if (list == null) {
|
|
+ list = world.redstoneUpdateInfos = new java.util.ArrayDeque<>();
|
|
+ }
|
|
+
|
|
|
|
if (addNew) {
|
|
list.add(new RedstoneTorchBlock.Toggle(pos.immutable(), world.getGameTime()));
|
|
@@ -162,9 +169,9 @@ public class RedstoneTorchBlock extends TorchBlock {
|
|
|
|
int i = 0;
|
|
|
|
- for (int j = 0; j < list.size(); ++j) {
|
|
- RedstoneTorchBlock.Toggle blockredstonetorch_redstoneupdateinfo = (RedstoneTorchBlock.Toggle) list.get(j);
|
|
-
|
|
+ for (java.util.Iterator<RedstoneTorchBlock.Toggle> iterator = list.iterator(); iterator.hasNext();) {
|
|
+ RedstoneTorchBlock.Toggle blockredstonetorch_redstoneupdateinfo = iterator.next();
|
|
+ // Paper end
|
|
if (blockredstonetorch_redstoneupdateinfo.pos.equals(pos)) {
|
|
++i;
|
|
if (i >= 8) {
|