1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-02-16 18:31:53 +01:00

Patches!!! MORE MORE MORE MOOOOORE

This commit is contained in:
Owen1212055 2023-12-06 11:34:54 -05:00
parent 0087658702
commit 6f010858de
73 changed files with 58 additions and 60 deletions
patches/server
API-for-an-entity-s-scoreboard-name.patchAPI-for-updating-recipes-on-clients.patchAdd-Listing-API-for-Player.patchAdd-PlayerPickItemEvent.patchAdd-Sign-getInteractableSideFor.patchAdd-event-for-player-editing-sign.patchAdd-method-to-remove-all-active-potion-effects.patchAdd-missing-InventoryHolders-to-inventories.patchAdd-option-to-disable-block-updates.patchAdd-slot-sanity-checks-in-container-clicks.patchAdd-titleOverride-to-InventoryOpenEvent.patchAdd-whitelist-events.patchAllow-proper-checking-of-empty-item-stacks.patchAllow-trident-custom-damage.patchArray-backed-synched-entity-data.patchBandaid-fix-for-Effect.patchCache-map-ids-on-item-frames.patchCall-BlockGrowEvent-for-missing-blocks.patchCall-BlockRedstoneEvents-for-lecterns.patchCall-missing-BlockDispenseEvent.patchConfigurable-Region-Compression-Format.patchConfigurable-entity-tracking-range-by-Y-coordinate.patchConfigure-sniffer-egg-hatch-time.patchDeep-clone-unhandled-nbt-tags.patchDeprecate-and-replace-methods-with-old-StructureType.patchDetermine-lava-and-water-fluid-explosion-resistance-.patchDo-crystal-portal-proximity-check-before-entity-look.patchDo-not-read-tile-entities-in-chunks-that-are-positio.patchDon-t-enforce-icanhasbukkit-default-if-alias-block-e.patchDon-t-load-chunks-for-supporting-block-checks.patchDon-t-tab-complete-namespaced-commands-if-send-names.patchDon-t-tick-signs.patchExpand-Pose-API.patchExperienceOrb-should-call-EntitySpawnEvent.patchExpose-clicked-BlockFace-during-BlockDamageEvent.patchExpose-hand-during-BlockCanBuildEvent.patchFire-entity-death-event-for-ender-dragon.patchFix-BanList-API.patchFix-NPE-on-Boat-getStatus.patchFix-custom-statistic-criteria-creation.patchFix-incorrect-crafting-result-amount-for-fireworks.patchFix-inventory-desync.patchFix-possible-NPE-on-painting-creation.patchFix-rotation-when-spawning-display-entities.patchFix-silent-equipment-change-for-mobs.patchFix-sniffer-removeExploredLocation.patchFix-spigot-s-Forced-Stats.patchFolia-scheduler-and-owned-region-API.patchImplement-OfflinePlayer-isConnected.patchImplement-PlayerFailMoveEvent.patchImprove-cancelling-PreCreatureSpawnEvent-with-per-pl.patchImprove-command-function-perm-level-checks.patchImprove-performance-of-mass-crafts.patchMake-Amethyst-throw-both-Spread-and-Grow-Events.patchMore-DragonBattle-API.patchOnly-capture-actual-tree-growth.patchOnly-erase-allay-memory-on-non-item-targets.patchOnly-set-despawnTimer-for-Wandering-Traders-spawned-.patchOnly-tick-item-frames-if-players-can-see-it.patchOptimize-nearest-structure-border-iteration.patchOptimize-player-lookups-for-beacons.patchProperly-Cancel-Usable-Items.patchProperly-handle-BlockBreakEvent-isDropItems.patchRemove-UpgradeData-neighbour-ticks-outside-of-range.patchRespect-randomizeData-on-more-entities-when-spawning.patchSculkCatalyst-bloom-API.patchSkip-POI-finding-if-stuck-in-vehicle.patchSuppress-Item-Meta-Validation-Checks.patchTemp-Pre-init-PlayerChunkLoaderData-in-order-to-prep.patchUse-correct-seed-on-api-world-load.patchUse-correct-source-for-mushroom-block-spread-event.patchfix-MapLike-spam-for-missing-key-selector.patchfix-item-meta-for-tadpole-buckets.patch

View file

@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableChorusPlantUpdates) return this.defaultBlockState(); // Paper - add option to disable block updates
return this.getStateForPlacement(ctx.getLevel(), ctx.getClickedPos());
return getStateWithConnections(ctx.getLevel(), ctx.getClickedPos(), this.defaultBlockState());
}
@@ -0,0 +0,0 @@ public class ChorusPlantBlock extends PipeBlock {
@ -144,8 +144,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class TripWireBlock extends Block {
@Override
public void playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) {
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return; // Paper - prevent disarming tripwires
public BlockState playerWillDestroy(Level world, BlockPos pos, BlockState state, Player player) {
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return state; // Paper - prevent disarming tripwires
if (!world.isClientSide && !player.getMainHandItem().isEmpty() && player.getMainHandItem().is(Items.SHEARS)) {
world.setBlock(pos, (BlockState) state.setValue(TripWireBlock.DISARMED, true), 4);
world.gameEvent((Entity) player, GameEvent.SHEAR, pos);

View file

@ -33,13 +33,3 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
slot = (Slot) this.slots.get(slotIndex);
itemstack = this.getCarried();
if (AbstractContainerMenu.canItemQuickReplace(slot, itemstack, true) && slot.mayPlace(itemstack) && (this.quickcraftType == 2 || itemstack.getCount() > this.quickcraftSlots.size()) && this.canDragTo(slot)) {
@@ -0,0 +0,0 @@ public abstract class AbstractContainerMenu {
Slot slot2;
int j2;
- if (actionType == ClickType.SWAP) {
+ if (actionType == ClickType.SWAP && (button == 40 || button >= 0 && button < 9)) { // Paper
+ if (slotIndex < 0 || button < 0) return; // Paper
slot2 = (Slot) this.slots.get(slotIndex);
itemstack1 = playerinventory.getItem(button);
itemstack = slot2.getItem();

View file

@ -24,17 +24,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ThrownTrident extends AbstractArrow {
public ThrownTrident(EntityType<? extends ThrownTrident> type, Level world) {
super(type, world);
super(type, world, ThrownTrident.DEFAULT_ARROW_STACK);
+ this.baseDamage = net.minecraft.world.item.TridentItem.BASE_DAMAGE; // Paper
this.tridentItem = new ItemStack(Items.TRIDENT);
}
public ThrownTrident(Level world, LivingEntity owner, ItemStack stack) {
super(EntityType.TRIDENT, owner, world);
super(EntityType.TRIDENT, owner, world, stack);
+ this.baseDamage = net.minecraft.world.item.TridentItem.BASE_DAMAGE; // Paper
this.tridentItem = new ItemStack(Items.TRIDENT);
this.tridentItem = stack.copy();
this.entityData.set(ThrownTrident.ID_LOYALTY, (byte) EnchantmentHelper.getLoyalty(stack));
this.entityData.set(ThrownTrident.ID_FOIL, stack.hasFoil());
}
@@ -0,0 +0,0 @@ public class ThrownTrident extends AbstractArrow {
@Override
protected void onHitEntity(EntityHitResult entityHitResult) {

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
}
protected BlockPos getOnPos(float offset) {

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
private UUID originWorld;
public boolean freezeLocked = false; // Paper - Freeze Tick Lock API
public boolean collidingWithWorldBorder; // Paper
@ -16,7 +16,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public void setOrigin(@javax.annotation.Nonnull Location location) {
this.origin = location.toVector();
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
public void onClientRemoval() {}
public void setPose(net.minecraft.world.entity.Pose pose) {

View file

@ -9,14 +9,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -0,0 +0,0 @@ public class CraftEventFactory {
} else if (entity instanceof net.minecraft.world.entity.ExperienceOrb) {
net.minecraft.world.entity.ExperienceOrb xp = (net.minecraft.world.entity.ExperienceOrb) entity;
// Spigot start - SPIGOT-7523: Merge after spawn event and only merge if the event was not cancelled (gets checked above)
if (entity instanceof net.minecraft.world.entity.ExperienceOrb xp) {
double radius = world.spigotConfig.expMerge;
- if (radius > 0) {
+ // Paper start - Call EntitySpawnEvent for ExperienceOrb entities.
+ event = CraftEventFactory.callEntitySpawnEvent(entity);
+ if (radius > 0 && !event.isCancelled() && !entity.isRemoved()) {
+ // Paper end
+ // Paper end
// Paper start - Maximum exp value when merging - Whole section has been tweaked, see comments for specifics
final int maxValue = world.paperConfig().entities.behavior.experienceMergeMaxValue;
final boolean mergeUnconditionally = world.paperConfig().entities.behavior.experienceMergeMaxValue <= 0;

View file

@ -1161,7 +1161,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
public @Nullable Throwable addedToWorldStack; // Paper - entity debug
public CraftEntity getBukkitEntity() {
if (this.bukkitEntity == null) {
@ -1186,7 +1186,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@Override
public CommandSender getBukkitSender(CommandSourceStack wrapper) {
return this.getBukkitEntity();
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
return;
}
// Paper end - rewrite chunk system
@ -1194,7 +1194,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.removalReason == null) {
this.removalReason = reason;
}
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S
if (reason != RemovalReason.UNLOADED_TO_CHUNK) this.getPassengers().forEach(Entity::stopRiding); // Paper - chunk system - don't adjust passenger state when unloading, it's just not safe (and messes with our logic in entity chunk unload)
this.levelCallback.onRemove(reason);

View file

@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.player.isPassenger()) {
this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1);
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
}
}
// Paper start - Prevent moving into unloaded chunks
if (this.player.level().paperConfig().chunks.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !worldserver.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position())))) {
+ // Paper start - Add fail move event
@ -36,21 +36,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
if (d10 - d9 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
// CraftBukkit end
+ // Paper start - Add fail move event
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY,
+ toX, toY, toZ, toYaw, toPitch, true);
+ if (!event.isAllowed()) {
+ if (event.getLogWarning())
ServerGamePacketListenerImpl.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
if (d10 - d9 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
// CraftBukkit end
+ // Paper start - Add fail move event
+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY,
+ toX, toY, toZ, toYaw, toPitch, true);
+ if (!event.isAllowed()) {
+ if (event.getLogWarning())
ServerGamePacketListenerImpl.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
return;
+ }
+ // Paper end
}
}
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
from = event.getFrom();
this.internalTeleport(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch(), Collections.emptySet());
return;
+ }
+ // Paper end
}
// Paper end
}
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
boolean flag2 = false;

View file

@ -42,24 +42,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
@@ -0,0 +0,0 @@ public class ServerChunkCache extends ChunkSource {
if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
// re-set mob counts
for (ServerPlayer player : this.level.players) {
- Arrays.fill(player.mobCounts, 0);
+ // Paper start - per player mob spawning backoff
+ for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
+ player.mobCounts[ii] = 0;
if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
// re-set mob counts
for (ServerPlayer player : this.level.players) {
- Arrays.fill(player.mobCounts, 0);
+ // Paper start - per player mob spawning backoff
+ for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
+ player.mobCounts[ii] = 0;
+
+ int newBackoff = player.mobBackoffCounts[ii] - 1; // TODO make configurable bleed // TODO use nonlinear algorithm?
+ if (newBackoff < 0) {
+ newBackoff = 0;
+ int newBackoff = player.mobBackoffCounts[ii] - 1; // TODO make configurable bleed // TODO use nonlinear algorithm?
+ if (newBackoff < 0) {
+ newBackoff = 0;
+ }
+ player.mobBackoffCounts[ii] = newBackoff;
+ }
+ player.mobBackoffCounts[ii] = newBackoff;
+ }
+ // Paper end - per player mob spawning backoff
}
spawnercreature_d = NaturalSpawner.createState(l, this.level.getAllEntities(), this::getFullChunk, null, true);
} else {
+ // Paper end - per player mob spawning backoff
}
spawnercreature_d = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, null, true);
} else {
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/commands/CommandSourceStack.java
+++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java
@@ -0,0 +0,0 @@ public class CommandSourceStack implements SharedSuggestionProvider, com.destroy
@@ -0,0 +0,0 @@ public class CommandSourceStack implements ExecutionCommandSource<CommandSourceS
// CraftBukkit start
public boolean hasPermission(int i, String bukkitPermission) {

View file

@ -15,11 +15,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class ServerPlayerGameMode {
isCorrectTool = flag1; // Paper
itemstack.mineBlock(this.level, iblockdata, pos, this.player);
itemstack.mineBlock(this.level, iblockdata1, pos, this.player);
- if (flag && flag1 && event.isDropItems()) { // CraftBukkit - Check if block should drop items
- block.playerDestroy(this.level, this.player, pos, iblockdata, tileentity, itemstack1);
+ if (flag && flag1 /* && event.isDropItems() */) { // CraftBukkit - Check if block should drop items // Paper - fix drops not preventing stats/food exhaustion
+ block.playerDestroy(this.level, this.player, pos, iblockdata, tileentity, itemstack1, event.isDropItems()); // Paper
- block.playerDestroy(this.level, this.player, pos, iblockdata1, tileentity, itemstack1);
+ if (flag && flag1 && event.isDropItems()/* && event.isDropItems() */) { // CraftBukkit - Check if block should drop items // Paper - fix drops not preventing stats/food exhaustion
+ block.playerDestroy(this.level, this.player, pos, iblockdata1, tileentity, itemstack1, event.isDropItems()); // Paper
}
// return true; // CraftBukkit
@ -75,7 +75,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ super.playerDestroy(world, player, pos, Blocks.AIR.defaultBlockState(), blockEntity, tool, includeDrops); // Paper
}
protected static void preventCreativeDropFromBottomPart(Level world, BlockPos pos, BlockState state, Player player) {
protected static void preventDropFromBottomPart(Level world, BlockPos pos, BlockState state, Player player) {
diff --git a/src/main/java/net/minecraft/world/level/block/IceBlock.java b/src/main/java/net/minecraft/world/level/block/IceBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/IceBlock.java