[SPIGOT-7996] Cancelling EntityTransformEvent does not keep equipment Created: 19/Jan/25  Updated: 19/Jan/25  Resolved: 19/Jan/25

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Asteraoth Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None

Version: 4424-Spigot-aa7842e-442838f (MC: 1.21.4) (Implementing API version 1.21.4-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

If a plugin cancels the EntityTransformEvent event, the equipment on the original entity will be lost as it goes to the transformed entity.

How to reproduce:

  1. Run a test plugin with the following code:
    @EventHandler
    public void onEliteTransform(EntityTransformEvent event) {
        Bukkit.getLogger().info("Cancelled EntityTransformEvent for " + event.getEntity().getName());
        event.setCancelled(true);
    }
    
  2. Run this command in the console:
    give @p zombie_spawn_egg[entity_data={id:zombie,DrownedConversionTime:20,HandItems:[{id:diamond_sword,count:1},{id:shield,count:1}],ArmorItems:[{id:diamond_boots,count:1},{id:diamond_leggings,count:1},{id:diamond_chestplate,count:1},{id:diamond_helmet,count:1}],HandDropChances:[0f,0f],ArmorDropChances:[0f,0f,0f,0f]}] 1
    
  3. Spawn the Zombie

Observed Results:
The Zombie lost its equipment. You can see that it went to the transformed entity by doing:

EntityEquipment equipment = ((LivingEntity) event.getTransformedEntity()).getEquipment();
Bukkit.getLogger().info("ArmorContents: " + equipment.getArmorContents());
Bukkit.getLogger().info("ItemInMainHand: " + equipment.getItemInMainHand());
Bukkit.getLogger().info("ItemInOffHand: " + equipment.getItemInOffHand());

Expected Results:
The Zombie keeps the equipment since the event was cancelled.


Generated at Sat Dec 13 13:43:08 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.