9
0
mirror of https://github.com/Samsuik/Sakura.git synced 2025-12-30 04:09:09 +00:00

Updated Upstream (Paper 1.21.9)

Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@7e70636 Initial 1.21.9 update (squashed)
PaperMC/Paper@0a28816 Add Server#getRespawnWorld and Server#setRespawnWorld(World)
PaperMC/Paper@b67fa6d move todos txt content into tracking issue
PaperMC/Paper@68f26a1 Drop no-longer-needed packet diffs
PaperMC/Paper@f9434d2 Use pitch when setting spawn position with Location
PaperMC/Paper@810b3c6 Deprecate the Conversation API (for removal), Metadata API, and PlayerSpawnLocationEvent (for removal)
PaperMC/Paper@1870261 Update Moonrise to 1.21.9-pre1
PaperMC/Paper@1141058 Shift feature patch #s for Moonrise being first
PaperMC/Paper@510aa9b Update 'Optimize Network Manager and add advanced packet support'
PaperMC/Paper@89cc24a Update 'Allow Saving of Oversized Chunks'
PaperMC/Paper@bcd75d8 Update EAR 2.0 patch and enable oldPaperCommit for better 3-way merges
PaperMC/Paper@6b44820 Update 'Use Velocity compression and cipher natives'
PaperMC/Paper@87f3e2f Update 'Optimize GoalSelector Goal.Flag Set operations'
PaperMC/Paper@5323486 Update 'Optimize Voxel Shape Merging'
PaperMC/Paper@5aac8b4 Update 'Handle Oversized block entities in chunks'
PaperMC/Paper@f0b3d62 Update 'optimize dirt and snow spreading' and drop 'Optimise getChunkAt calls for loaded chunks' patch to code replaced by Moonrise
PaperMC/Paper@92f822d Update 'Optimize Bit Operations by inlining', 'Remove streams from hot code'
PaperMC/Paper@98e745a Update 'Optimize Pathfinder - Remove Streams / Optimized collections'
PaperMC/Paper@49e49d0 Update 'Fix entity tracker desync when new players are added to the tracker'
PaperMC/Paper@87e0525 Update alternate redstone impls
PaperMC/Paper@35e973d Update 'Improve exact choice recipe ingredients', 'Only write chunk data to disk if it serializes without throwing'
PaperMC/Paper@181f9bb Update 'Entity load/save limit per chunk', 'Attempt to recalculate regionfile header if it is corrupt'
PaperMC/Paper@b31ca18 Update 'Incremental chunk and player saving', 'Optimise general POI access'
PaperMC/Paper@9b69cc5 Add some more Mannequin API
PaperMC/Paper@8bb12cb Fix compile
PaperMC/Paper@e3aca92 Replace ConcurrentUtil's Validate with Objects
PaperMC/Paper@9a626dd Rewrite ticket counter system
PaperMC/Paper@65250cb Drop "Optimize Collision to not load chunks"
PaperMC/Paper@55d56d9 Apply "Flush regionfiles on save configuration option"
PaperMC/Paper@920e8d3 Apply "Optimise collision checking in player move packet handling"
PaperMC/Paper@ec492d3 Apply "Improve keepalive ping system"
PaperMC/Paper@8f65947 Apply "Optimise EntityScheduler ticking"
PaperMC/Paper@086b4fd Apply "Optional per player mob spawns"
PaperMC/Paper@2f4211e Apply "Improve cancelling PreCreatureSpawnEvent with per player mob spawns"
PaperMC/Paper@b6d9557 Apply "Optimize Hoppers"
PaperMC/Paper@388e693 update generator
PaperMC/Paper@a3c89a8 add javadocs for new api
PaperMC/Paper@fcc763a Call BlockRedstoneEvent for the shelf
PaperMC/Paper@03eb18b replace requireNonNull by checkArgument and deprecate MCUtil#toLocation
PaperMC/Paper@6b7bf01 bump built-in datapack version
PaperMC/Paper@2779a53 deprecate #lanterns material tag in favour of vanilla tag
PaperMC/Paper@6f9957e Mannequin#createDefaultProfile -> Mannequin#defaultProfile
PaperMC/Paper@24874e5 Also rename Mannequin profile getter/setters for consistency
PaperMC/Paper@bc2ae10 Fix default respawn dimension being null for new worlds
PaperMC/Paper@eb42158 Use 0.0.4 release of ConcurrentUtil
PaperMC/Paper@bb01745 1.21.9-pre2
PaperMC/Paper@0249204 1.21.9-pre2 feature patches
PaperMC/Paper@9360ba4 Identifying comments for MinecraftServer
PaperMC/Paper@5d3aa53 Some diff improvements in prepare spawn task
PaperMC/Paper@22ad451 Move some stuff to ATs
PaperMC/Paper@0ea15c9 Drop no longer applicable ATs
PaperMC/Paper@cf78f2a bump api-version/datapack format and add a copper torch tag
PaperMC/Paper@60cb0df generate ClientOption enums and mark CraftBlockData impl as null marked
PaperMC/Paper@4025289 Add pre2 to api version
PaperMC/Paper@f2cb073 Set build channel to alpha
PaperMC/Paper@90b29c4 Port most of the anti-xray patch
PaperMC/Paper@4a8e88d Disable oldPaperCommit to fix CI build
PaperMC/Paper@121ac2e Port the last Anti-XRay hunk
PaperMC/Paper@f43641f Use ConcurrentUtil 0.0.5
PaperMC/Paper@1f79388 fix end portal teleportation
PaperMC/Paper@2efb400 [ci skip] Adjust spawn location event docs
PaperMC/Paper@cb9fc05 simplify overloads
PaperMC/Paper@25ecc59 Enable Anti-Xray
PaperMC/Paper@4d7185f Add AsyncPlayerSpawnLocationEvent#isNewPlayer (#13081)
PaperMC/Paper@dc474a8 Fixup vanilla code for Anti-Xray changes
PaperMC/Paper@0e23b02 Add back null check for chunkPacketBlockController
PaperMC/Paper@e6f1483 Update to 1.21.9-pre3
PaperMC/Paper@44259ea Add ResolvableProfile.SkinPatch (#13091)
PaperMC/Paper@634f51e Update to 1.21.9-pre4
PaperMC/Paper@fada3a7 Update DataConverter to 1.21.9-pre4
PaperMC/Paper@037179f Update Starlight stored version
PaperMC/Paper@6b0b29a Update publishing endpoint
PaperMC/Paper@f6fabc5 Call EntityChangeBlockEvent for copper golem statue changes (#13090)
PaperMC/Paper@1d6ee7d Update adventure
PaperMC/Paper@404e49f Update to 1.21.9-rc1
PaperMC/Paper@4055274 Fix empty SkinPatch initialization and swapped dynamic/static heuristic in ResolvableProfile build method
PaperMC/Paper@51fe7aa Fixed modern forwarding support (#13098)
PaperMC/Paper@5613a35 fix PlayerGameModeChangeEvent#cancelMessage
PaperMC/Paper@673abf4 use PlayerShieldDisableEvent#getCooldown
PaperMC/Paper@3a0dc7f Fix a couple PlayerProfile mutability issues
PaperMC/Paper@e97fb40 Remove parallel generation config option
PaperMC/Paper@c3a60b8 Use ThreadLocal for Starlight and ticket level propagator cache
PaperMC/Paper@e16b369 Resize propagator queues less aggressively
This commit is contained in:
Samsuik
2025-09-27 15:39:58 +01:00
parent f6f596821d
commit 40897f76f7
86 changed files with 807 additions and 722 deletions

View File

@@ -0,0 +1,6 @@
package me.samsuik.sakura.explosion;
import net.minecraft.world.phys.Vec3;
public record ExplosionToSend(Vec3 position, int blocksDestroyed) {
}

View File

@@ -3,7 +3,7 @@ package me.samsuik.sakura.explosion;
import ca.spottedleaf.moonrise.common.util.WorldUtil;
import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.ChunkEntitySlices;
import ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.*;
import me.samsuik.sakura.mechanics.MechanicVersion;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
@@ -12,23 +12,25 @@ import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ExplosionDamageCalculator;
import net.minecraft.world.level.ServerExplosion;
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.function.Consumer;
@NullMarked
public abstract class SpecialisedExplosion<T extends Entity> extends ServerExplosion {
private static final double ENTITY_DISPATCH_DISTANCE = Math.pow(32.0, 2.0);
private static final double ENTITY_DISPATCH_DISTANCE_SQR = 32.0 * 32.0;
protected final T cause; // preferred over source
private Vec3 impactPosition;
protected final BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos();
private final Consumer<SpecialisedExplosion<T>> applyEffects;
private Vec3 dispatchPosition;
private final List<Vec3> bufferedExplosions = new ObjectArrayList<>();
private AABB bounds;
private final Set<BlockPos> gameEvents = new ObjectOpenHashSet<>();
private final Deque<ExplosionToSend> explosionsToSend = new ArrayDeque<>();
public SpecialisedExplosion(
final ServerLevel level,
@@ -38,50 +40,80 @@ public abstract class SpecialisedExplosion<T extends Entity> extends ServerExplo
final Vec3 center,
final float power,
final boolean createFire,
final BlockInteraction destructionType,
final Consumer<SpecialisedExplosion<T>> applyEffects
final BlockInteraction destructionType
) {
super(level, entity, damageSource, behavior, center, power, createFire, destructionType);
this.cause = entity;
this.impactPosition = center;
this.applyEffects = applyEffects;
this.dispatchPosition = center;
this.bounds = new AABB(center, center);
}
public final Queue<ExplosionToSend> getExplosionsToSend() {
return this.explosionsToSend;
}
protected double getExplosionOffset() {
return (double) this.cause.getBbHeight() * 0.0625D;
return 0.0;
}
protected abstract void beginExplosion();
protected abstract int handleExplosion();
@Override
public final void explode() {
public final int explode() {
this.createBlockCache();
this.beginExplosion(); // search for blocks, impact entities, finalise if necessary
final int blocksDestroyed = this.handleExplosion();
this.clearBlockCache();
return blocksDestroyed;
}
protected final boolean requiresImpactEntities(final List<BlockPos> blocks, final Vec3 center) {
if (this.impactPosition.distanceToSqr(center) > ENTITY_DISPATCH_DISTANCE) {
this.impactPosition = center;
protected final List<BlockPos> collectBlocksAndImpactEntities(final boolean interactWithBlocks, final boolean dispatch) {
if (interactWithBlocks && this.gameEvents.add(BlockPos.containing(this.center))) {
this.level().gameEvent(this.source, GameEvent.EXPLODE, this.center);
}
// Collect all the blocks to explode
final List<BlockPos> blocksToExplode = interactWithBlocks
? this.calculateExplodedPositions()
: List.of();
// Buffer explosions to reduce the amount of calculations and improve locality
final Vec3 center = this.center;
this.bounds = this.bounds.expand(center);
this.bufferedExplosions.add(center);
// Dispatch the buffered explosions
if (dispatch || this.needToDispatchEntities(blocksToExplode, center)) {
this.locateAndImpactEntitiesInBounds(this.bounds, this.bufferedExplosions);
this.bounds = new AABB(center, center);
this.bufferedExplosions.clear();
}
return blocksToExplode;
}
protected final boolean needToDispatchEntities(final List<BlockPos> blocksToBlow, final Vec3 center) {
if (this.dispatchPosition.distanceToSqr(center) > ENTITY_DISPATCH_DISTANCE_SQR) {
this.dispatchPosition = center;
this.gameEvents.clear();
return true;
}
return !blocks.isEmpty();
return !blocksToBlow.isEmpty();
}
protected final boolean finalizeExplosionAndParticles(final List<BlockPos> blocks) {
protected final int finalizeExplosionAndParticles(final List<BlockPos> blocksToBlow, final boolean lastCycle) {
this.wasCanceled = false;
final List<BlockPos> explodedPositions = new ObjectArrayList<>(blocks);
final List<BlockPos> explodedPositions = new ObjectArrayList<>(blocksToBlow);
this.interactWithBlocks(explodedPositions);
if (!this.wasCanceled) {
this.applyEffects.accept(this);
this.getHitPlayers().clear();
if (!this.wasCanceled && !lastCycle) {
// Packets are sent after the explosion
this.explosionsToSend.add(new ExplosionToSend(this.center, explodedPositions.size()));
}
return !explodedPositions.isEmpty() && !this.wasCanceled;
return this.wasCanceled ? 0 : explodedPositions.size();
}
protected void postExplosion(final List<BlockPos> foundBlocks, final boolean destroyedBlocks) {
protected void nextExplosion(final List<BlockPos> foundBlocks, final boolean destroyedBlocks) {
// Reuse the block cache between explosions. This can help a lot when searching for blocks and raytracing.
// This is disabled by default as it's incompatible with plugins that modify blocks in the explosion event.
if (this.level().sakuraConfig().cannons.explosion.reuseBlockCacheAcrossExplosions && !foundBlocks.isEmpty() && !destroyedBlocks) {
@@ -188,7 +220,7 @@ public abstract class SpecialisedExplosion<T extends Entity> extends ServerExplo
distance = (float) distance;
}
if (distance != 0.0D) {
if (distance >= 1.0e-5 || distance != 0.0 && this.mechanicsTarget.before(MechanicVersion.v1_21_9)) {
x /= distance;
y /= distance;
z /= distance;

View File

@@ -1,7 +1,6 @@
package me.samsuik.sakura.explosion;
import ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import me.samsuik.sakura.entity.EntityState;
import me.samsuik.sakura.entity.merge.MergeLevel;
import me.samsuik.sakura.entity.merge.MergeableEntity;
@@ -13,13 +12,11 @@ import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.item.PrimedTnt;
import net.minecraft.world.level.ExplosionDamageCalculator;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.NullMarked;
import java.util.List;
import java.util.function.Consumer;
@NullMarked
public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
@@ -27,8 +24,6 @@ public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
private static final int FOUND_ALL_BLOCKS = ALL_DIRECTIONS + 12;
private final Vec3 originalPosition;
private final List<Vec3> explosions = new ObjectArrayList<>();
private AABB bounds;
private int swinging = 0;
private boolean moved = false;
@@ -40,19 +35,17 @@ public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
final Vec3 center,
final float power,
final boolean createFire,
final BlockInteraction destructionType,
final Consumer<SpecialisedExplosion<PrimedTnt>> applyEffects
final BlockInteraction destructionType
) {
super(level, tnt, damageSource, behavior, center, power, createFire, destructionType, applyEffects);
super(level, tnt, damageSource, behavior, center, power, createFire, destructionType);
this.originalPosition = center;
this.bounds = new AABB(center, center);
}
@Override
protected double getExplosionOffset() {
return this.mechanicsTarget.before(MechanicVersion.v1_10)
? (double) 0.49f
: super.getExplosionOffset();
: (double) this.cause.getBbHeight() * 0.0625D;
}
private void mergeEntitiesBeforeExploding() {
@@ -89,41 +82,28 @@ public final class TntExplosion extends SpecialisedExplosion<PrimedTnt> {
}
@Override
protected void beginExplosion() {
protected int handleExplosion() {
int blocksDestroyed = 0;
for (int remaining = this.mergeAndGetExplosionPotential() - 1; remaining >= 0; --remaining) {
final boolean lastCycle = remaining == 0;
final List<BlockPos> toBlow = this.midExplosion(lastCycle); // search for blocks and impact entities
final boolean destroyedBlocks = this.finalizeExplosionAndParticles(toBlow); // call events, break blocks and send particles
final List<BlockPos> blocksToBlow = this.collectBlocksAndImpactEntities(this.swinging < FOUND_ALL_BLOCKS, lastCycle);
blocksDestroyed = this.finalizeExplosionAndParticles(blocksToBlow, lastCycle);
if (!lastCycle) {
// The source velocity has to be calculated before nextExplosion as it clears the blockCache
final EntityState entityState = this.nextSourceVelocity();
this.postExplosion(toBlow, destroyedBlocks);
final boolean destroyedBlocks = blocksDestroyed > 0;
this.nextExplosion(blocksToBlow, destroyedBlocks);
this.updateExplosionPosition(entityState, destroyedBlocks);
}
}
}
private List<BlockPos> midExplosion(final boolean lastCycle) {
final List<BlockPos> explodedPositions = this.swinging < FOUND_ALL_BLOCKS
? this.calculateExplodedPositions()
: List.of();
final Vec3 center = this.center;
this.bounds = this.bounds.expand(center);
this.explosions.add(center);
if (lastCycle || this.requiresImpactEntities(explodedPositions, center)) {
this.locateAndImpactEntitiesInBounds(this.bounds, this.explosions);
this.bounds = new AABB(center, center);
this.explosions.clear();
}
return explodedPositions;
return blocksDestroyed;
}
@Override
protected void postExplosion(final List<BlockPos> foundBlocks, final boolean destroyedBlocks) {
super.postExplosion(foundBlocks, destroyedBlocks);
protected void nextExplosion(final List<BlockPos> foundBlocks, final boolean destroyedBlocks) {
super.nextExplosion(foundBlocks, destroyedBlocks);
if (this.swinging >= ALL_DIRECTIONS) {
// Increment "swinging" if no blocks have been found, and it has swung in every direction.
// This is used to skip expensive exploded block calculations.

View File

@@ -23,7 +23,7 @@ public final class EntityBehaviour {
final Vec3 newEntityPosition;
if (mechanicsTarget.is(MechanicVersion.v1_21_5)) {
newEntityPosition = manglePosition(position, relativeMovement);
entity.addMovementThisTick(new Entity.Movement(position, newPosition, true));
entity.addMovementThisTick(new Entity.Movement(position, newPosition, relativeMovement));
} else {
newEntityPosition = newPosition;
}
@@ -33,7 +33,7 @@ public final class EntityBehaviour {
private static Vec3 manglePosition(final Vec3 position, final Vec3 relativeMovement) {
Vec3 newPosition = position;
for (final Direction.Axis axis : Entity.axisStepOrder(relativeMovement)) {
for (final Direction.Axis axis : Direction.axisStepOrder(relativeMovement)) {
final double movement = relativeMovement.get(axis);
if (movement != 0.0) {
newPosition = newPosition.relative(axis.getPositive(), movement);

View File

@@ -36,6 +36,7 @@ public final class LegacyDamageMapping {
LEGACY_ITEM_DAMAGE_MAP.put(Items.WOODEN_AXE, 3.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.GOLDEN_AXE, 3.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.STONE_AXE, 4.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.COPPER_AXE, 4.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.IRON_AXE, 5.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.DIAMOND_AXE, 6.0);
LEGACY_ITEM_DAMAGE_MAP.put(Items.NETHERITE_AXE, 7.0);

View File

@@ -11,7 +11,13 @@ import org.jspecify.annotations.NullMarked;
public final class DataComponentHelper {
public static int bucketMaxStackSize() {
final GlobalConfiguration config = GlobalConfiguration.get();
return config == null || !config.players.bucketStackSize.isDefined() ? -1 : config.players.bucketStackSize.intValue();
return config != null && config.players.bucketStackSize.isDefined()
? config.players.bucketStackSize.intValue()
: -1;
}
public static DataComponentMap updateBucketMaxStackSize(final DataComponentMap components) {
return copyComponentsAndModifyMaxStackSize(components, bucketMaxStackSize());
}
@SuppressWarnings("OptionalAssignedToNull")
@@ -20,7 +26,7 @@ public final class DataComponentHelper {
}
public static DataComponentMap copyComponentsAndModifyMaxStackSize(final DataComponentMap componentMap, final int maxItemSize) {
if (maxItemSize > 0 && maxItemSize <= 99) {
if (maxItemSize > 1 && maxItemSize <= 99) {
return DataComponentMap.builder()
.addAll(componentMap)
.set(DataComponents.MAX_STACK_SIZE, maxItemSize)

View File

@@ -1,9 +1,10 @@
package me.samsuik.sakura.player.item;
import me.samsuik.sakura.configuration.GlobalConfiguration;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.component.PatchedDataComponentMap;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import org.jspecify.annotations.NullMarked;
@NullMarked
@@ -13,10 +14,17 @@ public final class MilkBucketItem extends Item {
}
@Override
public void verifyComponentsAfterLoad(final ItemStack stack) {
final int maxStackSize = DataComponentHelper.bucketMaxStackSize();
if (maxStackSize > 0 && maxStackSize < 100 && stackableMilkBuckets()) {
stack.set(DataComponents.MAX_STACK_SIZE, maxStackSize);
public DataComponentMap components() {
final DataComponentMap components = super.components();
return stackableMilkBuckets()
? DataComponentHelper.updateBucketMaxStackSize(components)
: components;
}
@Override
public void modifyComponentsSentToClient(final PatchedDataComponentMap components) {
if (stackableMilkBuckets()) {
components.set(DataComponents.MAX_STACK_SIZE, DataComponentHelper.bucketMaxStackSize());
}
}

View File

@@ -1,8 +1,9 @@
package me.samsuik.sakura.player.item;
import net.minecraft.core.component.DataComponentMap;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.component.PatchedDataComponentMap;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.material.Fluid;
import org.jspecify.annotations.NullMarked;
@@ -13,11 +14,15 @@ public final class StackableBucketItem extends BucketItem {
}
@Override
public void verifyComponentsAfterLoad(final ItemStack stack) {
// It's also possible to override the components method and modify the stack size through the DataComponentHelper
public DataComponentMap components() {
return DataComponentHelper.updateBucketMaxStackSize(super.components());
}
@Override
public void modifyComponentsSentToClient(final PatchedDataComponentMap components) {
final int maxStackSize = DataComponentHelper.bucketMaxStackSize();
if (maxStackSize > 0 && maxStackSize < 100) {
stack.set(DataComponents.MAX_STACK_SIZE, maxStackSize);
if (maxStackSize > 1 && maxStackSize <= 99) {
components.set(DataComponents.MAX_STACK_SIZE, maxStackSize);
}
}
}