Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions paper-server/patches/features/0004-Anti-Xray.patch
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ index a2a4dbcfb77d44657b3dfbe97cb629de215c29eb..73717609fccd9af12e2cc39824106f49
}
// Paper end - Send empty chunk
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 1f26826b2161cfeb27e5b2060e178b493e9142d9..63f8b0c47e3321b74f4b6bcbc1e28cd751911198 100644
index c3390b0703a8852c85aca6a4150f54d04acca741..f1380f545cf7212968d66275fe620269a101230f 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -132,6 +132,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
Expand All @@ -210,7 +210,7 @@ index 1f26826b2161cfeb27e5b2060e178b493e9142d9..63f8b0c47e3321b74f4b6bcbc1e28cd7
private final CraftWorld world;
public boolean pvpMode;
public org.bukkit.generator.ChunkGenerator generator;
@@ -201,7 +202,8 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -202,7 +203,8 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
org.bukkit.generator.BiomeProvider biomeProvider, // CraftBukkit
org.bukkit.World.Environment env, // CraftBukkit
java.util.function.Function<org.spigotmc.SpigotWorldConfig, // Spigot - create per world config
Expand All @@ -220,15 +220,15 @@ index 1f26826b2161cfeb27e5b2060e178b493e9142d9..63f8b0c47e3321b74f4b6bcbc1e28cd7
) {
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
@@ -278,6 +280,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -279,6 +281,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
public void onBorderSetDamageSafeZOne(WorldBorder border, double safeZoneRadius) {}
});
// CraftBukkit end
+ this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new io.papermc.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : io.papermc.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray
}

// Paper start - Cancel hit for vanished players
@@ -483,6 +486,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -484,6 +487,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
snapshot.setFlags(flags); // Paper - always set the flag of the most recent call to mitigate issues with multiple update at the same pos with different flags
}
BlockState blockState = chunkAt.setBlockState(pos, state, flags);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29725,7 +29725,7 @@ index 300f3ed58109219d97846082941b860585f66fed..892a7c1eb1b321ca6d5ca709142e7fea

// Paper start - Affects Spawning API
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..eb4d03cfdb34243901cfba832d35559d5be9e876 100644
index f1380f545cf7212968d66275fe620269a101230f..e6f2fe03ec55f4ae1fa6c94af48db798795de72a 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -81,6 +81,7 @@ import net.minecraft.world.level.storage.LevelData;
Expand Down Expand Up @@ -29754,7 +29754,7 @@ index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..eb4d03cfdb34243901cfba832d35559d
@Deprecated
private final RandomSource threadSafeRandom = RandomSource.createThreadSafe();
private final Holder<DimensionType> dimensionTypeRegistration;
@@ -189,6 +190,629 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -190,6 +191,629 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl

public abstract ResourceKey<net.minecraft.world.level.dimension.LevelStem> getTypeKey();

Expand Down Expand Up @@ -30384,7 +30384,7 @@ index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..eb4d03cfdb34243901cfba832d35559d
protected Level(
WritableLevelData levelData,
ResourceKey<Level> dimension,
@@ -205,6 +829,15 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -206,6 +830,15 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, // Paper - create paper world config
java.util.concurrent.Executor executor // Paper - Anti-Xray
) {
Expand All @@ -30400,15 +30400,15 @@ index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..eb4d03cfdb34243901cfba832d35559d
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config
this.generator = gen;
@@ -281,6 +914,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -282,6 +915,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
});
// CraftBukkit end
this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new io.papermc.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : io.papermc.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray
+ this.entityLookup = new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.dfl.DefaultEntityLookup(this); // Paper - rewrite chunk system
}

// Paper start - Cancel hit for vanished players
@@ -555,7 +1189,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -556,7 +1190,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
this.setBlocksDirty(pos, blockState, blockState1);
}

Expand All @@ -30417,15 +30417,15 @@ index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..eb4d03cfdb34243901cfba832d35559d
this.sendBlockUpdated(pos, blockState, state, flags);
}

@@ -820,6 +1454,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -821,6 +1455,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
// Spigot start
boolean runsNormally = this.tickRateManager().runsNormally();

+ int tickedEntities = 0; // Paper - rewrite chunk system
var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<TickingBlockEntity>(); // Paper - Fix MC-117075; use removeAll
toRemove.add(null); // Paper - Fix MC-117075
for (this.tileTickPosition = 0; this.tileTickPosition < this.blockEntityTickers.size(); this.tileTickPosition++) { // Paper - Disable tick limiters
@@ -829,6 +1464,11 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -830,6 +1465,11 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll
} else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) {
tickingBlockEntity.tick();
Expand All @@ -30437,15 +30437,15 @@ index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..eb4d03cfdb34243901cfba832d35559d
}
}
this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075
@@ -849,6 +1489,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -850,6 +1490,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD);
// Paper end - Prevent block entity and entity crashes
}
+ this.moonrise$midTickTasks(); // Paper - rewrite chunk system
}

// Paper start - Option to prevent armor stands from doing entity lookups
@@ -856,7 +1497,14 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -857,7 +1498,14 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
public boolean noCollision(@Nullable Entity entity, AABB box) {
if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups)
return false;
Expand All @@ -30461,7 +30461,7 @@ index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..eb4d03cfdb34243901cfba832d35559d
}
// Paper end - Option to prevent armor stands from doing entity lookups

@@ -994,7 +1642,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -995,7 +1643,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
if (this.isOutsideBuildHeight(pos)) {
return null;
} else {
Expand All @@ -30470,7 +30470,7 @@ index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..eb4d03cfdb34243901cfba832d35559d
? null
: this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE);
}
@@ -1087,22 +1735,16 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -1088,22 +1736,16 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
public List<Entity> getEntities(@Nullable Entity entity, AABB boundingBox, Predicate<? super Entity> predicate) {
Profiler.get().incrementCounter("getEntities");
List<Entity> list = Lists.newArrayList();
Expand Down Expand Up @@ -30501,7 +30501,7 @@ index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..eb4d03cfdb34243901cfba832d35559d
}

@Override
@@ -1116,33 +1758,94 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -1117,33 +1759,94 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
this.getEntities(entityTypeTest, bounds, predicate, output, Integer.MAX_VALUE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2352,10 +2352,10 @@ index 8afe96bfdc37e57129f1bb4af5b6d5cc22c11aee..32db2b9e375c12cbf7abab69cc01e8ac
@Override
public void onCreated(Entity entity) {
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
index eb4d03cfdb34243901cfba832d35559d5be9e876..013ed7dbe2309f562f63e66203179a90566e8115 100644
index e6f2fe03ec55f4ae1fa6c94af48db798795de72a..a031dcbcc97a3345cdd5f5bcd9d6aa23cbc1ad0d 100644
--- a/net/minecraft/world/level/Level.java
+++ b/net/minecraft/world/level/Level.java
@@ -2096,6 +2096,17 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
@@ -2097,6 +2097,17 @@ public abstract class Level implements LevelAccessor, UUIDLookup<Entity>, AutoCl
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- a/net/minecraft/world/item/BowItem.java
+++ b/net/minecraft/world/item/BowItem.java
@@ -36,9 +_,9 @@
if (powerForTime < 0.1) {
return false;
} else {
- List<ItemStack> list = draw(stack, projectile, player);
+ List<ItemStack> list = draw(stack, projectile, player, ProjectileDrawingItemConsumption.MAYBE_LATER); // Paper - prevent item consumption for cancelled events
if (level instanceof ServerLevel serverLevel && !list.isEmpty()) {
- this.shoot(serverLevel, player, player.getUsedItemHand(), stack, list, powerForTime * 3.0F, 1.0F, powerForTime == 1.0F, null);
+ if (!this.shoot(serverLevel, player, player.getUsedItemHand(), stack, new UnrealizedDrawResult(list, projectile), powerForTime * 3.0F, 1.0F, powerForTime == 1.0F, null)) return false; // Paper - prevent item consumption for cancelled events
}

level.playSound(
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,24 @@
+ }
+
+ private static boolean tryLoadProjectiles(LivingEntity shooter, ItemStack crossbowStack, boolean consume) {
+ List<ItemStack> list = draw(crossbowStack, shooter.getProjectile(crossbowStack), shooter, consume);
+ List<ItemStack> list = draw(crossbowStack, shooter.getProjectile(crossbowStack), shooter, consume ? ProjectileDrawingItemConsumption.IMMEDIATELY : ProjectileDrawingItemConsumption.NEVER); // Paper - prevent item consumption for cancelled events
+ // Paper end - Add EntityLoadCrossbowEvent
if (!list.isEmpty()) {
crossbowStack.set(DataComponents.CHARGED_PROJECTILES, ChargedProjectiles.of(list));
return true;
@@ -122,8 +_,10 @@
}

projectile.shoot(projectileShotVector.x(), projectileShotVector.y(), projectileShotVector.z(), velocity, inaccuracy);
- float shotPitch = getShotPitch(shooter.getRandom(), index);
- shooter.level().playSound(null, shooter.getX(), shooter.getY(), shooter.getZ(), SoundEvents.CROSSBOW_SHOOT, shooter.getSoundSource(), 1.0F, shotPitch);
+ // Paper start - moved up to ensure events weren't cancelled
+ // float shotPitch = getShotPitch(shooter.getRandom(), index);
+ // shooter.level().playSound(null, shooter.getX(), shooter.getY(), shooter.getZ(), SoundEvents.CROSSBOW_SHOOT, shooter.getSoundSource(), 1.0F, shotPitch);
+ // Paper end - moved up to ensure events weren't cancelled
}

private static Vector3f getProjectileShotVector(LivingEntity shooter, Vec3 distance, float angle) {
@@ -141,7 +_,11 @@
@Override
protected Projectile createProjectile(Level level, LivingEntity shooter, ItemStack weapon, ItemStack ammo, boolean isCrit) {
Expand All @@ -30,6 +43,27 @@
} else {
Projectile projectile = super.createProjectile(level, shooter, weapon, ammo, isCrit);
if (projectile instanceof AbstractArrow abstractArrow) {
@@ -161,9 +_,9 @@
Level level, LivingEntity shooter, InteractionHand hand, ItemStack weapon, float velocity, float inaccuracy, @Nullable LivingEntity target
) {
if (level instanceof ServerLevel serverLevel) {
- ChargedProjectiles chargedProjectiles = weapon.set(DataComponents.CHARGED_PROJECTILES, ChargedProjectiles.EMPTY);
+ ChargedProjectiles chargedProjectiles = weapon.get(DataComponents.CHARGED_PROJECTILES); // Paper - prevent item consumption for cancelled events
if (chargedProjectiles != null && !chargedProjectiles.isEmpty()) {
- this.shoot(serverLevel, shooter, hand, weapon, chargedProjectiles.getItems(), velocity, inaccuracy, shooter instanceof Player, target);
+ if (!this.shoot(serverLevel, shooter, hand, weapon, chargedProjectiles.getItems(), velocity, inaccuracy, shooter instanceof Player, target)) return; // Paper - prevent item consumption for cancelled events
if (shooter instanceof ServerPlayer serverPlayer) {
CriteriaTriggers.SHOT_CROSSBOW.trigger(serverPlayer, weapon);
serverPlayer.awardStat(Stats.ITEM_USED.get(weapon.getItem()));
@@ -172,7 +_,7 @@
}
}

- private static float getShotPitch(RandomSource random, int index) {
+ public static float getShotPitch(RandomSource random, int index) {
return index == 0 ? 1.0F : getRandomShotPitch((index & 1) == 1, random);
}

@@ -211,7 +_,14 @@
);
}
Expand Down
Loading
Loading