--- a/net/minecraft/world/item/ArmorStandItem.java
+++ b/net/minecraft/world/item/ArmorStandItem.java
@@ -8,9 +8,11 @@
 import net.minecraft.sounds.SoundSource;
 import net.minecraft.util.Mth;
 import net.minecraft.world.InteractionResult;
+import net.minecraft.world.entity.Entity;
 import net.minecraft.world.entity.EntityType;
 import net.minecraft.world.entity.MobSpawnType;
 import net.minecraft.world.entity.decoration.ArmorStand;
+import net.minecraft.world.entity.player.Player;
 import net.minecraft.world.item.context.BlockPlaceContext;
 import net.minecraft.world.item.context.UseOnContext;
 import net.minecraft.world.level.Level;
@@ -19,41 +21,51 @@
 import net.minecraft.world.phys.Vec3;
 
 public class ArmorStandItem extends Item {
+
     public ArmorStandItem(Item.Properties settings) {
         super(settings);
     }
 
     @Override
     public InteractionResult useOn(UseOnContext context) {
-        Direction direction = context.getClickedFace();
-        if (direction == Direction.DOWN) {
+        Direction enumdirection = context.getClickedFace();
+
+        if (enumdirection == Direction.DOWN) {
             return InteractionResult.FAIL;
         } else {
-            Level level = context.getLevel();
-            BlockPlaceContext blockPlaceContext = new BlockPlaceContext(context);
-            BlockPos blockPos = blockPlaceContext.getClickedPos();
-            ItemStack itemStack = context.getItemInHand();
-            Vec3 vec3 = Vec3.atBottomCenterOf(blockPos);
-            AABB aABB = EntityType.ARMOR_STAND.getDimensions().makeBoundingBox(vec3.x(), vec3.y(), vec3.z());
-            if (level.noCollision(null, aABB) && level.getEntities(null, aABB).isEmpty()) {
-                if (level instanceof ServerLevel serverLevel) {
-                    Consumer<ArmorStand> consumer = EntityType.createDefaultStackConfig(serverLevel, itemStack, context.getPlayer());
-                    ArmorStand armorStand = EntityType.ARMOR_STAND.create(serverLevel, consumer, blockPos, MobSpawnType.SPAWN_EGG, true, true);
-                    if (armorStand == null) {
+            Level world = context.getLevel();
+            BlockPlaceContext blockactioncontext = new BlockPlaceContext(context);
+            BlockPos blockposition = blockactioncontext.getClickedPos();
+            ItemStack itemstack = context.getItemInHand();
+            Vec3 vec3d = Vec3.atBottomCenterOf(blockposition);
+            AABB axisalignedbb = EntityType.ARMOR_STAND.getDimensions().makeBoundingBox(vec3d.x(), vec3d.y(), vec3d.z());
+
+            if (world.noCollision((Entity) null, axisalignedbb) && world.getEntities((Entity) null, axisalignedbb).isEmpty()) {
+                if (world instanceof ServerLevel) {
+                    ServerLevel worldserver = (ServerLevel) world;
+                    Consumer<ArmorStand> consumer = EntityType.createDefaultStackConfig(worldserver, itemstack, context.getPlayer());
+                    ArmorStand entityarmorstand = (ArmorStand) EntityType.ARMOR_STAND.create(worldserver, consumer, blockposition, MobSpawnType.SPAWN_EGG, true, true);
+
+                    if (entityarmorstand == null) {
                         return InteractionResult.FAIL;
                     }
 
-                    float f = (float)Mth.floor((Mth.wrapDegrees(context.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F;
-                    armorStand.moveTo(armorStand.getX(), armorStand.getY(), armorStand.getZ(), f, 0.0F);
-                    serverLevel.addFreshEntityWithPassengers(armorStand);
-                    level.playSound(
-                        null, armorStand.getX(), armorStand.getY(), armorStand.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F
-                    );
-                    armorStand.gameEvent(GameEvent.ENTITY_PLACE, context.getPlayer());
+                    float f = (float) Mth.floor((Mth.wrapDegrees(context.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F;
+
+                    entityarmorstand.moveTo(entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), f, 0.0F);
+                    // CraftBukkit start
+                    if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(context, entityarmorstand).isCancelled()) {
+                        if (context.getPlayer() != null) context.getPlayer().containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync
+                        return InteractionResult.FAIL;
+                    }
+                    // CraftBukkit end
+                    worldserver.addFreshEntityWithPassengers(entityarmorstand);
+                    world.playSound((Player) null, entityarmorstand.getX(), entityarmorstand.getY(), entityarmorstand.getZ(), SoundEvents.ARMOR_STAND_PLACE, SoundSource.BLOCKS, 0.75F, 0.8F);
+                    entityarmorstand.gameEvent(GameEvent.ENTITY_PLACE, context.getPlayer());
                 }
 
-                itemStack.shrink(1);
-                return InteractionResult.sidedSuccess(level.isClientSide);
+                itemstack.shrink(1);
+                return InteractionResult.sidedSuccess(world.isClientSide);
             } else {
                 return InteractionResult.FAIL;
             }
