Program: 422
Project: 422
Buggy source:
/** 
 * Changes held item entity. <p>Detaches old held item and removes it's components. Adds components to new held item and attaches it to the mount point entity.</p>
 */
private void linkHeldItemLocationForLocalPlayer(EntityRef newItem,EntityRef oldItem){
  if (!newItem.equals(oldItem)) {
    EntityRef camera=localPlayer.getCameraEntity();
    FirstPersonHeldItemMountPointComponent mountPointComponent=camera.getComponent(FirstPersonHeldItemMountPointComponent.class);
    if (mountPointComponent != null) {
      if (clientHeldItem.exists()) {
        clientHeldItem.removeComponent(MeshComponent.class);
        clientHeldItem.removeComponent(LightComponent.class);
      }
      if (oldItem != null && oldItem.exists()) {
        oldItem.removeComponent(ItemIsHeldComponent.class);
      }
 else {
        getHandEntity().removeComponent(ItemIsHeldComponent.class);
      }
      EntityRef heldItem;
      if (!newItem.exists()) {
        heldItem=getHandEntity();
      }
 else {
        heldItem=newItem;
      }
      clientHeldItem=heldItem.copy();
      clientHeldItem.removeComponent(NetworkComponent.class);
      clientHeldItem.removeComponent(RigidBodyComponent.class);
      clientHeldItem.addOrSaveComponent(new LocationComponent());
      heldItem.addOrSaveComponent(new ItemIsHeldComponent());
      FirstPersonHeldItemTransformComponent heldItemTransformComponent=clientHeldItem.getComponent(FirstPersonHeldItemTransformComponent.class);
      if (heldItemTransformComponent == null) {
        heldItemTransformComponent=new FirstPersonHeldItemTransformComponent();
        clientHeldItem.addComponent(heldItemTransformComponent);
      }
      Location.attachChild(mountPointComponent.mountPointEntity,clientHeldItem,heldItemTransformComponent.translate,new Quat4f(TeraMath.DEG_TO_RAD * heldItemTransformComponent.rotateDegrees.y,TeraMath.DEG_TO_RAD * heldItemTransformComponent.rotateDegrees.x,TeraMath.DEG_TO_RAD * heldItemTransformComponent.rotateDegrees.z),heldItemTransformComponent.scale);
      currentHeldItem=clientHeldItem;
    }
  }
}

Fixed version (ground truth):
/** 
 * Changes held item entity. <p>Detaches old held item and removes it's components. Adds components to new held item and attaches it to the mount point entity.</p>
 */
private void linkHeldItemLocationForLocalPlayer(EntityRef newItem){
  if (!newItem.equals(currentHeldItem)) {
    EntityRef camera=localPlayer.getCameraEntity();
    FirstPersonHeldItemMountPointComponent mountPointComponent=camera.getComponent(FirstPersonHeldItemMountPointComponent.class);
    if (mountPointComponent != null) {
      if (currentHeldItem != EntityRef.NULL) {
        currentHeldItem.destroy();
      }
      EntityRef newHeldItem;
      if (newItem == EntityRef.NULL) {
        newHeldItem=getHandEntity();
      }
 else {
        newHeldItem=newItem;
      }
      currentHeldItem=entityManager.create();
      for (      Component component : newHeldItem.iterateComponents()) {
        if (component instanceof VisualComponent) {
          currentHeldItem.addComponent(component);
        }
      }
      currentHeldItem.addComponent(new LocationComponent());
      currentHeldItem.addComponent(new ItemIsHeldComponent());
      FirstPersonHeldItemTransformComponent heldItemTransformComponent=currentHeldItem.getComponent(FirstPersonHeldItemTransformComponent.class);
      if (heldItemTransformComponent == null) {
        heldItemTransformComponent=new FirstPersonHeldItemTransformComponent();
        currentHeldItem.addComponent(heldItemTransformComponent);
      }
      Location.attachChild(mountPointComponent.mountPointEntity,currentHeldItem,heldItemTransformComponent.translate,new Quat4f(TeraMath.DEG_TO_RAD * heldItemTransformComponent.rotateDegrees.y,TeraMath.DEG_TO_RAD * heldItemTransformComponent.rotateDegrees.x,TeraMath.DEG_TO_RAD * heldItemTransformComponent.rotateDegrees.z),heldItemTransformComponent.scale);
    }
  }
}