Compare commits

...

4 Commits

Author SHA1 Message Date
Spottedleaf ef2c697189 Properly handle unticked hopper tick adjustment
For unticked hoppers, we should use MIN_VALUE as a marker
so that they compare equivalently regardless of whether they've
been through a region merge.
2024-03-28 18:43:02 -07:00
Spottedleaf e50d09b67b Use redstone time in a few appropriate areas
1. Moving piston last tick
2. Living entity last damage stamp
3. Entity piston deltas

This should resolve primarily timing problems using pistons.
2024-03-28 18:38:09 -07:00
Spottedleaf a9e9e5f7e0 Use ThreadLocal for SignItem#openSign
This fixes cross-region data access where there shouldn't be any
2024-03-28 18:38:09 -07:00
Spottedleaf e73566fdc2 Use redstone game time for hopper tickedGameTime
This should fix timing inconsistencies for hoppers
2024-03-28 18:38:09 -07:00
3 changed files with 245 additions and 47 deletions

View File

@ -16402,7 +16402,7 @@ index ea27b46eec01bda427653335f922ccd068cffcb5..e551d3b875eab6851b75041f418c9a08
return blockToFallLocation(blockState);
} else {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f2191176347e25 100644
index b2eff51f1ad1e702525ef298807ea7d2083f6218..79e9039d77a993d8f1e02942f87fac2a0bd9e8a8 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -170,7 +170,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@ -16423,6 +16423,15 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
public @org.jetbrains.annotations.Nullable net.minecraft.server.level.ChunkMap.TrackedEntity tracker; // Paper
public CraftEntity getBukkitEntity() {
@@ -378,7 +378,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
private boolean hasGlowingTag;
private final Set<String> tags;
private final double[] pistonDeltas;
- private long pistonDeltasGameTime;
+ private long pistonDeltasGameTime = Long.MIN_VALUE; // Folia - region threading
private EntityDimensions dimensions;
private float eyeHeight;
public boolean isInPowderSnow;
@@ -479,28 +479,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.isLegacyTrackingEntity = isLegacyTrackingEntity;
}
@ -16453,7 +16462,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
// Paper end - optimise entity tracking
public float getBukkitYaw() {
return this.yRot;
@@ -567,6 +546,16 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -567,6 +546,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
public boolean updatingSectionStatus = false;
// Paper end
@ -16465,12 +16474,15 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
+ if (this.activatedImmunityTick != Integer.MIN_VALUE) {
+ this.activatedImmunityTick += fromTickOffset;
+ }
+ if (this.pistonDeltasGameTime != Long.MIN_VALUE) {
+ this.pistonDeltasGameTime += fromRedstoneTimeOffset;
+ }
+ }
+ // Folia end - region ticking
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -825,6 +814,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -825,6 +817,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
// CraftBukkit start
public void postTick() {
@ -16483,7 +16495,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
// No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle
if (!(this instanceof ServerPlayer) && this.isAlive()) { // Paper - don't attempt to teleport dead entities
this.handleNetherPortal();
@@ -847,7 +842,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -847,7 +845,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.walkDistO = this.walkDist;
this.xRotO = this.getXRot();
this.yRotO = this.getYRot();
@ -16492,7 +16504,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
if (this.canSpawnSprintParticle()) {
this.spawnSprintParticle();
}
@@ -1105,8 +1100,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1105,8 +1103,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
} else {
this.wasOnFire = this.isOnFire();
if (movementType == MoverType.PISTON) {
@ -16503,7 +16515,16 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
movement = this.limitPistonMovement(movement);
if (movement.equals(Vec3.ZERO)) {
return;
@@ -3018,7 +3013,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -1433,7 +1431,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
if (movement.lengthSqr() <= 1.0E-7D) {
return movement;
} else {
- long i = this.level().getGameTime();
+ long i = this.level().getRedstoneGameTime(); // Folia - region threading
if (i != this.pistonDeltasGameTime) {
Arrays.fill(this.pistonDeltas, 0.0D);
@@ -3018,7 +3016,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.passengers = ImmutableList.copyOf(list);
}
@ -16512,7 +16533,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
}
}
@@ -3066,7 +3061,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3066,7 +3064,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
entity.boardingCooldown = 60;
@ -16521,7 +16542,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
}
return true; // CraftBukkit
}
@@ -3346,6 +3341,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3346,6 +3344,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@Nullable
public PlayerTeam getTeam() {
@ -16533,7 +16554,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof Player)) { return null; } // Paper - Perf: Disable Scoreboards for non players by default
return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName());
}
@@ -3635,6 +3635,775 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3635,6 +3638,775 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.portalEntrancePos = original.portalEntrancePos;
}
@ -17309,7 +17330,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
@Nullable
public Entity changeDimension(ServerLevel destination) {
// CraftBukkit start
@@ -3643,6 +4412,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3643,6 +4415,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@Nullable
public Entity teleportTo(ServerLevel worldserver, Vec3 location) {
@ -17321,7 +17342,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
// CraftBukkit end
// Paper start - Fix item duplication and teleport issues
if (!this.isAlive() || !this.valid) {
@@ -3735,6 +4509,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3735,6 +4512,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
}
@ -17334,7 +17355,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
protected void removeAfterChangingDimensions() {
this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION, null); // CraftBukkit - add Bukkit remove cause
}
@@ -4669,7 +5449,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4669,7 +5452,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
}
// Paper end - Fix MC-4
@ -17344,7 +17365,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
synchronized (this.posLock) { // Paper
this.position = new Vec3(x, y, z);
} // Paper
@@ -4690,7 +5471,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4690,7 +5474,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
// Paper start - Block invalid positions and bounding box; don't allow desync of pos and AABB
// hanging has its own special logic
@ -17353,7 +17374,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
this.setBoundingBox(this.makeBoundingBox());
}
// Paper end - Block invalid positions and bounding box
@@ -4777,6 +5558,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4777,6 +5561,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
return this.removalReason != null;
}
@ -17366,7 +17387,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
@Nullable
public Entity.RemovalReason getRemovalReason() {
return this.removalReason;
@@ -4800,6 +5587,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4800,6 +5590,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
CraftEventFactory.callEntityRemoveEvent(this, cause);
// CraftBukkit end
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
@ -17376,7 +17397,7 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
if (this.removalReason == null) {
this.removalReason = entity_removalreason;
}
@@ -4822,6 +5612,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -4822,6 +5615,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
this.removalReason = null;
}
@ -17388,15 +17409,32 @@ index b2eff51f1ad1e702525ef298807ea7d2083f6218..39434804e84418e44d595012e8f21911
/**
* Invoked only when the entity is truly removed from the server, never to be added to any world.
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 23570a0b1227a840b9c1e6ae326827ea655bb5f7..206e662c8a43604d5a7563868348d501c135017c 100644
index 23570a0b1227a840b9c1e6ae326827ea655bb5f7..a8b47867f05af2a1a4409be5ff49ad0d95bebcae 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -276,6 +276,13 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -246,7 +246,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
private Optional<BlockPos> lastClimbablePos;
@Nullable
private DamageSource lastDamageSource;
- private long lastDamageStamp;
+ private long lastDamageStamp = Long.MIN_VALUE; // Folia - region threading
protected int autoSpinAttackTicks;
private float swimAmount;
private float swimAmountO;
@@ -276,6 +276,21 @@ public abstract class LivingEntity extends Entity implements Attackable {
++this.noActionTime; // Above all the floats
}
// Spigot end
+ // Folia start - region threading
+ @Override
+ public void updateTicks(long fromTickOffset, long fromRedstoneTimeOffset) {
+ super.updateTicks(fromTickOffset, fromRedstoneTimeOffset);
+ if (this.lastDamageStamp != Long.MIN_VALUE) {
+ this.lastDamageStamp += fromRedstoneTimeOffset;
+ }
+ }
+
+ @Override
+ protected void resetStoredPositions() {
+ super.resetStoredPositions();
+ this.lastClimbablePos = Optional.empty();
@ -17405,7 +17443,7 @@ index 23570a0b1227a840b9c1e6ae326827ea655bb5f7..206e662c8a43604d5a7563868348d501
protected LivingEntity(EntityType<? extends LivingEntity> type, Level world) {
super(type, world);
@@ -481,7 +488,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -481,7 +496,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
if (this.isDeadOrDying() && this.level().shouldTickDeath(this)) {
this.tickDeath();
@ -17414,7 +17452,7 @@ index 23570a0b1227a840b9c1e6ae326827ea655bb5f7..206e662c8a43604d5a7563868348d501
if (this.lastHurtByPlayerTime > 0) {
--this.lastHurtByPlayerTime;
@@ -627,11 +634,14 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -627,11 +642,14 @@ public abstract class LivingEntity extends Entity implements Attackable {
return true;
}
@ -17431,7 +17469,7 @@ index 23570a0b1227a840b9c1e6ae326827ea655bb5f7..206e662c8a43604d5a7563868348d501
}
}
@@ -860,9 +870,9 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -860,9 +878,9 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
this.hurtTime = nbt.getShort("HurtTime");
@ -17443,7 +17481,7 @@ index 23570a0b1227a840b9c1e6ae326827ea655bb5f7..206e662c8a43604d5a7563868348d501
String s = nbt.getString("Team");
PlayerTeam scoreboardteam = this.level().getScoreboard().getPlayerTeam(s);
if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof net.minecraft.world.entity.player.Player)) { scoreboardteam = null; } // Paper - Perf: Disable Scoreboards for non players by default
@@ -1149,6 +1159,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -1149,6 +1167,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
public boolean addEffect(MobEffectInstance mobeffect, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent) {
// Paper end - Don't fire sync event during generation
// org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot // Paper - move to API
@ -17451,7 +17489,25 @@ index 23570a0b1227a840b9c1e6ae326827ea655bb5f7..206e662c8a43604d5a7563868348d501
if (this.isTickingEffects) {
this.effectsToProcess.add(new ProcessableEffect(mobeffect, cause));
return true;
@@ -2359,7 +2370,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -1573,7 +1592,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
if (flag2) {
this.lastDamageSource = source;
- this.lastDamageStamp = this.level().getGameTime();
+ this.lastDamageStamp = this.level().getRedstoneGameTime(); // Folia - region threading
}
if (this instanceof ServerPlayer) {
@@ -1656,7 +1675,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@Nullable
public DamageSource getLastDamageSource() {
- if (this.level().getGameTime() - this.lastDamageStamp > 40L) {
+ if (this.level().getRedstoneGameTime() - this.lastDamageStamp > 40L || this.lastDamageStamp == Long.MIN_VALUE) { // Folia - region threading
this.lastDamageSource = null;
}
@@ -2359,7 +2378,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@Nullable
public LivingEntity getKillCredit() {
@ -17460,7 +17516,16 @@ index 23570a0b1227a840b9c1e6ae326827ea655bb5f7..206e662c8a43604d5a7563868348d501
}
public final float getMaxHealth() {
@@ -3502,7 +3513,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -2437,7 +2456,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
this.hurt(this.damageSources().generic(), 0.0F);
this.lastDamageSource = damageSource;
- this.lastDamageStamp = this.level().getGameTime();
+ this.lastDamageStamp = this.level().getRedstoneGameTime(); // Folia - region threading
}
@Override
@@ -3502,7 +3521,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
this.pushEntities();
this.level().getProfiler().pop();
// Paper start - Add EntityMoveEvent
@ -17469,7 +17534,7 @@ index 23570a0b1227a840b9c1e6ae326827ea655bb5f7..206e662c8a43604d5a7563868348d501
if (this.xo != this.getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) {
Location from = new Location(this.level().getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO);
Location to = new Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
@@ -4195,7 +4206,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -4195,7 +4214,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
BlockPos blockposition = BlockPos.containing(d0, d1, d2);
Level world = this.level();
@ -18882,7 +18947,7 @@ index 6b81be03f87967124b046708557e05d519aa79e4..2220ac02eec17c0791e5b4ce8f5e0853
}
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 1ad126d992d95062a3db08374db7a927f23a0cac..7de615a1b474269bb1c1dcb613d564fbc59c13b5 100644
index 1ad126d992d95062a3db08374db7a927f23a0cac..43d8f91cdbc4e197f2811fb406a7dae8a8ebfdc1 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -379,31 +379,32 @@ public final class ItemStack {
@ -18927,8 +18992,12 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..7de615a1b474269bb1c1dcb613d564fb
StructureGrowEvent structureEvent = null;
if (treeType != null) {
boolean isBonemeal = this.getItem() == Items.BONE_MEAL;
@@ -432,13 +433,13 @@ public final class ItemStack {
SignItem.openSign = null; // SPIGOT-6758 - Reset on early return
@@ -429,16 +430,16 @@ public final class ItemStack {
entityhuman.awardStat(Stats.ITEM_USED.get(item)); // SPIGOT-7236 - award stat
}
- SignItem.openSign = null; // SPIGOT-6758 - Reset on early return
+ SignItem.openSign.set(null); // SPIGOT-6758 - Reset on early return // Folia - region threading
return enuminteractionresult;
}
- world.captureTreeGeneration = false;
@ -18961,6 +19030,15 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..7de615a1b474269bb1c1dcb613d564fb
// Brute force all possible updates
// Paper start - Don't resync blocks
@@ -464,7 +465,7 @@ public final class ItemStack {
// ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, placedPos.relative(dir)));
// }
// Paper end - Don't resync blocks
- SignItem.openSign = null; // SPIGOT-6758 - Reset on early return
+ SignItem.openSign.set(null); // SPIGOT-6758 - Reset on early return // Folia - region threading
} else {
// Change the stack to its new contents if it hasn't been tampered with.
if (this.getCount() == oldCount && Objects.equals(this.tag, oldData)) {
@@ -472,7 +473,7 @@ public final class ItemStack {
this.setCount(newCount);
}
@ -18970,6 +19048,26 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..7de615a1b474269bb1c1dcb613d564fb
world.setBlockEntity(e.getValue());
}
@@ -523,15 +524,15 @@ public final class ItemStack {
}
// SPIGOT-4678
- if (this.item instanceof SignItem && SignItem.openSign != null) {
+ if (this.item instanceof SignItem && SignItem.openSign.get() != null) { // Folia - region threading
try {
- if (world.getBlockEntity(SignItem.openSign) instanceof SignBlockEntity tileentitysign) {
- if (world.getBlockState(SignItem.openSign).getBlock() instanceof SignBlock blocksign) {
+ if (world.getBlockEntity(SignItem.openSign.get()) instanceof SignBlockEntity tileentitysign) { // Folia - region threading
+ if (world.getBlockState(SignItem.openSign.get()).getBlock() instanceof SignBlock blocksign) { // Folia - region threading
blocksign.openTextEdit(entityhuman, tileentitysign, true, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.PLACE); // Paper - Add PlayerOpenSignEvent
}
}
} finally {
- SignItem.openSign = null;
+ SignItem.openSign.set(null); // Folia - region threading
}
}
@@ -559,8 +560,8 @@ public final class ItemStack {
entityhuman.awardStat(Stats.ITEM_USED.get(item));
}
@ -19058,6 +19156,28 @@ index 3aa73cd44aa8c86b78c35bc1788e4f83018c49ed..cfead7686da25d2cd9203256962170d7
worldserver.getCraftServer().getPluginManager().callEvent(event);
}
diff --git a/src/main/java/net/minecraft/world/item/SignItem.java b/src/main/java/net/minecraft/world/item/SignItem.java
index 21c25026da4117b2cb2c85576d2def945a97dbe2..e0b51cb4ef9e847dc9a2e66f2c87c94d6d93c6a3 100644
--- a/src/main/java/net/minecraft/world/item/SignItem.java
+++ b/src/main/java/net/minecraft/world/item/SignItem.java
@@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockState;
public class SignItem extends StandingAndWallBlockItem {
- public static BlockPos openSign; // CraftBukkit
+ public static final ThreadLocal<BlockPos> openSign = new ThreadLocal<>(); // CraftBukkit // Folia - region threading
public SignItem(Item.Properties settings, Block standingBlock, Block wallBlock) {
super(standingBlock, wallBlock, settings, Direction.DOWN);
@@ -39,7 +39,7 @@ public class SignItem extends StandingAndWallBlockItem {
// CraftBukkit start - SPIGOT-4678
// blocksign.openTextEdit(entityhuman, tileentitysign, true);
- SignItem.openSign = pos;
+ SignItem.openSign.set(pos); // Folia - region threading
// CraftBukkit end
}
}
diff --git a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java b/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
index 524b0f1086c01888fe0b76e180c40915d16a1eb9..50b3025189938374886c7e2725dd3e4d54ac2160 100644
--- a/src/main/java/net/minecraft/world/level/BaseCommandBlock.java
@ -20274,10 +20394,45 @@ index 37e0b762b86e74f607a4541ecb7b24ad7a591d0e..4ddc3b3dc704610bf1fb7082e1c89a28
if (i % 40L == 0L) {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index cdb739df2a285032d25d84f4464f202a7a3fa578..4fe1b822b4c280de9d5b46c1dc965045791c83d0 100644
index cdb739df2a285032d25d84f4464f202a7a3fa578..82e7e76fecceb55522b5828a56f036e42ef55201 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -234,12 +234,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -50,7 +50,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
public static final int HOPPER_CONTAINER_SIZE = 5;
private NonNullList<ItemStack> items;
public int cooldownTime;
- private long tickedGameTime;
+ private long tickedGameTime = Long.MIN_VALUE; // Folia - region threading
// CraftBukkit start - add fields and methods
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
@@ -82,6 +82,16 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
}
// CraftBukkit end
+ // Folia start - region threading
+ @Override
+ public void updateTicks(final long fromTickOffset, final long fromRedstoneTimeOffset) {
+ super.updateTicks(fromTickOffset, fromRedstoneTimeOffset);
+ if (this.tickedGameTime != Long.MIN_VALUE) {
+ this.tickedGameTime += fromRedstoneTimeOffset;
+ }
+ }
+ // Folia end - region threading
+
public HopperBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityType.HOPPER, pos, state);
this.items = NonNullList.withSize(5, ItemStack.EMPTY);
@@ -137,7 +147,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
public static void pushItemsTick(Level world, BlockPos pos, BlockState state, HopperBlockEntity blockEntity) {
--blockEntity.cooldownTime;
- blockEntity.tickedGameTime = world.getGameTime();
+ blockEntity.tickedGameTime = world.getRedstoneGameTime(); // Folia - region threading
if (!blockEntity.isOnCooldown()) {
blockEntity.setCooldown(0);
// Spigot start
@@ -234,12 +244,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
}
// Paper start - Perf: Optimize Hoppers
@ -20293,7 +20448,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..4fe1b822b4c280de9d5b46c1dc965045
boolean foundItem = false;
for (int i = 0; i < hopper.getContainerSize(); ++i) {
final ItemStack item = hopper.getItem(i);
@@ -254,7 +253,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -254,7 +263,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
// We only need to fire the event once to give protection plugins a chance to cancel this event
// Because nothing uses getItem, every event call should end up the same result.
@ -20302,7 +20457,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..4fe1b822b4c280de9d5b46c1dc965045
movedItem = callPushMoveEvent(destination, movedItem, hopper);
if (movedItem == null) { // cancelled
origItemStack.setCount(originalItemCount);
@@ -284,13 +283,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -284,13 +293,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
}
private static boolean hopperPull(final Level level, final Hopper hopper, final Container container, ItemStack origItemStack, final int i) {
@ -20318,7 +20473,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..4fe1b822b4c280de9d5b46c1dc965045
movedItem = callPullMoveEvent(hopper, container, movedItem);
if (movedItem == null) { // cancelled
origItemStack.setCount(originalItemCount);
@@ -310,9 +310,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -310,9 +320,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
origItemStack.setCount(originalItemCount - movedItemCount + remainingItemCount);
}
@ -20330,7 +20485,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..4fe1b822b4c280de9d5b46c1dc965045
container.setChanged();
return true;
}
@@ -327,12 +327,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -327,12 +337,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@Nullable
private static ItemStack callPushMoveEvent(Container iinventory, ItemStack itemstack, HopperBlockEntity hopper) {
@ -20345,7 +20500,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..4fe1b822b4c280de9d5b46c1dc965045
}
if (!result) {
cooldownHopper(hopper);
@@ -348,6 +349,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -348,6 +359,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@Nullable
private static ItemStack callPullMoveEvent(final Hopper hopper, final Container container, final ItemStack itemstack) {
@ -20353,7 +20508,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..4fe1b822b4c280de9d5b46c1dc965045
final Inventory sourceInventory = getInventory(container);
final Inventory destination = getInventory(hopper);
@@ -355,7 +357,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -355,7 +367,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
final io.papermc.paper.event.inventory.PaperInventoryMoveItemEvent event = new io.papermc.paper.event.inventory.PaperInventoryMoveItemEvent(sourceInventory, CraftItemStack.asCraftMirror(itemstack), destination, false);
final boolean result = event.callEvent();
if (!event.calledGetItem && !event.calledSetItem) {
@ -20362,7 +20517,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..4fe1b822b4c280de9d5b46c1dc965045
}
if (!result) {
cooldownHopper(hopper);
@@ -518,13 +520,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -518,13 +530,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
}
public static boolean suckInItems(Level world, Hopper hopper) {
@ -20378,7 +20533,7 @@ index cdb739df2a285032d25d84f4464f202a7a3fa578..4fe1b822b4c280de9d5b46c1dc965045
// merge container isEmpty check and move logic into one loop
if (iinventory instanceof WorldlyContainer worldlyContainer) {
for (final int slot : worldlyContainer.getSlotsForFace(enumdirection)) {
@@ -724,9 +727,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -724,9 +737,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
stack = stack.split(to.getMaxStackSize());
}
// Spigot end
@ -20790,11 +20945,45 @@ index 8cb822fed0cda4268f288feae1079a3dc4dc103e..3f53d51960ded5df3b8be12362110f22
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
index be74adc86f0ca467f3b59e7b57fd47a8f381d86e..363a712d6b9e717b075aa52643c6cf91497e7c3b 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
@@ -152,7 +152,7 @@ public class PistonBaseBlock extends DirectionalBlock {
if (tileentity instanceof PistonMovingBlockEntity) {
PistonMovingBlockEntity tileentitypiston = (PistonMovingBlockEntity) tileentity;
- if (tileentitypiston.isExtending() && (tileentitypiston.getProgress(0.0F) < 0.5F || world.getGameTime() == tileentitypiston.getLastTicked() || ((ServerLevel) world).isHandlingTick())) {
+ if (tileentitypiston.isExtending() && (tileentitypiston.getProgress(0.0F) < 0.5F || world.getRedstoneGameTime() == tileentitypiston.getLastTicked() || ((ServerLevel) world).isHandlingTick())) { // Folia - region threading
b0 = 2;
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
index c71690dbc3dc52803945f1608f0ee3ba94146354..1c23597f172f46eec714b510acfedb415bb01bff 100644
index c71690dbc3dc52803945f1608f0ee3ba94146354..1955b660907c5d6b5ca4bf7741f8d568b9255347 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java
@@ -144,8 +144,8 @@ public class PistonMovingBlockEntity extends BlockEntity {
@@ -41,9 +41,19 @@ public class PistonMovingBlockEntity extends BlockEntity {
});
private float progress;
private float progressO;
- private long lastTicked;
+ private long lastTicked = Long.MIN_VALUE; // Folia - region threading
private int deathTicks;
+ // Folia start - region threading
+ @Override
+ public void updateTicks(long fromTickOffset, long fromRedstoneTimeOffset) {
+ super.updateTicks(fromTickOffset, fromRedstoneTimeOffset);
+ if (this.lastTicked != Long.MIN_VALUE) {
+ this.lastTicked += fromRedstoneTimeOffset;
+ }
+ }
+ // Folia end - region threading
+
public PistonMovingBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityType.PISTON, pos, state);
}
@@ -144,8 +154,8 @@ public class PistonMovingBlockEntity extends BlockEntity {
entity.setDeltaMovement(e, g, h);
// Paper - EAR items stuck in in slime pushed by a piston
@ -20805,6 +20994,15 @@ index c71690dbc3dc52803945f1608f0ee3ba94146354..1c23597f172f46eec714b510acfedb41
// Paper end
break;
}
@@ -277,7 +287,7 @@ public class PistonMovingBlockEntity extends BlockEntity {
}
public static void tick(Level world, BlockPos pos, BlockState state, PistonMovingBlockEntity blockEntity) {
- blockEntity.lastTicked = world.getGameTime();
+ blockEntity.lastTicked = world.getRedstoneGameTime(); // Folia - region threading
blockEntity.progressO = blockEntity.progress;
if (blockEntity.progressO >= 1.0F) {
if (world.isClientSide && blockEntity.deathTicks < 5) {
diff --git a/src/main/java/net/minecraft/world/level/border/WorldBorder.java b/src/main/java/net/minecraft/world/level/border/WorldBorder.java
index 350aabd20329f429248c84d73ab8b5eb145943a7..bdb864f5e7a1bacde88be632442c9de000ce7729 100644
--- a/src/main/java/net/minecraft/world/level/border/WorldBorder.java

View File

@ -29,10 +29,10 @@ index 41bf71d116ffc5431586ce54abba7f8def6c1dcf..519da6886613b8460e989767b1a21e31
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 39434804e84418e44d595012e8f2191176347e25..edb4ffe78e28755e061c46c6834bbc9b7a23ff16 100644
index 79e9039d77a993d8f1e02942f87fac2a0bd9e8a8..1d77bc6bdb87de1ad6c8740376391dedcaa73089 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2927,6 +2927,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -2930,6 +2930,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
if (!force && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
return false;
} else {
@ -40,7 +40,7 @@ index 39434804e84418e44d595012e8f2191176347e25..edb4ffe78e28755e061c46c6834bbc9b
// CraftBukkit start
if (entity.getBukkitEntity() instanceof Vehicle && this.getBukkitEntity() instanceof LivingEntity) {
VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) entity.getBukkitEntity(), this.getBukkitEntity());
@@ -2948,6 +2949,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -2951,6 +2952,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
return false;
}
// CraftBukkit end
@ -48,7 +48,7 @@ index 39434804e84418e44d595012e8f2191176347e25..edb4ffe78e28755e061c46c6834bbc9b
if (this.isPassenger()) {
this.stopRiding();
}
@@ -3025,6 +3027,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3028,6 +3030,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
// CraftBukkit start
@ -56,7 +56,7 @@ index 39434804e84418e44d595012e8f2191176347e25..edb4ffe78e28755e061c46c6834bbc9b
CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
Entity orig = craft == null ? null : craft.getHandle();
if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
@@ -3052,6 +3055,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
@@ -3055,6 +3058,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
return false;
}
// CraftBukkit end

View File

@ -22,10 +22,10 @@ index add6fc106d3c38d97b48ec0df3ac2515c8c0486e..cbc89b8898f9243776af88c2b04ad3c2
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 206e662c8a43604d5a7563868348d501c135017c..cced2d25936eed5360716c8c25e4ca87f9150017 100644
index a8b47867f05af2a1a4409be5ff49ad0d95bebcae..fdb5ef574c14fafa1af50f4f656763119695f00e 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -4382,6 +4382,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
@@ -4390,6 +4390,11 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
});