Compare commits

...
Author SHA1 Message Date
Nassim Jahnke e4d6dfd159 Update publishing workflow 2026-10-25 12:17:43 +01:00
Nassim Jahnke 91693c3ec1 Fix equipment check 2026-10-23 19:12:57 +02:00
TheosReeandTheosRee 3e24be0380 Rewrite Adventure Book calls to BookMeta (#14385)
See: 6e1bb67eb1
Co-authored-by: TheosRee <theosree@users.noreply.github.com>
2026-10-14 19:32:19 +01:00
Bjarne Koll 58e6e45d67 Correctly revert SulfurCube on cancelled explode event
A plugin cancelling a sulfur cube explosion should fully revert the cube
to its pre-primed state. Previously the sulfur cube would remain
invulnerable after the event was cancelled.
2026-10-09 18:16:37 +01:00
WarriorandJason Penilla 19ebc4a49b Prevent shearing villager display items (#14356)
Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
2026-10-06 19:52:15 +01:00
Nassim Jahnke e8c8a68254 Make test block codec conditional 2026-10-06 20:19:30 +02:00
WarriorandBjarne Koll a3d63e8d81 Fix bundle contents corruption with item obfuscation and shelves (#14353)
Co-authored-by: Bjarne Koll <git@lynxplay.dev>
2026-10-05 19:25:19 +02:00
Owen1212055 9240f586a4 Fix golem target block check 2026-09-23 20:48:33 +02:00
Pantera 5749698297 Fix weather clear desync on player respawn (#14288) 2026-09-22 09:08:41 -03:00
Pedro ad9a0347f5 Fix Player#applyMending for custom items using max_damage (#14276) 2026-09-21 10:49:49 -03:00
Pedro c646fafccf Call EntityCollideWithEntityEvent for Sulfur Cube pushed by Player (#14157) 2026-09-19 23:37:27 -03:00
Strokkur24 eb5b0dee24 Add SulfurCube#swallow (#14062) 2026-09-19 15:02:06 -03:00
ZeroAura-exeandLulu13022002 22ca6c7de3 Fix panda/bee nearby target reason (#14253)
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
2026-09-15 19:47:37 +02:00
25 changed files with 317 additions and 123 deletions

No files matched your search

+1 -1
View File
@@ -18,7 +18,7 @@ indent_style = tab
[*.bat]
end_of_line = crlf
[*.yml]
[{*.yaml,*.yml}]
indent_size = 2
[{*.patch,*.md}]
@@ -5,14 +5,17 @@
# of the PR relating to this action.
name: Build Paper
on:
push:
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
push:
branches-ignore:
- ver/26.2
jobs:
build:
@@ -107,7 +110,7 @@ jobs:
if: always()
uses: actions/upload-artifact@v7
with:
name: Test Results
name: test-results
path: |
**/build/test-results/test/TEST-*.xml
@@ -137,12 +140,12 @@ jobs:
publishing-task: ":paper-api:publishAllPublicationsTo_githubPackages_PRsRepository publishDevBundlePublicationTo_githubPackages_PRsRepository -PpublishDevBundle"
event_file:
name: "Event File"
# Only run on PRs if the source branch is on someone else's repo
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
needs: build
if: ${{ !cancelled() && needs.build.result != 'skipped' }}
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v7
with:
name: Event File
name: event-data
path: ${{ github.event_path }}
+56
View File
@@ -0,0 +1,56 @@
name: Release 26.2
on:
workflow_dispatch:
push:
branches:
- ver/26.2
permissions:
contents: read
concurrency:
cancel-in-progress: false
group: release-26.2
jobs:
release:
# guard for manual dispatch
if: ${{ github.ref == 'refs/heads/ver/26.2' }}
runs-on: namespace-profile-linux-default
timeout-minutes: 30
#env:
# BUILD_NUMBER: ${{ github.run_number }}
steps:
- name: "environment"
run: |
echo "BUILD_NUMBER=$((134 + GITHUB_RUN_NUMBER))" >> "$GITHUB_ENV"
echo "BUILD_STARTED_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_ENV"
- name: "git / checkout"
uses: namespacelabs/nscloud-checkout-action@66f2dc6f6c42a8ac6c4e53473c4840006822831e # v9.0.1
with:
fetch-depth: 0
- uses: papermc/ci/setup-gradle@main
- uses: papermc/ci/build-paper@main
- if: ${{ !cancelled() }}
uses: papermc/ci/upload-event-data@main
with:
path: ${{ github.event_path }}
- if: ${{ !cancelled() }}
uses: papermc/ci/upload-test-results@main
- uses: papermc/ci/publish-fill@main
with:
fill_api_url: ${{ secrets.FILL_API_URL }}
fill_api_key: ${{ secrets.FILL_API_KEY }}
- uses: papermc/ci/publish-maven@main
with:
maven_username: ${{ secrets.ARTIFACTORY_USERNAME }}
maven_password: ${{ secrets.ARTIFACTORY_PASSWORD }}
maven_tasks: -PpublishDevBundle :paper-api:publish publishDevBundlePublicationToPaperReleasesRepository
+24
View File
@@ -0,0 +1,24 @@
name: Test Results
on:
workflow_run:
workflows: [ "Build Paper" ]
types:
- completed
permissions:
actions: read
checks: write
jobs:
test-results:
name: Test Results
if: github.event.workflow_run.conclusion != 'skipped'
runs-on: namespace-profile-linux-small
steps:
- uses: papermc/ci/publish-test-results@main
with:
event: ${{ github.event.workflow_run.event }}
commit: ${{ github.event.workflow_run.head_sha }}
github_token: ${{ secrets.GITHUB_TOKEN }}
run_id: ${{ github.event.workflow_run.id }}
-34
View File
@@ -1,34 +0,0 @@
name: Test Results
on:
workflow_run:
workflows: [ "Build Paper" ]
types:
- completed
permissions: { }
jobs:
test-results:
name: Test Results
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion != 'skipped'
permissions:
checks: write
# for downloading test result artifacts
actions: read
steps:
- name: Download and Extract Artifacts
uses: dawidd6/action-download-artifact@v21
with:
run_id: ${{ github.event.workflow_run.id }}
path: test_artifacts
name: "Test Results|Event File"
name_is_regexp: true
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
commit: ${{ github.event.workflow_run.head_sha }}
event_file: test_artifacts/Event File/event.json
event_name: ${{ github.event.workflow_run.event }}
files: "test_artifacts/**/*.xml"
comment_mode: off
@@ -1,12 +1,12 @@
package io.papermc.paper.event.entity;
import java.util.List;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import org.jspecify.annotations.NullMarked;
/**
* Fired when two entities collide with each other.
@@ -15,6 +15,7 @@ import java.util.List;
* Note that even if cancelled, the client may still run its own collision unless
* disabled via player teams.
*/
@NullMarked
public class EntityCollideWithEntityEvent extends Event implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
@@ -22,8 +23,8 @@ public class EntityCollideWithEntityEvent extends Event implements Cancellable {
private final List<Entity> entities;
@ApiStatus.Internal
public EntityCollideWithEntityEvent(@NotNull Entity entity1, @NotNull Entity entity2) {
entities = List.of(entity1, entity2);
public EntityCollideWithEntityEvent(final Entity entity1, final Entity entity2) {
this.entities = List.of(entity1, entity2);
}
/**
@@ -31,23 +32,22 @@ public class EntityCollideWithEntityEvent extends Event implements Cancellable {
*
* @return entities that are involved in this event
*/
public @NotNull List<Entity> getEntities() {
return entities;
public List<Entity> getEntities() {
return this.entities;
}
@Override
public @NotNull HandlerList getHandlers() {
public HandlerList getHandlers() {
return HANDLER_LIST;
}
@NotNull
public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
@Override
public boolean isCancelled() {
return cancelled;
return this.cancelled;
}
@Override
@@ -1,12 +1,17 @@
package org.bukkit.entity;
import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
import io.papermc.paper.entity.Bucketable;
import io.papermc.paper.entity.Shearable;
import io.papermc.paper.event.entity.EntityEquipmentChangedEvent;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryKey;
import io.papermc.paper.registry.keys.tags.ItemTypeTagKeys;
import net.kyori.adventure.key.Key;
import net.kyori.adventure.key.KeyPattern;
import org.bukkit.Keyed;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.jspecify.annotations.NullMarked;
/**
@@ -73,6 +78,58 @@ public interface SulfurCube extends AbstractCubeMob, Shearable, Bucketable, Agea
return this.ignite(false);
}
/**
* Makes this sulfur cube swallow the provided item, following any Vanilla logic.
* <p>
* This method will:
* <ul>
* <li>not equip the item to a baby sulfur cube,</li>
* <li>if present, drop a previously swallowed item, and</li>
* <li>play the swallow sound.</li>
* </ul>
* <p>
* If the currently swallowed item is changed, a {@link EntityEquipmentChangedEvent} is called.
* May also call a {@link EntityAddToWorldEvent} for the newly dropped {@link Item} entity.
*
* @param itemStack the item to swallow. Use {@link ItemStack#empty()} to unset the item.
* Items not in the {@link ItemTypeTagKeys#SULFUR_CUBE_SWALLOWABLE} tag
* will not be properly rendered inside the sulfur cube
* @return whether the sulfur cube's absorbed item was updated
* @see #setEquipped(ItemStack) set the swallowed item, skipping any Vanilla swallow logic
*/
boolean swallow(ItemStack itemStack);
/**
* Sets the swallowed item stack for this sulfur cube.
* <p>
* This method acts as a simple utility method to set the {@link EquipmentSlot#BODY}
* equipment slot of this sulfur cube, which holds the sulfur cube's swallowed item.
* <p>
* Different to {@link #swallow(ItemStack)}, this method does not play a sound or
* drop the previously equipped item on the ground.
* <p>
* This method will call a {@link EntityEquipmentChangedEvent}.
*
* @param itemStack the item stack to be equipped, use {@link ItemStack#empty()} to unset the item
* @see #swallow(ItemStack) set the swallowed item, following any Vanilla swallow logic
*/
default void setEquipped(final ItemStack itemStack) {
this.getEquipment().setItem(EquipmentSlot.BODY, itemStack);
}
/**
* Retrieves the item stack currently swallowed by this sulfur cube.
* <p>
* This method acts as a simple utility method to get the {@link EquipmentSlot#BODY}
* equipment slot of this sulfur cube, which holds the sulfur cube's swallowed item.
*
* @return the item stack in the {@link EquipmentSlot#BODY} equipment slot, returns {@link ItemStack#empty()}
* if no item is present
*/
default ItemStack getEquipped() {
return this.getEquipment().getItem(EquipmentSlot.BODY);
}
/**
* Represents the archetype of a sulfur cube
* which define a lot of possible behavior and interaction
+1 -1
View File
@@ -8,7 +8,7 @@ plugins {
`maven-publish`
idea
id("io.papermc.paperweight.core")
id("io.papermc.fill.gradle") version "1.0.12"
id("io.papermc.fill.gradle") version "1.0.14"
}
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
@@ -28892,7 +28892,7 @@ index 3271c83bd103bea9b9ffcd6882b52896ea4da770..f6601bc30fa37a309923ea9883b04233
PrepareSpawnTask.this.loadListener.updateFocus(this.spawnLevel.dimension(), spawnChunk);
}
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
index b4845731ba1eaae582afece7e09e2af427b29d6a..1dbb1d49c797be89f3739c2fa226aef25f68ee87 100644
index 7e311382fb265f49b1f079a3d9ffa7f7e6fde67c..ea16325d61c8bf8c8dba161c16207551bffc2aaf 100644
--- a/net/minecraft/server/players/PlayerList.java
+++ b/net/minecraft/server/players/PlayerList.java
@@ -982,8 +982,8 @@ public abstract class PlayerList {
@@ -28906,7 +28906,7 @@ index b4845731ba1eaae582afece7e09e2af427b29d6a..1dbb1d49c797be89f3739c2fa226aef2
// Paper end - view distances
if (level.isRaining()) {
// CraftBukkit start - handle player weather
@@ -1200,7 +1200,7 @@ public abstract class PlayerList {
@@ -1203,7 +1203,7 @@ public abstract class PlayerList {
public void setViewDistance(final int viewDistance) {
this.viewDistance = viewDistance;
@@ -28915,7 +28915,7 @@ index b4845731ba1eaae582afece7e09e2af427b29d6a..1dbb1d49c797be89f3739c2fa226aef2
for (ServerLevel level : this.server.getAllLevels()) {
level.getChunkSource().setViewDistance(viewDistance);
@@ -1209,7 +1209,7 @@ public abstract class PlayerList {
@@ -1212,7 +1212,7 @@ public abstract class PlayerList {
public void setSimulationDistance(final int simulationDistance) {
this.simulationDistance = simulationDistance;
@@ -0,0 +1,49 @@
--- a/net/minecraft/network/protocol/game/GameProtocols.java
+++ b/net/minecraft/network/protocol/game/GameProtocols.java
@@ -37,8 +_,29 @@
import net.minecraft.network.protocol.ping.ServerboundPingRequestPacket;
public class GameProtocols {
+ // Paper start - check if game master
+ public static final CodecModifier<RegistryFriendlyByteBuf, ServerboundTestInstanceBlockActionPacket, GameProtocols.Context> IS_GAME_MASTER = (original, context) -> new StreamCodec<>(
+ ) {
+ @Override
+ public ServerboundTestInstanceBlockActionPacket decode(final RegistryFriendlyByteBuf input) {
+ if (!context.canUseCommandBlocks()) {
+ throw new SkipPacketDecoderException("Not a game master");
+ } else {
+ return original.decode(input);
+ }
+ }
+
+ @Override
+ public void encode(final RegistryFriendlyByteBuf output, final ServerboundTestInstanceBlockActionPacket value) {
+ if (!context.canUseCommandBlocks()) {
+ throw new SkipPacketEncoderException("Not a game master");
+ }
+ original.encode(output, value);
+ }
+ };
+ // Paper end - check if game master
public static final CodecModifier<RegistryFriendlyByteBuf, ServerboundSetCreativeModeSlotPacket, GameProtocols.Context> HAS_INFINITE_MATERIALS = (original, context) -> new StreamCodec<RegistryFriendlyByteBuf, ServerboundSetCreativeModeSlotPacket>(
-
+
) {
@Override
public ServerboundSetCreativeModeSlotPacket decode(final RegistryFriendlyByteBuf input) {
@@ -125,7 +_,7 @@
.addPacket(GamePacketTypes.SERVERBOUND_SPECTATOR_ACTION, ServerboundSpectatorActionPacket.STREAM_CODEC)
.addPacket(GamePacketTypes.SERVERBOUND_SWING, ServerboundSwingPacket.STREAM_CODEC)
.addPacket(GamePacketTypes.SERVERBOUND_TELEPORT_TO_ENTITY, ServerboundTeleportToEntityPacket.STREAM_CODEC)
- .addPacket(GamePacketTypes.SERVERBOUND_TEST_INSTANCE_BLOCK_ACTION, ServerboundTestInstanceBlockActionPacket.STREAM_CODEC)
+ .addPacket(GamePacketTypes.SERVERBOUND_TEST_INSTANCE_BLOCK_ACTION, ServerboundTestInstanceBlockActionPacket.STREAM_CODEC, IS_GAME_MASTER) // Paper - check if game master
.addPacket(GamePacketTypes.SERVERBOUND_USE_ITEM_ON, ServerboundUseItemOnPacket.STREAM_CODEC)
.addPacket(GamePacketTypes.SERVERBOUND_USE_ITEM, ServerboundUseItemPacket.STREAM_CODEC)
.addPacket(CommonPacketTypes.SERVERBOUND_CUSTOM_CLICK_ACTION, ServerboundCustomClickActionPacket.STREAM_CODEC)
@@ -277,5 +_,6 @@
public interface Context {
boolean hasInfiniteMaterials();
+ boolean canUseCommandBlocks(); // Paper - check if game master
}
}
@@ -2584,6 +2584,19 @@
if (!this.receivedMovementThisTick) {
this.player.setKnownMovement(Vec3.ZERO);
}
@@ -2220,6 +_,12 @@
public boolean hasInfiniteMaterials() {
return this.player.hasInfiniteMaterials();
}
+ // Paper start - check if game master
+ @Override
+ public boolean canUseCommandBlocks() {
+ return this.player.canUseGameMasterBlocks();
+ }
+ // Paper end - check if game master
@Override
public ServerPlayer getPlayer() {
@@ -2231,12 +_,23 @@
}
@@ -737,7 +737,7 @@
}
public UserWhiteList getWhiteList() {
@@ -654,12 +_,20 @@
@@ -654,12 +_,23 @@
public void sendLevelInfo(final ServerPlayer player, final ServerLevel level) {
WorldBorder worldBorder = level.getWorldBorder();
player.connection.send(new ClientboundInitializeBorderPacket(worldBorder));
@@ -758,6 +758,9 @@
+ // player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, level.getThunderLevel(1.0F)));
+ player.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false);
+ player.updateWeather(-level.rainLevel, level.rainLevel, -level.thunderLevel, level.thunderLevel);
+ } else {
+ player.setPlayerWeather(org.bukkit.WeatherType.CLEAR, false);
+ player.updateWeather(-1.0F, level.rainLevel, -1.0F, level.thunderLevel);
+ // CraftBukkit end
}
@@ -172,6 +172,15 @@
double dropChance = this.dropChances.byEquipment(slot);
if (!current.isEmpty() && Math.max(this.random.nextFloat() - 0.1F, 0.0F) < dropChance) {
this.spawnAtLocation(level, current);
@@ -566,7 +_,7 @@
}
protected boolean canShearEquipment(final Player player) {
- return !this.isVehicle();
+ return !this.isVehicle() && !(this instanceof net.minecraft.world.entity.npc.villager.Villager); // Paper - Prevent shearing villager display items
}
protected boolean attemptToShearEquipment(final Player player, final InteractionHand hand, final ItemStack heldItem) {
@@ -688,22 +_,29 @@
@Override
public void checkDespawn() {
@@ -12,3 +12,23 @@
return isValidTarget ? transportItemTarget : null;
}
@@ -377,8 +_,17 @@
}
private boolean targetHasNotChanged(final Level level, final TransportItemsBetweenContainers.TransportItemTarget target) {
- return target.blockEntity.equals(level.getBlockEntity(target.pos));
- }
+ // Paper start
+ return target.blockEntity.equals(level.getBlockEntity(target.pos)) && !isContainerRemoved(target.container);
+ }
+
+ private static boolean isContainerRemoved(final Container container) {
+ if (container instanceof net.minecraft.world.CompoundContainer compoundContainer) {
+ return isContainerRemoved(compoundContainer.container1) || isContainerRemoved(compoundContainer.container2);
+ }
+ return container instanceof BlockEntity blockEntity && blockEntity.isRemoved();
+ }
+ // Paper end
private Stream<TransportItemsBetweenContainers.TransportItemTarget> getConnectedTargets(
final TransportItemsBetweenContainers.TransportItemTarget target, final Level level
@@ -60,7 +60,8 @@
+ this.inventory.getItems().stream().filter(item -> !item.isEmpty()).forEach(stack -> this.spawnAtLocation(level, stack)); // Paper - delay removal post event - taken from removeAllItems
+ this.postDeathEventTasks.add(this.inventory::clearContent); // Paper - only clear after death event
ItemStack itemStack = this.getItemBySlot(EquipmentSlot.MAINHAND);
if (!itemStack.isEmpty() && !EnchantmentHelper.has(itemStack, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) {
- if (!itemStack.isEmpty() && !EnchantmentHelper.has(itemStack, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) {
+ if (!itemStack.isEmpty() && !EnchantmentHelper.has(itemStack, EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP) && !this.droppedEquipmentSlots.contains(EquipmentSlot.MAINHAND)) { // Paper
this.spawnAtLocation(level, itemStack);
- this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
+ this.postDeathEventTasks.add(() -> this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY)); // Paper
@@ -113,7 +113,7 @@
protected void alertOther(final Mob other, final LivingEntity hurtByMob) {
if (other instanceof Bee && this.mob.hasLineOfSight(hurtByMob)) {
- other.setTarget(hurtByMob);
+ other.setTarget(hurtByMob, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY); // CraftBukkit - reason
+ other.setTarget(hurtByMob, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY); // CraftBukkit - reason
}
}
}
@@ -50,7 +50,7 @@
protected void alertOther(final Mob other, final LivingEntity hurtByMob) {
if (other instanceof Panda && other.isAggressive()) {
- other.setTarget(hurtByMob);
+ other.setTarget(hurtByMob, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY); // CraftBukkit
+ other.setTarget(hurtByMob, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY); // CraftBukkit
}
}
}
@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/cubemob/SulfurCube.java
+++ b/net/minecraft/world/entity/monster/cubemob/SulfurCube.java
@@ -295,13 +_,34 @@
@@ -295,13 +_,35 @@
if (!this.explosionData.isEmpty()) {
if (this.fuse == 0) {
@@ -30,6 +30,7 @@
+ if (primeEvent.isCancelled()) {
+ this.setFuse(PrimedTnt.NO_FUSE);
+ this.entityData.set(MAX_FUSE, PrimedTnt.NO_FUSE);
+ this.setInvulnerable(false);
+ return;
+ }
+ afterEvent.run();
@@ -37,7 +38,7 @@
level.explode(
this,
Explosion.getDefaultDamageSource(this.level(), this),
@@ -309,16 +_,20 @@
@@ -309,17 +_,27 @@
this.getX(),
this.getY(0.0625),
this.getZ(),
@@ -59,8 +60,15 @@
- this.discard();
+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
}
+ // Paper start - properly reset fuse if explosion data was unset by game
+ } else if (this.tickCount > 1 && this.isPrimed()) {
+ this.setFuse(PrimedTnt.NO_FUSE);
+ this.entityData.set(MAX_FUSE, PrimedTnt.NO_FUSE);
+ this.setInvulnerable(false);
+ // Paper end - properly reset fuse if explosion data was unset by game
}
}
@@ -340,6 +_,12 @@
&& !this.isPrimed()) {
int fuse = this.explosionData.get().fuse();
@@ -156,6 +164,17 @@
this.playSound(this.getEjectSound());
this.pickupTimer = 100;
}
@@ -748,6 +_,10 @@
double sulfurCubeTopPosition = sulfurCubeBottomPosition + this.getBbHeight();
double pusherTopPosition = pusherFeetPosition + pusher.getBbHeight();
if (cubeToPusher.horizontalDistance() < 1.3F && pusherFeetPosition <= sulfurCubeTopPosition && pusherTopPosition > sulfurCubeBottomPosition) {
+ // Paper start - Add EntityCollideWithEntity Event
+ if (io.papermc.paper.event.entity.EntityCollideWithEntityEvent.getHandlerList().getRegisteredListeners().length != 0 &&
+ !new io.papermc.paper.event.entity.EntityCollideWithEntityEvent(this.getBukkitEntity(), pusher.getBukkitEntity()).callEvent()) return;
+ // Paper end - Add EntityCollideWithEntity Event
double knockback = Math.max(0.0, 1.0 - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE));
Vec3 pushDirection = cubeToPusher.horizontal().normalize().scale(knockback);
float pushSpeedScale = player.isPassenger() ? 0.16F : 0.3F;
@@ -827,7 +_,7 @@
}
@@ -80,7 +80,7 @@
public void startUnderWaterConversion(final int time) {
this.conversionTime = time;
this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true);
@@ -246,17 +_,28 @@
@@ -246,17 +_,35 @@
}
protected void convertToZombieType(final ServerLevel level, final EntityType<? extends Zombie> zombieType) {
@@ -110,6 +110,13 @@
+
+ public static @Nullable ZombieVillager convertVillagerToZombieVillager(final ServerLevel level, final Villager villager, final net.minecraft.core.BlockPos blockPosition, boolean silent, org.bukkit.event.entity.EntityTransformEvent.TransformReason transformReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) {
+ // CraftBukkit end
+ // Paper start - Clear display items before conversion
+ for (net.minecraft.world.entity.ai.behavior.BehaviorControl<? super Villager> behavior : villager.getBrain().getRunningBehaviors()) {
+ if (behavior instanceof net.minecraft.world.entity.ai.behavior.ShowTradesToPlayer) {
+ behavior.doStop(level, villager, level.getGameTime());
+ }
+ }
+ // Paper end - Clear display items before conversion
ZombieVillager zombieVillager = villager.convertTo(
EntityTypes.ZOMBIE_VILLAGER,
ConversionParams.single(villager, true, true),
@@ -32,7 +32,8 @@ public final class OversizedItemComponentSanitizer {
public static final Codec<ChargedProjectiles> CHARGED_PROJECTILES = codec(ChargedProjectiles.CODEC, OversizedItemComponentSanitizer::sanitizeChargedProjectiles);
public static final StreamCodec<RegistryFriendlyByteBuf, ItemContainerContents> CONTAINER_STREAM = codec(ItemContainerContents.STREAM_CODEC, OversizedItemComponentSanitizer::sanitizeItemContainerContents);
public static final Codec<ItemContainerContents> CONTAINER = codec(ItemContainerContents.CODEC, OversizedItemComponentSanitizer::sanitizeItemContainerContents);
public static final Codec<BundleContents> BUNDLE_CONTENTS = new Codec<>() {
public static final Codec<BundleContents> BUNDLE_CONTENTS = new BundleContentsCodec();
static class BundleContentsCodec implements Codec<BundleContents>, ObfuscationDependantCodec {
@Override
public <T> DataResult<Pair<BundleContents, T>> decode(final DynamicOps<T> ops, final T input) {
@@ -51,7 +52,8 @@ public final class OversizedItemComponentSanitizer {
}
}
};
public static final StreamCodec<RegistryFriendlyByteBuf, BundleContents> BUNDLE_CONTENTS_STREAM = new StreamCodec<>() {
public static final StreamCodec<RegistryFriendlyByteBuf, BundleContents> BUNDLE_CONTENTS_STREAM = new BundleContentsStreamCodec();
static class BundleContentsStreamCodec implements StreamCodec<RegistryFriendlyByteBuf, BundleContents>, ObfuscationDependantCodec {
@Override
public BundleContents decode(final RegistryFriendlyByteBuf buffer) {
return BundleContents.STREAM_CODEC.decode(buffer);
@@ -1693,8 +1693,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa
final Optional<net.minecraft.world.item.enchantment.EnchantedItemInUse> selected = net.minecraft.world.item.enchantment.EnchantmentHelper
.getRandomItemWith(net.minecraft.world.item.enchantment.EnchantmentEffectComponents.REPAIR_WITH_XP, handle, net.minecraft.world.item.ItemStack::isDamaged);
final net.minecraft.world.item.ItemStack itemstack = selected.map(net.minecraft.world.item.enchantment.EnchantedItemInUse::itemStack).orElse(net.minecraft.world.item.ItemStack.EMPTY);
if (!itemstack.isEmpty() && itemstack.getItem().components().has(net.minecraft.core.component.DataComponents.MAX_DAMAGE)) {
net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityTypes.EXPERIENCE_ORB.create(handle.level(), net.minecraft.world.entity.EntitySpawnReason.COMMAND);
if (!itemstack.isEmpty()) {
final net.minecraft.world.entity.ExperienceOrb orb = net.minecraft.world.entity.EntityTypes.EXPERIENCE_ORB.create(handle.level(), net.minecraft.world.entity.EntitySpawnReason.COMMAND);
if (orb == null) {
return amount;
}
orb.setValue(amount);
orb.spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.CUSTOM;
orb.setPosRaw(handle.getX(), handle.getY(), handle.getZ());
@@ -10,7 +10,9 @@ import net.minecraft.world.entity.SulfurCubeArchetype;
import net.minecraft.world.entity.item.PrimedTnt;
import org.bukkit.craftbukkit.CraftRegistry;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.SulfurCube;
import org.bukkit.inventory.ItemStack;
public class CraftSulfurCube extends CraftAbstractCubeMob implements SulfurCube, PaperShearable, PaperBucketable {
public CraftSulfurCube(final CraftServer server, final net.minecraft.world.entity.monster.cubemob.SulfurCube entity) {
@@ -44,6 +46,11 @@ public class CraftSulfurCube extends CraftAbstractCubeMob implements SulfurCube,
return this.getHandle().primeTime(imminent);
}
@Override
public boolean swallow(final ItemStack itemStack) {
return this.getHandle().equipItem(CraftItemStack.asNMSCopy(itemStack));
}
@Override
public int getAge() {
return this.getHandle().getAge();
@@ -370,7 +370,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta, WritableBo
@Override
public @NotNull Book asBook() {
return Book.book(net.kyori.adventure.text.Component.empty(), net.kyori.adventure.text.Component.empty(), this.getPages().stream().map(net.kyori.adventure.text.Component::text).collect(Collectors.toList()));
return Book.book(pages());
}
// Spigot start
@@ -365,7 +365,7 @@ public class CraftMetaBookSigned extends CraftMetaItem implements BookMeta {
@Override
public @NotNull Book asBook() {
return Book.book(net.kyori.adventure.text.Component.empty(), net.kyori.adventure.text.Component.empty(), this.getPages().stream().map(net.kyori.adventure.text.Component::text).collect(Collectors.toList()));
return Book.book(Objects.requireNonNullElse(title(), net.kyori.adventure.text.Component.empty()), Objects.requireNonNullElse(author(), net.kyori.adventure.text.Component.empty()), pages());
}
// Spigot start
@@ -1,15 +1,12 @@
package org.bukkit.craftbukkit.util;
import com.google.common.base.Predicates;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.google.common.io.ByteStreams;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -23,7 +20,6 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.zip.ZipEntry;
import javax.annotation.Nonnull;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import joptsimple.OptionSpec;
@@ -142,11 +138,6 @@ public class Commodore {
return CB_PACKAGE_PREFIX;
}
@Nonnull
private static String getOriginalOrRewrite(@Nonnull String original)
{
return original;
}
// Paper end - Plugin rewrites
public static void main(String[] args) {
@@ -294,46 +285,22 @@ public class Commodore {
// Paper start - Plugin rewrites
@Override
public void visitTypeInsn(int opcode, String type) {
type = getOriginalOrRewrite(type);
super.visitTypeInsn(opcode, type);
}
@Override
public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) {
for (int i = 0; i < local.length; i++)
{
if (!(local[i] instanceof String)) { continue; }
local[i] = getOriginalOrRewrite((String) local[i]);
}
for (int i = 0; i < stack.length; i++)
{
if (!(stack[i] instanceof String)) { continue; }
stack[i] = getOriginalOrRewrite((String) stack[i]);
}
super.visitFrame(type, nLocal, local, nStack, stack);
}
@Override
public void visitLocalVariable(String name, String descriptor, String signature, Label start, Label end, int index) {
descriptor = getOriginalOrRewrite(descriptor);
super.visitLocalVariable(name, descriptor, signature, start, end, index);
}
// Paper end - Plugin rewrites
@Override
public void visitFieldInsn(int opcode, String owner, String name, String desc) {
// Paper start - Rewrite plugins
owner = getOriginalOrRewrite(owner);
if (desc != null) {
desc = getOriginalOrRewrite(desc);
}
// Paper end
name = FieldRename.rename(pluginVersion, owner, name);
if (modern) {
@@ -449,13 +416,6 @@ public class Commodore {
return;
}
// Paper start - Rewrite plugins
owner = getOriginalOrRewrite(owner);
if (desc != null) {
desc = getOriginalOrRewrite(desc);
}
// Paper end - Rewrite plugins
// Paper start - Rewrite plugins
if ((owner.equals("org/bukkit/OfflinePlayer") || owner.equals("org/bukkit/entity/Player")) && name.equals("getPlayerProfile") && desc.equals("()Lorg/bukkit/profile/PlayerProfile;")) {
super.visitMethodInsn(opcode, owner, name, "()Lcom/destroystokyo/paper/profile/PlayerProfile;", itf);
@@ -495,6 +455,15 @@ public class Commodore {
}
}
if (pluginVersion.isOlderThan(ApiVersion.ABSTRACT_CUBE_MOB) && owner.equals("org/bukkit/inventory/meta/BookMeta") && name.equals("pages")) {
if (desc.contains("Lnet/kyori/adventure/inventory/Book;")) {
desc = desc.replace("Lnet/kyori/adventure/inventory/Book;", "Lorg/bukkit/inventory/meta/BookMeta;");
visitor.visit(opcode, owner, name, desc, itf, samMethodType, instantiatedMethodType);
visitor.visit(opcode, owner, "asBook", "()Lnet/kyori/adventure/inventory/Book;", itf, samMethodType, instantiatedMethodType);
return;
}
}
visitor.visit(opcode, owner, name, desc, itf, samMethodType, instantiatedMethodType);
return;
}
@@ -582,11 +551,11 @@ public class Commodore {
// Paper start
if (value instanceof Type type) {
if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
value = Type.getType(getOriginalOrRewrite(type.getDescriptor()));
value = Type.getType(type.getDescriptor());
}
}
// Paper end
if (value instanceof String && ((String) value).equals("com.mysql.jdbc.Driver")) {
if (value instanceof String && value.equals("com.mysql.jdbc.Driver")) {
super.visitLdcInsn("com.mysql.cj.jdbc.Driver");
return;
}
@@ -596,14 +565,6 @@ public class Commodore {
@Override
public void visitInvokeDynamicInsn(String name, String descriptor, Handle bootstrapMethodHandle, Object... bootstrapMethodArguments) {
// Paper start - Rewrite plugins
name = getOriginalOrRewrite(name);
if (descriptor != null) {
descriptor = getOriginalOrRewrite(descriptor);
}
final String fName = name;
final String fDescriptor = descriptor;
// Paper end - Rewrite plugins
if (bootstrapMethodHandle.getOwner().equals("java/lang/invoke/LambdaMetafactory")
&& bootstrapMethodHandle.getName().equals("metafactory") && bootstrapMethodArguments.length == 3) {
Type samMethodType = (Type) bootstrapMethodArguments[0];
@@ -620,7 +581,7 @@ public class Commodore {
methodArgs.add(new Handle(newOpcode, newOwner, newName, newDescription, newItf));
methodArgs.add(newInstantiated);
super.visitInvokeDynamicInsn(fName, fDescriptor, bootstrapMethodHandle, methodArgs.toArray(Object[]::new)); // Paper - use final local vars
super.visitInvokeDynamicInsn(name, descriptor, bootstrapMethodHandle, methodArgs.toArray(Object[]::new));
}, implMethod.getTag(), implMethod.getOwner(), implMethod.getName(), implMethod.getDesc(), implMethod.isInterface(), samMethodType, instantiatedMethodType);
return;
}
@@ -671,12 +632,6 @@ public class Commodore {
@Override
public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
// Paper start - Rewrite plugins
descriptor = getOriginalOrRewrite(descriptor);
if (signature != null) {
signature = getOriginalOrRewrite(signature);
}
// Paper end
return new FieldVisitor(this.api, super.visitField(access, name, descriptor, signature, value)) {
@Override
public AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {