Skip to content

Commit

Permalink
[ci skip] Add more patch identifying comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytv committed Jan 13, 2024
1 parent 8c8862f commit e84621a
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 85 deletions.
60 changes: 30 additions & 30 deletions patches/server/1040-Restore-vanilla-entity-drops-behavior.patch

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions patches/server/1042-Dont-resend-blocks-on-interactions.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In general, the client now has an acknowledgment system which will prevent block
It should be noted that this system does not yet support block entities, so those still need to resynced when needed.

diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index 4634f4fbb0c06c68436c5e30069621c9fcd4ffb5..a0d69082f5fdeee15bba0d76b940aa48cff36fa9 100644
index 4634f4fbb0c06c68436c5e30069621c9fcd4ffb5..51bf6c740ac08548eedf0c026c5a66d6a3c6d83e 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -199,7 +199,7 @@ public class ServerPlayerGameMode {
Expand Down Expand Up @@ -52,7 +52,7 @@ index 4634f4fbb0c06c68436c5e30069621c9fcd4ffb5..a0d69082f5fdeee15bba0d76b940aa48
+ //} else if (data.getBlock() instanceof TrapDoorBlock) {
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
+ //}
+ // Paper end
+ // Paper end - Don't resync blocks
} else if (!iblockdata.isAir()) {
iblockdata.attack(this.level, pos, this.player);
f = iblockdata.getDestroyProgress(this.player, this.player.level(), pos);
Expand Down Expand Up @@ -87,7 +87,7 @@ index 4634f4fbb0c06c68436c5e30069621c9fcd4ffb5..a0d69082f5fdeee15bba0d76b940aa48
if (isSwordNoBreak) {
return false;
}
+ // Paper start - Dont resync blocks
+ // Paper start - Don't resync blocks
// Let the client know the block still exists
- this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
+ //this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos));
Expand All @@ -99,7 +99,7 @@ index 4634f4fbb0c06c68436c5e30069621c9fcd4ffb5..a0d69082f5fdeee15bba0d76b940aa48
+ //for (Direction dir : Direction.values()) {
+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos.relative(dir)));
+ //}
+ // Paper end
+ // Paper end - Don't resync blocks

// Update any tile entity data for this block
if (!captureSentBlockEntities) { // Paper - Toggle this location for capturing as this is used for api
Expand All @@ -112,17 +112,17 @@ index 4634f4fbb0c06c68436c5e30069621c9fcd4ffb5..a0d69082f5fdeee15bba0d76b940aa48
+ // Paper start - Don't resync blocks
+ // boolean bottom = iblockdata.getValue(DoorBlock.HALF) == DoubleBlockHalf.LOWER;
+ // player.connection.send(new ClientboundBlockUpdatePacket(world, bottom ? blockposition.above() : blockposition.below()));
+ // Paper end
+ // Paper end - Don't resync blocks
} else if (iblockdata.getBlock() instanceof CakeBlock) {
player.getBukkitEntity().sendHealthUpdate(); // SPIGOT-1341 - reset health for cake
} else if (this.interactItemStack.getItem() instanceof DoubleHighBlockItem) {
// send a correcting update to the client, as it already placed the upper half of the bisected item
- player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.relative(hitResult.getDirection()).above()));
+ //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.relative(hitResult.getDirection()).above())); // Paper - don't resync blocks
+ //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.relative(hitResult.getDirection()).above())); // Paper - Don't resync blocks

// send a correcting update to the client for the block above as well, this because of replaceable blocks (such as grass, sea grass etc)
- player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above()));
+ //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above())); // Paper - don't resync blocks
+ //player.connection.send(new ClientboundBlockUpdatePacket(world, blockposition.above())); // Paper - Don't resync blocks
// Paper start - extend Player Interact cancellation // TODO: consider merging this into the extracted method
} else if (iblockdata.getBlock() instanceof net.minecraft.world.level.block.StructureBlock) {
player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerClosePacket(this.player.containerMenu.containerId));
Expand All @@ -149,7 +149,7 @@ index 277555a26e8281dd1a626e572794b08cf51d00c5..aa0f09a18ea781e027ea70928b30d3e9
return false;
}
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 666533627e772e5e85ba04e65dd2b376efc0b139..5b8a1f31e0b55da15daa4ab271317e4393a87e96 100644
index 666533627e772e5e85ba04e65dd2b376efc0b139..bab97eedd92f7131fd0cd478580ddd52d2173de9 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -457,10 +457,12 @@ public final class ItemStack {
Expand All @@ -160,12 +160,12 @@ index 666533627e772e5e85ba04e65dd2b376efc0b139..5b8a1f31e0b55da15daa4ab271317e43
- for (Direction dir : Direction.values()) {
- ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, placedPos.relative(dir)));
- }
+ // Paper start - don't resync blocks
+ // Paper start - Don't resync blocks
+ // BlockPos placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition();
+ // for (Direction dir : Direction.values()) {
+ // ((ServerPlayer) entityhuman).connection.send(new ClientboundBlockUpdatePacket(world, placedPos.relative(dir)));
+ // }
+ // Paper end
+ // Paper end - Don't resync blocks
SignItem.openSign = null; // SPIGOT-6758 - Reset on early return
} else {
// Change the stack to its new contents if it hasn't been tampered with.
4 changes: 2 additions & 2 deletions patches/server/1050-Add-experience-points-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ Subject: [PATCH] Add experience points API


diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 7f3466340891b4409d1399ebeb2ca865d77841cd..3e597833b57377b855505b8a0f2744801c791f90 100644
index 7f3466340891b4409d1399ebeb2ca865d77841cd..0a9ee8aee52b34566f1613229951e33e53394f29 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1833,7 +1833,7 @@ public abstract class Player extends LivingEntity {
}

public int getXpNeededForNextLevel() {
- return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2);
+ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); // Paper - diff on change
+ return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2); // Paper - diff on change; calculateTotalExperiencePoints
}
// Paper start - send SoundEffect to everyone who can see fromEntity
private static void sendSoundEffect(Player fromEntity, double x, double y, double z, SoundEvent soundEffect, SoundSource soundCategory, float volume, float pitch) {
Expand Down
24 changes: 12 additions & 12 deletions patches/server/1052-Add-drops-to-shear-events.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,46 @@ Subject: [PATCH] Add drops to shear events


diff --git a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java
index 45d356c1ed888b4d749379ceaa8a95d7d7c876d5..887e75c940ab5089f4e42e4553ab95adf172df46 100644
index 45d356c1ed888b4d749379ceaa8a95d7d7c876d5..8d65cdb013706a932c2c73231108b2810b99e1c7 100644
--- a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java
+++ b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java
@@ -103,11 +103,14 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior {

if (ishearable.readyForShearing()) {
// CraftBukkit start
- if (CraftEventFactory.callBlockShearEntityEvent(entityliving, bukkitBlock, craftItem).isCancelled()) {
+ // Paper start
+ // Paper start - Add drops to shear events
+ org.bukkit.event.block.BlockShearEntityEvent event = CraftEventFactory.callBlockShearEntityEvent(entityliving, bukkitBlock, craftItem, ishearable.generateDefaultDrops());
+ if (event.isCancelled()) {
+ // Paper end
+ // Paper end - Add drops to shear events
continue;
}
// CraftBukkit end
- ishearable.shear(SoundSource.BLOCKS);
+ ishearable.shear(SoundSource.BLOCKS, CraftItemStack.asNMSCopy(event.getDrops())); // Paper
+ ishearable.shear(SoundSource.BLOCKS, CraftItemStack.asNMSCopy(event.getDrops())); // Paper - Add drops to shear events
worldserver.gameEvent((Entity) null, GameEvent.SHEAR, blockposition);
return true;
}
diff --git a/src/main/java/net/minecraft/world/entity/Shearable.java b/src/main/java/net/minecraft/world/entity/Shearable.java
index 5e8cc5cfac8888628c6d513148f41be09ca65a2c..4921d1b2ff9112374477c5c9b4a68cc75a51dbf8 100644
index 5e8cc5cfac8888628c6d513148f41be09ca65a2c..2ee48ac3b665db2b02bcb1a30ec972d43a3725b0 100644
--- a/src/main/java/net/minecraft/world/entity/Shearable.java
+++ b/src/main/java/net/minecraft/world/entity/Shearable.java
@@ -3,7 +3,13 @@ package net.minecraft.world.entity;
import net.minecraft.sounds.SoundSource;

public interface Shearable {
+ default void shear(SoundSource soundCategory, java.util.List<net.minecraft.world.item.ItemStack> drops) { this.shear(soundCategory); } // Paper
+ default void shear(SoundSource soundCategory, java.util.List<net.minecraft.world.item.ItemStack> drops) { this.shear(soundCategory); } // Paper - Add drops to shear events
void shear(SoundSource shearedSoundCategory);

boolean readyForShearing();
+ // Paper start - ensure all implementing entities override this
+ // Paper start - custom shear drops; ensure all implementing entities override this
+ default java.util.List<net.minecraft.world.item.ItemStack> generateDefaultDrops() {
+ return java.util.Collections.emptyList();
+ }
+ // Paper end
+ // Paper end - custom shear drops
}
diff --git a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
index e42b0b19019ef74733fd19b08f882cccff920142..a7e8b544d7b05efe95182a03cabaf1993da9d839 100644
index e42b0b19019ef74733fd19b08f882cccff920142..7a82ba6e29fde33841c049e8520300aa66608f34 100644
--- a/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
+++ b/src/main/java/net/minecraft/world/entity/animal/MushroomCow.java
@@ -122,11 +122,18 @@ public class MushroomCow extends Cow implements Shearable, VariantHolder<Mushroo
Expand All @@ -65,7 +65,7 @@ index e42b0b19019ef74733fd19b08f882cccff920142..a7e8b544d7b05efe95182a03cabaf199
+ // Paper end - custom shear drops
// CraftBukkit end
- this.shear(SoundSource.PLAYERS);
+ this.shear(SoundSource.PLAYERS, drops); // Paper
+ this.shear(SoundSource.PLAYERS, drops); // Paper - custom shear drops
this.gameEvent(GameEvent.SHEAR, player);
if (!this.level().isClientSide) {
itemstack.hurtAndBreak(1, player, (entityhuman1) -> {
Expand Down Expand Up @@ -106,7 +106,7 @@ index e42b0b19019ef74733fd19b08f882cccff920142..a7e8b544d7b05efe95182a03cabaf199
- }
- this.level().addFreshEntity(entityitem);
- // CraftBukkit end
+ // Paper start - custom shear drops (moved drop generation to separate method)
+ // Paper start - custom shear drops; moved drop generation to separate method
+ for (final ItemStack drop : drops) {
+ ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(1.0D), this.getZ(), drop);
+ this.spawnAtLocation(entityitem);
Expand Down Expand Up @@ -233,7 +233,7 @@ index 8adcfc8f6772a32b5915e4a07100e8eb735f907a..b5d6857eaf2bed14adcb5f5e80d91b44

}
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 7d9fc84dd684093098fdefdcaf7c92a0fbc158de..2aab68bac670dcd134d817940020214c7b0797f9 100644
index 66a05f9a5d114c7f39c3a88b7835e2a45f7db16f..cbaaa7d54e70bf4e0604d1716d253453bab03744 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -1718,20 +1718,20 @@ public class CraftEventFactory {
Expand Down
20 changes: 10 additions & 10 deletions patches/server/1053-Add-PlayerShieldDisableEvent.patch
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,47 @@ sideeffects, meaning the disable event cannot share a handlerlist with
the cooldown event

diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 5af48151159135b869ec4753bbcf79dd257c1570..e0cf7771488ab0065708d68b4e8550b865af0ed4 100644
index 5af48151159135b869ec4753bbcf79dd257c1570..538eaf327bdae975ce854871189990fbfe17b918 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -1703,7 +1703,11 @@ public abstract class Mob extends LivingEntity implements Targeting {
float f = 0.25F + (float) EnchantmentHelper.getBlockEfficiency(this) * 0.05F;

if (this.random.nextFloat() < f) {
- player.getCooldowns().addCooldown(Items.SHIELD, 100);
+ // Paper start
+ // Paper start - Add PlayerShieldDisableEvent
+ final io.papermc.paper.event.player.PlayerShieldDisableEvent shieldDisableEvent = new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) player.getBukkitEntity(), getBukkitEntity(), 100);
+ if (!shieldDisableEvent.callEvent()) return;
+ player.getCooldowns().addCooldown(Items.SHIELD, shieldDisableEvent.getCooldown());
+ // Paper end
+ // Paper end - Add PlayerShieldDisableEvent
this.level().broadcastEntityEvent(player, (byte) 30);
}
}
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 3e597833b57377b855505b8a0f2744801c791f90..ccc1caafb0ada52c7b99b7358253826f5390843e 100644
index 0a9ee8aee52b34566f1613229951e33e53394f29..5fffd5fde567affa51b3cf4bcc58249134a95e20 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -979,7 +979,7 @@ public abstract class Player extends LivingEntity {
protected void blockUsingShield(LivingEntity attacker) {
super.blockUsingShield(attacker);
if (attacker.canDisableShield()) {
- this.disableShield(true);
+ this.disableShield(true, attacker); // Paper
+ this.disableShield(true, attacker); // Paper - Add PlayerShieldDisableEvent
}

}
@@ -1462,7 +1462,14 @@ public abstract class Player extends LivingEntity {
this.attack(target);
}

+ @io.papermc.paper.annotation.DoNotUse // Paper - add player shield disable event
+ @io.papermc.paper.annotation.DoNotUse // Paper - Add PlayerShieldDisableEvent
public void disableShield(boolean sprinting) {
+ // Paper start - add player shield disable event
+ // Paper start - Add PlayerShieldDisableEvent
+ disableShield(sprinting, null);
+ }
+
+ public void disableShield(boolean sprinting, @Nullable LivingEntity attacker) {
+ // Paper end - add player shield disable event
+ // Paper end - Add PlayerShieldDisableEvent
float f = 0.25F + (float) EnchantmentHelper.getBlockEfficiency(this) * 0.05F;

if (sprinting) {
Expand All @@ -65,7 +65,7 @@ index 3e597833b57377b855505b8a0f2744801c791f90..ccc1caafb0ada52c7b99b7358253826f

if (this.random.nextFloat() < f) {
- this.getCooldowns().addCooldown(Items.SHIELD, 100);
+ // Paper start - add player shield disable event
+ // Paper start - Add PlayerShieldDisableEvent
+ final org.bukkit.entity.Entity finalAttacker = attacker != null ? attacker.getBukkitEntity() : null;
+ if (finalAttacker != null) {
+ final io.papermc.paper.event.player.PlayerShieldDisableEvent shieldDisableEvent = new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) getBukkitEntity(), finalAttacker, 100);
Expand All @@ -74,7 +74,7 @@ index 3e597833b57377b855505b8a0f2744801c791f90..ccc1caafb0ada52c7b99b7358253826f
+ } else {
+ this.getCooldowns().addCooldown(Items.SHIELD, 100);
+ }
+ // Paper end - add player shield disable event
+ // Paper end - Add PlayerShieldDisableEvent
this.stopUsingItem();
this.level().broadcastEntityEvent(this, (byte) 30);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ in order to fire the BlockDispenseEvent. This patch corrects
that.

diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
index f42a86549e389ec53962f7a5e7a625f351cd4724..bf1c5834717758991c1520afd4b2a5c3fa68a558 100644
index f42a86549e389ec53962f7a5e7a625f351cd4724..a1739f6f091fe922ac0e97141fc9446664713fc3 100644
--- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
+++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java
@@ -628,7 +628,13 @@ public interface DispenseItemBehavior {
Expand All @@ -19,7 +19,7 @@ index f42a86549e389ec53962f7a5e7a625f351cd4724..bf1c5834717758991c1520afd4b2a5c3
+ // Paper start - correctly check if the bucket place will succeed
+ /* Taken from SolidBucketItem#emptyContents */
+ boolean willEmptyContentsSolidBucketItem = dispensiblecontaineritem instanceof net.minecraft.world.item.SolidBucketItem && worldserver.isInWorldBounds(blockposition) && iblockdata.isAir();
+ /* Take from BucketItem#emptyContents */
+ /* Taken from BucketItem#emptyContents */
+ boolean willEmptyBucketItem = dispensiblecontaineritem instanceof final BucketItem bucketItem && bucketItem.content instanceof net.minecraft.world.level.material.FlowingFluid && (iblockdata.isAir() || iblockdata.canBeReplaced(bucketItem.content) || (iblockdata.getBlock() instanceof LiquidBlockContainer liquidBlockContainer && liquidBlockContainer.canPlaceLiquid(null, worldserver, blockposition, iblockdata, bucketItem.content)));
+ if (willEmptyContentsSolidBucketItem || willEmptyBucketItem) {
+ // Paper end - correctly check if the bucket place will succeed
Expand Down
Loading

0 comments on commit e84621a

Please sign in to comment.